unix-Makefile.tmpl 79 KB

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