unix-Makefile.tmpl 66 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690
  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. my @cryptoheaders_tmpl =
  992. qw( include/internal/dso.h
  993. include/internal/o_dir.h
  994. include/internal/err.h
  995. include/internal/evp.h
  996. include/internal/pem.h
  997. include/internal/asn1.h
  998. include/internal/sslconf.h );
  999. my @cryptoskipheaders = ( @sslheaders_tmpl,
  1000. qw( include/openssl/conf_api.h
  1001. include/openssl/ebcdic.h
  1002. include/openssl/opensslconf.h
  1003. include/openssl/symhacks.h ) );
  1004. our %cryptoheaders = ();
  1005. our %sslheaders = ();
  1006. foreach my $d ( qw( include/openssl include/internal ) ) {
  1007. my @header_patterns =
  1008. map { catfile($config{sourcedir}, $d, $_) } ( '*.h', '*.h.in' );
  1009. foreach my $f ( map { glob($_) } @header_patterns ) {
  1010. my $base = basename($f);
  1011. my $base_in = basename($f, '.in');
  1012. my $dir = catfile($config{sourcedir}, $d);
  1013. if ($base ne $base_in) {
  1014. # We have a .h.in file, which means the header file is in the
  1015. # build tree.
  1016. $base = $base_in;
  1017. $dir = catfile($config{builddir}, $d);
  1018. }
  1019. my $new_f = catfile($dir, $base);
  1020. my $fn = "$d/$base";
  1021. # The logic to add files to @cryptoheaders is a bit complex. The
  1022. # file to be added must be either in the public header directory
  1023. # or one of the pre-declared internal headers, and must under no
  1024. # circumstances be one of those that must be skipped.
  1025. $cryptoheaders{$new_f} = 1
  1026. if (($d eq 'include/openssl'
  1027. || ( grep { $_ eq $fn } @cryptoheaders_tmpl ))
  1028. && !( grep { $_ eq $fn } @cryptoskipheaders ));
  1029. # The logic to add files to @sslheaders is much simpler...
  1030. $sslheaders{$new_f} = 1 if grep { $_ eq $fn } @sslheaders_tmpl;
  1031. }
  1032. }
  1033. "";
  1034. -}
  1035. CRYPTOHEADERS={- join(" \\\n" . ' ' x 14,
  1036. fill_lines(" ", $COLUMNS - 14, sort keys %cryptoheaders)) -}
  1037. SSLHEADERS={- join(" \\\n" . ' ' x 11,
  1038. fill_lines(" ", $COLUMNS - 11, sort keys %sslheaders)) -}
  1039. ordinals: build_generated
  1040. $(PERL) $(SRCDIR)/util/mknum.pl --version $(VERSION) --no-warnings \
  1041. --ordinals $(SRCDIR)/util/libcrypto.num \
  1042. --symhacks $(SRCDIR)/include/openssl/symhacks.h \
  1043. $(CRYPTOHEADERS)
  1044. $(PERL) $(SRCDIR)/util/mknum.pl --version $(VERSION) --no-warnings \
  1045. --ordinals $(SRCDIR)/util/libssl.num \
  1046. --symhacks $(SRCDIR)/include/openssl/symhacks.h \
  1047. $(SSLHEADERS)
  1048. test_ordinals:
  1049. ( cd test; \
  1050. SRCTOP=../$(SRCDIR) \
  1051. BLDTOP=../$(BLDDIR) \
  1052. $(PERL) ../$(SRCDIR)/test/run_tests.pl test_ordinals )
  1053. tags TAGS: FORCE
  1054. rm -f TAGS tags
  1055. -ctags -R .
  1056. -etags `find . -name '*.[ch]' -o -name '*.pm'`
  1057. # Release targets (note: only available on Unix) #####################
  1058. tar:
  1059. (cd $(SRCDIR); ./util/mktar.sh --name='$(NAME)' --tarfile='$(TARFILE)')
  1060. # Helper targets #####################################################
  1061. link-utils: $(BLDDIR)/util/opensslwrap.sh $(BLDDIR)/util/wrap.pl
  1062. $(BLDDIR)/util/opensslwrap.sh $(BLDDIR)/util/wrap.pl: configdata.pm
  1063. @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
  1064. mkdir -p "$(BLDDIR)/util"; \
  1065. ln -sf "../$(SRCDIR)/util/`basename "$@"`" "$(BLDDIR)/util"; \
  1066. fi
  1067. FORCE:
  1068. # Building targets ###################################################
  1069. libcrypto.pc libssl.pc openssl.pc: configdata.pm $(LIBS) {- join(" ",map { platform->sharedlib_simple($_) // () } @{$unified_info{libraries}}) -}
  1070. libcrypto.pc:
  1071. @ ( echo 'prefix=$(INSTALLTOP)'; \
  1072. echo 'exec_prefix=$${prefix}'; \
  1073. if [ -n "$(LIBDIR)" ]; then \
  1074. echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
  1075. else \
  1076. echo 'libdir=$(libdir)'; \
  1077. fi; \
  1078. echo 'includedir=$${prefix}/include'; \
  1079. echo 'enginesdir=$${libdir}/engines-{- $sover_dirname -}'; \
  1080. echo ''; \
  1081. echo 'Name: OpenSSL-libcrypto'; \
  1082. echo 'Description: OpenSSL cryptography library'; \
  1083. echo 'Version: '$(VERSION); \
  1084. echo 'Libs: -L$${libdir} -lcrypto'; \
  1085. echo 'Libs.private: $(LIB_EX_LIBS)'; \
  1086. echo 'Cflags: -I$${includedir}' ) > libcrypto.pc
  1087. libssl.pc:
  1088. @ ( echo 'prefix=$(INSTALLTOP)'; \
  1089. echo 'exec_prefix=$${prefix}'; \
  1090. if [ -n "$(LIBDIR)" ]; then \
  1091. echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
  1092. else \
  1093. echo 'libdir=$(libdir)'; \
  1094. fi; \
  1095. echo 'includedir=$${prefix}/include'; \
  1096. echo ''; \
  1097. echo 'Name: OpenSSL-libssl'; \
  1098. echo 'Description: Secure Sockets Layer and cryptography libraries'; \
  1099. echo 'Version: '$(VERSION); \
  1100. echo 'Requires.private: libcrypto'; \
  1101. echo 'Libs: -L$${libdir} -lssl'; \
  1102. echo 'Cflags: -I$${includedir}' ) > libssl.pc
  1103. openssl.pc:
  1104. @ ( echo 'prefix=$(INSTALLTOP)'; \
  1105. echo 'exec_prefix=$${prefix}'; \
  1106. if [ -n "$(LIBDIR)" ]; then \
  1107. echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
  1108. else \
  1109. echo 'libdir=$(libdir)'; \
  1110. fi; \
  1111. echo 'includedir=$${prefix}/include'; \
  1112. echo ''; \
  1113. echo 'Name: OpenSSL'; \
  1114. echo 'Description: Secure Sockets Layer and cryptography libraries and tools'; \
  1115. echo 'Version: '$(VERSION); \
  1116. echo 'Requires: libssl libcrypto' ) > openssl.pc
  1117. configdata.pm: $(SRCDIR)/Configure $(SRCDIR)/config \
  1118. {- join(" \\\n" . ' ' x 15,
  1119. fill_lines(" ", $COLUMNS - 15,
  1120. @{$config{build_file_templates}},
  1121. @{$config{build_infos}},
  1122. @{$config{conf_files}})) -}
  1123. @echo "Detected changed: $?"
  1124. $(PERL) configdata.pm -r
  1125. @echo "**************************************************"
  1126. @echo "*** ***"
  1127. @echo "*** Please run the same make command again ***"
  1128. @echo "*** ***"
  1129. @echo "**************************************************"
  1130. @false
  1131. reconfigure reconf:
  1132. $(PERL) configdata.pm -r
  1133. {-
  1134. use File::Basename;
  1135. use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
  1136. # Helper function to figure out dependencies on libraries
  1137. # It takes a list of library names and outputs a list of dependencies
  1138. sub compute_lib_depends {
  1139. # Depending on shared libraries:
  1140. # On Windows POSIX layers, we depend on {libname}.dll.a
  1141. # On Unix platforms, we depend on {shlibname}.so
  1142. return map { platform->sharedlib_simple($_) // platform->staticlib($_) } @_;
  1143. }
  1144. sub generatesrc {
  1145. my %args = @_;
  1146. my $generator = join(" ", @{$args{generator}});
  1147. my $generator_incs = join("", map { " -I".$_ } @{$args{generator_incs}});
  1148. my $incs = join("", map { " -I".$_ } @{$args{incs}});
  1149. my $defs = join("", map { " -D".$_ } @{$args{defs}});
  1150. my $deps = join(" ", @{$args{generator_deps}}, @{$args{deps}});
  1151. if ($args{src} =~ /\.html$/) {
  1152. my $title = basename($args{src}, ".html");
  1153. my $pod = $args{generator}->[0];
  1154. return <<"EOF";
  1155. $args{src}: $pod
  1156. \$(PERL) \$(SRCDIR)/util/mkpod2html.pl -i "$pod" -o \$\@ -t "$title" -r "\$(SRCDIR)/doc"
  1157. EOF
  1158. } elsif ($args{src} =~ /\.(\d)$/) {
  1159. my $section = $1;
  1160. my $name = uc basename($args{src}, ".$section");
  1161. my $pod = $args{generator}->[0];
  1162. return <<"EOF";
  1163. $args{src}: $pod
  1164. pod2man --name=$name --section=$section --center=OpenSSL \\
  1165. --release=\$(VERSION) $pod >\$\@
  1166. EOF
  1167. } elsif (platform->isdef($args{src})) {
  1168. my $target = platform->def($args{src});
  1169. (my $mkdef_os = $target{shared_target}) =~ s|-shared$||;
  1170. my $ord_ver = $args{intent} eq 'lib' ? ' --version $(VERSION)' : '';
  1171. my $ord_name = $args{generator}->[1] || $args{product};
  1172. return <<"EOF";
  1173. $target: $args{generator}->[0] $deps \$(SRCDIR)/util/mkdef.pl
  1174. \$(PERL) \$(SRCDIR)/util/mkdef.pl$ord_ver --ordinals $args{generator}->[0] --name $ord_name --OS $mkdef_os > $target
  1175. EOF
  1176. } elsif (!platform->isasm($args{src})) {
  1177. if ($args{generator}->[0] =~ m|^.*\.in$|) {
  1178. my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
  1179. "util", "dofile.pl")),
  1180. rel2abs($config{builddir}));
  1181. my @modules = ( 'configdata.pm',
  1182. grep { $_ =~ m|\.pm$| } @{$args{deps}} );
  1183. my %moduleincs = map { '"-I'.dirname($_).'"' => 1 } @modules;
  1184. @modules = map { "-M".basename($_, '.pm') } @modules;
  1185. my $modules = join(' ', '', sort keys %moduleincs, @modules);
  1186. return <<"EOF";
  1187. $args{src}: $args{generator}->[0] $deps \$(BLDDIR)/configdata.pm
  1188. \$(PERL)$modules "$dofile" "-o$target{build_file}" $generator > \$@
  1189. EOF
  1190. } else {
  1191. return <<"EOF";
  1192. $args{src}: $args{generator}->[0] $deps
  1193. \$(PERL)$generator_incs $generator > \$@
  1194. EOF
  1195. }
  1196. } else {
  1197. my $cppflags = {
  1198. shlib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
  1199. lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
  1200. dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)',
  1201. bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
  1202. } -> {$args{intent}};
  1203. if ($args{generator}->[0] =~ /\.pl$/) {
  1204. $generator = 'CC="$(CC)" $(PERL)'.$generator_incs.' '.$generator
  1205. .' "$(PERLASM_SCHEME)"'.$incs.' '.$cppflags.$defs.' $(PROCESSOR)';
  1206. } elsif ($args{generator}->[0] =~ /\.m4$/) {
  1207. $generator = 'm4 -B 8192'.$generator_incs.' '.$generator.' >'
  1208. } elsif ($args{generator}->[0] =~ /\.S$/) {
  1209. $generator = undef;
  1210. } else {
  1211. die "Generator type for $args{src} unknown: $generator\n";
  1212. }
  1213. if (defined($generator)) {
  1214. return <<"EOF";
  1215. $args{src}: $args{generator}->[0] $deps
  1216. $generator \$@
  1217. EOF
  1218. }
  1219. return <<"EOF";
  1220. $args{src}: $args{generator}->[0] $deps
  1221. \$(CC) $incs $cppflags $defs -E $args{generator}->[0] | \\
  1222. \$(PERL) -ne '/^#(line)?\\s*[0-9]+/ or print' > \$@
  1223. EOF
  1224. }
  1225. }
  1226. # Should one wonder about the end of the Perl snippet, it's because this
  1227. # second regexp eats up line endings as well, if the removed path is the
  1228. # last in the line. We may therefore need to put back a line ending.
  1229. sub src2obj {
  1230. my %args = @_;
  1231. my $obj = platform->convertext($args{obj});
  1232. my $dep = platform->dep($args{obj});
  1233. my @srcs = @{$args{srcs}};
  1234. my $srcs = join(" ", @srcs);
  1235. my $deps = join(" ", @srcs, @{$args{deps}});
  1236. my $incs = join("", map { " -I".$_ } @{$args{incs}});
  1237. my $defs = join("", map { " -D".$_ } @{$args{defs}});
  1238. my $cmd;
  1239. my $cmdflags;
  1240. my $cmdcompile;
  1241. if (grep /\.rc$/, @srcs) {
  1242. $cmd = '$(RC)';
  1243. $cmdflags = '$(RCFLAGS)';
  1244. $cmdcompile = '';
  1245. } elsif (grep /\.(cc|cpp)$/, @srcs) {
  1246. $cmd = '$(CXX)';
  1247. $cmdcompile = ' -c';
  1248. $cmdflags = {
  1249. shlib => '$(LIB_CXXFLAGS) $(LIB_CPPFLAGS)',
  1250. lib => '$(LIB_CXXFLAGS) $(LIB_CPPFLAGS)',
  1251. dso => '$(DSO_CXXFLAGS) $(DSO_CPPFLAGS)',
  1252. bin => '$(BIN_CXXFLAGS) $(BIN_CPPFLAGS)'
  1253. } -> {$args{intent}};
  1254. } else {
  1255. $cmd = '$(CC)';
  1256. $cmdcompile = ' -c';
  1257. $cmdflags = {
  1258. shlib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
  1259. lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
  1260. dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)',
  1261. bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
  1262. } -> {$args{intent}};
  1263. }
  1264. my $recipe;
  1265. # extension-specific rules
  1266. if (grep /\.s$/, @srcs) {
  1267. $recipe .= <<"EOF";
  1268. $obj: $deps
  1269. $cmd $cmdflags -c -o \$\@ $srcs
  1270. EOF
  1271. } elsif (grep /\.S$/, @srcs) {
  1272. # Originally there was mutli-step rule with $(CC) -E file.S
  1273. # followed by $(CC) -c file.s. It compensated for one of
  1274. # legacy platform compiler's inability to handle .S files.
  1275. # The platform is long discontinued by vendor so there is
  1276. # hardly a point to drag it along...
  1277. $recipe .= <<"EOF";
  1278. $obj: $deps
  1279. $cmd $incs $defs $cmdflags -c -o \$\@ $srcs
  1280. EOF
  1281. } elsif (defined $makedepprog && $makedepprog !~ /\/makedepend/
  1282. && !grep /\.rc$/, @srcs) {
  1283. $recipe .= <<"EOF";
  1284. $obj: $deps
  1285. $cmd $incs $defs $cmdflags -MMD -MF $dep.tmp -MT \$\@ -c -o \$\@ $srcs
  1286. \@touch $dep.tmp
  1287. \@if cmp $dep.tmp $dep > /dev/null 2> /dev/null; then \\
  1288. rm -f $dep.tmp; \\
  1289. else \\
  1290. mv $dep.tmp $dep; \\
  1291. fi
  1292. EOF
  1293. } else {
  1294. $recipe .= <<"EOF";
  1295. $obj: $deps
  1296. $cmd $incs $defs $cmdflags $cmdcompile -o \$\@ $srcs
  1297. EOF
  1298. if (defined $makedepprog && $makedepprog =~ /\/makedepend/) {
  1299. $recipe .= <<"EOF";
  1300. \$(MAKEDEPEND) -f- -Y -- $incs $cmdflags -- $srcs 2>/dev/null \\
  1301. > $dep
  1302. EOF
  1303. }
  1304. }
  1305. return $recipe;
  1306. }
  1307. # We *know* this routine is only called when we've configure 'shared'.
  1308. sub obj2shlib {
  1309. my %args = @_;
  1310. my @linkdirs = ();
  1311. my @linklibs = ();
  1312. foreach (@{$args{deps}}) {
  1313. if (platform->isstaticlib($_)) {
  1314. push @linklibs, platform->convertext($_);
  1315. } else {
  1316. my $d = "-L" . dirname($_);
  1317. my $l = basename($_);
  1318. $l =~ s/^lib//;
  1319. $l = "-l" . $l;
  1320. push @linklibs, $l;
  1321. push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
  1322. }
  1323. }
  1324. my $linkflags = join("", map { $_." " } @linkdirs);
  1325. my $linklibs = join("", map { $_." " } @linklibs);
  1326. my @objs = map { platform->convertext($_) }
  1327. grep { !platform->isdef($_) }
  1328. @{$args{objs}};
  1329. my @defs = map { platform->def($_) }
  1330. grep { platform->isdef($_) }
  1331. @{$args{objs}};
  1332. my @deps = compute_lib_depends(@{$args{deps}});
  1333. die "More than one exported symbol map" if scalar @defs > 1;
  1334. my $simple = platform->sharedlib_simple($args{lib});
  1335. my $full = platform->sharedlib($args{lib});
  1336. my $argfile = defined $target{shared_argfileflag} ? $full.".args" : undef;
  1337. my $shared_soname = "";
  1338. $shared_soname .= ' '.$target{shared_sonameflag}.basename($full)
  1339. if defined $target{shared_sonameflag};
  1340. my $shared_imp = "";
  1341. $shared_imp .= ' '.$target{shared_impflag}.basename($simple)
  1342. if defined $target{shared_impflag};
  1343. my $shared_def = join("", map { ' '.$target{shared_defflag}.$_ } @defs);
  1344. # There is at least one platform where the compiler-as-linker needs to
  1345. # have one object file directly on the command line. That won't hurt
  1346. # any other platform, so we do that for everyone when there's an argfile
  1347. # to be had. This depends heavily on splice, which removes elements from
  1348. # the given array, and returns them so they can be captured.
  1349. my @argfileobjs = $argfile
  1350. ? splice(@objs, 1)
  1351. : ();
  1352. my $argfilecmds = $argfile
  1353. ? join("\n\t", map { "echo $_ >> $argfile" } @argfileobjs)
  1354. : undef;
  1355. my $argfiledeps = $argfile
  1356. ? join(" \\\n" . ' ' x (length($argfile) + 2),
  1357. fill_lines(' ', $COLUMNS - length($full) - 2, @argfileobjs))
  1358. : undef;
  1359. my @fulldeps = (@objs, ($argfile ? $argfile : ()), @defs, @deps);
  1360. my @fullobjs = (
  1361. @objs,
  1362. ($argfile ? $target{shared_argfileflag}.$argfile : ())
  1363. );
  1364. my $fulldeps =
  1365. join(" \\\n" . ' ' x (length($full) + 2),
  1366. fill_lines(' ', $COLUMNS - length($full) - 2, @fulldeps));
  1367. my $fullobjs =
  1368. join(" \\\n\t\t", fill_lines(' ', $COLUMNS - 16, @fullobjs));
  1369. my $recipe = '';
  1370. if ($simple ne $full) {
  1371. if (sharedaix()) {
  1372. $recipe .= <<"EOF";
  1373. $simple: $full
  1374. rm -f $simple && \\
  1375. \$(AR) r $simple $full
  1376. EOF
  1377. } else {
  1378. $recipe .= <<"EOF";
  1379. $simple: $full
  1380. rm -f $simple && \\
  1381. ln -s $full $simple
  1382. EOF
  1383. }
  1384. }
  1385. $recipe .= <<"EOF";
  1386. $full: $fulldeps
  1387. \$(CC) \$(LIB_CFLAGS) $linkflags\$(LIB_LDFLAGS)$shared_soname$shared_imp \\
  1388. -o $full$shared_def \\
  1389. $fullobjs \\
  1390. $linklibs \$(LIB_EX_LIBS)
  1391. EOF
  1392. if (windowsdll()) {
  1393. $recipe .= <<"EOF";
  1394. rm -f apps/$full
  1395. rm -f test/$full
  1396. rm -f fuzz/$full
  1397. cp -p $full apps/
  1398. cp -p $full test/
  1399. cp -p $full fuzz/
  1400. EOF
  1401. }
  1402. $recipe .= <<"EOF" if defined $argfile;
  1403. $argfile: $argfiledeps
  1404. \$(RM) $argfile
  1405. $argfilecmds
  1406. EOF
  1407. return $recipe;
  1408. }
  1409. sub obj2dso {
  1410. my %args = @_;
  1411. my $dso = platform->dso($args{module});
  1412. my @linkdirs = ();
  1413. my @linklibs = ();
  1414. foreach (@{$args{deps}}) {
  1415. next unless defined $_;
  1416. if (platform->isstaticlib($_)) {
  1417. push @linklibs, platform->convertext($_);
  1418. } else {
  1419. my $d = "-L" . dirname($_);
  1420. my $l = basename($_);
  1421. $l =~ s/^lib//;
  1422. $l = "-l" . $l;
  1423. push @linklibs, $l;
  1424. push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
  1425. }
  1426. }
  1427. my $linkflags = join("", map { $_." " } @linkdirs);
  1428. my $linklibs = join("", map { $_." " } @linklibs);
  1429. my @objs = map { platform->convertext($_) }
  1430. grep { !platform->isdef($_) }
  1431. @{$args{objs}};
  1432. my @defs = map { platform->def($_) }
  1433. grep { platform->isdef($_) }
  1434. @{$args{objs}};
  1435. my @deps = compute_lib_depends(@{$args{deps}});
  1436. my $shared_def = join("", map { ' '.$target{shared_defflag}.$_ } @defs);
  1437. # TODO(3.0): next line needs to become "less magic" (see PR #11950)
  1438. $shared_def .= ' '.$target{shared_fipsflag} if (m/providers\/fips/ && defined $target{shared_fipsflag});
  1439. my $objs = join(" \\\n\t\t", fill_lines(' ', $COLUMNS - 16, @objs));
  1440. my $deps = join(" \\\n" . ' ' x (length($dso) + 2),
  1441. fill_lines(' ', $COLUMNS - length($dso) - 2,
  1442. @objs, @defs, @deps));
  1443. return <<"EOF";
  1444. $dso: $deps
  1445. \$(CC) \$(DSO_CFLAGS) $linkflags\$(DSO_LDFLAGS) \\
  1446. -o $dso$shared_def \\
  1447. $objs \\
  1448. $linklibs\$(DSO_EX_LIBS)
  1449. EOF
  1450. }
  1451. sub obj2lib {
  1452. my %args = @_;
  1453. my $lib = platform->staticlib($args{lib});
  1454. my @objs = map { platform->obj($_) } @{$args{objs}};
  1455. my $deps = join(" \\\n" . ' ' x (length($lib) + 2),
  1456. fill_lines(' ', $COLUMNS - length($lib) - 2, @objs));
  1457. my $max_per_call = 500;
  1458. my @objs_grouped;
  1459. push @objs_grouped, join(" ", splice @objs, 0, $max_per_call) while @objs;
  1460. my $fill_lib =
  1461. join("\n\t", (map { "\$(AR) \$(ARFLAGS) $lib $_" } @objs_grouped));
  1462. return <<"EOF";
  1463. $lib: $deps
  1464. \$(RM) $lib
  1465. $fill_lib
  1466. \$(RANLIB) \$\@ || echo Never mind.
  1467. EOF
  1468. }
  1469. sub obj2bin {
  1470. my %args = @_;
  1471. my $bin = platform->bin($args{bin});
  1472. my @objs = map { platform->obj($_) } @{$args{objs}};
  1473. my @deps = compute_lib_depends(@{$args{deps}});
  1474. my $objs = join(" \\\n" . ' ' x (length($bin) + 2),
  1475. fill_lines(' ', $COLUMNS - length($bin) - 2, @objs));
  1476. my @linkdirs = ();
  1477. my @linklibs = ();
  1478. foreach (@{$args{deps}}) {
  1479. next unless defined $_;
  1480. if (platform->isstaticlib($_)) {
  1481. push @linklibs, platform->convertext($_);
  1482. } else {
  1483. my $d = "-L" . dirname($_);
  1484. my $l = basename($_);
  1485. $l =~ s/^lib//;
  1486. $l = "-l" . $l;
  1487. push @linklibs, $l;
  1488. push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
  1489. }
  1490. }
  1491. my $linkflags = join("", map { $_." " } @linkdirs);
  1492. my $linklibs = join("", map { $_." " } @linklibs);
  1493. my $cmd = '$(CC)';
  1494. my $cmdflags = '$(BIN_CFLAGS)';
  1495. if (grep /_cc\.o$/, @{$args{objs}}) {
  1496. $cmd = '$(CXX)';
  1497. $cmdflags = '$(BIN_CXXFLAGS)';
  1498. }
  1499. my $objs = join(" \\\n\t\t", fill_lines(' ', $COLUMNS - 16, @objs));
  1500. my $deps = join(" \\\n" . ' ' x (length($bin) + 2),
  1501. fill_lines(' ', $COLUMNS - length($bin) - 2,
  1502. @objs, @deps));
  1503. return <<"EOF";
  1504. $bin: $deps
  1505. rm -f $bin
  1506. \$\${LDCMD:-$cmd} $cmdflags $linkflags\$(BIN_LDFLAGS) \\
  1507. -o $bin \\
  1508. $objs \\
  1509. $linklibs\$(BIN_EX_LIBS)
  1510. EOF
  1511. }
  1512. sub in2script {
  1513. my %args = @_;
  1514. my $script = $args{script};
  1515. my $sources = join(" ", @{$args{sources}});
  1516. my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
  1517. "util", "dofile.pl")),
  1518. rel2abs($config{builddir}));
  1519. return <<"EOF";
  1520. $script: $sources
  1521. \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
  1522. "-o$target{build_file}" $sources > "$script"
  1523. chmod a+x $script
  1524. EOF
  1525. }
  1526. sub generatedir {
  1527. my %args = @_;
  1528. my $dir = $args{dir};
  1529. my @deps = map { platform->convertext($_) } @{$args{deps}};
  1530. my @comments = ();
  1531. my %extinfo = ( dso => platform->dsoext(),
  1532. lib => platform->libext(),
  1533. bin => platform->binext() );
  1534. # We already have a 'test' target, and the top directory is just plain
  1535. # silly
  1536. return if $dir eq "test" || $dir eq ".";
  1537. foreach my $type (("dso", "lib", "bin", "script")) {
  1538. next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type});
  1539. # For lib object files, we could update the library. However, it
  1540. # was decided that it's enough to build the directory local object
  1541. # files, so we don't need to add any actions, and the dependencies
  1542. # are already taken care of.
  1543. if ($type ne "lib") {
  1544. foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) {
  1545. if (dirname($prod) eq $dir) {
  1546. push @deps, $prod.$extinfo{$type};
  1547. } else {
  1548. push @comments, "# No support to produce $type ".join(", ", @{$unified_info{dirinfo}->{$dir}->{products}->{$type}});
  1549. }
  1550. }
  1551. }
  1552. }
  1553. my $target = "$dir $dir/";
  1554. my $deps = join(" \\\n\t",
  1555. fill_lines(' ', $COLUMNS - 8, @deps));
  1556. my $comments = join("\n", "", @comments);
  1557. return <<"EOF";
  1558. $target: \\
  1559. $deps$comments
  1560. EOF
  1561. }
  1562. "" # Important! This becomes part of the template result.
  1563. -}