windows-makefile.tmpl 31 KB

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