unix-Makefile.tmpl 61 KB

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