2
0

unix-Makefile.tmpl 82 KB

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