2
0

unix-Makefile.tmpl 66 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691
  1. ##
  2. ## Makefile for OpenSSL
  3. ##
  4. ## {- join("\n## ", @autowarntext) -}
  5. {-
  6. our $makedepprog = platform->makedepprog();
  7. sub windowsdll { $config{target} =~ /^(?:Cygwin|mingw)/ }
  8. # Shared AIX support is special. We put libcrypto[64].so.ver into
  9. # libcrypto.a and use libcrypto_a.a as static one.
  10. sub sharedaix { !$disabled{shared} && $config{target} =~ /^aix/ }
  11. our $sover_dirname = platform->shlib_version_as_filename();
  12. # This makes sure things get built in the order they need
  13. # to. You're welcome.
  14. sub dependmagic {
  15. my $target = shift;
  16. return "$target: build_generated\n\t\$(MAKE) depend && \$(MAKE) _$target\n_$target";
  17. }
  18. our $COLUMNS = $ENV{COLUMNS};
  19. if ($COLUMNS =~ /^\d+$/) {
  20. $COLUMNS = int($COLUMNS) - 2; # 2 to leave space for ending ' \'
  21. } else {
  22. $COLUMNS = 76;
  23. }
  24. sub fill_lines {
  25. my $item_sep = shift; # string
  26. my $line_length = shift; # number of chars
  27. my @result = ();
  28. my $resultpos = 0;
  29. foreach (@_) {
  30. my $fill_line = $result[$resultpos] // '';
  31. my $newline =
  32. ($fill_line eq '' ? '' : $fill_line . $item_sep) . $_;
  33. if (length($newline) > $line_length) {
  34. # If this is a single item and the intended result line
  35. # is empty, we put it there anyway
  36. if ($fill_line eq '') {
  37. $result[$resultpos++] = $newline;
  38. } else {
  39. $result[++$resultpos] = $_;
  40. }
  41. } else {
  42. $result[$resultpos] = $newline;
  43. }
  44. }
  45. return @result;
  46. }
  47. '';
  48. -}
  49. PLATFORM={- $config{target} -}
  50. OPTIONS={- $config{options} -}
  51. CONFIGURE_ARGS=({- join(", ",quotify_l(@{$config{perlargv}})) -})
  52. SRCDIR={- $config{sourcedir} -}
  53. BLDDIR={- $config{builddir} -}
  54. FIPSKEY={- $config{FIPSKEY} -}
  55. VERSION={- "$config{full_version}" -}
  56. MAJOR={- $config{major} -}
  57. MINOR={- $config{minor} -}
  58. SHLIB_VERSION_NUMBER={- $config{shlib_version} -}
  59. SHLIB_TARGET={- $target{shared_target} -}
  60. LIBS={- join(" \\\n" . ' ' x 5,
  61. fill_lines(" ", $COLUMNS - 5,
  62. map { platform->staticlib($_) // () }
  63. @{$unified_info{libraries}})) -}
  64. SHLIBS={- join(" \\\n" . ' ' x 7,
  65. fill_lines(" ", $COLUMNS - 7,
  66. map { platform->sharedlib($_) // () }
  67. @{$unified_info{libraries}})) -}
  68. SHLIB_INFO={- join(" \\\n" . ' ' x 11,
  69. fill_lines(" ", $COLUMNS - 11,
  70. map { my $x = platform->sharedlib($_);
  71. my $y = platform->sharedlib_simple($_);
  72. $x ? "\"$x;$y\"" : () }
  73. @{$unified_info{libraries}})) -}
  74. MODULES={- join(" \\\n" . ' ' x 8,
  75. fill_lines(" ", $COLUMNS - 8,
  76. map { platform->dso($_) }
  77. @{$unified_info{modules}})) -}
  78. FIPSMODULENAME={- # We do some extra checking here, as there should be only one
  79. my @fipsmodules =
  80. grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
  81. && $unified_info{attributes}->{modules}->{$_}->{fips} }
  82. @{$unified_info{modules}};
  83. die "More that one FIPS module" if scalar @fipsmodules > 1;
  84. join(" ", map { basename platform->dso($_) } @fipsmodules) -}
  85. PROGRAMS={- join(" \\\n" . ' ' x 9,
  86. fill_lines(" ", $COLUMNS - 9,
  87. map { platform->bin($_) }
  88. @{$unified_info{programs}})) -}
  89. SCRIPTS={- join(" \\\n" . ' ' x 8,
  90. fill_lines(" ", $COLUMNS - 8, @{$unified_info{scripts}})) -}
  91. {- output_off() if $disabled{makedepend}; "" -}
  92. DEPS={- join(" \\\n" . ' ' x 5,
  93. fill_lines(" ", $COLUMNS - 5,
  94. map { platform->isobj($_) ? platform->dep($_) : () }
  95. grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
  96. keys %{$unified_info{sources}})); -}
  97. {- output_on() if $disabled{makedepend}; "" -}
  98. GENERATED_MANDATORY={- join(" \\\n" . ' ' x 20,
  99. fill_lines(" ", $COLUMNS - 20,
  100. @{$unified_info{depends}->{""}})) -}
  101. GENERATED={- # common0.tmpl provides @generated
  102. join(" \\\n" . ' ' x 5,
  103. fill_lines(" ", $COLUMNS - 5,
  104. map { platform->convertext($_) } @generated )) -}
  105. INSTALL_LIBS={-
  106. join(" \\\n" . ' ' x 13,
  107. fill_lines(" ", $COLUMNS - 13,
  108. map { platform->staticlib($_) // () }
  109. grep { !$unified_info{attributes}->{libraries}->{$_}->{noinst} }
  110. @{$unified_info{libraries}}))
  111. -}
  112. INSTALL_SHLIBS={-
  113. join(" \\\n" . ' ' x 15,
  114. fill_lines(" ", $COLUMNS - 15,
  115. map { platform->sharedlib($_) // () }
  116. grep { !$unified_info{attributes}->{libraries}->{$_}->{noinst} }
  117. @{$unified_info{libraries}}))
  118. -}
  119. INSTALL_SHLIB_INFO={-
  120. join(" \\\n" . ' ' x 19,
  121. fill_lines(" ", $COLUMNS - 19,
  122. map { my $x = platform->sharedlib($_);
  123. my $y = platform->sharedlib_simple($_);
  124. $x ? "\"$x;$y\"" : () }
  125. grep { !$unified_info{attributes}->{libraries}->{$_}->{noinst} }
  126. @{$unified_info{libraries}}))
  127. -}
  128. INSTALL_ENGINES={-
  129. join(" \\\n" . ' ' x 16,
  130. fill_lines(" ", $COLUMNS - 16,
  131. map { platform->dso($_) }
  132. grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
  133. && $unified_info{attributes}->{modules}->{$_}->{engine} }
  134. @{$unified_info{modules}}))
  135. -}
  136. INSTALL_MODULES={-
  137. join(" \\\n" . ' ' x 16,
  138. fill_lines(" ", $COLUMNS - 16,
  139. map { platform->dso($_) }
  140. grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
  141. && !$unified_info{attributes}->{modules}->{$_}->{engine} }
  142. @{$unified_info{modules}}))
  143. -}
  144. INSTALL_PROGRAMS={-
  145. join(" \\\n" . ' ' x 16,
  146. fill_lines(" ", $COLUMNS - 16, map { platform->bin($_) }
  147. grep { !$unified_info{attributes}->{programs}->{$_}->{noinst} }
  148. @{$unified_info{programs}}))
  149. -}
  150. BIN_SCRIPTS={-
  151. join(" \\\n" . ' ' x 12,
  152. fill_lines(" ", $COLUMNS - 12,
  153. map { my $x = $unified_info{attributes}->{scripts}->{$_}->{linkname};
  154. $x ? "$_:$x" : $_ }
  155. grep { !$unified_info{attributes}->{scripts}->{$_}->{noinst}
  156. && !$unified_info{attributes}->{scripts}->{$_}->{misc} }
  157. @{$unified_info{scripts}}))
  158. -}
  159. MISC_SCRIPTS={-
  160. join(" \\\n" . ' ' x 13,
  161. fill_lines(" ", $COLUMNS - 13,
  162. map { my $x = $unified_info{attributes}->{scripts}->{$_}->{linkname};
  163. $x ? "$_:$x" : $_ }
  164. grep { !$unified_info{attributes}->{scripts}->{$_}->{noinst}
  165. && $unified_info{attributes}->{scripts}->{$_}->{misc} }
  166. @{$unified_info{scripts}}))
  167. -}
  168. HTMLDOCS1={-
  169. join(" \\\n" . ' ' x 10,
  170. fill_lines(" ", $COLUMNS - 10,
  171. @{$unified_info{htmldocs}->{man1}})) -}
  172. HTMLDOCS3={-
  173. join(" \\\n" . ' ' x 10,
  174. fill_lines(" ", $COLUMNS - 10,
  175. @{$unified_info{htmldocs}->{man3}})) -}
  176. HTMLDOCS5={-
  177. join(" \\\n" . ' ' x 10,
  178. fill_lines(" ", $COLUMNS - 10,
  179. @{$unified_info{htmldocs}->{man5}})) -}
  180. HTMLDOCS7={-
  181. join(" \\\n" . ' ' x 10,
  182. fill_lines(" ", $COLUMNS - 10,
  183. @{$unified_info{htmldocs}->{man7}})) -}
  184. MANDOCS1={-
  185. join(" \\\n" . ' ' x 9,
  186. fill_lines(" ", $COLUMNS - 9,
  187. @{$unified_info{mandocs}->{man1}})) -}
  188. MANDOCS3={-
  189. join(" \\\n" . ' ' x 9,
  190. fill_lines(" ", $COLUMNS - 9,
  191. @{$unified_info{mandocs}->{man3}})) -}
  192. MANDOCS5={-
  193. join(" \\\n" . ' ' x 9,
  194. fill_lines(" ", $COLUMNS - 9,
  195. @{$unified_info{mandocs}->{man5}})) -}
  196. MANDOCS7={-
  197. join(" \\\n" . ' ' x 9,
  198. fill_lines(" ", $COLUMNS - 9,
  199. @{$unified_info{mandocs}->{man7}})) -}
  200. APPS_OPENSSL="{- use File::Spec::Functions;
  201. catfile("apps","openssl") -}"
  202. # DESTDIR is for package builders so that they can configure for, say,
  203. # /usr/ and yet have everything installed to /tmp/somedir/usr/.
  204. # Normally it is left empty.
  205. DESTDIR=
  206. # Do not edit these manually. Use Configure with --prefix or --openssldir
  207. # to change this! Short explanation in the top comment in Configure
  208. INSTALLTOP={- # $prefix is used in the OPENSSLDIR perl snippet
  209. #
  210. our $prefix = $config{prefix} || "/usr/local";
  211. $prefix -}
  212. OPENSSLDIR={- #
  213. # The logic here is that if no --openssldir was given,
  214. # OPENSSLDIR will get the value from $prefix plus "/ssl".
  215. # If --openssldir was given and the value is an absolute
  216. # path, OPENSSLDIR will get its value without change.
  217. # If the value from --openssldir is a relative path,
  218. # OPENSSLDIR will get $prefix with the --openssldir
  219. # value appended as a subdirectory.
  220. #
  221. use File::Spec::Functions;
  222. our $openssldir =
  223. $config{openssldir} ?
  224. (file_name_is_absolute($config{openssldir}) ?
  225. $config{openssldir}
  226. : catdir($prefix, $config{openssldir}))
  227. : catdir($prefix, "ssl");
  228. $openssldir -}
  229. LIBDIR={- our $libdir = $config{libdir};
  230. unless ($libdir) {
  231. #
  232. # if $prefix/lib$target{multilib} is not an existing
  233. # directory, then assume that it's not searched by linker
  234. # automatically, in which case adding $target{multilib} suffix
  235. # causes more grief than we're ready to tolerate, so don't...
  236. our $multilib =
  237. -d "$prefix/lib$target{multilib}" ? $target{multilib} : "";
  238. $libdir = "lib$multilib";
  239. }
  240. file_name_is_absolute($libdir) ? "" : $libdir -}
  241. # $(libdir) is chosen to be compatible with the GNU coding standards
  242. libdir={- file_name_is_absolute($libdir)
  243. ? $libdir : '$(INSTALLTOP)/$(LIBDIR)' -}
  244. ENGINESDIR=$(libdir)/engines-{- $sover_dirname -}
  245. MODULESDIR=$(libdir)/ossl-modules
  246. # Convenience variable for those who want to set the rpath in shared
  247. # libraries and applications
  248. LIBRPATH=$(libdir)
  249. MANDIR=$(INSTALLTOP)/share/man
  250. DOCDIR=$(INSTALLTOP)/share/doc/$(BASENAME)
  251. HTMLDIR=$(DOCDIR)/html
  252. # MANSUFFIX is for the benefit of anyone who may want to have a suffix
  253. # appended after the manpage file section number. "ssl" is popular,
  254. # resulting in files such as config.5ssl rather than config.5.
  255. MANSUFFIX=
  256. HTMLSUFFIX=html
  257. # For "optional" echo messages, to get "real" silence
  258. ECHO = echo
  259. ##### User defined commands and flags ################################
  260. # We let the C compiler driver to take care of .s files. This is done in
  261. # order to be excused from maintaining a separate set of architecture
  262. # dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC
  263. # gcc, then the driver will automatically translate it to -xarch=v8plus
  264. # and pass it down to assembler. In any case, we do not define AS or
  265. # ASFLAGS for this reason.
  266. CROSS_COMPILE={- $config{CROSS_COMPILE} -}
  267. CC=$(CROSS_COMPILE){- $config{CC} -}
  268. CXX={- $config{CXX} ? "\$(CROSS_COMPILE)$config{CXX}" : '' -}
  269. CPPFLAGS={- our $cppflags1 = join(" ",
  270. (map { "-D".$_} @{$config{CPPDEFINES}}),
  271. (map { "-I".$_} @{$config{CPPINCLUDES}}),
  272. @{$config{CPPFLAGS}}) -}
  273. CFLAGS={- join(' ', @{$config{CFLAGS}}) -}
  274. CXXFLAGS={- join(' ', @{$config{CXXFLAGS}}) -}
  275. LDFLAGS= {- join(' ', @{$config{LDFLAGS}}) -}
  276. EX_LIBS= {- join(' ', @{$config{LDLIBS}}) -}
  277. MAKEDEPEND={- $config{makedepprog} -}
  278. PERL={- $config{PERL} -}
  279. AR=$(CROSS_COMPILE){- $config{AR} -}
  280. ARFLAGS= {- join(' ', @{$config{ARFLAGS}}) -}
  281. RANLIB={- $config{RANLIB} ? "\$(CROSS_COMPILE)$config{RANLIB}" : "true"; -}
  282. RC= $(CROSS_COMPILE){- $config{RC} -}
  283. RCFLAGS={- join(' ', @{$config{RCFLAGS}}) -} {- $target{shared_rcflag} -}
  284. RM= rm -f
  285. RMDIR= rmdir
  286. TAR= {- $target{TAR} || "tar" -}
  287. TARFLAGS= {- $target{TARFLAGS} -}
  288. BASENAME= openssl
  289. NAME= $(BASENAME)-$(VERSION)
  290. # Relative to $(SRCDIR)
  291. TARFILE= ../$(NAME).tar
  292. ##### Project flags ##################################################
  293. # Variables starting with CNF_ are common variables for all product types
  294. CNF_CPPFLAGS={- our $cppflags2 =
  295. join(' ', $target{cppflags} || (),
  296. (map { "-D".$_} @{$target{defines}},
  297. @{$config{defines}}),
  298. (map { "-I".$_} @{$target{includes}},
  299. @{$config{includes}}),
  300. @{$config{cppflags}}) -}
  301. CNF_CFLAGS={- join(' ', $target{cflags} || (),
  302. @{$config{cflags}}) -}
  303. CNF_CXXFLAGS={- join(' ', $target{cxxflags} || (),
  304. @{$config{cxxflags}}) -}
  305. CNF_LDFLAGS={- join(' ', $target{lflags} || (),
  306. @{$config{lflags}}) -}
  307. CNF_EX_LIBS={- join(' ', $target{ex_libs} || (),
  308. @{$config{ex_libs}}) -}
  309. # Variables starting with LIB_ are used to build library object files
  310. # and shared libraries.
  311. # Variables starting with DSO_ are used to build DSOs and their object files.
  312. # Variables starting with BIN_ are used to build programs and their object
  313. # files.
  314. LIB_CPPFLAGS={- our $lib_cppflags =
  315. join(' ', $target{lib_cppflags} || (),
  316. $target{shared_cppflag} || (),
  317. (map { '-D'.$_ }
  318. @{$target{lib_defines} || ()},
  319. @{$target{shared_defines} || ()},
  320. @{$config{lib_defines} || ()},
  321. @{$config{shared_defines} || ()}),
  322. (map { '-I'.quotify1($_) }
  323. @{$target{lib_includes}},
  324. @{$target{shared_includes}},
  325. @{$config{lib_includes}},
  326. @{$config{shared_includes}}),
  327. @{$config{lib_cppflags}},
  328. @{$config{shared_cppflag}});
  329. join(' ', $lib_cppflags,
  330. (map { '-D'.$_ }
  331. 'OPENSSLDIR="\"$(OPENSSLDIR)\""',
  332. 'ENGINESDIR="\"$(ENGINESDIR)\""',
  333. 'MODULESDIR="\"$(MODULESDIR)\""'),
  334. '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
  335. LIB_CFLAGS={- join(' ', $target{lib_cflags} || (),
  336. $target{shared_cflag} || (),
  337. @{$config{lib_cflags}},
  338. @{$config{shared_cflag}},
  339. '$(CNF_CFLAGS)', '$(CFLAGS)') -}
  340. LIB_CXXFLAGS={- join(' ', $target{lib_cxxflags} || (),
  341. $target{shared_cxxflag} || (),
  342. @{$config{lib_cxxflags}},
  343. @{$config{shared_cxxflag}},
  344. '$(CNF_CXXFLAGS)', '$(CXXFLAGS)') -}
  345. LIB_LDFLAGS={- join(' ', $target{shared_ldflag} || (),
  346. $config{shared_ldflag} || (),
  347. '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
  348. LIB_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
  349. DSO_CPPFLAGS={- join(' ', $target{dso_cppflags} || (),
  350. $target{module_cppflags} || (),
  351. (map { '-D'.$_ }
  352. @{$target{dso_defines}},
  353. @{$target{module_defines}},
  354. @{$config{dso_defines} || ()},
  355. @{$config{module_defines} || ()}),
  356. (map { '-I'.quotify1($_) }
  357. @{$target{dso_includes}},
  358. @{$target{module_includes}},
  359. @{$config{dso_includes}},
  360. @{$config{module_includes}}),
  361. @{$config{dso_cppflags}},
  362. @{$config{module_cppflags}},
  363. '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
  364. DSO_CFLAGS={- join(' ', $target{dso_cflags} || (),
  365. $target{module_cflags} || (),
  366. @{$config{dso_cflags}},
  367. @{$config{module_cflags}},
  368. '$(CNF_CFLAGS)', '$(CFLAGS)') -}
  369. DSO_CXXFLAGS={- join(' ', $target{dso_cxxflags} || (),
  370. $target{module_cxxflags} || (),
  371. @{$config{dso_cxxflags}},
  372. @{$config{module_cxxflag}},
  373. '$(CNF_CXXFLAGS)', '$(CXXFLAGS)') -}
  374. DSO_LDFLAGS={- join(' ', $target{dso_ldflags} || (),
  375. $target{module_ldflags} || (),
  376. @{$config{dso_ldflags}},
  377. @{$config{module_ldflags}},
  378. '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
  379. DSO_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
  380. BIN_CPPFLAGS={- join(' ', $target{bin_cppflags} || (),
  381. (map { '-D'.$_ } @{$config{bin_defines} || ()}),
  382. @{$config{bin_cppflags}},
  383. '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
  384. BIN_CFLAGS={- join(' ', $target{bin_cflags} || (),
  385. @{$config{bin_cflags}},
  386. '$(CNF_CFLAGS)', '$(CFLAGS)') -}
  387. BIN_CXXFLAGS={- join(' ', $target{bin_cxxflags} || (),
  388. @{$config{bin_cxxflags}},
  389. '$(CNF_CXXFLAGS)', '$(CXXFLAGS)') -}
  390. BIN_LDFLAGS={- join(' ', $target{bin_lflags} || (),
  391. @{$config{bin_lflags}},
  392. '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
  393. BIN_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
  394. # CPPFLAGS_Q is used for one thing only: to build up buildinf.h
  395. CPPFLAGS_Q={- $cppflags1 =~ s|([\\"])|\\$1|g;
  396. $cppflags2 =~ s|([\\"])|\\$1|g;
  397. $lib_cppflags =~ s|([\\"])|\\$1|g;
  398. join(' ', $lib_cppflags || (), $cppflags2 || (),
  399. $cppflags1 || ()) -}
  400. PERLASM_SCHEME= {- $target{perlasm_scheme} -}
  401. # For x86 assembler: Set PROCESSOR to 386 if you want to support
  402. # the 80386.
  403. PROCESSOR= {- $config{processor} -}
  404. # We want error [and other] messages in English. Trouble is that make(1)
  405. # doesn't pass macros down as environment variables unless there already
  406. # was corresponding variable originally set. In other words we can only
  407. # reassign environment variables, but not set new ones, not in portable
  408. # manner that is. That's why we reassign several, just to be sure...
  409. LC_ALL=C
  410. LC_MESSAGES=C
  411. LANG=C
  412. # The main targets ###################################################
  413. {- dependmagic('build_sw'); -}: build_libs_nodep build_modules_nodep build_programs_nodep link-utils
  414. {- dependmagic('build_libs'); -}: build_libs_nodep
  415. {- dependmagic('build_modules'); -}: build_modules_nodep
  416. {- dependmagic('build_programs'); -}: build_programs_nodep
  417. build_docs: build_man_docs build_html_docs
  418. build_man_docs: $(MANDOCS1) $(MANDOCS3) $(MANDOCS5) $(MANDOCS7)
  419. build_html_docs: $(HTMLDOCS1) $(HTMLDOCS3) $(HTMLDOCS5) $(HTMLDOCS7)
  420. build_generated: $(GENERATED_MANDATORY)
  421. build_libs_nodep: libcrypto.pc libssl.pc openssl.pc
  422. build_modules_nodep: $(MODULES)
  423. build_programs_nodep: $(PROGRAMS) $(SCRIPTS)
  424. # Kept around for backward compatibility
  425. build_apps build_tests: build_programs
  426. # Convenience target to prebuild all generated files, not just the mandatory
  427. # ones
  428. build_all_generated: $(GENERATED_MANDATORY) $(GENERATED) build_docs
  429. @ : {- output_off() if $disabled{makedepend}; "" -}
  430. @echo "Warning: consider configuring with no-makedepend, because if"
  431. @echo " target system doesn't have $(PERL),"
  432. @echo " then make will fail..."
  433. @ : {- output_on() if $disabled{makedepend}; "" -}
  434. all: build_sw build_docs
  435. test: tests
  436. {- dependmagic('tests'); -}: build_programs_nodep build_modules_nodep link-utils
  437. @ : {- output_off() if $disabled{tests}; "" -}
  438. ( SRCTOP=$(SRCDIR) \
  439. BLDTOP=$(BLDDIR) \
  440. PERL="$(PERL)" \
  441. FIPSKEY="$(FIPSKEY)" \
  442. EXE_EXT={- platform->binext() -} \
  443. $(PERL) $(SRCDIR)/test/run_tests.pl $(TESTS) )
  444. @ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
  445. @echo "Tests are not supported with your chosen Configure options"
  446. @ : {- output_on() if !$disabled{tests}; "" -}
  447. list-tests:
  448. @ : {- output_off() if $disabled{tests}; "" -}
  449. @SRCTOP="$(SRCDIR)" \
  450. $(PERL) $(SRCDIR)/test/run_tests.pl list
  451. @ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
  452. @echo "Tests are not supported with your chosen Configure options"
  453. @ : {- output_on() if !$disabled{tests}; "" -}
  454. install: install_sw install_ssldirs install_docs
  455. uninstall: uninstall_docs uninstall_sw
  456. libclean:
  457. @set -e; for s in $(SHLIB_INFO); do \
  458. if [ "$$s" = ";" ]; then continue; fi; \
  459. s1=`echo "$$s" | cut -f1 -d";"`; \
  460. s2=`echo "$$s" | cut -f2 -d";"`; \
  461. $(ECHO) $(RM) $$s1; {- output_off() unless windowsdll(); "" -}\
  462. $(RM) apps/$$s1; \
  463. $(RM) test/$$s1; \
  464. $(RM) fuzz/$$s1; {- output_on() unless windowsdll(); "" -}\
  465. $(RM) $$s1; \
  466. if [ "$$s1" != "$$s2" ]; then \
  467. $(ECHO) $(RM) $$s2; \
  468. $(RM) $$s2; \
  469. fi; \
  470. done
  471. $(RM) $(LIBS)
  472. $(RM) *{- platform->defext() -}
  473. clean: libclean
  474. $(RM) $(HTMLDOCS1) $(HTMLDOCS3) $(HTMLDOCS5) $(HTMLDOCS7)
  475. $(RM) $(MANDOCS1) $(MANDOCS3) $(MANDOCS5) $(MANDOCS7)
  476. $(RM) $(PROGRAMS) $(TESTPROGS) $(MODULES) $(SCRIPTS)
  477. $(RM) $(GENERATED_MANDATORY) $(GENERATED)
  478. -find . -name '*{- platform->depext() -}' \! -name '.*' \! -type d -exec $(RM) {} \;
  479. -find . -name '*{- platform->objext() -}' \! -name '.*' \! -type d -exec $(RM) {} \;
  480. $(RM) core
  481. $(RM) tags TAGS doc-nits cmd-nits md-nits
  482. $(RM) -r test/test-runs
  483. $(RM) openssl.pc libcrypto.pc libssl.pc
  484. -find . -type l \! -name '.*' -exec $(RM) {} \;
  485. $(RM) $(TARFILE)
  486. distclean: clean
  487. $(RM) configdata.pm
  488. $(RM) Makefile
  489. # We check if any depfile is newer than Makefile and decide to
  490. # concatenate only if that is true.
  491. depend:
  492. @: {- output_off() if $disabled{makedepend}; "" -}
  493. @$(PERL) $(SRCDIR)/util/add-depends.pl {-
  494. defined $makedepprog && $makedepprog =~ /\/makedepend/
  495. ? 'makedepend' : 'gcc' -}
  496. @: {- output_on() if $disabled{makedepend}; "" -}
  497. # Install helper targets #############################################
  498. install_sw: install_dev install_engines install_modules install_runtime
  499. uninstall_sw: uninstall_runtime uninstall_modules uninstall_engines uninstall_dev
  500. install_docs: install_man_docs install_html_docs
  501. uninstall_docs: uninstall_man_docs uninstall_html_docs
  502. $(RM) -r $(DESTDIR)$(DOCDIR)
  503. install_fips: install_sw
  504. @$(ECHO) "*** Installing FIPS module configuration"
  505. @$(ECHO) "fipsinstall $(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME).cnf"
  506. @openssl fipsinstall -module $(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME) \
  507. -out $(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME).cnf \
  508. -macopt 'key:$(FIPSKEY)'
  509. uninstall_fips: uninstall_sw
  510. @$(ECHO) "*** Uninstalling FIPS module configuration"
  511. @$(ECHO) "$(RM) $(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME).cnf"
  512. @$(RM) $(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME).cnf
  513. install_ssldirs:
  514. @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/certs
  515. @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/private
  516. @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(OPENSSLDIR)/misc
  517. @set -e; for x in dummy $(MISC_SCRIPTS); do \
  518. if [ "$$x" = "dummy" ]; then continue; fi; \
  519. x1=`echo "$$x" | cut -f1 -d:`; \
  520. x2=`echo "$$x" | cut -f2 -d:`; \
  521. fn=`basename $$x1`; \
  522. $(ECHO) "install $$x1 -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
  523. cp $$x1 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
  524. chmod 755 $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new; \
  525. mv -f $(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new \
  526. $(DESTDIR)$(OPENSSLDIR)/misc/$$fn; \
  527. if [ "$$x1" != "$$x2" ]; then \
  528. ln=`basename "$$x2"`; \
  529. : {- output_off() unless windowsdll(); "" -}; \
  530. $(ECHO) "copy $(DESTDIR)$(OPENSSLDIR)/misc/$$ln -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
  531. cp $(DESTDIR)$(OPENSSLDIR)/misc/$$fn $(DESTDIR)$(OPENSSLDIR)/misc/$$ln; \
  532. : {- output_on() unless windowsdll();
  533. output_off() if windowsdll(); "" -}; \
  534. $(ECHO) "link $(DESTDIR)$(OPENSSLDIR)/misc/$$ln -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
  535. ln -sf $$fn $(DESTDIR)$(OPENSSLDIR)/misc/$$ln; \
  536. : {- output_on() if windowsdll(); "" -}; \
  537. fi; \
  538. done
  539. @$(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist"
  540. @cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
  541. @chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new
  542. @mv -f $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist
  543. @if [ ! -f "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf" ]; then \
  544. $(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf"; \
  545. cp $(SRCDIR)/apps/openssl.cnf $(DESTDIR)$(OPENSSLDIR)/openssl.cnf; \
  546. chmod 644 $(DESTDIR)$(OPENSSLDIR)/openssl.cnf; \
  547. fi
  548. @$(ECHO) "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist"
  549. @cp $(SRCDIR)/apps/ct_log_list.cnf $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new
  550. @chmod 644 $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new
  551. @mv -f $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist
  552. @if [ ! -f "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf" ]; then \
  553. $(ECHO) "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf"; \
  554. cp $(SRCDIR)/apps/ct_log_list.cnf $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf; \
  555. chmod 644 $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf; \
  556. fi
  557. install_dev: install_runtime_libs
  558. @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
  559. @$(ECHO) "*** Installing development files"
  560. @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/include/openssl
  561. @ : {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
  562. @$(ECHO) "install $(SRCDIR)/ms/applink.c -> $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
  563. @cp $(SRCDIR)/ms/applink.c $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
  564. @chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
  565. @ : {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
  566. @set -e; for i in $(SRCDIR)/include/openssl/*.h \
  567. $(BLDDIR)/include/openssl/*.h; do \
  568. fn=`basename $$i`; \
  569. $(ECHO) "install $$i -> $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
  570. cp $$i $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
  571. chmod 644 $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
  572. done
  573. @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(libdir)
  574. @set -e; for l in $(INSTALL_LIBS); do \
  575. fn=`basename $$l`; \
  576. $(ECHO) "install $$l -> $(DESTDIR)$(libdir)/$$fn"; \
  577. cp $$l $(DESTDIR)$(libdir)/$$fn.new; \
  578. $(RANLIB) $(DESTDIR)$(libdir)/$$fn.new; \
  579. chmod 644 $(DESTDIR)$(libdir)/$$fn.new; \
  580. mv -f $(DESTDIR)$(libdir)/$$fn.new \
  581. $(DESTDIR)$(libdir)/$$fn; \
  582. done
  583. @ : {- output_off() if $disabled{shared}; "" -}
  584. @set -e; for s in $(INSTALL_SHLIB_INFO); do \
  585. s1=`echo "$$s" | cut -f1 -d";"`; \
  586. s2=`echo "$$s" | cut -f2 -d";"`; \
  587. fn1=`basename $$s1`; \
  588. fn2=`basename $$s2`; \
  589. : {- output_off(); output_on() unless windowsdll() or sharedaix(); "" -}; \
  590. if [ "$$fn1" != "$$fn2" ]; then \
  591. $(ECHO) "link $(DESTDIR)$(libdir)/$$fn2 -> $(DESTDIR)$(libdir)/$$fn1"; \
  592. ln -sf $$fn1 $(DESTDIR)$(libdir)/$$fn2; \
  593. fi; \
  594. : {- output_off() unless windowsdll() or sharedaix(); output_on() if windowsdll(); "" -}; \
  595. $(ECHO) "install $$s2 -> $(DESTDIR)$(libdir)/$$fn2"; \
  596. cp $$s2 $(DESTDIR)$(libdir)/$$fn2.new; \
  597. chmod 755 $(DESTDIR)$(libdir)/$$fn2.new; \
  598. mv -f $(DESTDIR)$(libdir)/$$fn2.new \
  599. $(DESTDIR)$(libdir)/$$fn2; \
  600. : {- output_off() if windowsdll(); output_on() if sharedaix(); "" -}; \
  601. a=$(DESTDIR)$(libdir)/$$fn2; \
  602. $(ECHO) "install $$s1 -> $$a"; \
  603. if [ -f $$a ]; then ( trap "rm -rf /tmp/ar.$$$$" INT 0; \
  604. mkdir /tmp/ar.$$$$; ( cd /tmp/ar.$$$$; \
  605. cp -f $$a $$a.new; \
  606. for so in `$(AR) t $$a`; do \
  607. $(AR) x $$a $$so; \
  608. chmod u+w $$so; \
  609. strip -X32_64 -e $$so; \
  610. $(AR) r $$a.new $$so; \
  611. done; \
  612. )); fi; \
  613. $(AR) r $$a.new $$s1; \
  614. mv -f $$a.new $$a; \
  615. : {- output_off() if sharedaix(); output_on(); "" -}; \
  616. done
  617. @ : {- output_on() if $disabled{shared}; "" -}
  618. @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(libdir)/pkgconfig
  619. @$(ECHO) "install libcrypto.pc -> $(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc"
  620. @cp libcrypto.pc $(DESTDIR)$(libdir)/pkgconfig
  621. @chmod 644 $(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc
  622. @$(ECHO) "install libssl.pc -> $(DESTDIR)$(libdir)/pkgconfig/libssl.pc"
  623. @cp libssl.pc $(DESTDIR)$(libdir)/pkgconfig
  624. @chmod 644 $(DESTDIR)$(libdir)/pkgconfig/libssl.pc
  625. @$(ECHO) "install openssl.pc -> $(DESTDIR)$(libdir)/pkgconfig/openssl.pc"
  626. @cp openssl.pc $(DESTDIR)$(libdir)/pkgconfig
  627. @chmod 644 $(DESTDIR)$(libdir)/pkgconfig/openssl.pc
  628. uninstall_dev: uninstall_runtime_libs
  629. @$(ECHO) "*** Uninstalling development files"
  630. @ : {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
  631. @$(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
  632. @$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c
  633. @ : {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
  634. @set -e; for i in $(SRCDIR)/include/openssl/*.h \
  635. $(BLDDIR)/include/openssl/*.h; do \
  636. fn=`basename $$i`; \
  637. $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
  638. $(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn; \
  639. done
  640. -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/include/openssl
  641. -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/include
  642. @set -e; for l in $(INSTALL_LIBS); do \
  643. fn=`basename $$l`; \
  644. $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn"; \
  645. $(RM) $(DESTDIR)$(libdir)/$$fn; \
  646. done
  647. @ : {- output_off() if $disabled{shared}; "" -}
  648. @set -e; for s in $(INSTALL_SHLIB_INFO); do \
  649. s1=`echo "$$s" | cut -f1 -d";"`; \
  650. s2=`echo "$$s" | cut -f2 -d";"`; \
  651. fn1=`basename $$s1`; \
  652. fn2=`basename $$s2`; \
  653. : {- output_off() if windowsdll(); "" -}; \
  654. $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn2"; \
  655. $(RM) $(DESTDIR)$(libdir)/$$fn2; \
  656. if [ "$$fn1" != "$$fn2" -a -f "$(DESTDIR)$(libdir)/$$fn1" ]; then \
  657. $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn1"; \
  658. $(RM) $(DESTDIR)$(libdir)/$$fn1; \
  659. fi; \
  660. : {- output_on() if windowsdll(); "" -}{- output_off() unless windowsdll(); "" -}; \
  661. $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn2"; \
  662. $(RM) $(DESTDIR)$(libdir)/$$fn2; \
  663. : {- output_on() unless windowsdll(); "" -}; \
  664. done
  665. @ : {- output_on() if $disabled{shared}; "" -}
  666. $(RM) $(DESTDIR)$(libdir)/pkgconfig/libcrypto.pc
  667. $(RM) $(DESTDIR)$(libdir)/pkgconfig/libssl.pc
  668. $(RM) $(DESTDIR)$(libdir)/pkgconfig/openssl.pc
  669. -$(RMDIR) $(DESTDIR)$(libdir)/pkgconfig
  670. -$(RMDIR) $(DESTDIR)$(libdir)
  671. _install_modules_deps: install_runtime_libs build_modules
  672. install_engines: _install_modules_deps
  673. @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
  674. @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(ENGINESDIR)/
  675. @$(ECHO) "*** Installing engines"
  676. @set -e; for e in dummy $(INSTALL_ENGINES); do \
  677. if [ "$$e" = "dummy" ]; then continue; fi; \
  678. fn=`basename $$e`; \
  679. $(ECHO) "install $$e -> $(DESTDIR)$(ENGINESDIR)/$$fn"; \
  680. cp $$e $(DESTDIR)$(ENGINESDIR)/$$fn.new; \
  681. chmod 755 $(DESTDIR)$(ENGINESDIR)/$$fn.new; \
  682. mv -f $(DESTDIR)$(ENGINESDIR)/$$fn.new \
  683. $(DESTDIR)$(ENGINESDIR)/$$fn; \
  684. done
  685. uninstall_engines:
  686. @$(ECHO) "*** Uninstalling engines"
  687. @set -e; for e in dummy $(INSTALL_ENGINES); do \
  688. if [ "$$e" = "dummy" ]; then continue; fi; \
  689. fn=`basename $$e`; \
  690. $(ECHO) "$(RM) $(DESTDIR)$(ENGINESDIR)/$$fn"; \
  691. $(RM) $(DESTDIR)$(ENGINESDIR)/$$fn; \
  692. done
  693. -$(RMDIR) $(DESTDIR)$(ENGINESDIR)
  694. install_modules: _install_modules_deps
  695. @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
  696. @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(MODULESDIR)/
  697. @$(ECHO) "*** Installing modules"
  698. @set -e; for e in dummy $(INSTALL_MODULES); do \
  699. if [ "$$e" = "dummy" ]; then continue; fi; \
  700. fn=`basename $$e`; \
  701. $(ECHO) "install $$e -> $(DESTDIR)$(MODULESDIR)/$$fn"; \
  702. cp $$e $(DESTDIR)$(MODULESDIR)/$$fn.new; \
  703. chmod 755 $(DESTDIR)$(MODULESDIR)/$$fn.new; \
  704. mv -f $(DESTDIR)$(MODULESDIR)/$$fn.new \
  705. $(DESTDIR)$(MODULESDIR)/$$fn; \
  706. done
  707. uninstall_modules:
  708. @$(ECHO) "*** Uninstalling modules"
  709. @set -e; for e in dummy $(INSTALL_MODULES); do \
  710. if [ "$$e" = "dummy" ]; then continue; fi; \
  711. fn=`basename $$e`; \
  712. $(ECHO) "$(RM) $(DESTDIR)$(MODULESDIR)/$$fn"; \
  713. $(RM) $(DESTDIR)$(MODULESDIR)/$$fn; \
  714. done
  715. -$(RMDIR) $(DESTDIR)$(MODULESDIR)
  716. install_runtime: install_programs
  717. install_runtime_libs: build_libs
  718. @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
  719. @ : {- output_off() if windowsdll(); "" -}
  720. @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(libdir)
  721. @ : {- output_on() if windowsdll(); output_off() unless windowsdll(); "" -}
  722. @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/bin
  723. @ : {- output_on() unless windowsdll(); "" -}
  724. @$(ECHO) "*** Installing runtime libraries"
  725. @set -e; for s in dummy $(INSTALL_SHLIBS); do \
  726. if [ "$$s" = "dummy" ]; then continue; fi; \
  727. fn=`basename $$s`; \
  728. : {- output_off() unless windowsdll(); "" -}; \
  729. $(ECHO) "install $$s -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
  730. cp $$s $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
  731. chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
  732. mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
  733. $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
  734. : {- output_on() unless windowsdll(); "" -}{- output_off() if windowsdll(); "" -}; \
  735. $(ECHO) "install $$s -> $(DESTDIR)$(libdir)/$$fn"; \
  736. cp $$s $(DESTDIR)$(libdir)/$$fn.new; \
  737. chmod 755 $(DESTDIR)$(libdir)/$$fn.new; \
  738. mv -f $(DESTDIR)$(libdir)/$$fn.new \
  739. $(DESTDIR)$(libdir)/$$fn; \
  740. : {- output_on() if windowsdll(); "" -}; \
  741. done
  742. install_programs: install_runtime_libs build_programs
  743. @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
  744. @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(INSTALLTOP)/bin
  745. @$(ECHO) "*** Installing runtime programs"
  746. @set -e; for x in dummy $(INSTALL_PROGRAMS); do \
  747. if [ "$$x" = "dummy" ]; then continue; fi; \
  748. fn=`basename $$x`; \
  749. $(ECHO) "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
  750. cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
  751. chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
  752. mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
  753. $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
  754. done
  755. @set -e; for x in dummy $(BIN_SCRIPTS); do \
  756. if [ "$$x" = "dummy" ]; then continue; fi; \
  757. fn=`basename $$x`; \
  758. $(ECHO) "install $$x -> $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
  759. cp $$x $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
  760. chmod 755 $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new; \
  761. mv -f $(DESTDIR)$(INSTALLTOP)/bin/$$fn.new \
  762. $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
  763. done
  764. uninstall_runtime: uninstall_programs uninstall_runtime_libs
  765. uninstall_programs:
  766. @$(ECHO) "*** Uninstalling runtime programs"
  767. @set -e; for x in dummy $(INSTALL_PROGRAMS); \
  768. do \
  769. if [ "$$x" = "dummy" ]; then continue; fi; \
  770. fn=`basename $$x`; \
  771. $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
  772. $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
  773. done;
  774. @set -e; for x in dummy $(BIN_SCRIPTS); \
  775. do \
  776. if [ "$$x" = "dummy" ]; then continue; fi; \
  777. fn=`basename $$x`; \
  778. $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
  779. $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
  780. done
  781. -$(RMDIR) $(DESTDIR)$(INSTALLTOP)/bin
  782. uninstall_runtime_libs:
  783. @$(ECHO) "*** Uninstalling runtime libraries"
  784. @ : {- output_off() unless windowsdll(); "" -}
  785. @set -e; for s in dummy $(INSTALL_SHLIBS); do \
  786. if [ "$$s" = "dummy" ]; then continue; fi; \
  787. fn=`basename $$s`; \
  788. $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn"; \
  789. $(RM) $(DESTDIR)$(INSTALLTOP)/bin/$$fn; \
  790. done
  791. @ : {- output_on() unless windowsdll(); "" -}
  792. install_man_docs: build_man_docs
  793. @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
  794. @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(MANDIR)/man1
  795. @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(MANDIR)/man3
  796. @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(MANDIR)/man5
  797. @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(MANDIR)/man7
  798. @$(ECHO) "*** Installing manpages"
  799. @set -e; for x in dummy $(MANDOCS1); do \
  800. if [ "$$x" = "dummy" ]; then continue; fi; \
  801. fn=`basename $$x`; \
  802. $(ECHO) "install $$x -> $(DESTDIR)$(MANDIR)/man1/$${fn}$(MANSUFFIX)"; \
  803. cp $$x $(DESTDIR)$(MANDIR)/man1/$${fn}$(MANSUFFIX); \
  804. chmod 644 $(DESTDIR)$(MANDIR)/man1/$${fn}$(MANSUFFIX); \
  805. done
  806. @set -e; for x in dummy $(MANDOCS3); do \
  807. if [ "$$x" = "dummy" ]; then continue; fi; \
  808. fn=`basename $$x`; \
  809. $(ECHO) "install $$x -> $(DESTDIR)$(MANDIR)/man3/$${fn}$(MANSUFFIX)"; \
  810. cp $$x $(DESTDIR)$(MANDIR)/man3/$${fn}$(MANSUFFIX); \
  811. chmod 644 $(DESTDIR)$(MANDIR)/man3/$${fn}$(MANSUFFIX); \
  812. done
  813. @set -e; for x in dummy $(MANDOCS5); do \
  814. if [ "$$x" = "dummy" ]; then continue; fi; \
  815. fn=`basename $$x`; \
  816. $(ECHO) "install $$x -> $(DESTDIR)$(MANDIR)/man5/$${fn}$(MANSUFFIX)"; \
  817. cp $$x $(DESTDIR)$(MANDIR)/man5/$${fn}$(MANSUFFIX); \
  818. chmod 644 $(DESTDIR)$(MANDIR)/man5/$${fn}$(MANSUFFIX); \
  819. done
  820. @set -e; for x in dummy $(MANDOCS7); do \
  821. if [ "$$x" = "dummy" ]; then continue; fi; \
  822. fn=`basename $$x`; \
  823. $(ECHO) "install $$x -> $(DESTDIR)$(MANDIR)/man7/$${fn}$(MANSUFFIX)"; \
  824. cp $$x $(DESTDIR)$(MANDIR)/man7/$${fn}$(MANSUFFIX); \
  825. chmod 644 $(DESTDIR)$(MANDIR)/man7/$${fn}$(MANSUFFIX); \
  826. done
  827. uninstall_man_docs:
  828. @$(ECHO) "*** Uninstalling manpages"
  829. @set -e; for x in dummy $(MANDOCS1); do \
  830. if [ "$$x" = "dummy" ]; then continue; fi; \
  831. fn=`basename $$x`; \
  832. $(ECHO) "$(RM) $(DESTDIR)$(MANDIR)/man1/$${fn}$(MANSUFFIX)"; \
  833. $(RM) $(DESTDIR)$(MANDIR)/man1/$${fn}$(MANSUFFIX); \
  834. done
  835. @set -e; for x in dummy $(MANDOCS3); do \
  836. if [ "$$x" = "dummy" ]; then continue; fi; \
  837. fn=`basename $$x`; \
  838. $(ECHO) "$(RM) $(DESTDIR)$(MANDIR)/man3/$${fn}$(MANSUFFIX)"; \
  839. $(RM) $(DESTDIR)$(MANDIR)/man3/$${fn}$(MANSUFFIX); \
  840. done
  841. @set -e; for x in dummy $(MANDOCS5); do \
  842. if [ "$$x" = "dummy" ]; then continue; fi; \
  843. fn=`basename $$x`; \
  844. $(ECHO) "$(RM) $(DESTDIR)$(MANDIR)/man5/$${fn}$(MANSUFFIX)"; \
  845. $(RM) $(DESTDIR)$(MANDIR)/man5/$${fn}$(MANSUFFIX); \
  846. done
  847. @set -e; for x in dummy $(MANDOCS7); do \
  848. if [ "$$x" = "dummy" ]; then continue; fi; \
  849. fn=`basename $$x`; \
  850. $(ECHO) "$(RM) $(DESTDIR)$(MANDIR)/man7/$${fn}$(MANSUFFIX)"; \
  851. $(RM) $(DESTDIR)$(MANDIR)/man7/$${fn}$(MANSUFFIX); \
  852. done
  853. install_html_docs: build_html_docs
  854. @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
  855. @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(HTMLDIR)/man1
  856. @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(HTMLDIR)/man3
  857. @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(HTMLDIR)/man5
  858. @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(HTMLDIR)/man7
  859. @$(ECHO) "*** Installing HTML manpages"
  860. @set -e; for x in dummy $(HTMLDOCS1); do \
  861. if [ "$$x" = "dummy" ]; then continue; fi; \
  862. fn=`basename $$x`; \
  863. $(ECHO) "install $$x -> $(DESTDIR)$(HTMLDIR)/man1/$$fn"; \
  864. cp $$x $(DESTDIR)$(HTMLDIR)/man1/$$fn; \
  865. chmod 644 $(DESTDIR)$(HTMLDIR)/man1/$$fn; \
  866. done
  867. @set -e; for x in dummy $(HTMLDOCS3); do \
  868. if [ "$$x" = "dummy" ]; then continue; fi; \
  869. fn=`basename $$x`; \
  870. $(ECHO) "install $$x -> $(DESTDIR)$(HTMLDIR)/man3/$$fn"; \
  871. cp $$x $(DESTDIR)$(HTMLDIR)/man3/$$fn; \
  872. chmod 644 $(DESTDIR)$(HTMLDIR)/man3/$$fn; \
  873. done
  874. @set -e; for x in dummy $(HTMLDOCS5); do \
  875. if [ "$$x" = "dummy" ]; then continue; fi; \
  876. fn=`basename $$x`; \
  877. $(ECHO) "install $$x -> $(DESTDIR)$(HTMLDIR)/man5/$$fn"; \
  878. cp $$x $(DESTDIR)$(HTMLDIR)/man5/$$fn; \
  879. chmod 644 $(DESTDIR)$(HTMLDIR)/man5/$$fn; \
  880. done
  881. @set -e; for x in dummy $(HTMLDOCS7); do \
  882. if [ "$$x" = "dummy" ]; then continue; fi; \
  883. fn=`basename $$x`; \
  884. $(ECHO) "install $$x -> $(DESTDIR)$(HTMLDIR)/man7/$$fn"; \
  885. cp $$x $(DESTDIR)$(HTMLDIR)/man7/$$fn; \
  886. chmod 644 $(DESTDIR)$(HTMLDIR)/man7/$$fn; \
  887. done
  888. uninstall_html_docs:
  889. @$(ECHO) "*** Uninstalling HTML manpages"
  890. @set -e; for x in dummy $(HTMLDOCS1); do \
  891. if [ "$$x" = "dummy" ]; then continue; fi; \
  892. fn=`basename $$x`; \
  893. $(ECHO) "$(RM) $(DESTDIR)$(HTMLDIR)/man1/$$fn"; \
  894. $(RM) $(DESTDIR)$(HTMLDIR)/man1/$$fn; \
  895. done
  896. @set -e; for x in dummy $(HTMLDOCS3); do \
  897. if [ "$$x" = "dummy" ]; then continue; fi; \
  898. fn=`basename $$x`; \
  899. $(ECHO) "$(RM) $(DESTDIR)$(HTMLDIR)/man3/$$fn"; \
  900. $(RM) $(DESTDIR)$(HTMLDIR)/man3/$$fn; \
  901. done
  902. @set -e; for x in dummy $(HTMLDOCS5); do \
  903. if [ "$$x" = "dummy" ]; then continue; fi; \
  904. fn=`basename $$x`; \
  905. $(ECHO) "$(RM) $(DESTDIR)$(HTMLDIR)/man5/$$fn"; \
  906. $(RM) $(DESTDIR)$(HTMLDIR)/man5/$$fn; \
  907. done
  908. @set -e; for x in dummy $(HTMLDOCS7); do \
  909. if [ "$$x" = "dummy" ]; then continue; fi; \
  910. fn=`basename $$x`; \
  911. $(ECHO) "$(RM) $(DESTDIR)$(HTMLDIR)/man7/$$fn"; \
  912. $(RM) $(DESTDIR)$(HTMLDIR)/man7/$$fn; \
  913. done
  914. # Developer targets (note: these are only available on Unix) #########
  915. update: generate errors ordinals
  916. generate: generate_apps generate_crypto_bn generate_crypto_objects \
  917. generate_crypto_conf generate_crypto_asn1 generate_fuzz_oids
  918. .PHONY: doc-nits cmd-nits md-nits
  919. doc-nits: build_generated
  920. $(PERL) $(SRCDIR)/util/find-doc-nits -n -l -e
  921. cmd-nits: build_generated apps/openssl
  922. $(PERL) $(SRCDIR)/util/find-doc-nits -c
  923. # This uses "mdl", the markdownlint application, which is written in ruby.
  924. # The source is at https://github.com/markdownlint/markdownlint
  925. # If you have ruby installed, "gem install mdl" should work.
  926. # Another option is at https://snapcraft.io/install/mdl/debian
  927. # Finally, there's a Node.js version, which we haven't tried, that
  928. # can be found at https://github.com/DavidAnson/markdownlint
  929. md-nits:
  930. mdl -s util/markdownlint.rb . NOTES-Windows.txt
  931. # Test coverage is a good idea for the future
  932. #coverage: $(PROGRAMS) $(TESTPROGRAMS)
  933. # ...
  934. lint:
  935. lint -DLINT $(INCLUDES) $(SRCS)
  936. generate_apps:
  937. ( cd $(SRCDIR); $(PERL) VMS/VMSify-conf.pl \
  938. < apps/openssl.cnf > apps/openssl-vms.cnf )
  939. generate_crypto_bn:
  940. ( cd $(SRCDIR); $(PERL) crypto/bn/bn_prime.pl > crypto/bn/bn_prime.h )
  941. generate_crypto_objects:
  942. ( cd $(SRCDIR); $(PERL) crypto/objects/objects.pl -n \
  943. crypto/objects/objects.txt \
  944. crypto/objects/obj_mac.num \
  945. > crypto/objects/obj_mac.new && \
  946. mv crypto/objects/obj_mac.new crypto/objects/obj_mac.num )
  947. ( cd $(SRCDIR); $(PERL) crypto/objects/objects.pl \
  948. crypto/objects/objects.txt \
  949. crypto/objects/obj_mac.num \
  950. > include/openssl/obj_mac.h )
  951. ( cd $(SRCDIR); $(PERL) crypto/objects/obj_dat.pl \
  952. include/openssl/obj_mac.h \
  953. > crypto/objects/obj_dat.h )
  954. ( cd $(SRCDIR); $(PERL) crypto/objects/objxref.pl \
  955. crypto/objects/obj_mac.num \
  956. crypto/objects/obj_xref.txt \
  957. > crypto/objects/obj_xref.h )
  958. ( cd $(SRCDIR); cat crypto/objects/obj_compat.h >> include/openssl/obj_mac.h )
  959. generate_crypto_conf:
  960. ( cd $(SRCDIR); $(PERL) crypto/conf/keysets.pl \
  961. > crypto/conf/conf_def.h )
  962. generate_crypto_asn1:
  963. ( cd $(SRCDIR); $(PERL) crypto/asn1/charmap.pl \
  964. > crypto/asn1/charmap.h )
  965. generate_fuzz_oids:
  966. ( cd $(SRCDIR); $(PERL) fuzz/mkfuzzoids.pl \
  967. crypto/objects/obj_dat.h \
  968. > fuzz/oids.txt )
  969. # Set to -force to force a rebuild
  970. ERROR_REBUILD=
  971. errors:
  972. ( b=`pwd`; set -e; cd $(SRCDIR); \
  973. $(PERL) util/ck_errf.pl -strict -internal; \
  974. $(PERL) -I$$b util/mkerr.pl $(ERROR_REBUILD) -internal )
  975. ( b=`pwd`; set -e; cd $(SRCDIR)/engines; \
  976. for E in *.ec ; do \
  977. $(PERL) ../util/ck_errf.pl -strict \
  978. -conf $$E `basename $$E .ec`.c; \
  979. $(PERL) -I$$b ../util/mkerr.pl $(ERROR_REBUILD) -static \
  980. -conf $$E `basename $$E .ec`.c ; \
  981. done )
  982. {- use File::Basename;
  983. my @sslheaders_tmpl =
  984. qw( include/openssl/ssl.h
  985. include/openssl/ssl2.h
  986. include/openssl/ssl3.h
  987. include/openssl/sslerr.h
  988. include/openssl/tls1.h
  989. include/openssl/dtls1.h
  990. include/openssl/srtp.h
  991. include/openssl/sslerr_legacy.h );
  992. my @cryptoheaders_tmpl =
  993. qw( include/internal/dso.h
  994. include/internal/o_dir.h
  995. include/internal/err.h
  996. include/internal/evp.h
  997. include/internal/pem.h
  998. include/internal/asn1.h
  999. include/internal/sslconf.h );
  1000. my @cryptoskipheaders = ( @sslheaders_tmpl,
  1001. qw( include/openssl/conf_api.h
  1002. include/openssl/ebcdic.h
  1003. include/openssl/opensslconf.h
  1004. include/openssl/symhacks.h ) );
  1005. our %cryptoheaders = ();
  1006. our %sslheaders = ();
  1007. foreach my $d ( qw( include/openssl include/internal ) ) {
  1008. my @header_patterns =
  1009. map { catfile($config{sourcedir}, $d, $_) } ( '*.h', '*.h.in' );
  1010. foreach my $f ( map { glob($_) } @header_patterns ) {
  1011. my $base = basename($f);
  1012. my $base_in = basename($f, '.in');
  1013. my $dir = catfile($config{sourcedir}, $d);
  1014. if ($base ne $base_in) {
  1015. # We have a .h.in file, which means the header file is in the
  1016. # build tree.
  1017. $base = $base_in;
  1018. $dir = catfile($config{builddir}, $d);
  1019. }
  1020. my $new_f = catfile($dir, $base);
  1021. my $fn = "$d/$base";
  1022. # The logic to add files to @cryptoheaders is a bit complex. The
  1023. # file to be added must be either in the public header directory
  1024. # or one of the pre-declared internal headers, and must under no
  1025. # circumstances be one of those that must be skipped.
  1026. $cryptoheaders{$new_f} = 1
  1027. if (($d eq 'include/openssl'
  1028. || ( grep { $_ eq $fn } @cryptoheaders_tmpl ))
  1029. && !( grep { $_ eq $fn } @cryptoskipheaders ));
  1030. # The logic to add files to @sslheaders is much simpler...
  1031. $sslheaders{$new_f} = 1 if grep { $_ eq $fn } @sslheaders_tmpl;
  1032. }
  1033. }
  1034. "";
  1035. -}
  1036. CRYPTOHEADERS={- join(" \\\n" . ' ' x 14,
  1037. fill_lines(" ", $COLUMNS - 14, sort keys %cryptoheaders)) -}
  1038. SSLHEADERS={- join(" \\\n" . ' ' x 11,
  1039. fill_lines(" ", $COLUMNS - 11, sort keys %sslheaders)) -}
  1040. ordinals: build_generated
  1041. $(PERL) $(SRCDIR)/util/mknum.pl --version $(VERSION) --no-warnings \
  1042. --ordinals $(SRCDIR)/util/libcrypto.num \
  1043. --symhacks $(SRCDIR)/include/openssl/symhacks.h \
  1044. $(CRYPTOHEADERS)
  1045. $(PERL) $(SRCDIR)/util/mknum.pl --version $(VERSION) --no-warnings \
  1046. --ordinals $(SRCDIR)/util/libssl.num \
  1047. --symhacks $(SRCDIR)/include/openssl/symhacks.h \
  1048. $(SSLHEADERS)
  1049. test_ordinals:
  1050. ( cd test; \
  1051. SRCTOP=../$(SRCDIR) \
  1052. BLDTOP=../$(BLDDIR) \
  1053. $(PERL) ../$(SRCDIR)/test/run_tests.pl test_ordinals )
  1054. tags TAGS: FORCE
  1055. rm -f TAGS tags
  1056. -ctags -R .
  1057. -etags `find . -name '*.[ch]' -o -name '*.pm'`
  1058. # Release targets (note: only available on Unix) #####################
  1059. tar:
  1060. (cd $(SRCDIR); ./util/mktar.sh --name='$(NAME)' --tarfile='$(TARFILE)')
  1061. # Helper targets #####################################################
  1062. link-utils: $(BLDDIR)/util/opensslwrap.sh $(BLDDIR)/util/wrap.pl
  1063. $(BLDDIR)/util/opensslwrap.sh $(BLDDIR)/util/wrap.pl: configdata.pm
  1064. @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
  1065. mkdir -p "$(BLDDIR)/util"; \
  1066. ln -sf "../$(SRCDIR)/util/`basename "$@"`" "$(BLDDIR)/util"; \
  1067. fi
  1068. FORCE:
  1069. # Building targets ###################################################
  1070. libcrypto.pc libssl.pc openssl.pc: configdata.pm $(LIBS) {- join(" ",map { platform->sharedlib_simple($_) // () } @{$unified_info{libraries}}) -}
  1071. libcrypto.pc:
  1072. @ ( echo 'prefix=$(INSTALLTOP)'; \
  1073. echo 'exec_prefix=$${prefix}'; \
  1074. if [ -n "$(LIBDIR)" ]; then \
  1075. echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
  1076. else \
  1077. echo 'libdir=$(libdir)'; \
  1078. fi; \
  1079. echo 'includedir=$${prefix}/include'; \
  1080. echo 'enginesdir=$${libdir}/engines-{- $sover_dirname -}'; \
  1081. echo ''; \
  1082. echo 'Name: OpenSSL-libcrypto'; \
  1083. echo 'Description: OpenSSL cryptography library'; \
  1084. echo 'Version: '$(VERSION); \
  1085. echo 'Libs: -L$${libdir} -lcrypto'; \
  1086. echo 'Libs.private: $(LIB_EX_LIBS)'; \
  1087. echo 'Cflags: -I$${includedir}' ) > libcrypto.pc
  1088. libssl.pc:
  1089. @ ( echo 'prefix=$(INSTALLTOP)'; \
  1090. echo 'exec_prefix=$${prefix}'; \
  1091. if [ -n "$(LIBDIR)" ]; then \
  1092. echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
  1093. else \
  1094. echo 'libdir=$(libdir)'; \
  1095. fi; \
  1096. echo 'includedir=$${prefix}/include'; \
  1097. echo ''; \
  1098. echo 'Name: OpenSSL-libssl'; \
  1099. echo 'Description: Secure Sockets Layer and cryptography libraries'; \
  1100. echo 'Version: '$(VERSION); \
  1101. echo 'Requires.private: libcrypto'; \
  1102. echo 'Libs: -L$${libdir} -lssl'; \
  1103. echo 'Cflags: -I$${includedir}' ) > libssl.pc
  1104. openssl.pc:
  1105. @ ( echo 'prefix=$(INSTALLTOP)'; \
  1106. echo 'exec_prefix=$${prefix}'; \
  1107. if [ -n "$(LIBDIR)" ]; then \
  1108. echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
  1109. else \
  1110. echo 'libdir=$(libdir)'; \
  1111. fi; \
  1112. echo 'includedir=$${prefix}/include'; \
  1113. echo ''; \
  1114. echo 'Name: OpenSSL'; \
  1115. echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \
  1116. echo 'Version: '$(VERSION); \
  1117. echo 'Requires: libssl libcrypto' ) > openssl.pc
  1118. configdata.pm: $(SRCDIR)/Configure $(SRCDIR)/config \
  1119. {- join(" \\\n" . ' ' x 15,
  1120. fill_lines(" ", $COLUMNS - 15,
  1121. @{$config{build_file_templates}},
  1122. @{$config{build_infos}},
  1123. @{$config{conf_files}})) -}
  1124. @echo "Detected changed: $?"
  1125. $(PERL) configdata.pm -r
  1126. @echo "**************************************************"
  1127. @echo "*** ***"
  1128. @echo "*** Please run the same make command again ***"
  1129. @echo "*** ***"
  1130. @echo "**************************************************"
  1131. @false
  1132. reconfigure reconf:
  1133. $(PERL) configdata.pm -r
  1134. {-
  1135. use File::Basename;
  1136. use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
  1137. # Helper function to figure out dependencies on libraries
  1138. # It takes a list of library names and outputs a list of dependencies
  1139. sub compute_lib_depends {
  1140. # Depending on shared libraries:
  1141. # On Windows POSIX layers, we depend on {libname}.dll.a
  1142. # On Unix platforms, we depend on {shlibname}.so
  1143. return map { platform->sharedlib_simple($_) // platform->staticlib($_) } @_;
  1144. }
  1145. sub generatesrc {
  1146. my %args = @_;
  1147. my $generator = join(" ", @{$args{generator}});
  1148. my $generator_incs = join("", map { " -I".$_ } @{$args{generator_incs}});
  1149. my $incs = join("", map { " -I".$_ } @{$args{incs}});
  1150. my $defs = join("", map { " -D".$_ } @{$args{defs}});
  1151. my $deps = join(" ", @{$args{generator_deps}}, @{$args{deps}});
  1152. if ($args{src} =~ /\.html$/) {
  1153. my $title = basename($args{src}, ".html");
  1154. my $pod = $args{generator}->[0];
  1155. return <<"EOF";
  1156. $args{src}: $pod
  1157. \$(PERL) \$(SRCDIR)/util/mkpod2html.pl -i "$pod" -o \$\@ -t "$title" -r "\$(SRCDIR)/doc"
  1158. EOF
  1159. } elsif ($args{src} =~ /\.(\d)$/) {
  1160. my $section = $1;
  1161. my $name = uc basename($args{src}, ".$section");
  1162. my $pod = $args{generator}->[0];
  1163. return <<"EOF";
  1164. $args{src}: $pod
  1165. pod2man --name=$name --section=$section --center=OpenSSL \\
  1166. --release=\$(VERSION) $pod >\$\@
  1167. EOF
  1168. } elsif (platform->isdef($args{src})) {
  1169. my $target = platform->def($args{src});
  1170. (my $mkdef_os = $target{shared_target}) =~ s|-shared$||;
  1171. my $ord_ver = $args{intent} eq 'lib' ? ' --version $(VERSION)' : '';
  1172. my $ord_name = $args{generator}->[1] || $args{product};
  1173. return <<"EOF";
  1174. $target: $args{generator}->[0] $deps \$(SRCDIR)/util/mkdef.pl
  1175. \$(PERL) \$(SRCDIR)/util/mkdef.pl$ord_ver --ordinals $args{generator}->[0] --name $ord_name --OS $mkdef_os > $target
  1176. EOF
  1177. } elsif (!platform->isasm($args{src})) {
  1178. if ($args{generator}->[0] =~ m|^.*\.in$|) {
  1179. my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
  1180. "util", "dofile.pl")),
  1181. rel2abs($config{builddir}));
  1182. my @modules = ( 'configdata.pm',
  1183. grep { $_ =~ m|\.pm$| } @{$args{deps}} );
  1184. my %moduleincs = map { '"-I'.dirname($_).'"' => 1 } @modules;
  1185. @modules = map { "-M".basename($_, '.pm') } @modules;
  1186. my $modules = join(' ', '', sort keys %moduleincs, @modules);
  1187. return <<"EOF";
  1188. $args{src}: $args{generator}->[0] $deps \$(BLDDIR)/configdata.pm
  1189. \$(PERL)$modules "$dofile" "-o$target{build_file}" $generator > \$@
  1190. EOF
  1191. } else {
  1192. return <<"EOF";
  1193. $args{src}: $args{generator}->[0] $deps
  1194. \$(PERL)$generator_incs $generator > \$@
  1195. EOF
  1196. }
  1197. } else {
  1198. my $cppflags = {
  1199. shlib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
  1200. lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
  1201. dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)',
  1202. bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
  1203. } -> {$args{intent}};
  1204. if ($args{generator}->[0] =~ /\.pl$/) {
  1205. $generator = 'CC="$(CC)" $(PERL)'.$generator_incs.' '.$generator
  1206. .' "$(PERLASM_SCHEME)"'.$incs.' '.$cppflags.$defs.' $(PROCESSOR)';
  1207. } elsif ($args{generator}->[0] =~ /\.m4$/) {
  1208. $generator = 'm4 -B 8192'.$generator_incs.' '.$generator.' >'
  1209. } elsif ($args{generator}->[0] =~ /\.S$/) {
  1210. $generator = undef;
  1211. } else {
  1212. die "Generator type for $args{src} unknown: $generator\n";
  1213. }
  1214. if (defined($generator)) {
  1215. return <<"EOF";
  1216. $args{src}: $args{generator}->[0] $deps
  1217. $generator \$@
  1218. EOF
  1219. }
  1220. return <<"EOF";
  1221. $args{src}: $args{generator}->[0] $deps
  1222. \$(CC) $incs $cppflags $defs -E $args{generator}->[0] | \\
  1223. \$(PERL) -ne '/^#(line)?\\s*[0-9]+/ or print' > \$@
  1224. EOF
  1225. }
  1226. }
  1227. # Should one wonder about the end of the Perl snippet, it's because this
  1228. # second regexp eats up line endings as well, if the removed path is the
  1229. # last in the line. We may therefore need to put back a line ending.
  1230. sub src2obj {
  1231. my %args = @_;
  1232. my $obj = platform->convertext($args{obj});
  1233. my $dep = platform->dep($args{obj});
  1234. my @srcs = @{$args{srcs}};
  1235. my $srcs = join(" ", @srcs);
  1236. my $deps = join(" ", @srcs, @{$args{deps}});
  1237. my $incs = join("", map { " -I".$_ } @{$args{incs}});
  1238. my $defs = join("", map { " -D".$_ } @{$args{defs}});
  1239. my $cmd;
  1240. my $cmdflags;
  1241. my $cmdcompile;
  1242. if (grep /\.rc$/, @srcs) {
  1243. $cmd = '$(RC)';
  1244. $cmdflags = '$(RCFLAGS)';
  1245. $cmdcompile = '';
  1246. } elsif (grep /\.(cc|cpp)$/, @srcs) {
  1247. $cmd = '$(CXX)';
  1248. $cmdcompile = ' -c';
  1249. $cmdflags = {
  1250. shlib => '$(LIB_CXXFLAGS) $(LIB_CPPFLAGS)',
  1251. lib => '$(LIB_CXXFLAGS) $(LIB_CPPFLAGS)',
  1252. dso => '$(DSO_CXXFLAGS) $(DSO_CPPFLAGS)',
  1253. bin => '$(BIN_CXXFLAGS) $(BIN_CPPFLAGS)'
  1254. } -> {$args{intent}};
  1255. } else {
  1256. $cmd = '$(CC)';
  1257. $cmdcompile = ' -c';
  1258. $cmdflags = {
  1259. shlib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
  1260. lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
  1261. dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)',
  1262. bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
  1263. } -> {$args{intent}};
  1264. }
  1265. my $recipe;
  1266. # extension-specific rules
  1267. if (grep /\.s$/, @srcs) {
  1268. $recipe .= <<"EOF";
  1269. $obj: $deps
  1270. $cmd $cmdflags -c -o \$\@ $srcs
  1271. EOF
  1272. } elsif (grep /\.S$/, @srcs) {
  1273. # Originally there was mutli-step rule with $(CC) -E file.S
  1274. # followed by $(CC) -c file.s. It compensated for one of
  1275. # legacy platform compiler's inability to handle .S files.
  1276. # The platform is long discontinued by vendor so there is
  1277. # hardly a point to drag it along...
  1278. $recipe .= <<"EOF";
  1279. $obj: $deps
  1280. $cmd $incs $defs $cmdflags -c -o \$\@ $srcs
  1281. EOF
  1282. } elsif (defined $makedepprog && $makedepprog !~ /\/makedepend/
  1283. && !grep /\.rc$/, @srcs) {
  1284. $recipe .= <<"EOF";
  1285. $obj: $deps
  1286. $cmd $incs $defs $cmdflags -MMD -MF $dep.tmp -MT \$\@ -c -o \$\@ $srcs
  1287. \@touch $dep.tmp
  1288. \@if cmp $dep.tmp $dep > /dev/null 2> /dev/null; then \\
  1289. rm -f $dep.tmp; \\
  1290. else \\
  1291. mv $dep.tmp $dep; \\
  1292. fi
  1293. EOF
  1294. } else {
  1295. $recipe .= <<"EOF";
  1296. $obj: $deps
  1297. $cmd $incs $defs $cmdflags $cmdcompile -o \$\@ $srcs
  1298. EOF
  1299. if (defined $makedepprog && $makedepprog =~ /\/makedepend/) {
  1300. $recipe .= <<"EOF";
  1301. \$(MAKEDEPEND) -f- -Y -- $incs $cmdflags -- $srcs 2>/dev/null \\
  1302. > $dep
  1303. EOF
  1304. }
  1305. }
  1306. return $recipe;
  1307. }
  1308. # We *know* this routine is only called when we've configure 'shared'.
  1309. sub obj2shlib {
  1310. my %args = @_;
  1311. my @linkdirs = ();
  1312. my @linklibs = ();
  1313. foreach (@{$args{deps}}) {
  1314. if (platform->isstaticlib($_)) {
  1315. push @linklibs, platform->convertext($_);
  1316. } else {
  1317. my $d = "-L" . dirname($_);
  1318. my $l = basename($_);
  1319. $l =~ s/^lib//;
  1320. $l = "-l" . $l;
  1321. push @linklibs, $l;
  1322. push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
  1323. }
  1324. }
  1325. my $linkflags = join("", map { $_." " } @linkdirs);
  1326. my $linklibs = join("", map { $_." " } @linklibs);
  1327. my @objs = map { platform->convertext($_) }
  1328. grep { !platform->isdef($_) }
  1329. @{$args{objs}};
  1330. my @defs = map { platform->def($_) }
  1331. grep { platform->isdef($_) }
  1332. @{$args{objs}};
  1333. my @deps = compute_lib_depends(@{$args{deps}});
  1334. die "More than one exported symbol map" if scalar @defs > 1;
  1335. my $simple = platform->sharedlib_simple($args{lib});
  1336. my $full = platform->sharedlib($args{lib});
  1337. my $argfile = defined $target{shared_argfileflag} ? $full.".args" : undef;
  1338. my $shared_soname = "";
  1339. $shared_soname .= ' '.$target{shared_sonameflag}.basename($full)
  1340. if defined $target{shared_sonameflag};
  1341. my $shared_imp = "";
  1342. $shared_imp .= ' '.$target{shared_impflag}.basename($simple)
  1343. if defined $target{shared_impflag};
  1344. my $shared_def = join("", map { ' '.$target{shared_defflag}.$_ } @defs);
  1345. # There is at least one platform where the compiler-as-linker needs to
  1346. # have one object file directly on the command line. That won't hurt
  1347. # any other platform, so we do that for everyone when there's an argfile
  1348. # to be had. This depends heavily on splice, which removes elements from
  1349. # the given array, and returns them so they can be captured.
  1350. my @argfileobjs = $argfile
  1351. ? splice(@objs, 1)
  1352. : ();
  1353. my $argfilecmds = $argfile
  1354. ? join("\n\t", map { "echo $_ >> $argfile" } @argfileobjs)
  1355. : undef;
  1356. my $argfiledeps = $argfile
  1357. ? join(" \\\n" . ' ' x (length($argfile) + 2),
  1358. fill_lines(' ', $COLUMNS - length($full) - 2, @argfileobjs))
  1359. : undef;
  1360. my @fulldeps = (@objs, ($argfile ? $argfile : ()), @defs, @deps);
  1361. my @fullobjs = (
  1362. @objs,
  1363. ($argfile ? $target{shared_argfileflag}.$argfile : ())
  1364. );
  1365. my $fulldeps =
  1366. join(" \\\n" . ' ' x (length($full) + 2),
  1367. fill_lines(' ', $COLUMNS - length($full) - 2, @fulldeps));
  1368. my $fullobjs =
  1369. join(" \\\n\t\t", fill_lines(' ', $COLUMNS - 16, @fullobjs));
  1370. my $recipe = '';
  1371. if ($simple ne $full) {
  1372. if (sharedaix()) {
  1373. $recipe .= <<"EOF";
  1374. $simple: $full
  1375. rm -f $simple && \\
  1376. \$(AR) r $simple $full
  1377. EOF
  1378. } else {
  1379. $recipe .= <<"EOF";
  1380. $simple: $full
  1381. rm -f $simple && \\
  1382. ln -s $full $simple
  1383. EOF
  1384. }
  1385. }
  1386. $recipe .= <<"EOF";
  1387. $full: $fulldeps
  1388. \$(CC) \$(LIB_CFLAGS) $linkflags\$(LIB_LDFLAGS)$shared_soname$shared_imp \\
  1389. -o $full$shared_def \\
  1390. $fullobjs \\
  1391. $linklibs \$(LIB_EX_LIBS)
  1392. EOF
  1393. if (windowsdll()) {
  1394. $recipe .= <<"EOF";
  1395. rm -f apps/$full
  1396. rm -f test/$full
  1397. rm -f fuzz/$full
  1398. cp -p $full apps/
  1399. cp -p $full test/
  1400. cp -p $full fuzz/
  1401. EOF
  1402. }
  1403. $recipe .= <<"EOF" if defined $argfile;
  1404. $argfile: $argfiledeps
  1405. \$(RM) $argfile
  1406. $argfilecmds
  1407. EOF
  1408. return $recipe;
  1409. }
  1410. sub obj2dso {
  1411. my %args = @_;
  1412. my $dso = platform->dso($args{module});
  1413. my @linkdirs = ();
  1414. my @linklibs = ();
  1415. foreach (@{$args{deps}}) {
  1416. next unless defined $_;
  1417. if (platform->isstaticlib($_)) {
  1418. push @linklibs, platform->convertext($_);
  1419. } else {
  1420. my $d = "-L" . dirname($_);
  1421. my $l = basename($_);
  1422. $l =~ s/^lib//;
  1423. $l = "-l" . $l;
  1424. push @linklibs, $l;
  1425. push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
  1426. }
  1427. }
  1428. my $linkflags = join("", map { $_." " } @linkdirs);
  1429. my $linklibs = join("", map { $_." " } @linklibs);
  1430. my @objs = map { platform->convertext($_) }
  1431. grep { !platform->isdef($_) }
  1432. @{$args{objs}};
  1433. my @defs = map { platform->def($_) }
  1434. grep { platform->isdef($_) }
  1435. @{$args{objs}};
  1436. my @deps = compute_lib_depends(@{$args{deps}});
  1437. my $shared_def = join("", map { ' '.$target{shared_defflag}.$_ } @defs);
  1438. # TODO(3.0): next line needs to become "less magic" (see PR #11950)
  1439. $shared_def .= ' '.$target{shared_fipsflag} if (m/providers\/fips/ && defined $target{shared_fipsflag});
  1440. my $objs = join(" \\\n\t\t", fill_lines(' ', $COLUMNS - 16, @objs));
  1441. my $deps = join(" \\\n" . ' ' x (length($dso) + 2),
  1442. fill_lines(' ', $COLUMNS - length($dso) - 2,
  1443. @objs, @defs, @deps));
  1444. return <<"EOF";
  1445. $dso: $deps
  1446. \$(CC) \$(DSO_CFLAGS) $linkflags\$(DSO_LDFLAGS) \\
  1447. -o $dso$shared_def \\
  1448. $objs \\
  1449. $linklibs\$(DSO_EX_LIBS)
  1450. EOF
  1451. }
  1452. sub obj2lib {
  1453. my %args = @_;
  1454. my $lib = platform->staticlib($args{lib});
  1455. my @objs = map { platform->obj($_) } @{$args{objs}};
  1456. my $deps = join(" \\\n" . ' ' x (length($lib) + 2),
  1457. fill_lines(' ', $COLUMNS - length($lib) - 2, @objs));
  1458. my $max_per_call = 500;
  1459. my @objs_grouped;
  1460. push @objs_grouped, join(" ", splice @objs, 0, $max_per_call) while @objs;
  1461. my $fill_lib =
  1462. join("\n\t", (map { "\$(AR) \$(ARFLAGS) $lib $_" } @objs_grouped));
  1463. return <<"EOF";
  1464. $lib: $deps
  1465. \$(RM) $lib
  1466. $fill_lib
  1467. \$(RANLIB) \$\@ || echo Never mind.
  1468. EOF
  1469. }
  1470. sub obj2bin {
  1471. my %args = @_;
  1472. my $bin = platform->bin($args{bin});
  1473. my @objs = map { platform->obj($_) } @{$args{objs}};
  1474. my @deps = compute_lib_depends(@{$args{deps}});
  1475. my $objs = join(" \\\n" . ' ' x (length($bin) + 2),
  1476. fill_lines(' ', $COLUMNS - length($bin) - 2, @objs));
  1477. my @linkdirs = ();
  1478. my @linklibs = ();
  1479. foreach (@{$args{deps}}) {
  1480. next unless defined $_;
  1481. if (platform->isstaticlib($_)) {
  1482. push @linklibs, platform->convertext($_);
  1483. } else {
  1484. my $d = "-L" . dirname($_);
  1485. my $l = basename($_);
  1486. $l =~ s/^lib//;
  1487. $l = "-l" . $l;
  1488. push @linklibs, $l;
  1489. push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
  1490. }
  1491. }
  1492. my $linkflags = join("", map { $_." " } @linkdirs);
  1493. my $linklibs = join("", map { $_." " } @linklibs);
  1494. my $cmd = '$(CC)';
  1495. my $cmdflags = '$(BIN_CFLAGS)';
  1496. if (grep /_cc\.o$/, @{$args{objs}}) {
  1497. $cmd = '$(CXX)';
  1498. $cmdflags = '$(BIN_CXXFLAGS)';
  1499. }
  1500. my $objs = join(" \\\n\t\t", fill_lines(' ', $COLUMNS - 16, @objs));
  1501. my $deps = join(" \\\n" . ' ' x (length($bin) + 2),
  1502. fill_lines(' ', $COLUMNS - length($bin) - 2,
  1503. @objs, @deps));
  1504. return <<"EOF";
  1505. $bin: $deps
  1506. rm -f $bin
  1507. \$\${LDCMD:-$cmd} $cmdflags $linkflags\$(BIN_LDFLAGS) \\
  1508. -o $bin \\
  1509. $objs \\
  1510. $linklibs\$(BIN_EX_LIBS)
  1511. EOF
  1512. }
  1513. sub in2script {
  1514. my %args = @_;
  1515. my $script = $args{script};
  1516. my $sources = join(" ", @{$args{sources}});
  1517. my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
  1518. "util", "dofile.pl")),
  1519. rel2abs($config{builddir}));
  1520. return <<"EOF";
  1521. $script: $sources
  1522. \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
  1523. "-o$target{build_file}" $sources > "$script"
  1524. chmod a+x $script
  1525. EOF
  1526. }
  1527. sub generatedir {
  1528. my %args = @_;
  1529. my $dir = $args{dir};
  1530. my @deps = map { platform->convertext($_) } @{$args{deps}};
  1531. my @comments = ();
  1532. my %extinfo = ( dso => platform->dsoext(),
  1533. lib => platform->libext(),
  1534. bin => platform->binext() );
  1535. # We already have a 'test' target, and the top directory is just plain
  1536. # silly
  1537. return if $dir eq "test" || $dir eq ".";
  1538. foreach my $type (("dso", "lib", "bin", "script")) {
  1539. next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type});
  1540. # For lib object files, we could update the library. However, it
  1541. # was decided that it's enough to build the directory local object
  1542. # files, so we don't need to add any actions, and the dependencies
  1543. # are already taken care of.
  1544. if ($type ne "lib") {
  1545. foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) {
  1546. if (dirname($prod) eq $dir) {
  1547. push @deps, $prod.$extinfo{$type};
  1548. } else {
  1549. push @comments, "# No support to produce $type ".join(", ", @{$unified_info{dirinfo}->{$dir}->{products}->{$type}});
  1550. }
  1551. }
  1552. }
  1553. }
  1554. my $target = "$dir $dir/";
  1555. my $deps = join(" \\\n\t",
  1556. fill_lines(' ', $COLUMNS - 8, @deps));
  1557. my $comments = join("\n", "", @comments);
  1558. return <<"EOF";
  1559. $target: \\
  1560. $deps$comments
  1561. EOF
  1562. }
  1563. "" # Important! This becomes part of the template result.
  1564. -}