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