windows-makefile.tmpl 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757
  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" "-exclude_re=/__DECC_" \
  362. "$(SRCDIR)\include\openssl\*.h" \
  363. "$(INSTALLTOP)\include\openssl"
  364. @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BLDDIR)\include\openssl\*.h \
  365. "$(INSTALLTOP)\include\openssl"
  366. @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(libdir)"
  367. @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_LIBS) "$(libdir)"
  368. @if "$(SHLIBS)"=="" \
  369. "$(PERL)" "$(SRCDIR)\util\copy.pl" ossl_static.pdb "$(libdir)"
  370. uninstall_dev:
  371. install_engines:
  372. @if "$(INSTALLTOP)"=="" ( echo INSTALLTOP should not be empty & exit 1 )
  373. @echo *** Installing engines
  374. @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(ENGINESDIR)"
  375. @if not "$(ENGINES)"=="" \
  376. "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINES) "$(ENGINESDIR)"
  377. @if not "$(ENGINES)"=="" \
  378. "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINEPDBS) "$(ENGINESDIR)"
  379. uninstall_engines:
  380. install_runtime:
  381. @if "$(INSTALLTOP)"=="" ( echo INSTALLTOP should not be empty & exit 1 )
  382. @echo *** Installing runtime files
  383. @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\bin"
  384. @if not "$(SHLIBS)"=="" \
  385. "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_SHLIBS) "$(INSTALLTOP)\bin"
  386. @if not "$(SHLIBS)"=="" \
  387. "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_SHLIBPDBS) \
  388. "$(INSTALLTOP)\bin"
  389. @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMS) \
  390. "$(INSTALLTOP)\bin"
  391. @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMPDBS) \
  392. "$(INSTALLTOP)\bin"
  393. @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BIN_SCRIPTS) \
  394. "$(INSTALLTOP)\bin"
  395. uninstall_runtime:
  396. install_html_docs:
  397. "$(PERL)" "$(SRCDIR)\util\process_docs.pl" \
  398. "--destdir=$(INSTALLTOP)\html" --type=html
  399. uninstall_html_docs:
  400. # Building targets ###################################################
  401. configdata.pm: "$(SRCDIR)\Configure" {- join(" ", map { '"'.$_.'"' } @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
  402. @echo "Detected changed: $?"
  403. "$(PERL)" configdata.pm -r
  404. @echo "**************************************************"
  405. @echo "*** ***"
  406. @echo "*** Please run the same make command again ***"
  407. @echo "*** ***"
  408. @echo "**************************************************"
  409. @exit 1
  410. reconfigure reconf:
  411. "$(PERL)" configdata.pm -r
  412. {-
  413. use File::Basename;
  414. use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
  415. # Helper function to figure out dependencies on libraries
  416. # It takes a list of library names and outputs a list of dependencies
  417. sub compute_lib_depends {
  418. if ($disabled{shared}) {
  419. return map { lib($_) } @_;
  420. }
  421. foreach (@_) {
  422. (my $l = $_) =~ s/\.a$//;
  423. die "Linking with static variants of shared libraries is not supported in this configuration\n"
  424. if $l ne $_ && shlib($l);
  425. }
  426. return map { shlib_import($_) or lib($_) } @_;
  427. }
  428. sub generatesrc {
  429. my %args = @_;
  430. (my $target = $args{src}) =~ s/\.[sS]$/.asm/;
  431. my ($gen0, @gens) = @{$args{generator}};
  432. my $generator = '"'.$gen0.'"'.join('', map { " $_" } @gens);
  433. my $generator_incs = join("", map { " -I \"$_\"" } @{$args{generator_incs}});
  434. my $incs = join("", map { " /I \"$_\"" } @{$args{incs}});
  435. my $deps = @{$args{deps}} ?
  436. '"'.join('" "', @{$args{generator_deps}}, @{$args{deps}}).'"' : '';
  437. if ($target !~ /\.asm$/) {
  438. if ($args{generator}->[0] =~ m|^.*\.in$|) {
  439. my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
  440. "util", "dofile.pl")),
  441. rel2abs($config{builddir}));
  442. return <<"EOF";
  443. $target: "$args{generator}->[0]" $deps
  444. "\$(PERL)" "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
  445. "-o$target{build_file}" $generator > \$@
  446. EOF
  447. } else {
  448. return <<"EOF";
  449. $target: "$args{generator}->[0]" $deps
  450. "\$(PERL)"$generator_incs $generator > \$@
  451. EOF
  452. }
  453. } else {
  454. if ($args{generator}->[0] =~ /\.pl$/) {
  455. $generator = '"$(PERL)"'.$generator_incs.' '.$generator;
  456. } elsif ($args{generator}->[0] =~ /\.S$/) {
  457. $generator = undef;
  458. } else {
  459. die "Generator type for $src unknown: $generator\n";
  460. }
  461. my $cppflags = $incs;
  462. $cppflags .= {
  463. lib => ' $(LIB_CFLAGS) $(LIB_CPPFLAGS)',
  464. dso => ' $(DSO_CFLAGS) $(DSO_CPPFLAGS)',
  465. bin => ' $(BIN_CFLAGS) $(BIN_CPPFLAGS)'
  466. } -> {$args{intent}};
  467. if (defined($generator)) {
  468. # If the target is named foo.S in build.info, we want to
  469. # end up generating foo.s in two steps.
  470. if ($args{src} =~ /\.S$/) {
  471. return <<"EOF";
  472. $target: "$args{generator}->[0]" $deps
  473. set ASM=\$(AS)
  474. $generator \$@.S
  475. \$(CPP) $cppflags \$@.S > \$@.i && move /Y \$@.i \$@
  476. del /Q \$@.S
  477. EOF
  478. }
  479. # Otherwise....
  480. return <<"EOF";
  481. $target: "$args{generator}->[0]" $deps
  482. set ASM=\$(AS)
  483. $generator \$@
  484. EOF
  485. }
  486. return <<"EOF";
  487. $target: "$args{generator}->[0]" $deps
  488. \$(CPP) $incs $cppflags "$args{generator}->[0]" > \$@.i && move /Y \$@.i \$@
  489. EOF
  490. }
  491. }
  492. sub src2obj {
  493. my %args = @_;
  494. my @srcs = map { (my $x = $_) =~ s/\.s$/.asm/; $x
  495. } ( @{$args{srcs}} );
  496. my $srcs = '"'.join('" "', @srcs).'"';
  497. my $deps = '"'.join('" "', @srcs, @{$args{deps}}).'"';
  498. my $incs = join("", map { ' /I "'.$_.'"' } @{$args{incs}});
  499. my $cflags = { lib => ' $(LIB_CFLAGS)',
  500. dso => ' $(DSO_CFLAGS)',
  501. bin => ' $(BIN_CFLAGS)' } -> {$args{intent}};
  502. $cflags .= $incs;
  503. $cflags .= { lib => ' $(LIB_CPPFLAGS)',
  504. dso => ' $(DSO_CPPFLAGS)',
  505. bin => ' $(BIN_CPPFLAGS)' } -> {$args{intent}};
  506. my $asflags = { lib => ' $(LIB_ASFLAGS)',
  507. dso => ' $(DSO_ASFLAGS)',
  508. bin => ' $(BIN_ASFLAGS)' } -> {$args{intent}};
  509. my $makedepprog = $config{makedepprog};
  510. if ($srcs[0] =~ /\.rc$/) {
  511. return <<"EOF";
  512. $args{obj}: $deps
  513. \$(RC) \$(RCOUTFLAG)\$\@ $srcs
  514. EOF
  515. }
  516. (my $obj = $args{obj}) =~ s|\.o$||;
  517. if ($srcs[0] =~ /\.asm$/) {
  518. return <<"EOF";
  519. $obj$objext: $deps
  520. \$(AS) $asflags \$(ASOUTFLAG)\$\@ $srcs
  521. EOF
  522. } elsif ($srcs[0] =~ /.S$/) {
  523. return <<"EOF";
  524. $obj$objext: $deps
  525. \$(CC) /EP /D__ASSEMBLER__ $cflags $srcs > \$@.asm && \$(AS) $asflags \$(ASOUTFLAG)\$\@ \$@.asm
  526. EOF
  527. }
  528. return <<"EOF" if (!$disabled{makedepend});
  529. $obj$depext: $deps
  530. \$(CC) $cflags /Zs /showIncludes $srcs 2>&1 > $obj$depext
  531. $obj$objext: $obj$depext
  532. \$(CC) $cflags -c \$(COUTFLAG)\$\@ $srcs
  533. EOF
  534. return <<"EOF" if ($disabled{makedepend});
  535. $obj$objext: $deps
  536. \$(CC) $cflags -c \$(COUTFLAG)\$\@ $srcs
  537. EOF
  538. }
  539. # On Unix, we build shlibs from static libs, so we're ignoring the
  540. # object file array. We *know* this routine is only called when we've
  541. # configure 'shared'.
  542. sub libobj2shlib {
  543. my %args = @_;
  544. my $lib = $args{lib};
  545. my $shlib = $args{shlib};
  546. my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x }
  547. grep { $_ =~ m/\.(?:o|res)$/ }
  548. @{$args{objs}};
  549. my @defs = grep { $_ =~ /\.def$/ } @{$args{objs}};
  550. my @deps = compute_lib_depends(@{$args{deps}});
  551. die "More than one exported symbols list" if scalar @defs > 1;
  552. my $linklibs = join("", map { "$_\n" } @deps);
  553. my $objs = join("\n", @objs);
  554. my $deps = join(" ", @objs, @defs, @deps);
  555. my $target = shlib_import($lib);
  556. my $shared_def = join("", map { " /def:$_" } @defs);
  557. return <<"EOF"
  558. $target: $deps
  559. IF EXIST $shlib$shlibext.manifest DEL /F /Q $shlib$shlibext.manifest
  560. IF EXIST \$@ DEL /F /Q \$@
  561. \$(LD) \$(LDFLAGS) \$(LIB_LDFLAGS) \\
  562. /implib:\$@ \$(LDOUTFLAG)$shlib$shlibext$shared_def @<< || (DEL /Q \$(\@B).* $shlib.* && EXIT 1)
  563. $objs
  564. $linklibs\$(LIB_EX_LIBS)
  565. <<
  566. IF EXIST $shlib$shlibext.manifest \\
  567. \$(MT) \$(MTFLAGS) \$(MTINFLAG)$shlib$shlibext.manifest \$(MTOUTFLAG)$shlib$shlibext
  568. IF EXIST apps\\$shlib$shlibext DEL /Q /F apps\\$shlib$shlibext
  569. IF EXIST test\\$shlib$shlibext DEL /Q /F test\\$shlib$shlibext
  570. IF EXIST fuzz\\$shlib$shlibext DEL /Q /F fuzz\\$shlib$shlibext
  571. COPY $shlib$shlibext apps
  572. COPY $shlib$shlibext test
  573. COPY $shlib$shlibext fuzz
  574. EOF
  575. }
  576. sub obj2dso {
  577. my %args = @_;
  578. my $dso = $args{lib};
  579. my $dso_n = basename($dso);
  580. my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
  581. my @deps = compute_lib_depends(@{$args{deps}});
  582. my $objs = join("\n", @objs);
  583. my $linklibs = join("", map { "$_\n" } @deps);
  584. my $deps = join(" ", @objs, @deps);
  585. return <<"EOF";
  586. $dso$dsoext: $deps
  587. IF EXIST $dso$dsoext.manifest DEL /F /Q $dso$dsoext.manifest
  588. \$(LD) \$(LDFLAGS) \$(DSO_LDFLAGS) \$(LDOUTFLAG)$dso$dsoext /def:<< @<<
  589. LIBRARY $dso_n
  590. EXPORTS
  591. bind_engine @1
  592. v_check @2
  593. <<
  594. $objs
  595. $linklibs \$(DSO_EX_LIBS)
  596. <<
  597. IF EXIST $dso$dsoext.manifest \\
  598. \$(MT) \$(MTFLAGS) \$(MTINFLAG)$dso$dsoext.manifest \$(MTOUTFLAG)$dso$dsoext
  599. EOF
  600. }
  601. sub obj2lib {
  602. my %args = @_;
  603. my $lib = $args{lib};
  604. # Because static libs and import libs are both named the same in native
  605. # Windows, we can't have both. We skip the static lib in that case,
  606. # as the shared libs are what we use anyway.
  607. return "" unless $disabled{"shared"} || $lib =~ /\.a$/;
  608. $lib =~ s/\.a$//;
  609. my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
  610. my $objs = join("\n", @objs);
  611. my $deps = join(" ", @objs);
  612. return <<"EOF";
  613. $lib$libext: $deps
  614. \$(AR) \$(ARFLAGS) \$(AROUTFLAG)$lib$libext @<<
  615. $objs
  616. <<
  617. EOF
  618. }
  619. sub obj2bin {
  620. my %args = @_;
  621. my $bin = $args{bin};
  622. my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
  623. my @deps = compute_lib_depends(@{$args{deps}});
  624. my $objs = join("\n", @objs);
  625. my $linklibs = join("", map { "$_\n" } @deps);
  626. my $deps = join(" ", @objs, @deps);
  627. return <<"EOF";
  628. $bin$exeext: $deps
  629. IF EXIST $bin$exeext.manifest DEL /F /Q $bin$exeext.manifest
  630. \$(LD) \$(LDFLAGS) \$(BIN_LDFLAGS) \$(LDOUTFLAG)$bin$exeext @<<
  631. $objs
  632. setargv.obj
  633. $linklibs\$(BIN_EX_LIBS)
  634. <<
  635. IF EXIST $bin$exeext.manifest \\
  636. \$(MT) \$(MTFLAGS) \$(MTINFLAG)$bin$exeext.manifest \$(MTOUTFLAG)$bin$exeext
  637. EOF
  638. }
  639. sub in2script {
  640. my %args = @_;
  641. my $script = $args{script};
  642. my $sources = '"'.join('" "', @{$args{sources}}).'"';
  643. my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
  644. "util", "dofile.pl")),
  645. rel2abs($config{builddir}));
  646. return <<"EOF";
  647. $script: $sources
  648. "\$(PERL)" "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
  649. "-o$target{build_file}" $sources > "$script"
  650. EOF
  651. }
  652. sub generatedir {
  653. my %args = @_;
  654. my $dir = $args{dir};
  655. my @deps = map { s|\.o$|$objext|; $_ } @{$args{deps}};
  656. my @actions = ();
  657. my %extinfo = ( dso => $dsoext,
  658. lib => $libext,
  659. bin => $exeext );
  660. foreach my $type (("dso", "lib", "bin", "script")) {
  661. next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type});
  662. # For lib object files, we could update the library. However,
  663. # LIB on Windows doesn't work that way, so we won't create any
  664. # actions for it, and the dependencies are already taken care of.
  665. if ($type ne "lib") {
  666. foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) {
  667. if (dirname($prod) eq $dir) {
  668. push @deps, $prod.$extinfo{$type};
  669. } else {
  670. push @actions, "\t@rem No support to produce $type ".join(", ", @{$unified_info{dirinfo}->{$dir}->{products}->{$type}});
  671. }
  672. }
  673. }
  674. }
  675. my $deps = join(" ", @deps);
  676. my $actions = join("\n", "", @actions);
  677. return <<"EOF";
  678. $args{dir} $args{dir}\\ : $deps$actions
  679. EOF
  680. }
  681. "" # Important! This becomes part of the template result.
  682. -}