windows-makefile.tmpl 46 KB

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