windows-makefile.tmpl 32 KB

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