windows-makefile.tmpl 30 KB

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