windows-makefile.tmpl 33 KB

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