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