windows-makefile.tmpl 45 KB

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