unix-Makefile.tmpl 81 KB

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