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