windows-makefile.tmpl 37 KB

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