windows-makefile.tmpl 46 KB

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