windows-makefile.tmpl 29 KB

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