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