A local copy of OpenSSL from GitHub
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

995 lines
41 KiB

Switch to MAJOR.MINOR.PATCH versioning and version 3.0.0-dev We're strictly use version numbers of the form MAJOR.MINOR.PATCH. Letter releases are things of days past. The most central change is that we now express the version number with three macros, one for each part of the version number: OPENSSL_VERSION_MAJOR OPENSSL_VERSION_MINOR OPENSSL_VERSION_PATCH We also provide two additional macros to express pre-release and build metadata information (also specified in semantic versioning): OPENSSL_VERSION_PRE_RELEASE OPENSSL_VERSION_BUILD_METADATA To get the library's idea of all those values, we introduce the following functions: unsigned int OPENSSL_version_major(void); unsigned int OPENSSL_version_minor(void); unsigned int OPENSSL_version_patch(void); const char *OPENSSL_version_pre_release(void); const char *OPENSSL_version_build_metadata(void); Additionally, for shared library versioning (which is out of scope in semantic versioning, but that we still need): OPENSSL_SHLIB_VERSION We also provide a macro that contains the release date. This is not part of the version number, but is extra information that we want to be able to display: OPENSSL_RELEASE_DATE Finally, also provide the following convenience functions: const char *OPENSSL_version_text(void); const char *OPENSSL_version_text_full(void); The following macros and functions are deprecated, and while currently existing for backward compatibility, they are expected to disappear: OPENSSL_VERSION_NUMBER OPENSSL_VERSION_TEXT OPENSSL_VERSION OpenSSL_version_num() OpenSSL_version() Also, this function is introduced to replace OpenSSL_version() for all indexes except for OPENSSL_VERSION: OPENSSL_info() For configuration, the option 'newversion-only' is added to disable all the macros and functions that are mentioned as deprecated above. Reviewed-by: Tim Hudson <tjh@openssl.org> Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/7724)
4 years ago
  1. ##
  2. ## Makefile for OpenSSL
  3. ##
  4. ## {- join("\n## ", @autowarntext) -}
  5. {-
  6. use File::Basename;
  7. our $sover_dirname = platform->shlib_version_as_filename();
  8. my $build_scheme = $target{build_scheme};
  9. my $install_flavour = $build_scheme->[$#$build_scheme]; # last element
  10. my $win_installenv =
  11. $install_flavour eq "VC-WOW" ? "ProgramFiles(x86)"
  12. : "ProgramW6432";
  13. my $win_commonenv =
  14. $install_flavour eq "VC-WOW" ? "CommonProgramFiles(x86)"
  15. : "CommonProgramW6432";
  16. our $win_installroot =
  17. defined($ENV{$win_installenv}) ? $win_installenv : 'ProgramFiles';
  18. our $win_commonroot =
  19. defined($ENV{$win_commonenv}) ? $win_commonenv : 'CommonProgramFiles';
  20. # expand variables early
  21. $win_installroot = $ENV{$win_installroot};
  22. $win_commonroot = $ENV{$win_commonroot};
  23. # This makes sure things get built in the order they need
  24. # to. You're welcome.
  25. sub dependmagic {
  26. my $target = shift;
  27. return "$target: build_generated\n\t\$(MAKE) /\$(MAKEFLAGS) depend\n\t\$(MAKE) /\$(MAKEFLAGS) _$target\n_$target";
  28. }
  29. '';
  30. -}
  31. PLATFORM={- $config{target} -}
  32. SRCDIR={- $config{sourcedir} -}
  33. BLDDIR={- $config{builddir} -}
  34. FIPSKEY={- $config{FIPSKEY} -}
  35. VERSION={- "$config{full_version}" -}
  36. MAJOR={- $config{major} -}
  37. MINOR={- $config{minor} -}
  38. SHLIB_VERSION_NUMBER={- $config{shlib_version} -}
  39. LIBS={- join(" ", map { ( platform->sharedlib_import($_), platform->staticlib($_) ) } @{$unified_info{libraries}}) -}
  40. SHLIBS={- join(" ", map { platform->sharedlib($_) // () } @{$unified_info{libraries}}) -}
  41. SHLIBPDBS={- join(" ", map { platform->sharedlibpdb($_) // () } @{$unified_info{libraries}}) -}
  42. MODULES={- our @MODULES = map { platform->dso($_) } @{$unified_info{modules}};
  43. join(" ", @MODULES) -}
  44. MODULEPDBS={- join(" ", map { platform->dsopdb($_) } @{$unified_info{modules}}) -}
  45. FIPSMODULENAME={- # We do some extra checking here, as there should be only one
  46. use File::Basename;
  47. my @fipsmodules =
  48. grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
  49. && $unified_info{attributes}->{modules}->{$_}->{fips} }
  50. @{$unified_info{modules}};
  51. die "More that one FIPS module" if scalar @fipsmodules > 1;
  52. join(" ", map { basename(platform->dso($_)) } @fipsmodules) -}
  53. PROGRAMS={- our @PROGRAMS = map { platform->bin($_) } @{$unified_info{programs}}; join(" ", @PROGRAMS) -}
  54. PROGRAMPDBS={- join(" ", map { $_.".pdb" } @{$unified_info{programs}}) -}
  55. SCRIPTS={- our @SCRIPTS = @{$unified_info{scripts}}; join(" ", @SCRIPTS) -}
  56. {- output_off() if $disabled{makedepend}; "" -}
  57. DEPS={- join(" ", map { platform->isobj($_) ? platform->dep($_) : () }
  58. grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
  59. keys %{$unified_info{sources}}); -}
  60. {- output_on() if $disabled{makedepend}; "" -}
  61. GENERATED_MANDATORY={- our @GENERATED_MANDATORY = @{$unified_info{depends}->{""}};
  62. join(" ", @GENERATED_MANDATORY) -}
  63. GENERATED={- # common0.tmpl provides @generated
  64. our @GENERATED = map { platform->convertext($_) } @generated;
  65. join(" ", @GENERATED) -}
  66. INSTALL_LIBS={-
  67. join(" ", map { quotify1(platform->sharedlib_import($_)
  68. // platform->staticlib($_)) }
  69. grep { !$unified_info{attributes}->{libraries}->{$_}->{noinst} }
  70. @{$unified_info{libraries}})
  71. -}
  72. INSTALL_SHLIBS={-
  73. join(" ", map { my $x = platform->sharedlib($_);
  74. $x ? quotify_l($x) : () }
  75. grep { !$unified_info{attributes}->{libraries}->{$_}->{noinst} }
  76. @{$unified_info{libraries}})
  77. -}
  78. INSTALL_SHLIBPDBS={-
  79. join(" ", map { my $x = platform->sharedlibpdb($_);
  80. $x ? quotify_l($x) : () }
  81. grep { !$unified_info{attributes}->{libraries}->{$_}->{noinst} }
  82. @{$unified_info{libraries}})
  83. -}
  84. INSTALL_ENGINES={-
  85. join(" ", map { quotify1(platform->dso($_)) }
  86. grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
  87. && $unified_info{attributes}->{modules}->{$_}->{engine} }
  88. @{$unified_info{modules}})
  89. -}
  90. INSTALL_ENGINEPDBS={-
  91. join(" ", map { quotify1(platform->dsopdb($_)) }
  92. grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
  93. && $unified_info{attributes}->{modules}->{$_}->{engine} }
  94. @{$unified_info{modules}})
  95. -}
  96. INSTALL_MODULES={-
  97. join(" ", map { platform->dso($_) }
  98. grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
  99. && !$unified_info{attributes}->{modules}->{$_}->{engine} }
  100. @{$unified_info{modules}})
  101. -}
  102. INSTALL_MODULEPDBS={-
  103. join(" ", map { quotify1(platform->dsopdb($_)) }
  104. grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
  105. && !$unified_info{attributes}->{modules}->{$_}->{engine} }
  106. @{$unified_info{modules}})
  107. -}
  108. INSTALL_PROGRAMS={-
  109. join(" ", map { quotify1(platform->bin($_)) }
  110. grep { !$unified_info{attributes}->{programs}->{$_}->{noinst} }
  111. @{$unified_info{programs}})
  112. -}
  113. INSTALL_PROGRAMPDBS={-
  114. join(" ", map { quotify1(platform->binpdb($_)) }
  115. grep { !$unified_info{attributes}->{programs}->{$_}->{noinst} }
  116. @{$unified_info{programs}})
  117. -}
  118. BIN_SCRIPTS={-
  119. join(" ", map { quotify1($_) }
  120. grep { !$unified_info{attributes}->{scripts}->{$_}->{noinst}
  121. && !$unified_info{attributes}->{scripts}->{$_}->{misc} }
  122. @{$unified_info{scripts}})
  123. -}
  124. MISC_SCRIPTS={-
  125. join(" ", map { quotify1($_) }
  126. grep { !$unified_info{attributes}->{scripts}->{$_}->{noinst}
  127. && $unified_info{attributes}->{scripts}->{$_}->{misc} }
  128. @{$unified_info{scripts}})
  129. -}
  130. HTMLDOCS1={- our @HTMLDOCS1 = @{$unified_info{htmldocs}->{man1}};
  131. join(" ", @HTMLDOCS1) -}
  132. HTMLDOCS3={- our @HTMLDOCS3 = @{$unified_info{htmldocs}->{man3}};
  133. join(" ", @HTMLDOCS3) -}
  134. HTMLDOCS5={- our @HTMLDOCS5 = @{$unified_info{htmldocs}->{man5}};
  135. join(" ", @HTMLDOCS5) -}
  136. HTMLDOCS7={- our @HTMLDOCS7 = @{$unified_info{htmldocs}->{man7}};
  137. join(" ", @HTMLDOCS7) -}
  138. HTMLDOCS1_BLDDIRS={- my %dirs = map { dirname($_) => 1 } @HTMLDOCS1;
  139. join(' ', sort keys %dirs) -}
  140. HTMLDOCS3_BLDDIRS={- my %dirs = map { dirname($_) => 1 } @HTMLDOCS3;
  141. join(' ', sort keys %dirs) -}
  142. HTMLDOCS5_BLDDIRS={- my %dirs = map { dirname($_) => 1 } @HTMLDOCS5;
  143. join(' ', sort keys %dirs) -}
  144. HTMLDOCS7_BLDDIRS={- my %dirs = map { dirname($_) => 1 } @HTMLDOCS7;
  145. join(' ', sort keys %dirs) -}
  146. APPS_OPENSSL="{- use File::Spec::Functions;
  147. catfile("apps","openssl") -}"
  148. # Do not edit these manually. Use Configure with --prefix or --openssldir
  149. # to change this! Short explanation in the top comment in Configure
  150. INSTALLTOP_dev={- # $prefix is used in the OPENSSLDIR perl snippet
  151. #
  152. use File::Spec::Functions qw(:DEFAULT splitpath);
  153. our $prefix = canonpath($config{prefix}
  154. || "$win_installroot\\OpenSSL");
  155. our ($prefix_dev, $prefix_dir, $prefix_file) =
  156. splitpath($prefix, 1);
  157. $prefix_dev -}
  158. INSTALLTOP_dir={- canonpath($prefix_dir) -}
  159. OPENSSLDIR_dev={- #
  160. # The logic here is that if no --openssldir was given,
  161. # OPENSSLDIR will get the value "$win_commonroot\\SSL".
  162. # If --openssldir was given and the value is an absolute
  163. # path, OPENSSLDIR will get its value without change.
  164. # If the value from --openssldir is a relative path,
  165. # OPENSSLDIR will get $prefix with the --openssldir
  166. # value appended as a subdirectory.
  167. #
  168. use File::Spec::Functions qw(:DEFAULT splitpath);
  169. our $openssldir =
  170. $config{openssldir} ?
  171. (file_name_is_absolute($config{openssldir}) ?
  172. canonpath($config{openssldir})
  173. : catdir($prefix, $config{openssldir}))
  174. : canonpath("$win_commonroot\\SSL");
  175. our ($openssldir_dev, $openssldir_dir, $openssldir_file) =
  176. splitpath($openssldir, 1);
  177. $openssldir_dev -}
  178. OPENSSLDIR_dir={- canonpath($openssldir_dir) -}
  179. LIBDIR={- our $libdir = $config{libdir} || "lib";
  180. file_name_is_absolute($libdir) ? "" : $libdir -}
  181. MODULESDIR_dev={- use File::Spec::Functions qw(:DEFAULT splitpath catpath);
  182. our $modulesprefix = catdir($prefix,$libdir);
  183. our ($modulesprefix_dev, $modulesprefix_dir,
  184. $modulesprefix_file) =
  185. splitpath($modulesprefix, 1);
  186. our $modulesdir_dev = $modulesprefix_dev;
  187. our $modulesdir_dir =
  188. catdir($modulesprefix_dir, "ossl-modules");
  189. our $modulesdir = catpath($modulesdir_dev, $modulesdir_dir);
  190. our $enginesdir_dev = $modulesprefix_dev;
  191. our $enginesdir_dir =
  192. catdir($modulesprefix_dir, "engines-$sover_dirname");
  193. our $enginesdir = catpath($enginesdir_dev, $enginesdir_dir);
  194. $modulesdir_dev -}
  195. MODULESDIR_dir={- canonpath($modulesdir_dir) -}
  196. ENGINESDIR_dev={- $enginesdir_dev -}
  197. ENGINESDIR_dir={- canonpath($enginesdir_dir) -}
  198. !IF "$(DESTDIR)" != ""
  199. INSTALLTOP=$(DESTDIR)$(INSTALLTOP_dir)
  200. OPENSSLDIR=$(DESTDIR)$(OPENSSLDIR_dir)
  201. ENGINESDIR=$(DESTDIR)$(ENGINESDIR_dir)
  202. MODULESDIR=$(DESTDIR)$(MODULESDIR_dir)
  203. !ELSE
  204. INSTALLTOP=$(INSTALLTOP_dev)$(INSTALLTOP_dir)
  205. OPENSSLDIR=$(OPENSSLDIR_dev)$(OPENSSLDIR_dir)
  206. ENGINESDIR=$(ENGINESDIR_dev)$(ENGINESDIR_dir)
  207. MODULESDIR=$(MODULESDIR_dev)$(MODULESDIR_dir)
  208. !ENDIF
  209. # $(libdir) is chosen to be compatible with the GNU coding standards
  210. libdir={- file_name_is_absolute($libdir)
  211. ? $libdir : '$(INSTALLTOP)\$(LIBDIR)' -}
  212. ##### User defined commands and flags ################################
  213. CC="{- $config{CC} -}"
  214. CPP="{- $config{CPP} -}"
  215. CPPFLAGS={- our $cppflags1 = join(" ",
  216. (map { "-D".$_} @{$config{CPPDEFINES}}),
  217. (map { " -I".$_} @{$config{CPPINCLUDES}}),
  218. @{$config{CPPFLAGS}}) -}
  219. CFLAGS={- join(' ', @{$config{CFLAGS}}) -}
  220. LD="{- $config{LD} -}"
  221. LDFLAGS={- join(' ', @{$config{LDFLAGS}}) -}
  222. EX_LIBS={- join(' ', @{$config{LDLIBS}}) -}
  223. PERL={- $config{PERL} -}
  224. AR="{- $config{AR} -}"
  225. ARFLAGS= {- join(' ', @{$config{ARFLAGS}}) -}
  226. MT="{- $config{MT} -}"
  227. MTFLAGS= {- join(' ', @{$config{MTFLAGS}}) -}
  228. AS="{- $config{AS} -}"
  229. ASFLAGS={- join(' ', @{$config{ASFLAGS}}) -}
  230. RC="{- $config{RC} -}"
  231. RCFLAGS={- join(' ', @{$config{RCFLAGS}}) -}
  232. ECHO="$(PERL)" "$(SRCDIR)\util\echo.pl"
  233. ##### Special command flags ##########################################
  234. COUTFLAG={- $target{coutflag} -}$(OSSL_EMPTY)
  235. LDOUTFLAG={- $target{ldoutflag} -}$(OSSL_EMPTY)
  236. AROUTFLAG={- $target{aroutflag} -}$(OSSL_EMPTY)
  237. MTINFLAG={- $target{mtinflag} -}$(OSSL_EMPTY)
  238. MTOUTFLAG={- $target{mtoutflag} -}$(OSSL_EMPTY)
  239. ASOUTFLAG={- $target{asoutflag} -}$(OSSL_EMPTY)
  240. RCOUTFLAG={- $target{rcoutflag} -}$(OSSL_EMPTY)
  241. ##### Project flags ##################################################
  242. # Variables starting with CNF_ are common variables for all product types
  243. CNF_ASFLAGS={- join(' ', $target{asflags} || (),
  244. @{$config{asflags}}) -}
  245. CNF_CPPFLAGS={- our $cppfags2 =
  246. join(' ', $target{cppflags} || (),
  247. (map { '-D'.quotify1($_) } @{$target{defines}},
  248. @{$config{defines}}),
  249. (map { '-I'.'"'.$_.'"' } @{$target{includes}},
  250. @{$config{includes}}),
  251. @{$config{cppflags}}) -}
  252. CNF_CFLAGS={- join(' ', $target{cflags} || (),
  253. @{$config{cflags}}) -}
  254. CNF_CXXFLAGS={- join(' ', $target{cxxflags} || (),
  255. @{$config{cxxflags}}) -}
  256. CNF_LDFLAGS={- join(' ', $target{lflags} || (),
  257. @{$config{lflags}}) -}
  258. CNF_EX_LIBS={- join(' ', $target{ex_libs} || (),
  259. @{$config{ex_libs}}) -}
  260. # Variables starting with LIB_ are used to build library object files
  261. # and shared libraries.
  262. # Variables starting with DSO_ are used to build DSOs and their object files.
  263. # Variables starting with BIN_ are used to build programs and their object
  264. # files.
  265. LIB_ASFLAGS={- join(' ', $target{lib_asflags} || (),
  266. @{$config{lib_asflags}},
  267. '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
  268. LIB_CPPFLAGS={- our $lib_cppflags =
  269. join(' ', $target{lib_cppflags} || (),
  270. $target{shared_cppflag} || (),
  271. (map { '-D'.quotify1($_) }
  272. @{$target{lib_defines}},
  273. @{$target{shared_defines}},
  274. @{$config{lib_defines}},
  275. @{$config{shared_defines}}),
  276. (map { '-I'.quotify1($_) }
  277. @{$target{lib_includes}},
  278. @{$target{shared_includes}},
  279. @{$config{lib_includes}},
  280. @{$config{shared_includes}}),
  281. @{$config{lib_cppflags}},
  282. @{$config{shared_cppflag}});
  283. join(' ', $lib_cppflags,
  284. (map { '-D'.quotify1($_) }
  285. "OPENSSLDIR=\"$openssldir\"",
  286. "ENGINESDIR=\"$enginesdir\"",
  287. "MODULESDIR=\"$modulesdir\""),
  288. '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
  289. LIB_CFLAGS={- join(' ', $target{lib_cflags} || (),
  290. $target{shared_cflag} || (),
  291. @{$config{lib_cflags}},
  292. @{$config{shared_cflag}},
  293. '$(CNF_CFLAGS)', '$(CFLAGS)') -}
  294. LIB_LDFLAGS={- join(' ', $target{shared_ldflag} || (),
  295. $config{shared_ldflag} || (),
  296. '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
  297. LIB_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
  298. DSO_ASFLAGS={- join(' ', $target{dso_asflags} || (),
  299. $target{module_asflags} || (),
  300. @{$config{dso_asflags}},
  301. @{$config{module_asflags}},
  302. '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
  303. DSO_CPPFLAGS={- join(' ', $target{dso_cppflags} || (),
  304. $target{module_cppflag} || (),
  305. (map { '-D'.quotify1($_) }
  306. @{$target{dso_defines}},
  307. @{$target{module_defines}},
  308. @{$config{dso_defines}},
  309. @{$config{module_defines}}),
  310. (map { '-I'.quotify1($_) }
  311. @{$target{dso_includes}},
  312. @{$target{module_includes}},
  313. @{$config{dso_includes}},
  314. @{$config{module_includes}}),
  315. @{$config{dso_cppflags}},
  316. @{$config{module_cppflags}},
  317. '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
  318. DSO_CFLAGS={- join(' ', $target{dso_cflags} || (),
  319. $target{module_cflags} || (),
  320. @{$config{dso_cflags}},
  321. @{$config{module_cflags}},
  322. '$(CNF_CFLAGS)', '$(CFLAGS)') -}
  323. DSO_LDFLAGS={- join(' ', $target{dso_lflags} || (),
  324. $target{module_ldflags} || (),
  325. @{$config{dso_lflags}},
  326. @{$config{module_ldflags}},
  327. '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
  328. DSO_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
  329. BIN_ASFLAGS={- join(' ', $target{bin_asflags} || (),
  330. @{$config{bin_asflags}},
  331. '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
  332. BIN_CPPFLAGS={- join(' ', $target{bin_cppflags} || (),
  333. (map { '-D'.$_ } @{$config{bin_defines} || ()}),
  334. @{$config{bin_cppflags}},
  335. '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
  336. BIN_CFLAGS={- join(' ', $target{bin_cflags} || (),
  337. @{$config{bin_cflags}},
  338. '$(CNF_CFLAGS)', '$(CFLAGS)') -}
  339. BIN_LDFLAGS={- join(' ', $target{bin_lflags} || (),
  340. @{$config{bin_lflags}},
  341. '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
  342. BIN_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
  343. # CPPFLAGS_Q is used for one thing only: to build up buildinf.h
  344. CPPFLAGS_Q={- $cppflags1 =~ s|([\\"])|\\$1|g;
  345. $cppflags2 =~ s|([\\"])|\\$1|g;
  346. join(' ', $lib_cppflags || (), $cppflags2 || (),
  347. $cppflags1 || ()) -}
  348. PERLASM_SCHEME= {- $target{perlasm_scheme} -}
  349. PROCESSOR= {- $config{processor} -}
  350. # The main targets ###################################################
  351. {- dependmagic('build_sw'); -}: build_libs_nodep build_modules_nodep build_programs_nodep copy-utils
  352. {- dependmagic('build_libs'); -}: build_libs_nodep
  353. {- dependmagic('build_modules'); -}: build_modules_nodep
  354. {- dependmagic('build_programs'); -}: build_programs_nodep
  355. build_docs: build_html_docs
  356. build_html_docs: $(HTMLDOCS1) $(HTMLDOCS3) $(HTMLDOCS5) $(HTMLDOCS7)
  357. @
  358. build_generated: $(GENERATED_MANDATORY)
  359. @
  360. build_libs_nodep: $(LIBS) {- join(" ",map { platform->sharedlib_import($_) // () } @{$unified_info{libraries}}) -}
  361. @
  362. build_modules_nodep: $(MODULES)
  363. @
  364. build_programs_nodep: $(PROGRAMS) $(SCRIPTS)
  365. @
  366. # Kept around for backward compatibility
  367. build_apps build_tests: build_programs
  368. # Convenience target to prebuild all generated files, not just the mandatory
  369. # ones
  370. build_all_generated: $(GENERATED_MANDATORY) $(GENERATED) build_docs
  371. @{- output_off() if $disabled{makedepend}; "" -}
  372. @$(ECHO) "Warning: consider configuring with no-makedepend, because if"
  373. @$(ECHO) " target system doesn't have $(PERL),"
  374. @$(ECHO) " then make will fail..."
  375. @{- output_on() if $disabled{makedepend}; "" -}
  376. all: build_sw build_docs
  377. test: tests
  378. {- dependmagic('tests'); -}: build_programs_nodep build_modules_nodep copy-utils
  379. @{- output_off() if $disabled{tests}; "" -}
  380. cmd /C "set "SRCTOP=$(SRCDIR)" & set "BLDTOP=$(BLDDIR)" & set "PERL=$(PERL)" & set "FIPSKEY=$(FIPSKEY)" & "$(PERL)" "$(SRCDIR)\test\run_tests.pl" $(TESTS)"
  381. @{- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
  382. @$(ECHO) "Tests are not supported with your chosen Configure options"
  383. @{- output_on() if !$disabled{tests}; "" -}
  384. list-tests:
  385. @{- output_off() if $disabled{tests}; "" -}
  386. @cmd /C "set "SRCTOP=$(SRCDIR)" & "$(PERL)" "$(SRCDIR)\test\run_tests.pl" list"
  387. @{- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
  388. @$(ECHO) "Tests are not supported with your chosen Configure options"
  389. @{- output_on() if !$disabled{tests}; "" -}
  390. install: install_sw install_ssldirs install_docs
  391. uninstall: uninstall_docs uninstall_sw
  392. libclean:
  393. "$(PERL)" -e "map { m/(.*)\.dll$$/; unlink glob """{.,apps,test,fuzz}/$$1.*"""; } @ARGV" $(SHLIBS)
  394. -del /Q /F $(LIBS) libcrypto.* libssl.* ossl_static.pdb
  395. clean: libclean
  396. -rmdir /Q /S $(HTMLDOCS1_BLDDIRS)
  397. -rmdir /Q /S $(HTMLDOCS3_BLDDIRS)
  398. -rmdir /Q /S $(HTMLDOCS5_BLDDIRS)
  399. -rmdir /Q /S $(HTMLDOCS7_BLDDIRS)
  400. {- join("\n\t", map { "-del /Q /F $_" } @PROGRAMS) -}
  401. {- join("\n\t", map { "-del /Q /F $_" } @MODULES) -}
  402. {- join("\n\t", map { "-del /Q /F $_" } @SCRIPTS) -}
  403. {- join("\n\t", map { "-del /Q /F $_" } @GENERATED_MANDATORY) -}
  404. {- join("\n\t", map { "-del /Q /F $_" } @GENERATED) -}
  405. -del /Q /S /F *.d *.obj *.pdb *.ilk *.manifest
  406. -del /Q /S /F engines\*.lib engines\*.exp
  407. -del /Q /S /F apps\*.lib apps\*.rc apps\*.res apps\*.exp
  408. -del /Q /S /F test\*.exp
  409. -rmdir /Q /S test\test-runs
  410. distclean: clean
  411. -del /Q /F configdata.pm
  412. -del /Q /F makefile
  413. depend:
  414. @ {- output_off() if $disabled{makedepend}; "" -}
  415. @ "$(PERL)" "$(SRCDIR)\util\add-depends.pl" "VC"
  416. @ {- output_on() if $disabled{makedepend}; "" -}
  417. # Install helper targets #############################################
  418. install_sw: install_dev install_engines install_modules install_runtime
  419. uninstall_sw: uninstall_runtime uninstall_modules uninstall_engines uninstall_dev
  420. install_docs: install_html_docs
  421. uninstall_docs: uninstall_html_docs
  422. install_fips: install_sw
  423. @$(ECHO) "*** Installing FIPS module configuration"
  424. @$(ECHO) "fipsinstall $(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME).cnf"
  425. @openssl fipsinstall -module $(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME) \
  426. -out $(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME).cnf \
  427. -macopt "key:$(FIPSKEY)"
  428. uninstall_fips: uninstall_sw
  429. @$(ECHO) "*** Uninstalling FIPS module configuration"
  430. @$(ECHO) "$(RM) $(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME).cnf"
  431. @$(RM) $(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME).cnf
  432. install_ssldirs:
  433. @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\certs"
  434. @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\private"
  435. @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\misc"
  436. @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\openssl.cnf" \
  437. "$(OPENSSLDIR)\openssl.cnf.dist"
  438. @IF NOT EXIST "$(OPENSSLDIR)\openssl.cnf" \
  439. "$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\openssl.cnf" \
  440. "$(OPENSSLDIR)\openssl.cnf"
  441. @if not "$(MISC_SCRIPTS)"=="" \
  442. "$(PERL)" "$(SRCDIR)\util\copy.pl" $(MISC_SCRIPTS) \
  443. "$(OPENSSLDIR)\misc"
  444. @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\ct_log_list.cnf" \
  445. "$(OPENSSLDIR)\ct_log_list.cnf.dist"
  446. @IF NOT EXIST "$(OPENSSLDIR)\ct_log_list.cnf" \
  447. "$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\ct_log_list.cnf" \
  448. "$(OPENSSLDIR)\ct_log_list.cnf"
  449. install_dev: install_runtime_libs
  450. @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
  451. @$(ECHO) "*** Installing development files"
  452. @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\include\openssl"
  453. @{- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
  454. @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\ms\applink.c" \
  455. "$(INSTALLTOP)\include\openssl"
  456. @{- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
  457. @"$(PERL)" "$(SRCDIR)\util\copy.pl" "-exclude_re=/__DECC_" \
  458. "$(SRCDIR)\include\openssl\*.h" \
  459. "$(INSTALLTOP)\include\openssl"
  460. @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(BLDDIR)\include\openssl\*.h" \
  461. "$(INSTALLTOP)\include\openssl"
  462. @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(libdir)"
  463. @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_LIBS) "$(libdir)"
  464. @if "$(SHLIBS)"=="" \
  465. "$(PERL)" "$(SRCDIR)\util\copy.pl" ossl_static.pdb "$(libdir)"
  466. uninstall_dev:
  467. _install_modules_deps: install_runtime_libs build_modules
  468. install_engines: _install_modules_deps
  469. @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
  470. @$(ECHO) "*** Installing engines"
  471. @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(ENGINESDIR)"
  472. @if not "$(INSTALL_ENGINES)"=="" \
  473. "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINES) "$(ENGINESDIR)"
  474. @if not "$(INSTALL_ENGINES)"=="" \
  475. "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINEPDBS) "$(ENGINESDIR)"
  476. uninstall_engines:
  477. install_modules: _install_modules_deps
  478. @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
  479. @$(ECHO) "*** Installing modules"
  480. @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(MODULESDIR)"
  481. @if not "$(INSTALL_MODULES)"=="" \
  482. "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_MODULES) "$(MODULESDIR)"
  483. @if not "$(INSTALL_MODULES)"=="" \
  484. "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_MODULEPDBS) "$(MODULESDIR)"
  485. uninstall_modules:
  486. install_runtime: install_programs
  487. install_runtime_libs: build_libs
  488. @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
  489. @$(ECHO) "*** Installing runtime libraries"
  490. @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\bin"
  491. @if not "$(SHLIBS)"=="" \
  492. "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_SHLIBS) "$(INSTALLTOP)\bin"
  493. @if not "$(SHLIBS)"=="" \
  494. "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_SHLIBPDBS) \
  495. "$(INSTALLTOP)\bin"
  496. install_programs: install_runtime_libs build_programs
  497. @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
  498. @$(ECHO) "*** Installing runtime programs"
  499. @if not "$(INSTALL_PROGRAMS)"=="" \
  500. "$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\bin"
  501. @if not "$(INSTALL_PROGRAMS)"=="" \
  502. "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMS) \
  503. "$(INSTALLTOP)\bin"
  504. @if not "$(INSTALL_PROGRAMS)"=="" \
  505. "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMPDBS) \
  506. "$(INSTALLTOP)\bin"
  507. @if not "$(INSTALL_PROGRAMS)"=="" \
  508. "$(PERL)" "$(SRCDIR)\util\copy.pl" $(BIN_SCRIPTS) \
  509. "$(INSTALLTOP)\bin"
  510. uninstall_runtime:
  511. install_html_docs: build_html_docs
  512. @if "$(INSTALLTOP)"=="" ( echo INSTALLTOP should not be empty & exit 1 )
  513. @echo *** Installing HTML docs
  514. @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\html\man1"
  515. @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\html\man3"
  516. @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\html\man5"
  517. @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\html\man7"
  518. @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BLDDIR)\doc\html\man1\*.html \
  519. "$(INSTALLTOP)\html\man1"
  520. @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BLDDIR)\doc\html\man3\*.html \
  521. "$(INSTALLTOP)\html\man3"
  522. @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BLDDIR)\doc\html\man5\*.html \
  523. "$(INSTALLTOP)\html\man5"
  524. @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BLDDIR)\doc\html\man7\*.html \
  525. "$(INSTALLTOP)\html\man7"
  526. uninstall_html_docs:
  527. # Helper targets #####################################################
  528. copy-utils: $(BLDDIR)\util\wrap.pl $(BLDDIR)\apps\openssl.cnf
  529. $(BLDDIR)\util\wrap.pl: configdata.pm
  530. @if NOT EXIST "$(BLDDIR)\util" mkdir "$(BLDDIR)\util"
  531. @if NOT "$(SRCDIR)"=="$(BLDDIR)" copy "$(SRCDIR)\util\$(@F)" "$(BLDDIR)\util"
  532. $(BLDDIR)\apps\openssl.cnf: configdata.pm
  533. @if NOT EXIST "$(BLDDIR)\apps" mkdir "$(BLDDIR)\apps"
  534. @if NOT "$(SRCDIR)"=="$(BLDDIR)" copy "$(SRCDIR)\apps\$(@F)" "$(BLDDIR)\apps"
  535. # Building targets ###################################################
  536. configdata.pm: "$(SRCDIR)\Configure" {- join(" ", map { '"'.$_.'"' } @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
  537. @$(ECHO) "Detected changed: $?"
  538. "$(PERL)" configdata.pm -r
  539. @$(ECHO) "**************************************************"
  540. @$(ECHO) "*** ***"
  541. @$(ECHO) "*** Please run the same make command again ***"
  542. @$(ECHO) "*** ***"
  543. @$(ECHO) "**************************************************"
  544. @exit 1
  545. reconfigure reconf:
  546. "$(PERL)" configdata.pm -r
  547. {-
  548. use File::Basename;
  549. use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs file_name_is_absolute/;
  550. # Helper function to figure out dependencies on libraries
  551. # It takes a list of library names and outputs a list of dependencies
  552. sub compute_lib_depends {
  553. if ($disabled{shared}) {
  554. return map { platform->staticlib($_) } @_;
  555. }
  556. return map { platform->sharedlib_import($_) // platform->staticlib($_) } @_;
  557. }
  558. sub generatetarget {
  559. my %args = @_;
  560. my $deps = join(" ", @{$args{deps}});
  561. return <<"EOF";
  562. $args{target}: $deps
  563. EOF
  564. }
  565. # This function (and the next) avoids quoting paths of generated dependencies
  566. # (in the build tree), but quotes paths of non-generated dependencies (in the
  567. # source tree). This is a workaround for a limitation of C++Builder's make.exe
  568. # in handling quoted paths: https://quality.embarcadero.com/browse/RSP-31756
  569. sub generatesrc {
  570. my %args = @_;
  571. my $gen0 = $args{generator}->[0];
  572. my $gen_args = join('', map { " $_" }
  573. @{$args{generator}}[1..$#{$args{generator}}]);
  574. my $gen_incs = join("", map { " -I\"$_\"" } @{$args{generator_incs}});
  575. my $incs = join("", map { " -I\"$_\"" } @{$args{incs}});
  576. my $defs = join("", map { " -D".$_ } @{$args{defs}});
  577. my $deps = @{$args{deps}} ?
  578. join(' ',
  579. map { file_name_is_absolute($_) || ($_ =~ m|^../|) ? "\"$_\"" : $_ }
  580. (@{$args{generator_deps}}, @{$args{deps}}))
  581. : '';
  582. if ($args{src} =~ /\.html$/) {
  583. #
  584. # HTML generator
  585. #
  586. my $title = basename($args{src}, ".html");
  587. my $pod = $gen0;
  588. return <<"EOF";
  589. $args{src}: "$pod"
  590. \$(PERL) \$(SRCDIR)/util/mkpod2html.pl -i "$pod" -o \$\@ -t "$title" -r "\$(SRCDIR)/doc"
  591. EOF
  592. } elsif (platform->isdef($args{src})) {
  593. #
  594. # Linker script-ish generator
  595. #
  596. my $target = platform->def($args{src});
  597. my $mkdef = abs2rel(rel2abs(catfile($config{sourcedir},
  598. "util", "mkdef.pl")),
  599. rel2abs($config{builddir}));
  600. my $ord_ver = $args{intent} eq 'lib' ? ' --version $(VERSION)' : '';
  601. my $ord_name =
  602. $args{generator}->[1] || platform->dsoname($args{product});
  603. return <<"EOF";
  604. $target: $gen0 $deps $mkdef
  605. "\$(PERL)" $mkdef$ord_ver --ordinals $gen0 --name $ord_name --OS windows > $target
  606. EOF
  607. } elsif (platform->isasm($args{src})) {
  608. #
  609. # Assembler generator
  610. #
  611. my $cppflags = {
  612. shlib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
  613. lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
  614. dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)',
  615. bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
  616. } -> {$args{intent}};
  617. my $target = platform->asm($args{src});
  618. my $generator;
  619. if ($gen0 =~ /\.pl$/) {
  620. $generator = '"$(PERL)"'.$gen_incs.' '.$gen0.$gen_args
  621. .' "$(PERLASM_SCHEME)"'.$incs.' '.$cppflags.$defs.' $(PROCESSSOR)';
  622. } elsif ($gen0 =~ /\.S$/) {
  623. $generator = undef;
  624. } else {
  625. die "Generator type for $src unknown: $gen0\n";
  626. }
  627. if (defined($generator)) {
  628. # If the target is named foo.S in build.info, we want to
  629. # end up generating foo.s in two steps.
  630. if ($args{src} =~ /\.S$/) {
  631. return <<"EOF";
  632. $target: "$gen0" $deps
  633. cmd /C "set "ASM=\$(AS)" & $generator \$@.S"
  634. \$(CPP) $incs $cppflags $defs \$@.S > \$@.i
  635. move /Y \$@.i \$@
  636. del /Q \$@.S
  637. EOF
  638. }
  639. # Otherwise....
  640. return <<"EOF";
  641. $target: "$gen0" $deps
  642. cmd /C "set "ASM=\$(AS)" & $generator \$@"
  643. EOF
  644. }
  645. return <<"EOF";
  646. $target: "$gen0" $deps
  647. \$(CPP) $incs $cppflags $defs "$gen0" > \$@.i
  648. move /Y \$@.i \$@
  649. EOF
  650. } elsif ($gen0 =~ m|^.*\.in$|) {
  651. #
  652. # "dofile" generator (file.in -> file)
  653. #
  654. my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
  655. "util", "dofile.pl")),
  656. rel2abs($config{builddir}));
  657. my @modules = ( 'configdata.pm',
  658. grep { $_ =~ m|\.pm$| } @{$args{deps}} );
  659. my %moduleincs = map { '"-I'.dirname($_).'"' => 1 } @modules;
  660. $deps = join(' ', $deps, @modules);
  661. @modules = map { "-M".basename($_, '.pm') } @modules;
  662. my $modules = join(' ', '', sort keys %moduleincs, @modules);
  663. return <<"EOF";
  664. $args{src}: "$gen0" $deps
  665. "\$(PERL)"$modules "$dofile" "-o$target{build_file}" "$gen0"$gen_args > \$@
  666. EOF
  667. } elsif (grep { $_ eq $gen0 } @{$unified_info{programs}}) {
  668. #
  669. # Generic generator using OpenSSL programs
  670. #
  671. # Redo $deps, because programs aren't expected to have deps of their
  672. # own. This is a little more tricky, though, because running programs
  673. # may have dependencies on all sorts of files, so we search through
  674. # our database of programs and modules to see if our dependencies
  675. # are one of those.
  676. $deps = join(' ', map { my $x = $_;
  677. if (grep { $x eq $_ }
  678. @{$unified_info{programs}}) {
  679. platform->bin($x);
  680. } elsif (grep { $x eq $_ }
  681. @{$unified_info{modules}}) {
  682. platform->dso($x);
  683. } else {
  684. $x;
  685. }
  686. } @{$args{deps}});
  687. # Also redo $gen0, to ensure that we have the proper extension.
  688. $gen0 = platform->bin($gen0);
  689. return <<"EOF";
  690. $args{src}: $gen0 $deps
  691. $gen0$gen_args > \$@
  692. EOF
  693. } else {
  694. #
  695. # Generic generator using Perl
  696. #
  697. return <<"EOF";
  698. $args{src}: "$gen0" $deps
  699. "\$(PERL)"$gen_incs $gen0$gen_args > \$@
  700. EOF
  701. }
  702. }
  703. sub src2obj {
  704. my $asmext = platform->asmext();
  705. my %args = @_;
  706. my @srcs =
  707. map { my $x = $_;
  708. (platform->isasm($x) && grep { $x eq $_ } @generated)
  709. ? platform->asm($x) : $x }
  710. ( @{$args{srcs}} );
  711. my $srcs = '"'.join('" "', @srcs).'"';
  712. my $deps = join(' ',
  713. map { file_name_is_absolute($_) || ($_ =~ m|^../|) ? "\"$_\"" : $_ }
  714. (@srcs, @{$args{deps}}));
  715. my $incs = join("", map { ' -I"'.$_.'"' } @{$args{incs}});
  716. my $defs = join("", map { " -D".$_ } @{$args{defs}});
  717. my $cflags = { shlib => ' $(LIB_CFLAGS)',
  718. lib => ' $(LIB_CFLAGS)',
  719. dso => ' $(DSO_CFLAGS)',
  720. bin => ' $(BIN_CFLAGS)' } -> {$args{intent}};
  721. $cflags .= $incs;
  722. $cflags .= { shlib => ' $(LIB_CPPFLAGS)',
  723. lib => ' $(LIB_CPPFLAGS)',
  724. dso => ' $(DSO_CPPFLAGS)',
  725. bin => ' $(BIN_CPPFLAGS)' } -> {$args{intent}};
  726. my $asflags = { shlib => ' $(LIB_ASFLAGS)',
  727. lib => ' $(LIB_ASFLAGS)',
  728. dso => ' $(DSO_ASFLAGS)',
  729. bin => ' $(BIN_ASFLAGS)' } -> {$args{intent}};
  730. my $makedepprog = $config{makedepprog};
  731. if ($srcs[0] =~ /\.rc$/) {
  732. my $res = platform->res($args{obj});
  733. return <<"EOF";
  734. $res: $deps
  735. \$(RC) \$(RCFLAGS) \$(RCOUTFLAG)\$\@ $srcs
  736. EOF
  737. }
  738. my $obj = platform->obj($args{obj});
  739. my $dep = platform->dep($args{obj});
  740. if ($srcs[0] =~ /\Q${asmext}\E$/) {
  741. return <<"EOF";
  742. $obj: $deps
  743. \$(AS) $asflags \$(ASOUTFLAG)\$\@ $srcs
  744. EOF
  745. } elsif ($srcs[0] =~ /.S$/) {
  746. return <<"EOF";
  747. $obj: $deps
  748. \$(CC) /EP -D__ASSEMBLER__ $cflags $defs $srcs > \$@.asm
  749. \$(AS) $asflags \$(ASOUTFLAG)\$\@ \$@.asm
  750. EOF
  751. }
  752. my $recipe = <<"EOF";
  753. $obj: $deps
  754. \$(CC) $cflags $defs -c \$(COUTFLAG)\$\@ $srcs
  755. EOF
  756. $recipe .= <<"EOF" unless $disabled{makedepend};
  757. \$(CC) $cflags $defs /Zs /showIncludes $srcs 2>&1 > $dep
  758. EOF
  759. return $recipe;
  760. }
  761. # We *know* this routine is only called when we've configure 'shared'.
  762. # Also, note that even though the import library built here looks like
  763. # a static library, it really isn't.
  764. sub obj2shlib {
  765. my %args = @_;
  766. my $lib = $args{lib};
  767. my @objs = map { platform->convertext($_) }
  768. grep { platform->isobj($_) || platform->isres($_) }
  769. @{$args{objs}};
  770. my @defs = map { platform->def($_) }
  771. grep { platform->isdef($_) }
  772. @{$args{objs}};
  773. my @deps = compute_lib_depends(@{$args{deps}});
  774. die "More than one exported symbols list" if scalar @defs > 1;
  775. my $linklibs = join("", map { "$_$target{ld_resp_delim}" } @deps);
  776. my $objs = join($target{ld_resp_delim}, @objs);
  777. my $deps = join(" ", @objs, @defs, @deps);
  778. my $import = platform->sharedlib_import($lib);
  779. my $dll = platform->sharedlib($lib);
  780. my $shared_def = join("", map { " $target{lddefflag}$_" } @defs);
  781. my $implib_rule = $target{ld_implib_rule} || "";
  782. my $implib_flag = $target{ld_implib_flag}
  783. ? "$target{ld_implib_flag}$import"
  784. : "";
  785. return <<"EOF"
  786. # The import library may look like a static library, but it is not.
  787. # We MUST make the import library depend on the DLL, in case someone
  788. # mistakenly removes the latter.
  789. $import: $dll
  790. $implib_rule
  791. $dll: $deps
  792. IF EXIST $full.manifest DEL /F /Q $full.manifest
  793. IF EXIST \$@ DEL /F /Q \$@
  794. \$(LD) \$(LDFLAGS) \$(LIB_LDFLAGS) @<< $implib_flag || (DEL /Q \$(\@B).* $import; EXIT 1)
  795. $objs$target{ld_resp_delim}\$(LDOUTFLAG)$dll$target{ldpostoutflag}$target{ld_resp_delim}$linklibs\$(LIB_EX_LIBS)$shared_def
  796. <<
  797. IF EXIST $dll.manifest \\
  798. \$(MT) \$(MTFLAGS) \$(MTINFLAG)$dll.manifest \$(MTOUTFLAG)$dll
  799. IF EXIST apps\\$dll DEL /Q /F apps\\$dll
  800. IF EXIST test\\$dll DEL /Q /F test\\$dll
  801. IF EXIST fuzz\\$dll DEL /Q /F fuzz\\$dll
  802. COPY $dll apps
  803. COPY $dll test
  804. COPY $dll fuzz
  805. EOF
  806. }
  807. sub obj2dso {
  808. my %args = @_;
  809. my $dso = platform->dso($args{module});
  810. my $dso_n = platform->dsoname($args{module});
  811. my @objs = map { platform->convertext($_) }
  812. grep { platform->isobj($_) || platform->isres($_) }
  813. @{$args{objs}};
  814. my @defs = map { platform->def($_) }
  815. grep { platform->isdef($_) }
  816. @{$args{objs}};
  817. my @deps = compute_lib_depends(@{$args{deps}});
  818. my $objs = join($target{ld_resp_delim}, @objs);
  819. my $linklibs = join("", map { "$_$target{ld_resp_delim}" } @deps);
  820. my $deps = join(" ", @objs, @defs, @deps);
  821. my $shared_def = join("", map { " $target{lddefflag}$_" } @defs);
  822. return <<"EOF";
  823. $dso: $deps
  824. IF EXIST $dso.manifest DEL /F /Q $dso.manifest
  825. \$(LD) \$(LDFLAGS) \$(DSO_LDFLAGS) @<< || (DEL /Q \$(\@B).* $dso_n.*; EXIT 1)
  826. $objs$target{ld_resp_delim}\$(LDOUTFLAG)$dso$target{ldpostoutflag}$target{ld_resp_delim}$linklibs \$(DSO_EX_LIBS)$shared_def
  827. <<
  828. IF EXIST $dso.manifest \\
  829. \$(MT) \$(MTFLAGS) \$(MTINFLAG)$dso.manifest \$(MTOUTFLAG)$dso
  830. EOF
  831. }
  832. sub obj2lib {
  833. my %args = @_;
  834. my $lib = platform->staticlib($args{lib});
  835. my @objs = map { platform->obj($_) } @{$args{objs}};
  836. my $objs = join($target{ar_resp_delim}, @objs);
  837. my $deps = join(" ", @objs);
  838. return <<"EOF";
  839. $lib: $deps
  840. \$(AR) \$(ARFLAGS) \$(AROUTFLAG)$lib @<<
  841. $objs
  842. <<
  843. EOF
  844. }
  845. sub obj2bin {
  846. my %args = @_;
  847. my $bin = platform->bin($args{bin});
  848. my @objs = map { platform->convertext($_) }
  849. grep { platform->isobj($_) || platform->isres($_) }
  850. @{$args{objs}};
  851. my @deps = compute_lib_depends(@{$args{deps}});
  852. my $objs = join($target{ld_resp_delim}, @objs);
  853. my $linklibs = join("", map { "$_$target{ld_resp_delim}" } @deps);
  854. my $deps = join(" ", @objs, @deps);
  855. return <<"EOF";
  856. $bin: $deps
  857. IF EXIST $bin.manifest DEL /F /Q $bin.manifest
  858. \$(LD) \$(LDFLAGS) \$(BIN_LDFLAGS) @<<
  859. $objs$target{ld_resp_delim}\$(LDOUTFLAG)$bin$target{ldpostoutflag}$target{ld_resp_delim}$linklibs\$(BIN_EX_LIBS)
  860. <<
  861. IF EXIST $bin.manifest \\
  862. \$(MT) \$(MTFLAGS) \$(MTINFLAG)$bin.manifest \$(MTOUTFLAG)$bin
  863. EOF
  864. }
  865. sub in2script {
  866. my %args = @_;
  867. my $script = $args{script};
  868. my $sources = '"'.join('" "', @{$args{sources}}).'"';
  869. my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
  870. "util", "dofile.pl")),
  871. rel2abs($config{builddir}));
  872. return <<"EOF";
  873. $script: $sources
  874. "\$(PERL)" "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
  875. "-o$target{build_file}" $sources > \$@
  876. EOF
  877. }
  878. sub generatedir {
  879. my %args = @_;
  880. my $dir = $args{dir};
  881. my @deps = map { platform->convertext($_) } @{$args{deps}};
  882. my @actions = ();
  883. my %extinfo = ( dso => platform->dsoext(),
  884. lib => platform->libext(),
  885. bin => platform->binext() );
  886. # We already have a 'test' target, and the top directory is just plain
  887. # silly
  888. return if $dir eq "test" || $dir eq ".";
  889. foreach my $type (("dso", "lib", "bin", "script")) {
  890. next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type});
  891. # For lib object files, we could update the library. However,
  892. # LIB on Windows doesn't work that way, so we won't create any
  893. # actions for it, and the dependencies are already taken care of.
  894. if ($type ne "lib") {
  895. foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) {
  896. if (dirname($prod) eq $dir) {
  897. push @deps, $prod.$extinfo{$type};
  898. }
  899. }
  900. }
  901. }
  902. my $deps = join(" ", @deps);
  903. my $actions = join("\n", "", @actions);
  904. return <<"EOF";
  905. $dir $dir\\ : $deps$actions
  906. EOF
  907. }
  908. "" # Important! This becomes part of the template result.
  909. -}