windows-makefile.tmpl 30 KB

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