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