unix-Makefile.tmpl 63 KB

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