windows-makefile.tmpl 38 KB

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