windows-makefile.tmpl 37 KB

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