2
0

unix-Makefile.tmpl 53 KB

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