unix-Makefile.tmpl 81 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043
  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
  512. $(MAKE) run_tests
  513. run_tests: FORCE
  514. @ : {- output_off() if $disabled{tests}; "" -}
  515. ( SRCTOP=$(SRCDIR) \
  516. BLDTOP=$(BLDDIR) \
  517. PERL="$(PERL)" \
  518. FIPSKEY="$(FIPSKEY)" \
  519. EXE_EXT={- platform->binext() -} \
  520. $(PERL) $(SRCDIR)/test/run_tests.pl $(TESTS) )
  521. @ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
  522. @echo "Tests are not supported with your chosen Configure options"
  523. @ : {- output_on() if !$disabled{tests}; "" -}
  524. list-tests: ## List available tests that can be invoked via "make test TESTS=<name>"
  525. @ : {- output_off() if $disabled{tests}; "" -}
  526. $(MAKE) run_tests TESTS=list
  527. @ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
  528. @echo "Tests are not supported with your chosen Configure options"
  529. @ : {- output_on() if !$disabled{tests}; "" -}
  530. ##@ Workspace cleaning
  531. libclean:
  532. @set -e; for s in $(SHLIB_INFO); do \
  533. if [ "$$s" = ";" ]; then continue; fi; \
  534. s1=`echo "$$s" | cut -f1 -d";"`; \
  535. s2=`echo "$$s" | cut -f2 -d";"`; \
  536. s3=`echo "$$s" | cut -f3 -d";"`; \
  537. $(ECHO) $(RM) $$s1; {- output_off() unless windowsdll(); "" -}\
  538. $(RM) apps/$$s1; \
  539. $(RM) test/$$s1; \
  540. $(RM) fuzz/$$s1; {- output_on() unless windowsdll(); "" -}\
  541. $(RM) $$s1; \
  542. if [ "$$s2" != "" ]; then \
  543. $(ECHO) $(RM) $$s2; \
  544. $(RM) $$s2; \
  545. fi; \
  546. if [ "$$s3" != "" ]; then \
  547. $(ECHO) $(RM) $$s3; \
  548. $(RM) $$s3; \
  549. fi; \
  550. done
  551. $(RM) $(LIBS)
  552. $(RM) *{- platform->defext() -}
  553. clean: libclean ## Clean the workspace, keep the configuration
  554. $(RM) $(HTMLDOCS1)
  555. $(RM) $(HTMLDOCS3)
  556. $(RM) $(HTMLDOCS5)
  557. $(RM) $(HTMLDOCS7)
  558. $(RM) $(MANDOCS1)
  559. $(RM) $(MANDOCS3)
  560. $(RM) $(MANDOCS5)
  561. $(RM) $(MANDOCS7)
  562. $(RM) $(PROGRAMS) $(TESTPROGS) $(MODULES) $(FIPSMODULE) $(SCRIPTS)
  563. $(RM) $(GENERATED_MANDATORY) $(GENERATED)
  564. -find . -name '*{- platform->depext() -}' \! -name '.*' \! -type d -exec $(RM) {} \;
  565. -find . -name '*{- platform->objext() -}' \! -name '.*' \! -type d -exec $(RM) {} \;
  566. $(RM) core
  567. $(RM) tags TAGS doc-nits md-nits
  568. $(RM) -r test/test-runs
  569. $(RM) providers/fips*.new
  570. -find . -type l \! -name '.*' -exec $(RM) {} \;
  571. distclean: clean ## Clean and remove the configuration
  572. $(RM) include/openssl/configuration.h
  573. $(RM) configdata.pm
  574. $(RM) Makefile
  575. # We check if any depfile is newer than Makefile and decide to
  576. # concatenate only if that is true.
  577. depend: Makefile
  578. @: {- output_off() if $disabled{makedepend}; "" -}
  579. @$(PERL) $(SRCDIR)/util/add-depends.pl "{- $makedep_scheme -}"
  580. @: {- output_on() if $disabled{makedepend}; "" -}
  581. # Install helper targets #############################################
  582. ##@ Installation
  583. install: install_sw install_ssldirs {- "install_docs" if !$disabled{docs}; -} {- $disabled{fips} ? "" : "install_fips" -} ## Install software and documentation, create OpenSSL directories
  584. uninstall: {- "uninstall_docs" if !$disabled{docs}; -} uninstall_sw {- $disabled{fips} ? "" : "uninstall_fips" -} ## Uninstall software and documentation
  585. install_sw: install_dev install_engines install_modules install_runtime ## Install just the software and libraries
  586. uninstall_sw: uninstall_runtime uninstall_modules uninstall_engines uninstall_dev ## Uninstall the software and libraries
  587. install_docs: install_man_docs install_html_docs ## Install manpages and HTML documentation
  588. uninstall_docs: uninstall_man_docs uninstall_html_docs ## Uninstall manpages and HTML documentation
  589. $(RM) -r "$(DESTDIR)$(DOCDIR)"
  590. {- output_off() if $disabled{fips}; "" -}
  591. install_fips: build_sw $(INSTALL_FIPSMODULECONF)
  592. @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
  593. @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(MODULESDIR)"
  594. @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(OPENSSLDIR)"
  595. @$(ECHO) "*** Installing FIPS module"
  596. @$(ECHO) "install $(INSTALL_FIPSMODULE) -> $(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME)"
  597. @cp "$(INSTALL_FIPSMODULE)" "$(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME).new"
  598. @chmod 755 "$(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME).new"
  599. @mv -f "$(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME).new" \
  600. "$(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME)"
  601. @$(ECHO) "*** Installing FIPS module configuration"
  602. @$(ECHO) "install $(INSTALL_FIPSMODULECONF) -> $(DESTDIR)$(OPENSSLDIR)/fipsmodule.cnf"
  603. @cp $(INSTALL_FIPSMODULECONF) "$(DESTDIR)$(OPENSSLDIR)/fipsmodule.cnf"
  604. uninstall_fips:
  605. @$(ECHO) "*** Uninstalling FIPS module configuration"
  606. $(RM) "$(DESTDIR)$(OPENSSLDIR)/fipsmodule.cnf"
  607. @$(ECHO) "*** Uninstalling FIPS module"
  608. $(RM) "$(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME)"
  609. {- if ($disabled{fips}) { output_on(); } else { output_off(); } "" -}
  610. install_fips:
  611. @$(ECHO) "The 'install_fips' target requires the 'enable-fips' option"
  612. uninstall_fips:
  613. @$(ECHO) "The 'uninstall_fips' target requires the 'enable-fips' option"
  614. {- output_on() if !$disabled{fips}; "" -}
  615. install_ssldirs:
  616. @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(OPENSSLDIR)/certs"
  617. @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(OPENSSLDIR)/private"
  618. @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(OPENSSLDIR)/misc"
  619. @set -e; for x in dummy $(MISC_SCRIPTS); do \
  620. if [ "$$x" = "dummy" ]; then continue; fi; \
  621. x1=`echo "$$x" | cut -f1 -d:`; \
  622. x2=`echo "$$x" | cut -f2 -d:`; \
  623. fn=`basename $$x1`; \
  624. $(ECHO) "install $$x1 -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
  625. cp $$x1 "$(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new"; \
  626. chmod 755 "$(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new"; \
  627. mv -f "$(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new" \
  628. "$(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
  629. if [ "$$x1" != "$$x2" ]; then \
  630. ln=`basename "$$x2"`; \
  631. : {- output_off() unless windowsdll(); "" -}; \
  632. $(ECHO) "copy $(DESTDIR)$(OPENSSLDIR)/misc/$$ln -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
  633. cp "$(DESTDIR)$(OPENSSLDIR)/misc/$$fn" "$(DESTDIR)$(OPENSSLDIR)/misc/$$ln"; \
  634. : {- output_on() unless windowsdll();
  635. output_off() if windowsdll(); "" -}; \
  636. $(ECHO) "link $(DESTDIR)$(OPENSSLDIR)/misc/$$ln -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \
  637. ln -sf $$fn "$(DESTDIR)$(OPENSSLDIR)/misc/$$ln"; \
  638. : {- output_on() if windowsdll(); "" -}; \
  639. fi; \
  640. done
  641. @$(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist"
  642. @cp $(SRCDIR)/apps/openssl.cnf "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new"
  643. @chmod 644 "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new"
  644. @mv -f "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new" "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist"
  645. @if [ ! -f "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf" ]; then \
  646. $(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf"; \
  647. cp $(SRCDIR)/apps/openssl.cnf "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf"; \
  648. chmod 644 "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf"; \
  649. fi
  650. @$(ECHO) "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist"
  651. @cp $(SRCDIR)/apps/ct_log_list.cnf "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new"
  652. @chmod 644 "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new"
  653. @mv -f "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new" "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist"
  654. @if [ ! -f "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf" ]; then \
  655. $(ECHO) "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf"; \
  656. cp $(SRCDIR)/apps/ct_log_list.cnf "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf"; \
  657. chmod 644 "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf"; \
  658. fi
  659. install_dev: install_runtime_libs
  660. @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
  661. @$(ECHO) "*** Installing development files"
  662. @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(INSTALLTOP)/include/openssl"
  663. @ : {- output_off() if $disabled{uplink}; "" -}
  664. @$(ECHO) "install $(SRCDIR)/ms/applink.c -> $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
  665. @cp $(SRCDIR)/ms/applink.c "$(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
  666. @chmod 644 "$(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
  667. @ : {- output_on() if $disabled{uplink}; "" -}
  668. @set -e; for i in $(SRCDIR)/include/openssl/*.h \
  669. $(BLDDIR)/include/openssl/*.h; do \
  670. fn=`basename $$i`; \
  671. $(ECHO) "install $$i -> $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
  672. cp $$i "$(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
  673. chmod 644 "$(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
  674. done
  675. @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(libdir)"
  676. @set -e; for l in $(INSTALL_LIBS); do \
  677. fn=`basename $$l`; \
  678. $(ECHO) "install $$l -> $(DESTDIR)$(libdir)/$$fn"; \
  679. cp $$l "$(DESTDIR)$(libdir)/$$fn.new"; \
  680. $(RANLIB) "$(DESTDIR)$(libdir)/$$fn.new"; \
  681. chmod 644 "$(DESTDIR)$(libdir)/$$fn.new"; \
  682. mv -f "$(DESTDIR)$(libdir)/$$fn.new" \
  683. "$(DESTDIR)$(libdir)/$$fn"; \
  684. done
  685. @ : {- output_off() if $disabled{shared}; "" -}
  686. @set -e; for s in $(INSTALL_SHLIB_INFO); do \
  687. s1=`echo "$$s" | cut -f1 -d";"`; \
  688. s2=`echo "$$s" | cut -f2 -d";"`; \
  689. s3=`echo "$$s" | cut -f3 -d";"`; \
  690. fn1=`basename "$$s1"`; \
  691. fn2=`basename "$$s2"`; \
  692. fn3=`basename "$$s3"`; \
  693. : {- output_off(); output_on() unless windowsdll() or sharedaix(); "" -}; \
  694. if [ "$$fn2" != "" ]; then \
  695. $(ECHO) "link $(DESTDIR)$(libdir)/$$fn2 -> $(DESTDIR)$(libdir)/$$fn1"; \
  696. ln -sf $$fn1 "$(DESTDIR)$(libdir)/$$fn2"; \
  697. fi; \
  698. : {- output_off() unless windowsdll() or sharedaix(); output_on() if windowsdll(); "" -}; \
  699. if [ "$$fn3" != "" ]; then \
  700. $(ECHO) "install $$s3 -> $(DESTDIR)$(libdir)/$$fn3"; \
  701. cp $$s3 "$(DESTDIR)$(libdir)/$$fn3.new"; \
  702. chmod 755 "$(DESTDIR)$(libdir)/$$fn3.new"; \
  703. mv -f "$(DESTDIR)$(libdir)/$$fn3.new" \
  704. "$(DESTDIR)$(libdir)/$$fn3"; \
  705. fi; \
  706. : {- output_off() if windowsdll(); output_on() if sharedaix(); "" -}; \
  707. a="$(DESTDIR)$(libdir)/$$fn2"; \
  708. $(ECHO) "install $$s1 -> $$a"; \
  709. if [ -f $$a ]; then ( trap "rm -rf /tmp/ar.$$$$" INT 0; \
  710. mkdir /tmp/ar.$$$$; ( cd /tmp/ar.$$$$; \
  711. cp -f $$a $$a.new; \
  712. for so in `$(AR) t $$a`; do \
  713. $(AR) x $$a $$so; \
  714. chmod u+w $$so; \
  715. strip -X32_64 -e $$so; \
  716. $(AR) r $$a.new $$so; \
  717. done; \
  718. )); fi; \
  719. $(AR) r $$a.new $$s1; \
  720. mv -f $$a.new $$a; \
  721. : {- output_off() if sharedaix(); output_on(); "" -}; \
  722. done
  723. @ : {- output_on() if $disabled{shared}; "" -}
  724. @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(PKGCONFIGDIR)"
  725. @for e in $(INSTALL_EXPORTERS_PKGCONFIG); do \
  726. fn=`basename $$e`; \
  727. $(ECHO) "install $$e -> $(DESTDIR)$(PKGCONFIGDIR)/$$fn"; \
  728. cp $$e "$(DESTDIR)$(PKGCONFIGDIR)/$$fn"; \
  729. chmod 644 "$(DESTDIR)$(PKGCONFIGDIR)/$$fn"; \
  730. done
  731. @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(CMAKECONFIGDIR)
  732. @for e in $(INSTALL_EXPORTERS_CMAKE); do \
  733. fn=`basename $$e`; \
  734. $(ECHO) "install $$e -> $(DESTDIR)$(CMAKECONFIGDIR)/$$fn"; \
  735. cp $$e $(DESTDIR)$(CMAKECONFIGDIR)/$$fn; \
  736. chmod 644 $(DESTDIR)$(CMAKECONFIGDIR)/$$fn; \
  737. done
  738. uninstall_dev: uninstall_runtime_libs
  739. @$(ECHO) "*** Uninstalling development files"
  740. @ : {- output_off() if $disabled{uplink}; "" -}
  741. @$(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
  742. @$(RM) "$(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c"
  743. @ : {- output_on() if $disabled{uplink}; "" -}
  744. @set -e; for i in $(SRCDIR)/include/openssl/*.h \
  745. $(BLDDIR)/include/openssl/*.h; do \
  746. fn=`basename $$i`; \
  747. $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
  748. $(RM) "$(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \
  749. done
  750. -$(RMDIR) "$(DESTDIR)$(INSTALLTOP)/include/openssl"
  751. -$(RMDIR) "$(DESTDIR)$(INSTALLTOP)/include"
  752. @set -e; for l in $(INSTALL_LIBS); do \
  753. fn=`basename $$l`; \
  754. $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn"; \
  755. $(RM) "$(DESTDIR)$(libdir)/$$fn"; \
  756. done
  757. @ : {- output_off() if $disabled{shared}; "" -}
  758. @set -e; for s in $(INSTALL_SHLIB_INFO); do \
  759. s1=`echo "$$s" | cut -f1 -d";"`; \
  760. s2=`echo "$$s" | cut -f2 -d";"`; \
  761. s3=`echo "$$s" | cut -f3 -d";"`; \
  762. fn1=`basename "$$s1"`; \
  763. fn2=`basename "$$s2"`; \
  764. fn3=`basename "$$s3"`; \
  765. : {- output_off() if windowsdll(); "" -}; \
  766. $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn1"; \
  767. $(RM) "$(DESTDIR)$(libdir)/$$fn1"; \
  768. if [ -n "$$fn2" ]; then \
  769. $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn2"; \
  770. $(RM) "$(DESTDIR)$(libdir)/$$fn2"; \
  771. fi; \
  772. : {- output_on() if windowsdll(); "" -}{- output_off() unless windowsdll(); "" -}; \
  773. if [ -n "$$fn3" ]; then \
  774. $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn3"; \
  775. $(RM) "$(DESTDIR)$(libdir)/$$fn3"; \
  776. fi; \
  777. : {- output_on() unless windowsdll(); "" -}; \
  778. done
  779. @ : {- output_on() if $disabled{shared}; "" -}
  780. @for e in $(INSTALL_EXPORTERS_PKGCONFIG); do \
  781. fn=`basename "$$e"`; \
  782. $(RM) "$(DESTDIR)$(PKGCONFIGDIR)/$$fn"; \
  783. done
  784. @for e in $(INSTALL_EXPORTERS_CMAKE); do \
  785. fn=`basename "$$e"`; \
  786. $(RM) "$(DESTDIR)$(CMAKECONFIGDIR)/$$fn"; \
  787. done
  788. -$(RMDIR) "$(DESTDIR)$(PKGCONFIGDIR)"
  789. -$(RMDIR) "$(DESTDIR)$(CMAKECONFIGDIR)"
  790. -$(RMDIR) "$(DESTDIR)$(libdir)"
  791. _install_modules_deps: install_runtime_libs build_modules
  792. install_engines: _install_modules_deps
  793. @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
  794. @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(ENGINESDIR)/"
  795. @$(ECHO) "*** Installing engines"
  796. @set -e; for e in dummy $(INSTALL_ENGINES); do \
  797. if [ "$$e" = "dummy" ]; then continue; fi; \
  798. fn=`basename $$e`; \
  799. $(ECHO) "install $$e -> $(DESTDIR)$(ENGINESDIR)/$$fn"; \
  800. cp $$e "$(DESTDIR)$(ENGINESDIR)/$$fn.new"; \
  801. chmod 755 "$(DESTDIR)$(ENGINESDIR)/$$fn.new"; \
  802. mv -f "$(DESTDIR)$(ENGINESDIR)/$$fn.new" \
  803. "$(DESTDIR)$(ENGINESDIR)/$$fn"; \
  804. done
  805. uninstall_engines:
  806. @$(ECHO) "*** Uninstalling engines"
  807. @set -e; for e in dummy $(INSTALL_ENGINES); do \
  808. if [ "$$e" = "dummy" ]; then continue; fi; \
  809. fn=`basename $$e`; \
  810. $(ECHO) "$(RM) $(DESTDIR)$(ENGINESDIR)/$$fn"; \
  811. $(RM) "$(DESTDIR)$(ENGINESDIR)/$$fn"; \
  812. done
  813. -$(RMDIR) "$(DESTDIR)$(ENGINESDIR)"
  814. install_modules: _install_modules_deps
  815. @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
  816. @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(MODULESDIR)/"
  817. @$(ECHO) "*** Installing modules"
  818. @set -e; for e in dummy $(INSTALL_MODULES); do \
  819. if [ "$$e" = "dummy" ]; then continue; fi; \
  820. fn=`basename $$e`; \
  821. $(ECHO) "install $$e -> $(DESTDIR)$(MODULESDIR)/$$fn"; \
  822. cp $$e "$(DESTDIR)$(MODULESDIR)/$$fn.new"; \
  823. chmod 755 "$(DESTDIR)$(MODULESDIR)/$$fn.new"; \
  824. mv -f "$(DESTDIR)$(MODULESDIR)/$$fn.new" \
  825. "$(DESTDIR)$(MODULESDIR)/$$fn"; \
  826. done
  827. uninstall_modules:
  828. @$(ECHO) "*** Uninstalling modules"
  829. @set -e; for e in dummy $(INSTALL_MODULES); do \
  830. if [ "$$e" = "dummy" ]; then continue; fi; \
  831. fn=`basename $$e`; \
  832. $(ECHO) "$(RM) $(DESTDIR)$(MODULESDIR)/$$fn"; \
  833. $(RM) "$(DESTDIR)$(MODULESDIR)/$$fn"; \
  834. done
  835. -$(RMDIR) "$(DESTDIR)$(MODULESDIR)"
  836. install_runtime: install_programs
  837. install_runtime_libs: build_libs
  838. @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
  839. @ : {- output_off() if windowsdll(); "" -}
  840. @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(libdir)"
  841. @ : {- output_on() if windowsdll(); output_off() unless windowsdll(); "" -}
  842. @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(bindir)/"
  843. @ : {- output_on() unless windowsdll(); "" -}
  844. @$(ECHO) "*** Installing runtime libraries"
  845. @set -e; for s in dummy $(INSTALL_SHLIBS); do \
  846. if [ "$$s" = "dummy" ]; then continue; fi; \
  847. fn=`basename $$s`; \
  848. : {- output_off() unless windowsdll(); "" -}; \
  849. $(ECHO) "install $$s -> $(DESTDIR)$(bindir)/$$fn"; \
  850. cp $$s "$(DESTDIR)$(bindir)/$$fn.new"; \
  851. chmod 755 "$(DESTDIR)$(bindir)/$$fn.new"; \
  852. mv -f "$(DESTDIR)$(bindir)/$$fn.new" \
  853. "$(DESTDIR)$(bindir)/$$fn"; \
  854. : {- output_on() unless windowsdll(); "" -}{- output_off() if windowsdll(); "" -}; \
  855. $(ECHO) "install $$s -> $(DESTDIR)$(libdir)/$$fn"; \
  856. cp $$s "$(DESTDIR)$(libdir)/$$fn.new"; \
  857. chmod 755 "$(DESTDIR)$(libdir)/$$fn.new"; \
  858. mv -f "$(DESTDIR)$(libdir)/$$fn.new" \
  859. "$(DESTDIR)$(libdir)/$$fn"; \
  860. : {- output_on() if windowsdll(); "" -}; \
  861. done
  862. install_programs: install_runtime_libs build_programs
  863. @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
  864. @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(bindir)"
  865. @$(ECHO) "*** Installing runtime programs"
  866. @set -e; for x in dummy $(INSTALL_PROGRAMS); do \
  867. if [ "$$x" = "dummy" ]; then continue; fi; \
  868. fn=`basename $$x`; \
  869. $(ECHO) "install $$x -> $(DESTDIR)$(bindir)/$$fn"; \
  870. cp $$x "$(DESTDIR)$(bindir)/$$fn.new"; \
  871. chmod 755 "$(DESTDIR)$(bindir)/$$fn.new"; \
  872. mv -f "$(DESTDIR)$(bindir)/$$fn.new" \
  873. "$(DESTDIR)$(bindir)/$$fn"; \
  874. done
  875. @set -e; for x in dummy $(BIN_SCRIPTS); do \
  876. if [ "$$x" = "dummy" ]; then continue; fi; \
  877. fn=`basename $$x`; \
  878. $(ECHO) "install $$x -> $(DESTDIR)$(bindir)/$$fn"; \
  879. cp $$x "$(DESTDIR)$(bindir)/$$fn.new"; \
  880. chmod 755 "$(DESTDIR)$(bindir)/$$fn.new"; \
  881. mv -f "$(DESTDIR)$(bindir)/$$fn.new" \
  882. "$(DESTDIR)$(bindir)/$$fn"; \
  883. done
  884. uninstall_runtime: uninstall_programs uninstall_runtime_libs
  885. uninstall_programs:
  886. @$(ECHO) "*** Uninstalling runtime programs"
  887. @set -e; for x in dummy $(INSTALL_PROGRAMS); \
  888. do \
  889. if [ "$$x" = "dummy" ]; then continue; fi; \
  890. fn=`basename $$x`; \
  891. $(ECHO) "$(RM) $(DESTDIR)$(bindir)/$$fn"; \
  892. $(RM) "$(DESTDIR)$(bindir)/$$fn"; \
  893. done;
  894. @set -e; for x in dummy $(BIN_SCRIPTS); \
  895. do \
  896. if [ "$$x" = "dummy" ]; then continue; fi; \
  897. fn=`basename $$x`; \
  898. $(ECHO) "$(RM) $(DESTDIR)$(bindir)/$$fn"; \
  899. $(RM) "$(DESTDIR)$(bindir)/$$fn"; \
  900. done
  901. -$(RMDIR) "$(DESTDIR)$(bindir)"
  902. uninstall_runtime_libs:
  903. @$(ECHO) "*** Uninstalling runtime libraries"
  904. @ : {- output_off() unless windowsdll(); "" -}
  905. @set -e; for s in dummy $(INSTALL_SHLIBS); do \
  906. if [ "$$s" = "dummy" ]; then continue; fi; \
  907. fn=`basename $$s`; \
  908. $(ECHO) "$(RM) $(DESTDIR)$(bindir)/$$fn"; \
  909. $(RM) "$(DESTDIR)$(bindir)/$$fn"; \
  910. done
  911. @ : {- output_on() unless windowsdll(); "" -}
  912. install_man_docs: build_man_docs
  913. @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
  914. @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(MANDIR)/man1"
  915. @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(MANDIR)/man3"
  916. @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(MANDIR)/man5"
  917. @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(MANDIR)/man7"
  918. @$(ECHO) "*** Installing manpages"
  919. @set -e; for x in dummy $(MANDOCS1); do \
  920. if [ "$$x" = "dummy" ]; then continue; fi; \
  921. fn=`basename $$x`; \
  922. $(ECHO) "install $$x -> $(DESTDIR)$(MANDIR)/man1/$${fn}$(MANSUFFIX)"; \
  923. cp $$x "$(DESTDIR)$(MANDIR)/man1/$${fn}$(MANSUFFIX)"; \
  924. chmod 644 "$(DESTDIR)$(MANDIR)/man1/$${fn}$(MANSUFFIX)"; \
  925. $(PERL) $(SRCDIR)/util/write-man-symlinks install $(SRCDIR)/doc/man1 $(BLDDIR)/doc/man1 $${fn}$(MANSUFFIX) "$(DESTDIR)$(MANDIR)/man1"; \
  926. done
  927. @set -e; for x in dummy $(MANDOCS3); do \
  928. if [ "$$x" = "dummy" ]; then continue; fi; \
  929. fn=`basename $$x`; \
  930. $(ECHO) "install $$x -> $(DESTDIR)$(MANDIR)/man3/$${fn}$(MANSUFFIX)"; \
  931. cp $$x "$(DESTDIR)$(MANDIR)/man3/$${fn}$(MANSUFFIX)"; \
  932. chmod 644 "$(DESTDIR)$(MANDIR)/man3/$${fn}$(MANSUFFIX)"; \
  933. $(PERL) $(SRCDIR)/util/write-man-symlinks install $(SRCDIR)/doc/man3 $(BLDDIR)/doc/man3 $${fn}$(MANSUFFIX) "$(DESTDIR)$(MANDIR)/man3"; \
  934. done
  935. @set -e; for x in dummy $(MANDOCS5); do \
  936. if [ "$$x" = "dummy" ]; then continue; fi; \
  937. fn=`basename $$x`; \
  938. $(ECHO) "install $$x -> $(DESTDIR)$(MANDIR)/man5/$${fn}$(MANSUFFIX)"; \
  939. cp $$x "$(DESTDIR)$(MANDIR)/man5/$${fn}$(MANSUFFIX)"; \
  940. chmod 644 "$(DESTDIR)$(MANDIR)/man5/$${fn}$(MANSUFFIX)"; \
  941. $(PERL) $(SRCDIR)/util/write-man-symlinks install $(SRCDIR)/doc/man5 $(BLDDIR)/doc/man5 $${fn}$(MANSUFFIX) "$(DESTDIR)$(MANDIR)/man5"; \
  942. done
  943. @set -e; for x in dummy $(MANDOCS7); do \
  944. if [ "$$x" = "dummy" ]; then continue; fi; \
  945. fn=`basename $$x`; \
  946. $(ECHO) "install $$x -> $(DESTDIR)$(MANDIR)/man7/$${fn}$(MANSUFFIX)"; \
  947. cp $$x "$(DESTDIR)$(MANDIR)/man7/$${fn}$(MANSUFFIX)"; \
  948. chmod 644 "$(DESTDIR)$(MANDIR)/man7/$${fn}$(MANSUFFIX)"; \
  949. $(PERL) $(SRCDIR)/util/write-man-symlinks install $(SRCDIR)/doc/man7 $(BLDDIR)/doc/man7 $${fn}$(MANSUFFIX) "$(DESTDIR)$(MANDIR)/man7"; \
  950. done
  951. uninstall_man_docs: build_man_docs
  952. @$(ECHO) "*** Uninstalling manpages"
  953. @set -e; for x in dummy $(MANDOCS1); do \
  954. if [ "$$x" = "dummy" ]; then continue; fi; \
  955. fn=`basename $$x`; \
  956. $(ECHO) "$(RM) $(DESTDIR)$(MANDIR)/man1/$${fn}$(MANSUFFIX)"; \
  957. $(RM) "$(DESTDIR)$(MANDIR)/man1/$${fn}$(MANSUFFIX)"; \
  958. $(PERL) $(SRCDIR)/util/write-man-symlinks uninstall $(SRCDIR)/doc/man1 $(BLDDIR)/doc/man1 $${fn}$(MANSUFFIX) "$(DESTDIR)$(MANDIR)/man1"; \
  959. done
  960. @set -e; for x in dummy $(MANDOCS3); do \
  961. if [ "$$x" = "dummy" ]; then continue; fi; \
  962. fn=`basename $$x`; \
  963. $(ECHO) "$(RM) $(DESTDIR)$(MANDIR)/man3/$${fn}$(MANSUFFIX)"; \
  964. $(RM) "$(DESTDIR)$(MANDIR)/man3/$${fn}$(MANSUFFIX)"; \
  965. $(PERL) $(SRCDIR)/util/write-man-symlinks uninstall $(SRCDIR)/doc/man3 $(BLDDIR)/doc/man3 $${fn}$(MANSUFFIX) "$(DESTDIR)$(MANDIR)/man3"; \
  966. done
  967. @set -e; for x in dummy $(MANDOCS5); do \
  968. if [ "$$x" = "dummy" ]; then continue; fi; \
  969. fn=`basename $$x`; \
  970. $(ECHO) "$(RM) $(DESTDIR)$(MANDIR)/man5/$${fn}$(MANSUFFIX)"; \
  971. $(RM) "$(DESTDIR)$(MANDIR)/man5/$${fn}$(MANSUFFIX)"; \
  972. $(PERL) $(SRCDIR)/util/write-man-symlinks uninstall $(SRCDIR)/doc/man5 $(BLDDIR)/doc/man5 $${fn}$(MANSUFFIX) "$(DESTDIR)$(MANDIR)/man5"; \
  973. done
  974. @set -e; for x in dummy $(MANDOCS7); do \
  975. if [ "$$x" = "dummy" ]; then continue; fi; \
  976. fn=`basename $$x`; \
  977. $(ECHO) "$(RM) $(DESTDIR)$(MANDIR)/man7/$${fn}$(MANSUFFIX)"; \
  978. $(RM) "$(DESTDIR)$(MANDIR)/man7/$${fn}$(MANSUFFIX)"; \
  979. $(PERL) $(SRCDIR)/util/write-man-symlinks uninstall $(SRCDIR)/doc/man7 $(BLDDIR)/doc/man7 $${fn}$(MANSUFFIX) "$(DESTDIR)$(MANDIR)/man7"; \
  980. done
  981. install_html_docs: install_image_docs build_html_docs
  982. @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
  983. @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(HTMLDIR)/man1"
  984. @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(HTMLDIR)/man3"
  985. @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(HTMLDIR)/man5"
  986. @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(HTMLDIR)/man7"
  987. @$(ECHO) "*** Installing HTML manpages"
  988. @set -e; for x in dummy $(HTMLDOCS1); do \
  989. if [ "$$x" = "dummy" ]; then continue; fi; \
  990. fn=`basename $$x`; \
  991. $(ECHO) "install $$x -> $(DESTDIR)$(HTMLDIR)/man1/$$fn"; \
  992. cp $$x "$(DESTDIR)$(HTMLDIR)/man1/$$fn"; \
  993. chmod 644 "$(DESTDIR)$(HTMLDIR)/man1/$$fn"; \
  994. done
  995. @set -e; for x in dummy $(HTMLDOCS3); do \
  996. if [ "$$x" = "dummy" ]; then continue; fi; \
  997. fn=`basename $$x`; \
  998. $(ECHO) "install $$x -> $(DESTDIR)$(HTMLDIR)/man3/$$fn"; \
  999. cp $$x "$(DESTDIR)$(HTMLDIR)/man3/$$fn"; \
  1000. chmod 644 "$(DESTDIR)$(HTMLDIR)/man3/$$fn"; \
  1001. done
  1002. @set -e; for x in dummy $(HTMLDOCS5); do \
  1003. if [ "$$x" = "dummy" ]; then continue; fi; \
  1004. fn=`basename $$x`; \
  1005. $(ECHO) "install $$x -> $(DESTDIR)$(HTMLDIR)/man5/$$fn"; \
  1006. cp $$x "$(DESTDIR)$(HTMLDIR)/man5/$$fn"; \
  1007. chmod 644 "$(DESTDIR)$(HTMLDIR)/man5/$$fn"; \
  1008. done
  1009. @set -e; for x in dummy $(HTMLDOCS7); do \
  1010. if [ "$$x" = "dummy" ]; then continue; fi; \
  1011. fn=`basename $$x`; \
  1012. $(ECHO) "install $$x -> $(DESTDIR)$(HTMLDIR)/man7/$$fn"; \
  1013. cp $$x "$(DESTDIR)$(HTMLDIR)/man7/$$fn"; \
  1014. chmod 644 "$(DESTDIR)$(HTMLDIR)/man7/$$fn"; \
  1015. done
  1016. uninstall_html_docs: uninstall_image_docs
  1017. @$(ECHO) "*** Uninstalling HTML manpages"
  1018. @set -e; for x in dummy $(HTMLDOCS1); do \
  1019. if [ "$$x" = "dummy" ]; then continue; fi; \
  1020. fn=`basename $$x`; \
  1021. $(ECHO) "$(RM) $(DESTDIR)$(HTMLDIR)/man1/$$fn"; \
  1022. $(RM) "$(DESTDIR)$(HTMLDIR)/man1/$$fn"; \
  1023. done
  1024. @set -e; for x in dummy $(HTMLDOCS3); do \
  1025. if [ "$$x" = "dummy" ]; then continue; fi; \
  1026. fn=`basename $$x`; \
  1027. $(ECHO) "$(RM) $(DESTDIR)$(HTMLDIR)/man3/$$fn"; \
  1028. $(RM) "$(DESTDIR)$(HTMLDIR)/man3/$$fn"; \
  1029. done
  1030. @set -e; for x in dummy $(HTMLDOCS5); do \
  1031. if [ "$$x" = "dummy" ]; then continue; fi; \
  1032. fn=`basename $$x`; \
  1033. $(ECHO) "$(RM) $(DESTDIR)$(HTMLDIR)/man5/$$fn"; \
  1034. $(RM) "$(DESTDIR)$(HTMLDIR)/man5/$$fn"; \
  1035. done
  1036. @set -e; for x in dummy $(HTMLDOCS7); do \
  1037. if [ "$$x" = "dummy" ]; then continue; fi; \
  1038. fn=`basename $$x`; \
  1039. $(ECHO) "$(RM) $(DESTDIR)$(HTMLDIR)/man7/$$fn"; \
  1040. $(RM) "$(DESTDIR)$(HTMLDIR)/man7/$$fn"; \
  1041. done
  1042. install_image_docs:
  1043. @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(HTMLDIR)/man7/img"
  1044. @set -e; for x in dummy $(IMAGEDOCS7); do \
  1045. if [ "$$x" = "dummy" ]; then continue; fi; \
  1046. fn=`basename $$x`; \
  1047. $(ECHO) "install $$x -> $(DESTDIR)$(HTMLDIR)/man7/img/$$fn"; \
  1048. cp $(SRCDIR)/$$x "$(DESTDIR)$(HTMLDIR)/man7/img/$$fn"; \
  1049. chmod 644 "$(DESTDIR)$(HTMLDIR)/man7/img/$$fn"; \
  1050. done
  1051. uninstall_image_docs:
  1052. @set -e; for x in dummy $(IMAGEDOCS7); do \
  1053. if [ "$$x" = "dummy" ]; then continue; fi; \
  1054. fn=`basename $$x`; \
  1055. $(ECHO) "$(RM) $(DESTDIR)$(HTMLDIR)/man7/img/$$fn"; \
  1056. $(RM) "$(DESTDIR)$(HTMLDIR)/man7/img/$$fn"; \
  1057. done
  1058. # Developer targets (note: these are only available on Unix) #########
  1059. ##@ Code maintenance
  1060. # It's important that generate_buildinfo comes after ordinals, as ordinals
  1061. # is sensitive to build.info changes.
  1062. update: generate errors ordinals generate_buildinfo ## Update errors, ordinals and build info
  1063. .PHONY: generate generate_apps generate_crypto_bn generate_crypto_objects \
  1064. generate_crypto_conf generate_crypto_asn1 generate_fuzz_oids
  1065. generate: generate_apps generate_crypto_bn generate_crypto_objects \
  1066. generate_crypto_conf generate_crypto_asn1 generate_fuzz_oids
  1067. .PHONY: generate_buildinfo generate_doc_buildinfo
  1068. generate_buildinfo: generate_doc_buildinfo
  1069. .PHONY: doc-nits md-nits
  1070. doc-nits: build_generated_pods ## Evaluate OpenSSL documentation
  1071. $(PERL) $(SRCDIR)/util/find-doc-nits -c -n -l -e
  1072. # This uses "mdl", the markdownlint application, which is written in ruby.
  1073. # The source is at https://github.com/markdownlint/markdownlint
  1074. # If you have ruby installed, "gem install mdl" should work.
  1075. # Another option is at https://snapcraft.io/install/mdl/debian
  1076. # Finally, there's a Node.js version, which we haven't tried, that
  1077. # can be found at https://github.com/DavidAnson/markdownlint
  1078. md-nits: ## Evaluate markdown files via "mdl"
  1079. mdl -s $(SRCDIR)/util/markdownlint.rb .
  1080. # Test coverage is a good idea for the future
  1081. #coverage: $(PROGRAMS) $(TESTPROGRAMS)
  1082. # ...
  1083. .PHONY: lint
  1084. lint: ## Evaluate C code via "splint"
  1085. @( cd $(SRCDIR); \
  1086. echo splint -DLINT -posixlib -preproc -D__gnuc_va_list=void \
  1087. -I. -Iinclude -Iapps/include $(CRYPTOHEADERS) $(SSLHEADERS) $(SRCS) )
  1088. .PHONY: check-format
  1089. check-format: ## Evaluate C code according to OpenSSL coding standards
  1090. ( cd $(SRCDIR); $(PERL) util/check-format.pl \
  1091. $(SRCS) \$(CRYPTOHEADERS) $(SSLHEADERS) )
  1092. generate_apps:
  1093. ( cd $(SRCDIR); $(PERL) VMS/VMSify-conf.pl \
  1094. < apps/openssl.cnf > apps/openssl-vms.cnf )
  1095. generate_crypto_bn:
  1096. ( cd $(SRCDIR); $(PERL) crypto/bn/bn_prime.pl > crypto/bn/bn_prime.h )
  1097. generate_crypto_objects:
  1098. ( cd $(SRCDIR); $(PERL) crypto/objects/objects.pl -n \
  1099. crypto/objects/objects.txt \
  1100. crypto/objects/obj_mac.num \
  1101. > crypto/objects/obj_mac.new && \
  1102. mv crypto/objects/obj_mac.new crypto/objects/obj_mac.num )
  1103. ( cd $(SRCDIR); $(PERL) crypto/objects/objects.pl \
  1104. crypto/objects/objects.txt \
  1105. crypto/objects/obj_mac.num \
  1106. > include/openssl/obj_mac.h )
  1107. ( cd $(SRCDIR); $(PERL) crypto/objects/obj_dat.pl \
  1108. include/openssl/obj_mac.h \
  1109. > crypto/objects/obj_dat.h )
  1110. ( cd $(SRCDIR); $(PERL) crypto/objects/objxref.pl \
  1111. crypto/objects/obj_mac.num \
  1112. crypto/objects/obj_xref.txt \
  1113. > crypto/objects/obj_xref.h )
  1114. ( cd $(SRCDIR); sed -e '1,8d' crypto/objects/obj_compat.h >> include/openssl/obj_mac.h )
  1115. generate_crypto_conf:
  1116. ( cd $(SRCDIR); $(PERL) crypto/conf/keysets.pl \
  1117. > crypto/conf/conf_def.h )
  1118. generate_crypto_asn1:
  1119. ( cd $(SRCDIR); $(PERL) crypto/asn1/charmap.pl \
  1120. > crypto/asn1/charmap.h )
  1121. generate_fuzz_oids:
  1122. ( cd $(SRCDIR); $(PERL) fuzz/mkfuzzoids.pl \
  1123. crypto/objects/obj_dat.h \
  1124. > fuzz/oids.txt )
  1125. generate_doc_buildinfo:
  1126. ( $(PERL) -I$(BLDDIR) -Mconfigdata \
  1127. $(SRCDIR)/util/dofile.pl -o Makefile \
  1128. $(SRCDIR)/doc/build.info.in \
  1129. > $(SRCDIR)/doc/build.info.new; \
  1130. if ( test -e $(SRCDIR)/doc/build.info \
  1131. && cmp $(SRCDIR)/doc/build.info.new $(SRCDIR)/doc/build.info \
  1132. > /dev/null ); \
  1133. then \
  1134. rm $(SRCDIR)/doc/build.info.new; \
  1135. else \
  1136. mv $(SRCDIR)/doc/build.info.new $(SRCDIR)/doc/build.info; \
  1137. fi )
  1138. generate_fips_sources: providers/fips.module.sources.new
  1139. providers/fips.module.sources.new: configdata.pm
  1140. rm -rf sources-tmp
  1141. mkdir sources-tmp
  1142. ( \
  1143. srcdir=`cd $(SRCDIR); pwd`; \
  1144. cd sources-tmp \
  1145. && $$srcdir/Configure --banner=Configured enable-fips -O0 \
  1146. && ./configdata.pm --query 'get_sources("providers/fips")' > sources1 \
  1147. && $(MAKE) -sj 4 build_generated providers/fips.so \
  1148. && find . -name '*.d' | xargs cat > dep1 \
  1149. && $(MAKE) distclean \
  1150. && $$srcdir/Configure --banner=Configured enable-fips no-asm -O0 \
  1151. && ./configdata.pm --query 'get_sources("providers/fips")' > sources2 \
  1152. && $(MAKE) -sj 4 build_generated providers/fips.so \
  1153. && find . -name '*.d' | xargs cat > dep2 \
  1154. && cat sources1 sources2 \
  1155. | grep -v ' : \\$$' | grep -v util/providers.num \
  1156. | sed -e 's/^ *//' -e 's/ *\\$$//' \
  1157. | sort | uniq > sources \
  1158. && cat dep1 dep2 \
  1159. | $(PERL) -p -e 's/\\\n//' \
  1160. | sed -e 's/^.*: *//' -e 's/ */ /g' \
  1161. | fgrep -f sources \
  1162. | tr ' ' '\n' \
  1163. | sort | uniq > deps.raw \
  1164. && cat deps.raw \
  1165. | xargs ./configdata.pm --query 'get_sources(@ARGV)' \
  1166. | $(PERL) -p -e 's/\\\n//' \
  1167. | sed -e 's/\./\\\./g' -e 's/ : */:/' -e 's/^/s:/' -e 's/$$/:/' \
  1168. > deps.sed \
  1169. && cat deps.raw | sed -f deps.sed > deps \
  1170. )
  1171. ( \
  1172. cat sources-tmp/sources sources-tmp/deps \
  1173. | $(PERL) -p -e 's:^ *\Q../\E:: ;' \
  1174. -e 's:^\Q$(SRCDIR)/\E:: if "$(SRCDIR)" ne "." ;' \
  1175. -e 'my $$x; do { $$x = $$_; s:(^|/)((?!\Q../\E)[^/]*/)\Q..\E($$|/):$$1: } while ($$x ne $$_) ;' ; \
  1176. cd $(SRCDIR); \
  1177. for x in crypto/bn/asm/*.pl crypto/bn/asm/*.S \
  1178. crypto/aes/asm/*.pl crypto/aes/asm/*.S \
  1179. crypto/ec/asm/*.pl \
  1180. crypto/modes/asm/*.pl \
  1181. crypto/sha/asm/*.pl \
  1182. crypto/*cpuid.pl crypto/*cpuid.S \
  1183. crypto/*cap.c; do \
  1184. echo "$$x"; \
  1185. done \
  1186. ) | grep -v sm2p256 | sort | uniq > providers/fips.module.sources.new
  1187. rm -rf sources-tmp
  1188. # Set to -force to force a rebuild
  1189. ERROR_REBUILD=
  1190. errors:
  1191. ( b=`pwd`; set -e; cd $(SRCDIR); \
  1192. $(PERL) util/ck_errf.pl -strict -internal; \
  1193. $(PERL) -I$$b util/mkerr.pl $(ERROR_REBUILD) -internal )
  1194. ( b=`pwd`; set -e; cd $(SRCDIR)/engines; \
  1195. for E in *.ec ; do \
  1196. $(PERL) ../util/ck_errf.pl -strict \
  1197. -conf $$E `basename $$E .ec`.c; \
  1198. $(PERL) -I$$b ../util/mkerr.pl $(ERROR_REBUILD) -static \
  1199. -conf $$E `basename $$E .ec`.c ; \
  1200. done )
  1201. {- use File::Basename;
  1202. my @sslheaders_tmpl =
  1203. qw( include/openssl/ssl.h
  1204. include/openssl/ssl2.h
  1205. include/openssl/ssl3.h
  1206. include/openssl/sslerr.h
  1207. include/openssl/tls1.h
  1208. include/openssl/dtls1.h
  1209. include/openssl/srtp.h
  1210. include/openssl/quic.h
  1211. include/openssl/sslerr_legacy.h );
  1212. my @cryptoheaders_tmpl =
  1213. qw( include/internal/dso.h
  1214. include/internal/o_dir.h
  1215. include/internal/err.h
  1216. include/internal/evp.h
  1217. include/internal/pem.h
  1218. include/internal/asn1.h
  1219. include/internal/sslconf.h );
  1220. my @cryptoskipheaders = ( @sslheaders_tmpl,
  1221. qw( include/openssl/asn1_mac.h
  1222. include/openssl/conf_api.h
  1223. include/openssl/ebcdic.h
  1224. include/openssl/opensslconf.h
  1225. include/openssl/symhacks.h ) );
  1226. our %cryptoheaders = ();
  1227. our %sslheaders = ();
  1228. foreach my $d ( qw( include/openssl include/internal ) ) {
  1229. my @header_patterns =
  1230. map { catfile($config{sourcedir}, $d, $_) } ( '*.h', '*.h.in' );
  1231. foreach my $f ( map { glob($_) } @header_patterns ) {
  1232. my $base = basename($f);
  1233. my $base_in = basename($f, '.in');
  1234. my $dir = catfile($config{sourcedir}, $d);
  1235. if ($base ne $base_in) {
  1236. # We have a .h.in file, which means the header file is in the
  1237. # build tree.
  1238. $base = $base_in;
  1239. $dir = catfile($config{builddir}, $d);
  1240. }
  1241. my $new_f = catfile($dir, $base);
  1242. my $fn = "$d/$base";
  1243. # The logic to add files to @cryptoheaders is a bit complex. The
  1244. # file to be added must be either in the public header directory
  1245. # or one of the pre-declared internal headers, and must under no
  1246. # circumstances be one of those that must be skipped.
  1247. $cryptoheaders{$new_f} = 1
  1248. if (($d eq 'include/openssl'
  1249. || ( grep { $_ eq $fn } @cryptoheaders_tmpl ))
  1250. && !( grep { $_ eq $fn } @cryptoskipheaders ));
  1251. # The logic to add files to @sslheaders is much simpler...
  1252. $sslheaders{$new_f} = 1 if grep { $_ eq $fn } @sslheaders_tmpl;
  1253. }
  1254. }
  1255. "";
  1256. -}
  1257. SRCS={-
  1258. sub uniq { my %seen; grep !$seen{$_}++, @_; }
  1259. sub flat(@) { return map { ref eq 'ARRAY' ? @$_ : $_ } @_; }
  1260. join(" \\\n" . ' ' x 5, fill_lines(" ", $COLUMNS - 5,
  1261. uniq(grep /\.(c|cc|cpp)$/,
  1262. flat (map { $unified_info{sources}->{$_} }
  1263. (sort keys %{$unified_info{sources}})))))
  1264. -}
  1265. CRYPTOHEADERS={- join(" \\\n" . ' ' x 14,
  1266. fill_lines(" ", $COLUMNS - 14, sort keys %cryptoheaders)) -}
  1267. SSLHEADERS={- join(" \\\n" . ' ' x 11,
  1268. fill_lines(" ", $COLUMNS - 11, sort keys %sslheaders)) -}
  1269. renumber: build_generated
  1270. $(PERL) $(SRCDIR)/util/mknum.pl --version $(VERSION_NUMBER) --no-warnings \
  1271. --ordinals $(SRCDIR)/util/libcrypto.num \
  1272. --symhacks $(SRCDIR)/include/openssl/symhacks.h \
  1273. --renumber \
  1274. $(CRYPTOHEADERS)
  1275. $(PERL) $(SRCDIR)/util/mknum.pl --version $(VERSION_NUMBER) --no-warnings \
  1276. --ordinals $(SRCDIR)/util/libssl.num \
  1277. --symhacks $(SRCDIR)/include/openssl/symhacks.h \
  1278. --renumber \
  1279. $(SSLHEADERS)
  1280. .PHONY: ordinals
  1281. ordinals: build_generated
  1282. $(PERL) $(SRCDIR)/util/mknum.pl --version $(VERSION_NUMBER) --no-warnings \
  1283. --ordinals $(SRCDIR)/util/libcrypto.num \
  1284. --symhacks $(SRCDIR)/include/openssl/symhacks.h \
  1285. $(CRYPTOHEADERS)
  1286. $(PERL) $(SRCDIR)/util/mknum.pl --version $(VERSION_NUMBER) --no-warnings \
  1287. --ordinals $(SRCDIR)/util/libssl.num \
  1288. --symhacks $(SRCDIR)/include/openssl/symhacks.h \
  1289. $(SSLHEADERS)
  1290. test_ordinals:
  1291. $(MAKE) run_tests TESTS=test_ordinals
  1292. tags TAGS: FORCE
  1293. rm -f TAGS tags
  1294. -( cd $(SRCDIR); util/ctags.sh )
  1295. -etags `find . -name '*.[ch]' -o -name '*.pm'`
  1296. providers/fips.checksum.new: providers/fips.module.sources.new
  1297. @which unifdef > /dev/null || \
  1298. ( echo >&2 "ERROR: unifdef not in your \$$PATH, FIPS checksums not calculated"; \
  1299. false )
  1300. ( sources=`pwd`/providers/fips.module.sources.new; \
  1301. cd $(SRCDIR) \
  1302. && cat $$sources \
  1303. | xargs ./util/fips-checksums.sh ) \
  1304. > providers/fips-sources.checksums.new \
  1305. && sha256sum providers/fips-sources.checksums.new \
  1306. | sed -e 's|\.new||' > providers/fips.checksum.new
  1307. fips-checksums: providers/fips.checksum.new
  1308. $(SRCDIR)/providers/fips.checksum: providers/fips.checksum.new
  1309. cp -p providers/fips.module.sources.new $(SRCDIR)/providers/fips.module.sources
  1310. cp -p providers/fips-sources.checksums.new $(SRCDIR)/providers/fips-sources.checksums
  1311. cp -p providers/fips.checksum.new $(SRCDIR)/providers/fips.checksum
  1312. update-fips-checksums: $(SRCDIR)/providers/fips.checksum
  1313. diff-fips-checksums: fips-checksums
  1314. diff -u $(SRCDIR)/providers/fips.module.sources providers/fips.module.sources.new
  1315. diff -u $(SRCDIR)/providers/fips-sources.checksums providers/fips-sources.checksums.new
  1316. diff -u $(SRCDIR)/providers/fips.checksum providers/fips.checksum.new
  1317. # Release targets (note: only available on Unix) #####################
  1318. tar:
  1319. (cd $(SRCDIR); ./util/mktar.sh --name='$(NAME)' --tarfile='$(TARFILE)')
  1320. # Helper targets #####################################################
  1321. link-utils: $(BLDDIR)/util/opensslwrap.sh $(BLDDIR)/apps/openssl.cnf
  1322. $(BLDDIR)/util/opensslwrap.sh: Makefile
  1323. @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
  1324. mkdir -p "$(BLDDIR)/util"; \
  1325. ln -sf "../$(SRCDIR)/util/`basename "$@"`" "$(BLDDIR)/util"; \
  1326. fi
  1327. $(BLDDIR)/apps/openssl.cnf: Makefile
  1328. @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \
  1329. mkdir -p "$(BLDDIR)/apps"; \
  1330. ln -sf "../$(SRCDIR)/apps/`basename "$@"`" "$(BLDDIR)/apps"; \
  1331. fi
  1332. FORCE:
  1333. # Building targets ###################################################
  1334. Makefile: configdata.pm \
  1335. {- join(" \\\n" . ' ' x 10,
  1336. fill_lines(" ", $COLUMNS - 10,
  1337. @{$config{build_file_templates}})) -}
  1338. @echo "Detected changed: $?"
  1339. $(PERL) configdata.pm
  1340. @echo "**************************************************"
  1341. @echo "*** ***"
  1342. @echo "*** Please run the same make command again ***"
  1343. @echo "*** ***"
  1344. @echo "**************************************************"
  1345. @false
  1346. configdata.pm: $(SRCDIR)/Configure $(SRCDIR)/config \
  1347. {- join(" \\\n" . ' ' x 15,
  1348. fill_lines(" ", $COLUMNS - 15,
  1349. @{$config{build_infos}},
  1350. @{$config{conf_files}})) -}
  1351. @echo "Detected changed: $?"
  1352. $(PERL) configdata.pm -r
  1353. @echo "**************************************************"
  1354. @echo "*** ***"
  1355. @echo "*** Please run the same make command again ***"
  1356. @echo "*** ***"
  1357. @echo "**************************************************"
  1358. @false
  1359. reconfigure reconf:
  1360. $(PERL) configdata.pm -r
  1361. {-
  1362. use File::Basename;
  1363. use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
  1364. # Helper function to convert dependencies in platform agnostic form to
  1365. # dependencies in platform form.
  1366. sub compute_platform_depends {
  1367. map { my $x = $_;
  1368. grep { $x eq $_ } @{$unified_info{programs}} and platform->bin($x)
  1369. or grep { $x eq $_ } @{$unified_info{modules}} and platform->dso($x)
  1370. or grep { $x eq $_ } @{$unified_info{libraries}} and platform->lib($x)
  1371. or platform->convertext($x); } @_;
  1372. }
  1373. # Helper function to figure out dependencies on libraries
  1374. # It takes a list of library names and outputs a list of dependencies
  1375. sub compute_lib_depends {
  1376. # Depending on shared libraries:
  1377. # On Windows POSIX layers, we depend on {libname}.dll.a
  1378. # On Unix platforms, we depend on {shlibname}.so
  1379. return map { platform->sharedlib_simple($_)
  1380. // platform->sharedlib_import($_)
  1381. // platform->sharedlib($_)
  1382. // platform->staticlib($_)
  1383. } @_;
  1384. }
  1385. sub generatetarget {
  1386. my %args = @_;
  1387. my $deps = join(" ", compute_platform_depends(@{$args{deps}}));
  1388. return <<"EOF";
  1389. $args{target}: $deps
  1390. EOF
  1391. }
  1392. sub generatesrc {
  1393. my %args = @_;
  1394. my $gen0 = $args{generator}->[0];
  1395. my $gen_args = join('', map { " $_" }
  1396. @{$args{generator}}[1..$#{$args{generator}}]);
  1397. my $gen_incs = join("", map { " -I".$_ } @{$args{generator_incs}});
  1398. my $incs = join("", map { " -I".$_ } @{$args{incs}});
  1399. my $defs = join("", map { " -D".$_ } @{$args{defs}});
  1400. my $deps = join(" ", compute_platform_depends(@{$args{generator_deps}},
  1401. @{$args{deps}}));
  1402. if ($args{src} =~ /\.html$/) {
  1403. #
  1404. # HTML generator
  1405. #
  1406. my $title = basename($args{src}, ".html");
  1407. my $pod = $gen0;
  1408. return <<"EOF";
  1409. $args{src}: $pod
  1410. \$(PERL) \$(SRCDIR)/util/mkpod2html.pl -i "$pod" -o \$\@ -t "$title" -r "\$(SRCDIR)/doc"
  1411. EOF
  1412. } elsif ($args{src} =~ /\.(\d)$/) {
  1413. #
  1414. # Man-page generator
  1415. #
  1416. my $section = $1;
  1417. my $name = uc basename($args{src}, ".$section");
  1418. my $pod = $gen0;
  1419. return <<"EOF";
  1420. $args{src}: $pod
  1421. pod2man --name=$name --section=$section\$(MANSUFFIX) --center=OpenSSL \\
  1422. --release=\$(VERSION) $pod >\$\@
  1423. EOF
  1424. } elsif (platform->isdef($args{src})) {
  1425. #
  1426. # Linker script-ish generator
  1427. #
  1428. my $target = platform->def($args{src});
  1429. (my $mkdef_os = $target{shared_target}) =~ s|-shared$||;
  1430. my $ord_ver = $args{intent} eq 'lib' ? ' --version $(VERSION_NUMBER)' : '';
  1431. my $ord_name = $args{generator}->[1] || $args{product};
  1432. return <<"EOF";
  1433. $target: $gen0 $deps \$(SRCDIR)/util/mkdef.pl
  1434. \$(PERL) \$(SRCDIR)/util/mkdef.pl$ord_ver --type $args{intent} --ordinals $gen0 --name $ord_name --OS $mkdef_os > $target
  1435. EOF
  1436. } elsif (platform->isasm($args{src})
  1437. || platform->iscppasm($args{src})) {
  1438. #
  1439. # Assembler generator
  1440. #
  1441. my $cppflags = {
  1442. shlib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
  1443. lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
  1444. dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)',
  1445. bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
  1446. } -> {$args{intent}};
  1447. my $generator;
  1448. if ($gen0 =~ /\.pl$/) {
  1449. $generator = 'CC="$(CC)" $(PERL)'.$gen_incs.' '.$gen0.$gen_args
  1450. .' "$(PERLASM_SCHEME)"'.$incs.' '.$cppflags.$defs.' $(PROCESSOR)';
  1451. } elsif ($gen0 =~ /\.m4$/) {
  1452. $generator = 'm4 -B 8192'.$gen_incs.' '.$gen0.$gen_args.' >'
  1453. } elsif ($gen0 =~ /\.S$/) {
  1454. $generator = undef;
  1455. } else {
  1456. die "Generator type for $args{src} unknown: $gen0\n";
  1457. }
  1458. if (defined($generator)) {
  1459. return <<"EOF";
  1460. $args{src}: $gen0 $deps
  1461. $generator \$@
  1462. EOF
  1463. }
  1464. return <<"EOF";
  1465. $args{src}: $gen0 $deps
  1466. \$(CC) $incs $cppflags $defs -E $gen0 | \\
  1467. \$(PERL) -ne '/^#(line)?\\s*[0-9]+/ or print' > \$@
  1468. EOF
  1469. } elsif ($gen0 =~ m|^.*\.in$|) {
  1470. #
  1471. # "dofile" generator (file.in -> file)
  1472. #
  1473. my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
  1474. "util", "dofile.pl")),
  1475. rel2abs($config{builddir}));
  1476. my @perlmodules = ();
  1477. my %perlmoduleincs = ();
  1478. my %perlmoduledeps = ();
  1479. foreach my $x (('configdata.pm', @{$args{deps}})) {
  1480. # Compute (i)nclusion directory, (m)odule name and (d)ependency
  1481. my $i, $m, $d;
  1482. if ($x =~ /\|/) {
  1483. $i = $`;
  1484. $d = $';
  1485. # Massage the module part to become a real perl module spec
  1486. $m = $d;
  1487. $m =~ s|\.pm$||;
  1488. # Directory specs are :: in perl package names
  1489. $m =~ s|/|::|g;
  1490. # Full file name of the dependency
  1491. $d = catfile($i, $d) if $i;
  1492. } elsif ($x =~ /\.pm$/) {
  1493. $i = dirname($x);
  1494. $m = basename($x, '.pm');
  1495. $d = $x;
  1496. } else {
  1497. # All other dependencies are simply collected
  1498. $d = $x;
  1499. }
  1500. push @perlmodules, '"-M'.$m.'"' if $m;
  1501. $perlmoduledeps{$d} = 1;
  1502. $perlmoduleincs{'"-I'.$i.'"'} = 1 if $i;
  1503. }
  1504. # Because of the special treatment of dependencies, we need to
  1505. # recompute $deps completely
  1506. my $deps
  1507. = join(" ", compute_platform_depends(@{$args{generator_deps}},
  1508. sort keys %perlmoduledeps));
  1509. my $perlmodules = join(' ', '', ( sort keys %perlmoduleincs ), @perlmodules);
  1510. return <<"EOF";
  1511. $args{src}: $gen0 $deps
  1512. \$(PERL)$perlmodules "$dofile" "-o$target{build_file}" $gen0$gen_args > \$@
  1513. EOF
  1514. } elsif (grep { $_ eq $gen0 } @{$unified_info{programs}}) {
  1515. #
  1516. # Generic generator using OpenSSL programs
  1517. #
  1518. # Redo $gen0, to ensure that we have the proper extension where
  1519. # necessary.
  1520. $gen0 = platform->bin($gen0);
  1521. # Use $(PERL) to execute wrap.pl directly to avoid calling env
  1522. return <<"EOF";
  1523. $args{src}: $gen0 $deps \$(BLDDIR)/util/wrap.pl
  1524. \$(PERL) \$(BLDDIR)/util/wrap.pl $gen0$gen_args > \$@
  1525. EOF
  1526. } else {
  1527. #
  1528. # Generic generator using Perl
  1529. #
  1530. return <<"EOF";
  1531. $args{src}: $gen0 $deps
  1532. \$(PERL)$gen_incs $gen0$gen_args > \$@
  1533. EOF
  1534. }
  1535. }
  1536. # Should one wonder about the end of the Perl snippet, it's because this
  1537. # second regexp eats up line endings as well, if the removed path is the
  1538. # last in the line. We may therefore need to put back a line ending.
  1539. sub src2obj {
  1540. my %args = @_;
  1541. my $obj = platform->convertext($args{obj});
  1542. my $dep = platform->dep($args{obj});
  1543. my @srcs = @{$args{srcs}};
  1544. my $srcs = join(" ", @srcs);
  1545. my $deps = join(" ", @srcs, @{$args{deps}});
  1546. my $incs = join("", map { " -I".$_ } @{$args{incs}});
  1547. my $defs = join("", map { " -D".$_ } @{$args{defs}});
  1548. my $cmd;
  1549. my $cmdflags;
  1550. my $cmdcompile;
  1551. if (grep /\.rc$/, @srcs) {
  1552. $cmd = '$(RC)';
  1553. $cmdflags = '$(RCFLAGS)';
  1554. $cmdcompile = '';
  1555. } elsif (grep /\.(cc|cpp)$/, @srcs) {
  1556. $cmd = '$(CXX)';
  1557. $cmdcompile = ' -c';
  1558. $cmdflags = {
  1559. shlib => '$(LIB_CXXFLAGS) $(LIB_CPPFLAGS)',
  1560. lib => '$(LIB_CXXFLAGS) $(LIB_CPPFLAGS)',
  1561. dso => '$(DSO_CXXFLAGS) $(DSO_CPPFLAGS)',
  1562. bin => '$(BIN_CXXFLAGS) $(BIN_CPPFLAGS)'
  1563. } -> {$args{intent}};
  1564. } else {
  1565. $cmd = '$(CC)';
  1566. $cmdcompile = ' -c';
  1567. $cmdflags = {
  1568. shlib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
  1569. lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
  1570. dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)',
  1571. bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
  1572. } -> {$args{intent}};
  1573. }
  1574. my $recipe;
  1575. # extension-specific rules
  1576. if (grep /\.s$/, @srcs) {
  1577. $recipe .= <<"EOF";
  1578. $obj: $deps
  1579. $cmd $cmdflags -c -o \$\@ $srcs
  1580. EOF
  1581. } elsif (grep /\.S$/, @srcs) {
  1582. # Originally there was multi-step rule with $(CC) -E file.S
  1583. # followed by $(CC) -c file.s. It compensated for one of
  1584. # legacy platform compiler's inability to handle .S files.
  1585. # The platform is long discontinued by vendor so there is
  1586. # hardly a point to drag it along...
  1587. $recipe .= <<"EOF";
  1588. $obj: $deps
  1589. $cmd $incs $defs $cmdflags -c -o \$\@ $srcs
  1590. EOF
  1591. } elsif ($makedep_scheme eq 'gcc' && !grep /\.rc$/, @srcs) {
  1592. $recipe .= <<"EOF";
  1593. $obj: $deps
  1594. $cmd $incs $defs $cmdflags -MMD -MF $dep.tmp -MT \$\@ -c -o \$\@ $srcs
  1595. \@touch $dep.tmp
  1596. \@if cmp $dep.tmp $dep > /dev/null 2> /dev/null; then \\
  1597. rm -f $dep.tmp; \\
  1598. else \\
  1599. mv $dep.tmp $dep; \\
  1600. fi
  1601. EOF
  1602. } else {
  1603. $recipe .= <<"EOF";
  1604. $obj: $deps
  1605. $cmd $incs $defs $cmdflags $cmdcompile -o \$\@ $srcs
  1606. EOF
  1607. if ($makedep_scheme eq 'makedepend') {
  1608. $recipe .= <<"EOF";
  1609. \$(MAKEDEPEND) -f- -Y -- $incs $cmdflags -- $srcs 2>/dev/null \\
  1610. > $dep
  1611. EOF
  1612. }
  1613. }
  1614. return $recipe;
  1615. }
  1616. # We *know* this routine is only called when we've configure 'shared'.
  1617. sub obj2shlib {
  1618. my %args = @_;
  1619. my @linkdirs = ();
  1620. my @linklibs = ();
  1621. foreach (@{$args{deps}}) {
  1622. if (platform->isstaticlib($_)) {
  1623. push @linklibs, platform->convertext($_);
  1624. } else {
  1625. my $d = "-L" . dirname($_);
  1626. my $l = basename($_);
  1627. $l =~ s/^lib//;
  1628. $l = "-l" . $l;
  1629. push @linklibs, $l;
  1630. push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
  1631. }
  1632. }
  1633. my $linkflags = join("", map { $_." " } @linkdirs);
  1634. my $linklibs = join("", map { $_." " } @linklibs);
  1635. my @objs = map { platform->convertext($_) }
  1636. grep { !platform->isdef($_) }
  1637. @{$args{objs}};
  1638. my @defs = map { platform->def($_) }
  1639. grep { platform->isdef($_) }
  1640. @{$args{objs}};
  1641. my @deps = compute_lib_depends(@{$args{deps}});
  1642. die "More than one exported symbol map" if scalar @defs > 1;
  1643. my $full = platform->sharedlib($args{lib});
  1644. # $import is for Windows and subsystems thereof, where static import
  1645. # libraries for DLLs are a thing. On platforms that have this mechanism,
  1646. # $import has the name of this import library. On platforms that don't
  1647. # have this mechanism, $import will be |undef|.
  1648. my $import = platform->sharedlib_import($args{lib});
  1649. # $simple is for platforms where full shared library names include the
  1650. # shared library version, and there's a simpler name that doesn't include
  1651. # that version. On such platforms, $simple has the simpler name. On
  1652. # other platforms, it will be |undef|.
  1653. my $simple = platform->sharedlib_simple($args{lib});
  1654. my $argfile = defined $target{shared_argfileflag} ? $full.".args" : undef;
  1655. my $shared_soname = "";
  1656. $shared_soname .= ' '.$target{shared_sonameflag}.basename($full)
  1657. if defined $target{shared_sonameflag};
  1658. my $shared_imp = "";
  1659. $shared_imp .= ' '.$target{shared_impflag}.basename($import)
  1660. if defined $target{shared_impflag} && defined $import;
  1661. my $shared_def = join("", map { ' '.$target{shared_defflag}.$_ } @defs);
  1662. # There is at least one platform where the compiler-as-linker needs to
  1663. # have one object file directly on the command line. That won't hurt
  1664. # any other platform, so we do that for everyone when there's an argfile
  1665. # to be had. This depends heavily on splice, which removes elements from
  1666. # the given array, and returns them so they can be captured.
  1667. my @argfileobjs = $argfile
  1668. ? splice(@objs, 1)
  1669. : ();
  1670. my $argfilecmds = $argfile
  1671. ? join("\n\t", map { "echo $_ >> $argfile" } @argfileobjs)
  1672. : undef;
  1673. my $argfiledeps = $argfile
  1674. ? join(" \\\n" . ' ' x (length($argfile) + 2),
  1675. fill_lines(' ', $COLUMNS - length($full) - 2, @argfileobjs))
  1676. : undef;
  1677. my @fulldeps = (@objs, ($argfile ? $argfile : ()), @defs, @deps);
  1678. my @fullobjs = (
  1679. @objs,
  1680. ($argfile ? $target{shared_argfileflag}.$argfile : ())
  1681. );
  1682. my $fulldeps =
  1683. join(" \\\n" . ' ' x (length($full) + 2),
  1684. fill_lines(' ', $COLUMNS - length($full) - 2, @fulldeps));
  1685. my $fullobjs =
  1686. join(" \\\n\t\t", fill_lines(' ', $COLUMNS - 16, @fullobjs));
  1687. my $recipe = '';
  1688. if (defined $simple && $simple ne $full) {
  1689. if (sharedaix()) {
  1690. $recipe .= <<"EOF";
  1691. $simple: $full
  1692. rm -f $simple && \\
  1693. \$(AR) r $simple $full
  1694. EOF
  1695. } else {
  1696. $recipe .= <<"EOF";
  1697. $simple: $full
  1698. rm -f $simple && \\
  1699. ln -s $full $simple
  1700. EOF
  1701. }
  1702. }
  1703. if (defined $import) {
  1704. $recipe .= <<"EOF";
  1705. $import: $full
  1706. EOF
  1707. }
  1708. $recipe .= <<"EOF";
  1709. $full: $fulldeps
  1710. \$(CC) \$(LIB_CFLAGS) $linkflags\$(LIB_LDFLAGS)$shared_soname$shared_imp \\
  1711. -o $full$shared_def \\
  1712. $fullobjs \\
  1713. $linklibs \$(LIB_EX_LIBS)
  1714. EOF
  1715. if (windowsdll()) {
  1716. $recipe .= <<"EOF";
  1717. rm -f apps/$full
  1718. rm -f fuzz/$full
  1719. cp -p $full apps/
  1720. cp -p $full fuzz/
  1721. EOF
  1722. if (!$disabled{tests}) {
  1723. $recipe .= <<"EOF";
  1724. rm -f test/$full
  1725. cp -p $full test/
  1726. EOF
  1727. }
  1728. }
  1729. $recipe .= <<"EOF" if defined $argfile;
  1730. $argfile: $argfiledeps
  1731. \$(RM) $argfile
  1732. $argfilecmds
  1733. EOF
  1734. return $recipe;
  1735. }
  1736. sub obj2dso {
  1737. my %args = @_;
  1738. my $dso = platform->dso($args{module});
  1739. my @linkdirs = ();
  1740. my @linklibs = ();
  1741. foreach (@{$args{deps}}) {
  1742. next unless defined $_;
  1743. if (platform->isstaticlib($_)) {
  1744. push @linklibs, platform->convertext($_);
  1745. } else {
  1746. my $d = "-L" . dirname($_);
  1747. my $l = basename($_);
  1748. $l =~ s/^lib//;
  1749. $l = "-l" . $l;
  1750. push @linklibs, $l;
  1751. push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
  1752. }
  1753. }
  1754. my $linkflags = join("", map { $_." " } @linkdirs);
  1755. my $linklibs = join("", map { $_." " } @linklibs);
  1756. my @objs = map { platform->convertext($_) }
  1757. grep { !platform->isdef($_) }
  1758. @{$args{objs}};
  1759. my @defs = map { platform->def($_) }
  1760. grep { platform->isdef($_) }
  1761. @{$args{objs}};
  1762. my @deps = compute_lib_depends(@{$args{deps}});
  1763. my $shared_def = join("", map { ' '.$target{shared_defflag}.$_ } @defs);
  1764. # Next line needs to become "less magic" (see PR #11950)
  1765. $shared_def .= ' '.$target{shared_fipsflag} if (defined $target{shared_fipsflag} && $shared_def =~ m/providers\/fips/);
  1766. my $objs = join(" \\\n\t\t", fill_lines(' ', $COLUMNS - 16, @objs));
  1767. my $deps = join(" \\\n" . ' ' x (length($dso) + 2),
  1768. fill_lines(' ', $COLUMNS - length($dso) - 2,
  1769. @objs, @defs, @deps));
  1770. return <<"EOF";
  1771. $dso: $deps
  1772. \$(CC) \$(DSO_CFLAGS) $linkflags\$(DSO_LDFLAGS) \\
  1773. -o $dso$shared_def \\
  1774. $objs \\
  1775. $linklibs\$(DSO_EX_LIBS)
  1776. EOF
  1777. }
  1778. sub obj2lib {
  1779. my %args = @_;
  1780. my $lib = platform->staticlib($args{lib});
  1781. my @objs = map { platform->obj($_) } @{$args{objs}};
  1782. my $deps = join(" \\\n" . ' ' x (length($lib) + 2),
  1783. fill_lines(' ', $COLUMNS - length($lib) - 2, @objs));
  1784. my $max_per_call = 500;
  1785. my @objs_grouped;
  1786. push @objs_grouped, join(" ", splice @objs, 0, $max_per_call) while @objs;
  1787. my $fill_lib =
  1788. join("\n\t", (map { "\$(AR) \$(ARFLAGS) $lib $_" } @objs_grouped));
  1789. return <<"EOF";
  1790. $lib: $deps
  1791. \$(RM) $lib
  1792. $fill_lib
  1793. \$(RANLIB) \$\@ || echo Never mind.
  1794. EOF
  1795. }
  1796. sub obj2bin {
  1797. my %args = @_;
  1798. my $bin = platform->bin($args{bin});
  1799. my @objs = map { platform->obj($_) } @{$args{objs}};
  1800. my @deps = compute_lib_depends(@{$args{deps}});
  1801. my $objs = join(" \\\n" . ' ' x (length($bin) + 2),
  1802. fill_lines(' ', $COLUMNS - length($bin) - 2, @objs));
  1803. my @linkdirs = ();
  1804. my @linklibs = ();
  1805. foreach (@{$args{deps}}) {
  1806. next unless defined $_;
  1807. if (platform->isstaticlib($_)) {
  1808. push @linklibs, platform->convertext($_);
  1809. } else {
  1810. my $d = "-L" . dirname($_);
  1811. my $l = basename($_);
  1812. $l =~ s/^lib//;
  1813. $l = "-l" . $l;
  1814. push @linklibs, $l;
  1815. push @linkdirs, $d unless grep { $d eq $_ } @linkdirs;
  1816. }
  1817. }
  1818. my $linkflags = join("", map { $_." " } @linkdirs);
  1819. my $linklibs = join("", map { $_." " } @linklibs);
  1820. my $cmd = '$(CC)';
  1821. my $cmdflags = '$(BIN_CFLAGS)';
  1822. if (grep /_cc\.o$/, @{$args{objs}}) {
  1823. $cmd = '$(CXX)';
  1824. $cmdflags = '$(BIN_CXXFLAGS)';
  1825. }
  1826. my $objs = join(" \\\n\t\t", fill_lines(' ', $COLUMNS - 16, @objs));
  1827. my $deps = join(" \\\n" . ' ' x (length($bin) + 2),
  1828. fill_lines(' ', $COLUMNS - length($bin) - 2,
  1829. @objs, @deps));
  1830. return <<"EOF";
  1831. $bin: $deps
  1832. rm -f $bin
  1833. \$\${LDCMD:-$cmd} $cmdflags $linkflags\$(BIN_LDFLAGS) \\
  1834. -o $bin \\
  1835. $objs \\
  1836. $linklibs\$(BIN_EX_LIBS)
  1837. EOF
  1838. }
  1839. sub in2script {
  1840. my %args = @_;
  1841. my $script = $args{script};
  1842. my $sources = join(" ", @{$args{sources}});
  1843. my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
  1844. "util", "dofile.pl")),
  1845. rel2abs($config{builddir}));
  1846. return <<"EOF";
  1847. $script: $sources configdata.pm
  1848. \$(RM) "$script"
  1849. \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
  1850. "-o$target{build_file}" $sources > "$script"
  1851. chmod a+x $script
  1852. EOF
  1853. }
  1854. sub generatedir {
  1855. my %args = @_;
  1856. my $dir = $args{dir};
  1857. my @deps = compute_platform_depends(@{$args{deps}});
  1858. my @comments = ();
  1859. # We already have a 'test' target, and the top directory is just plain
  1860. # silly
  1861. return if $dir eq "test" || $dir eq ".";
  1862. foreach my $type (("dso", "lib", "bin", "script")) {
  1863. next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type});
  1864. # For lib object files, we could update the library. However, it
  1865. # was decided that it's enough to build the directory local object
  1866. # files, so we don't need to add any actions, and the dependencies
  1867. # are already taken care of.
  1868. if ($type ne "lib") {
  1869. foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) {
  1870. if (dirname($prod) eq $dir) {
  1871. push @deps, compute_platform_depends($prod);
  1872. } else {
  1873. push @comments, "# No support to produce $type ".join(", ", @{$unified_info{dirinfo}->{$dir}->{products}->{$type}});
  1874. }
  1875. }
  1876. }
  1877. }
  1878. my $target = "$dir $dir/";
  1879. my $deps = join(" \\\n\t",
  1880. fill_lines(' ', $COLUMNS - 8, @deps));
  1881. my $comments = join("\n", "", @comments);
  1882. return <<"EOF";
  1883. $target: \\
  1884. $deps$comments
  1885. EOF
  1886. }
  1887. "" # Important! This becomes part of the template result.
  1888. -}