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