unix-Makefile.tmpl 54 KB

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