windows-makefile.tmpl 30 KB

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