2
0

windows-makefile.tmpl 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091
  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. $(MAKE) /$(MAKEFLAGS) run_tests
  412. run_tests:
  413. @{- output_off() if $disabled{tests}; "\@rem" -}
  414. cmd /C "set "SRCTOP=$(SRCDIR)" & set "BLDTOP=$(BLDDIR)" & set "PERL=$(PERL)" & set "FIPSKEY=$(FIPSKEY)" & "$(PERL)" "$(SRCDIR)\test\run_tests.pl" $(TESTS)"
  415. @{- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
  416. @$(ECHO) "Tests are not supported with your chosen Configure options"
  417. @{- output_on() if !$disabled{tests}; "\@rem" -}
  418. list-tests:
  419. @{- output_off() if $disabled{tests}; "\@rem" -}
  420. @cmd /C "set "SRCTOP=$(SRCDIR)" & "$(PERL)" "$(SRCDIR)\test\run_tests.pl" list"
  421. @{- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
  422. @$(ECHO) "Tests are not supported with your chosen Configure options"
  423. @{- output_on() if !$disabled{tests}; "\@rem" -}
  424. install: install_sw install_ssldirs {- "install_docs" if !$disabled{docs}; -} {- $disabled{fips} ? "" : "install_fips" -}
  425. uninstall: {- "uninstall_docs" if !$disabled{docs}; -} uninstall_sw {- $disabled{fips} ? "" : "uninstall_fips" -}
  426. libclean:
  427. "$(PERL)" -e "map { m/(.*)\.dll$$/; unlink glob """{.,apps,test,fuzz}/$$1.*"""; } @ARGV" $(SHLIBS)
  428. -del /Q /F $(LIBS) libcrypto.* libssl.* ossl_static.pdb
  429. clean: libclean
  430. {- join("\n\t", map { "-del /Q /F $_" } @HTMLDOCS1) || "\@rem" -}
  431. {- join("\n\t", map { "-del /Q /F $_" } @HTMLDOCS3) || "\@rem" -}
  432. {- join("\n\t", map { "-del /Q /F $_" } @HTMLDOCS5) || "\@rem" -}
  433. {- join("\n\t", map { "-del /Q /F $_" } @HTMLDOCS7) || "\@rem" -}
  434. {- join("\n\t", map { "-del /Q /F $_" } @PROGRAMS) || "\@rem" -}
  435. {- join("\n\t", map { "-del /Q /F $_" } @MODULES) || "\@rem" -}
  436. {- join("\n\t", map { "-del /Q /F $_" } @SCRIPTS) || "\@rem" -}
  437. {- join("\n\t", map { "-del /Q /F $_" } @GENERATED_MANDATORY) || "\@rem" -}
  438. {- join("\n\t", map { "-del /Q /F $_" } @GENERATED) || "\@rem" -}
  439. -del /Q /S /F *.d *.obj *.pdb *.ilk *.manifest
  440. -del /Q /S /F engines\*.lib engines\*.exp
  441. -del /Q /S /F apps\*.lib apps\*.rc apps\*.res apps\*.exp
  442. -del /Q /S /F test\*.exp
  443. -rd /Q /S test\test-runs
  444. distclean: clean
  445. -del /Q /F include\openssl\configuration.h
  446. -del /Q /F configdata.pm
  447. -del /Q /F makefile
  448. depend: makefile
  449. @ {- output_off() if $disabled{makedepend}; "\@rem" -}
  450. @ "$(PERL)" "$(SRCDIR)\util\add-depends.pl" "{- $target{makedep_scheme} -}"
  451. @ {- output_on() if $disabled{makedepend}; "\@rem" -}
  452. # Install helper targets #############################################
  453. install_sw: install_dev install_engines install_modules install_runtime
  454. uninstall_sw: uninstall_runtime uninstall_modules uninstall_engines uninstall_dev
  455. install_docs: install_html_docs
  456. uninstall_docs: uninstall_html_docs
  457. {- output_off() if $disabled{fips}; "" -}
  458. install_fips: build_sw $(INSTALL_FIPSMODULECONF)
  459. # @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
  460. @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(MODULESDIR)"
  461. @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)"
  462. @$(ECHO) "*** Installing FIPS module"
  463. @$(ECHO) "install $(INSTALL_FIPSMODULE) -> $(MODULESDIR)\$(FIPSMODULENAME)"
  464. @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(INSTALL_FIPSMODULE)" "$(MODULESDIR)"
  465. @$(ECHO) "*** Installing FIPS module configuration"
  466. @$(ECHO) "install $(INSTALL_FIPSMODULECONF) -> $(OPENSSLDIR)\fipsmodule.cnf"
  467. @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(INSTALL_FIPSMODULECONF)" "$(OPENSSLDIR)"
  468. uninstall_fips:
  469. @$(ECHO) "*** Uninstalling FIPS module configuration"
  470. $(RM) "$(OPENSSLDIR)\fipsmodule.cnf"
  471. @$(ECHO) "*** Uninstalling FIPS module"
  472. $(RM) "$(MODULESDIR)\$(FIPSMODULENAME)"
  473. {- if ($disabled{fips}) { output_on(); } else { output_off(); } "" -}
  474. install_fips:
  475. @$(ECHO) "The 'install_fips' target requires the 'enable-fips' option"
  476. uninstall_fips:
  477. @$(ECHO) "The 'uninstall_fips' target requires the 'enable-fips' option"
  478. {- output_on() if !$disabled{fips}; "" -}
  479. install_ssldirs:
  480. @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\certs"
  481. @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\private"
  482. @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\misc"
  483. @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\openssl.cnf" \
  484. "$(OPENSSLDIR)\openssl.cnf.dist"
  485. @IF NOT EXIST "$(OPENSSLDIR)\openssl.cnf" \
  486. "$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\openssl.cnf" \
  487. "$(OPENSSLDIR)\openssl.cnf"
  488. @if not "$(MISC_SCRIPTS)"=="" \
  489. "$(PERL)" "$(SRCDIR)\util\copy.pl" $(MISC_SCRIPTS) \
  490. "$(OPENSSLDIR)\misc"
  491. @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\ct_log_list.cnf" \
  492. "$(OPENSSLDIR)\ct_log_list.cnf.dist"
  493. @IF NOT EXIST "$(OPENSSLDIR)\ct_log_list.cnf" \
  494. "$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\ct_log_list.cnf" \
  495. "$(OPENSSLDIR)\ct_log_list.cnf"
  496. install_dev: install_runtime_libs
  497. @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
  498. @$(ECHO) "*** Installing development files"
  499. @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\include\openssl"
  500. @{- output_off() if $disabled{uplink}; "" -}
  501. @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\ms\applink.c" \
  502. "$(INSTALLTOP)\include\openssl"
  503. @{- output_on() if $disabled{uplink}; "" -}
  504. @"$(PERL)" "$(SRCDIR)\util\copy.pl" "-exclude_re=/__DECC_" \
  505. "$(SRCDIR)\include\openssl\*.h" \
  506. "$(INSTALLTOP)\include\openssl"
  507. @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(BLDDIR)\include\openssl\*.h" \
  508. "$(INSTALLTOP)\include\openssl"
  509. @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(libdir)"
  510. @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_LIBS) "$(libdir)"
  511. @if "$(SHLIBS)"=="" \
  512. "$(PERL)" "$(SRCDIR)\util\copy.pl" ossl_static.pdb "$(libdir)"
  513. @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(CMAKECONFIGDIR)"
  514. @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_EXPORTERS_CMAKE) "$(CMAKECONFIGDIR)"
  515. uninstall_dev:
  516. _install_modules_deps: install_runtime_libs build_modules
  517. install_engines: _install_modules_deps
  518. @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
  519. @$(ECHO) "*** Installing engines"
  520. @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(ENGINESDIR)"
  521. @if not "$(INSTALL_ENGINES)"=="" \
  522. "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINES) "$(ENGINESDIR)"
  523. @if not "$(INSTALL_ENGINES)"=="" \
  524. "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINEPDBS) "$(ENGINESDIR)"
  525. uninstall_engines:
  526. install_modules: _install_modules_deps
  527. @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
  528. @$(ECHO) "*** Installing modules"
  529. @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(MODULESDIR)"
  530. @if not "$(INSTALL_MODULES)"=="" \
  531. "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_MODULES) "$(MODULESDIR)"
  532. @if not "$(INSTALL_MODULES)"=="" \
  533. "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_MODULEPDBS) "$(MODULESDIR)"
  534. uninstall_modules:
  535. install_runtime: install_programs
  536. install_runtime_libs: build_libs
  537. @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
  538. @$(ECHO) "*** Installing runtime libraries"
  539. @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\bin"
  540. @if not "$(SHLIBS)"=="" \
  541. "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_SHLIBS) "$(INSTALLTOP)\bin"
  542. @if not "$(SHLIBS)"=="" \
  543. "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_SHLIBPDBS) \
  544. "$(INSTALLTOP)\bin"
  545. install_programs: install_runtime_libs build_programs
  546. @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
  547. @$(ECHO) "*** Installing runtime programs"
  548. @if not "$(INSTALL_PROGRAMS)"=="" \
  549. "$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\bin"
  550. @if not "$(INSTALL_PROGRAMS)"=="" \
  551. "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMS) \
  552. "$(INSTALLTOP)\bin"
  553. @if not "$(INSTALL_PROGRAMS)"=="" \
  554. "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMPDBS) \
  555. "$(INSTALLTOP)\bin"
  556. @if not "$(INSTALL_PROGRAMS)"=="" \
  557. "$(PERL)" "$(SRCDIR)\util\copy.pl" $(BIN_SCRIPTS) \
  558. "$(INSTALLTOP)\bin"
  559. uninstall_runtime:
  560. install_html_docs: install_image_docs build_html_docs
  561. @if "$(INSTALLTOP)"=="" ( echo INSTALLTOP should not be empty & exit 1 )
  562. @echo *** Installing HTML docs
  563. @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\html\man1"
  564. @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\html\man3"
  565. @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\html\man5"
  566. @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\html\man7"
  567. @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BLDDIR)\doc\html\man1\*.html \
  568. "$(INSTALLTOP)\html\man1"
  569. @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BLDDIR)\doc\html\man3\*.html \
  570. "$(INSTALLTOP)\html\man3"
  571. @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BLDDIR)\doc\html\man5\*.html \
  572. "$(INSTALLTOP)\html\man5"
  573. @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BLDDIR)\doc\html\man7\*.html \
  574. "$(INSTALLTOP)\html\man7"
  575. uninstall_html_docs: uninstall_image_docs
  576. install_image_docs:
  577. @if "$(INSTALLTOP)"=="" ( echo INSTALLTOP should not be empty & exit 1 )
  578. @echo *** Installing HTML images
  579. @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\html\man7\img"
  580. @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(SRCDIR)\doc\man7\img\*.png \
  581. "$(INSTALLTOP)\html\man7\img"
  582. uninstall_image_docs:
  583. # Helper targets #####################################################
  584. copy-utils: $(BLDDIR)\apps\openssl.cnf
  585. $(BLDDIR)\apps\openssl.cnf: makefile
  586. @if NOT EXIST "$(BLDDIR)\apps" mkdir "$(BLDDIR)\apps"
  587. @if NOT "$(SRCDIR)"=="$(BLDDIR)" copy "$(SRCDIR)\apps\$(@F)" "$(BLDDIR)\apps"
  588. # Building targets ###################################################
  589. makefile: configdata.pm {- join(" ", map { '"'.$_.'"' } @{$config{build_file_templates}}) -}
  590. @$(ECHO) "Detected changed: $?"
  591. "$(PERL)" configdata.pm
  592. @$(ECHO) "**************************************************"
  593. @$(ECHO) "*** ***"
  594. @$(ECHO) "*** Please run the same make command again ***"
  595. @$(ECHO) "*** ***"
  596. @$(ECHO) "**************************************************"
  597. @exit 1
  598. configdata.pm: "$(SRCDIR)\Configure" {- join(" ", map { '"'.$_.'"' } @{$config{build_infos}}, @{$config{conf_files}}) -}
  599. @$(ECHO) "Detected changed: $?"
  600. "$(PERL)" configdata.pm -r
  601. @$(ECHO) "**************************************************"
  602. @$(ECHO) "*** ***"
  603. @$(ECHO) "*** Please run the same make command again ***"
  604. @$(ECHO) "*** ***"
  605. @$(ECHO) "**************************************************"
  606. @exit 1
  607. reconfigure reconf:
  608. "$(PERL)" configdata.pm -r
  609. {-
  610. use File::Basename;
  611. use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs file_name_is_absolute/;
  612. # Helper function to convert dependencies in platform agnostic form to
  613. # dependencies in platform form.
  614. sub compute_platform_depends {
  615. map { my $x = $_;
  616. grep { $x eq $_ } @{$unified_info{programs}} and platform->bin($x)
  617. or grep { $x eq $_ } @{$unified_info{modules}} and platform->dso($x)
  618. or grep { $x eq $_ } @{$unified_info{libraries}} and platform->lib($x)
  619. or platform->convertext($x); } @_;
  620. }
  621. # Helper function to figure out dependencies on libraries
  622. # It takes a list of library names and outputs a list of dependencies
  623. sub compute_lib_depends {
  624. if ($disabled{shared}) {
  625. return map { platform->staticlib($_) } @_;
  626. }
  627. return map { platform->sharedlib_import($_) // platform->staticlib($_) } @_;
  628. }
  629. sub generatetarget {
  630. my %args = @_;
  631. my $deps = join(" ", compute_platform_depends(@{$args{deps}}));
  632. return <<"EOF";
  633. $args{target}: $deps
  634. EOF
  635. }
  636. # This function (and the next) avoids quoting paths of generated dependencies
  637. # (in the build tree), but quotes paths of non-generated dependencies (in the
  638. # source tree). This is a workaround for a limitation of C++Builder's make.exe
  639. # in handling quoted paths: https://quality.embarcadero.com/browse/RSP-31756
  640. sub generatesrc {
  641. my %args = @_;
  642. my $gen0 = $args{generator}->[0];
  643. my $gen_args = join('', map { " $_" }
  644. @{$args{generator}}[1..$#{$args{generator}}]);
  645. my $gen_incs = join("", map { " -I\"$_\"" } @{$args{generator_incs}});
  646. my $incs = join("", map { " -I\"$_\"" } @{$args{incs}});
  647. my $defs = join("", map { " -D".$_ } @{$args{defs}});
  648. my $deps = join(' ',
  649. map { file_name_is_absolute($_) || ($_ =~ m|^../|) ? "\"$_\"" : $_ }
  650. compute_platform_depends(@{$args{generator_deps}},
  651. @{$args{deps}}));
  652. if ($args{src} =~ /\.html$/) {
  653. #
  654. # HTML generator
  655. #
  656. my $title = basename($args{src}, ".html");
  657. my $pod = $gen0;
  658. return <<"EOF";
  659. $args{src}: "$pod"
  660. "\$(PERL)" "\$(SRCDIR)/util/mkpod2html.pl" -i "$pod" -o \$\@ -t "$title" -r "\$(SRCDIR)/doc"
  661. EOF
  662. } elsif (platform->isdef($args{src})) {
  663. #
  664. # Linker script-ish generator
  665. #
  666. my $target = platform->def($args{src});
  667. my $mkdef = abs2rel(rel2abs(catfile($config{sourcedir},
  668. "util", "mkdef.pl")),
  669. rel2abs($config{builddir}));
  670. my $ord_ver = $args{intent} eq 'lib' ? ' --version $(VERSION_NUMBER)' : '';
  671. my $ord_name =
  672. $args{generator}->[1] || basename(platform->dsoname($args{product}));
  673. return <<"EOF";
  674. $target: $gen0 $deps $mkdef
  675. "\$(PERL)" "$mkdef"$ord_ver --type $args{intent} --ordinals $gen0 --name $ord_name --OS windows > $target
  676. EOF
  677. } elsif (platform->isasm($args{src})
  678. || platform->iscppasm($args{src})) {
  679. #
  680. # Assembler generator
  681. #
  682. my $cppflags = {
  683. shlib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
  684. lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
  685. dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)',
  686. bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
  687. } -> {$args{intent}};
  688. my $target = platform->isasm($args{src})
  689. ? platform->asm($args{src})
  690. : $args{src};
  691. my $generator;
  692. if ($gen0 =~ /\.pl$/) {
  693. $generator = '"$(PERL)"'.$gen_incs.' "'.$gen0.'"'.$gen_args
  694. .' "$(PERLASM_SCHEME)"'.$incs.' '.$cppflags.$defs.' $(PROCESSOR)';
  695. } elsif ($gen0 =~ /\.S$/) {
  696. $generator = undef;
  697. } else {
  698. die "Generator type for $src unknown: $gen0\n";
  699. }
  700. if (defined($generator)) {
  701. return <<"EOF";
  702. $target: "$gen0" $deps
  703. cmd /C "set "ASM=\$(AS)" & $generator \$@"
  704. EOF
  705. }
  706. return <<"EOF";
  707. $target: "$gen0" $deps
  708. \$(CPP) /D__ASSEMBLER__ $incs $cppflags $defs "$gen0" > \$@.i
  709. move /Y \$@.i \$@
  710. EOF
  711. } elsif ($gen0 =~ m|^.*\.in$|) {
  712. #
  713. # "dofile" generator (file.in -> file)
  714. #
  715. my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
  716. "util", "dofile.pl")),
  717. rel2abs($config{builddir}));
  718. my @perlmodules = ();
  719. my %perlmoduleincs = ();
  720. my %perlmoduledeps = ();
  721. foreach my $x (('configdata.pm', @{$args{deps}})) {
  722. # Compute (i)nclusion directory, (m)odule name and (d)ependency
  723. my $i, $m, $d;
  724. if ($x =~ /\|/) {
  725. $i = $`;
  726. $d = $';
  727. # Massage the module part to become a real perl module spec
  728. $m = $d;
  729. $m =~ s|\.pm$||;
  730. # Directory specs are :: in perl package names
  731. $m =~ s|/|::|g;
  732. # Full file name of the dependency
  733. $d = catfile($i, $d) if $i;
  734. } elsif ($x =~ /\.pm$/) {
  735. $i = dirname($x);
  736. $m = basename($x, '.pm');
  737. $d = $x;
  738. } else {
  739. # All other dependencies are simply collected
  740. $d = $x;
  741. }
  742. push @perlmodules, '"-M'.$m.'"' if $m;
  743. $perlmoduledeps{$d} = 1;
  744. $perlmoduleincs{'"-I'.$i.'"'} = 1 if $i;
  745. }
  746. # Because of the special treatment of dependencies, we need to
  747. # recompute $deps completely
  748. my $deps
  749. = join(" ", compute_platform_depends(@{$args{generator_deps}},
  750. sort keys %perlmoduledeps));
  751. my $perlmodules = join(' ', '', ( sort keys %perlmoduleincs ), @perlmodules);
  752. return <<"EOF";
  753. $args{src}: "$gen0" $deps
  754. "\$(PERL)"$perlmodules "$dofile" "-o$target{build_file}" "$gen0"$gen_args > \$@
  755. EOF
  756. } elsif (grep { $_ eq $gen0 } @{$unified_info{programs}}) {
  757. #
  758. # Generic generator using OpenSSL programs
  759. #
  760. # Redo $gen0, to ensure that we have the proper extension.
  761. $gen0 = platform->bin($gen0);
  762. return <<"EOF";
  763. $args{src}: $gen0 $deps "\$(BLDDIR)\\util\\wrap.pl"
  764. "\$(PERL)" "\$(BLDDIR)\\util\\wrap.pl" "$gen0"$gen_args > \$@
  765. EOF
  766. } else {
  767. #
  768. # Generic generator using Perl
  769. #
  770. return <<"EOF";
  771. $args{src}: "$gen0" $deps
  772. "\$(PERL)"$gen_incs "$gen0"$gen_args > \$@
  773. EOF
  774. }
  775. }
  776. sub src2obj {
  777. my $asmext = platform->asmext();
  778. my %args = @_;
  779. my @srcs =
  780. map { my $x = $_;
  781. (platform->isasm($x) && grep { $x eq $_ } @generated)
  782. ? platform->asm($x) : $x }
  783. ( @{$args{srcs}} );
  784. my $srcs = '"'.join('" "', @srcs).'"';
  785. my $deps = join(' ',
  786. map { file_name_is_absolute($_) || ($_ =~ m|^../|) ? "\"$_\"" : $_ }
  787. (@srcs, @{$args{deps}}));
  788. my $incs = join("", map { ' -I"'.$_.'"' } @{$args{incs}});
  789. my $defs = join("", map { " -D".$_ } @{$args{defs}});
  790. my $cflags = { shlib => ' $(LIB_CFLAGS)',
  791. lib => ' $(LIB_CFLAGS)',
  792. dso => ' $(DSO_CFLAGS)',
  793. bin => ' $(BIN_CFLAGS)' } -> {$args{intent}};
  794. $cflags .= $incs;
  795. $cflags .= { shlib => ' $(LIB_CPPFLAGS)',
  796. lib => ' $(LIB_CPPFLAGS)',
  797. dso => ' $(DSO_CPPFLAGS)',
  798. bin => ' $(BIN_CPPFLAGS)' } -> {$args{intent}};
  799. my $asflags = { shlib => ' $(LIB_ASFLAGS)',
  800. lib => ' $(LIB_ASFLAGS)',
  801. dso => ' $(DSO_ASFLAGS)',
  802. bin => ' $(BIN_ASFLAGS)' } -> {$args{intent}};
  803. my $makedepcmd = $config{makedepcmd} unless $disabled{makedepend};
  804. if ($srcs[0] =~ /\.rc$/) {
  805. my $res = platform->res($args{obj});
  806. return <<"EOF";
  807. $res: $deps
  808. \$(RC) \$(RCFLAGS) \$(RCOUTFLAG)\$\@ $srcs
  809. EOF
  810. }
  811. my $obj = platform->obj($args{obj});
  812. my $dep = platform->dep($args{obj});
  813. if ($srcs[0] =~ /\Q${asmext}\E$/) {
  814. return <<"EOF";
  815. $obj: $deps
  816. \$(AS) $asflags \$(ASOUTFLAG)\$\@ $srcs
  817. EOF
  818. } elsif ($srcs[0] =~ /.S$/) {
  819. return <<"EOF";
  820. $obj: $deps
  821. \$(CC) /EP -D__ASSEMBLER__ $cflags $defs $srcs > \$@.asm
  822. \$(AS) $asflags \$(ASOUTFLAG)\$\@ \$@.asm
  823. EOF
  824. }
  825. my $recipe = <<"EOF";
  826. $obj: $deps
  827. \$(CC) $cflags $defs -c \$(COUTFLAG)\$\@ $srcs
  828. EOF
  829. $recipe .= <<"EOF" unless $disabled{makedepend};
  830. cmd /C "$makedepcmd $cflags $defs $srcs > $dep 2>&1"
  831. EOF
  832. return $recipe;
  833. }
  834. # We *know* this routine is only called when we've configure 'shared'.
  835. # Also, note that even though the import library built here looks like
  836. # a static library, it really isn't.
  837. sub obj2shlib {
  838. my %args = @_;
  839. my $lib = $args{lib};
  840. my @objs = map { platform->convertext($_) }
  841. grep { platform->isobj($_) }
  842. @{$args{objs}};
  843. my @ress = map { platform->convertext($_) }
  844. grep { platform->isres($_) }
  845. @{$args{objs}};
  846. my @defs = map { platform->def($_) }
  847. grep { platform->isdef($_) }
  848. @{$args{objs}};
  849. my @deps = compute_lib_depends(@{$args{deps}});
  850. die "More than one exported symbols list" if scalar @defs > 1;
  851. my $linklibs = join("", map { "$_$target{ld_resp_delim}" } @deps);
  852. my $objs = join($target{ld_resp_delim}, @objs);
  853. my $ress = join($target{ld_resp_delim}, @ress);
  854. my $deps = join(" ", @objs, @ress, @defs, @deps);
  855. my $import = platform->sharedlib_import($lib);
  856. my $dll = platform->sharedlib($lib);
  857. my $shared_def = $target{lddefflag} . join("", @defs);
  858. my $implib_rule = $target{ld_implib_rule} || "";
  859. my $implib_flag = $target{ld_implib_flag}
  860. ? "$target{ld_implib_flag}$import"
  861. : "";
  862. return <<"EOF"
  863. # The import library may look like a static library, but it is not.
  864. # We MUST make the import library depend on the DLL, in case someone
  865. # mistakenly removes the latter.
  866. $import: $dll
  867. $implib_rule
  868. $dll: $deps
  869. IF EXIST $full.manifest DEL /F /Q $full.manifest
  870. IF EXIST \$@ DEL /F /Q \$@
  871. cmd /C "\$(LD) \$(LDFLAGS) \$(LIB_LDFLAGS) @<< $implib_flag || (DEL /Q \$(\@B).* $import & EXIT 1)"
  872. $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
  873. <<
  874. IF EXIST $dll.manifest \\
  875. \$(MT) \$(MTFLAGS) \$(MTINFLAG)$dll.manifest \$(MTOUTFLAG)$dll
  876. IF EXIST apps\\$dll DEL /Q /F apps\\$dll
  877. IF EXIST test\\$dll DEL /Q /F test\\$dll
  878. IF EXIST fuzz\\$dll DEL /Q /F fuzz\\$dll
  879. COPY $dll apps
  880. COPY $dll test
  881. COPY $dll fuzz
  882. EOF
  883. }
  884. sub obj2dso {
  885. my %args = @_;
  886. my $dso = platform->dso($args{module});
  887. my $dso_n = platform->dsoname($args{module});
  888. my @objs = map { platform->convertext($_) }
  889. grep { platform->isobj($_) }
  890. @{$args{objs}};
  891. my @ress = map { platform->convertext($_) }
  892. grep { platform->isres($_) }
  893. @{$args{objs}};
  894. my @defs = map { platform->def($_) }
  895. grep { platform->isdef($_) }
  896. @{$args{objs}};
  897. my @deps = compute_lib_depends(@{$args{deps}});
  898. die "More than one exported symbols list" if scalar @defs > 1;
  899. my $objs = join($target{ld_resp_delim}, @objs);
  900. my $ress = join($target{ld_resp_delim}, @ress);
  901. my $linklibs = join("", map { "$_$target{ld_resp_delim}" } @deps);
  902. my $deps = join(" ", @objs, @ress, @defs, @deps);
  903. my $shared_def = $target{lddefflag} . join("", @defs);
  904. return <<"EOF";
  905. $dso: $deps
  906. IF EXIST $dso.manifest DEL /F /Q $dso.manifest
  907. cmd /C "\$(LD) \$(LDFLAGS) \$(DSO_LDFLAGS) @<< || (DEL /Q \$(\@B).* $dso_n.* & EXIT 1)"
  908. $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
  909. <<
  910. IF EXIST $dso.manifest \\
  911. \$(MT) \$(MTFLAGS) \$(MTINFLAG)$dso.manifest \$(MTOUTFLAG)$dso
  912. EOF
  913. }
  914. sub obj2lib {
  915. my %args = @_;
  916. my $lib = platform->staticlib($args{lib});
  917. my @objs = map { platform->obj($_) } @{$args{objs}};
  918. my $objs = join($target{ar_resp_delim}, @objs);
  919. my $deps = join(" ", @objs);
  920. return <<"EOF";
  921. $lib: $deps
  922. \$(AR) \$(ARFLAGS) \$(AROUTFLAG)$lib @<<
  923. $objs
  924. <<
  925. EOF
  926. }
  927. sub obj2bin {
  928. my %args = @_;
  929. my $bin = platform->bin($args{bin});
  930. my @objs = map { platform->convertext($_) }
  931. grep { platform->isobj($_) }
  932. @{$args{objs}};
  933. my @ress = map { platform->convertext($_) }
  934. grep { platform->isres($_) }
  935. @{$args{objs}};
  936. my @deps = compute_lib_depends(@{$args{deps}});
  937. my $objs = join($target{ld_resp_delim}, @objs);
  938. my $ress = join($target{ld_resp_delim}, @ress);
  939. my $linklibs = join("", map { "$_$target{ld_resp_delim}" } @deps);
  940. my $deps = join(" ", @objs, @ress, @deps);
  941. return <<"EOF";
  942. $bin: $deps
  943. IF EXIST $bin.manifest DEL /F /Q $bin.manifest
  944. \$(LD) \$(LDFLAGS) \$(BIN_LDFLAGS) @<<
  945. $objs$target{ld_resp_delim}\$(LDOUTFLAG)$bin$target{ldpostoutflag}$target{ld_resp_delim}$linklibs\$(BIN_EX_LIBS)$target{ldresflag}$target{ldresflag}$ress
  946. <<
  947. IF EXIST $bin.manifest \\
  948. \$(MT) \$(MTFLAGS) \$(MTINFLAG)$bin.manifest \$(MTOUTFLAG)$bin
  949. EOF
  950. }
  951. sub in2script {
  952. my %args = @_;
  953. my $script = $args{script};
  954. my $sources = '"'.join('" "', @{$args{sources}}).'"';
  955. my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
  956. "util", "dofile.pl")),
  957. rel2abs($config{builddir}));
  958. return <<"EOF";
  959. $script: $sources configdata.pm
  960. "\$(PERL)" "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
  961. "-o$target{build_file}" $sources > \$@
  962. EOF
  963. }
  964. sub generatedir {
  965. my %args = @_;
  966. my $dir = $args{dir};
  967. my @deps = map { platform->convertext($_) } @{$args{deps}};
  968. my @actions = ();
  969. my %extinfo = ( dso => platform->dsoext(),
  970. lib => platform->libext(),
  971. bin => platform->binext() );
  972. # We already have a 'test' target, and the top directory is just plain
  973. # silly
  974. return if $dir eq "test" || $dir eq ".";
  975. foreach my $type (("dso", "lib", "bin", "script")) {
  976. next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type});
  977. # For lib object files, we could update the library. However,
  978. # LIB on Windows doesn't work that way, so we won't create any
  979. # actions for it, and the dependencies are already taken care of.
  980. if ($type ne "lib") {
  981. foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) {
  982. if (dirname($prod) eq $dir) {
  983. push @deps, $prod.$extinfo{$type};
  984. }
  985. }
  986. }
  987. }
  988. my $deps = join(" ", @deps);
  989. my $actions = join("\n", "", @actions);
  990. return <<"EOF";
  991. $dir $dir\\ : $deps$actions
  992. EOF
  993. }
  994. "" # Important! This becomes part of the template result.
  995. -}