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