unix-Makefile.tmpl 81 KB

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