Avoid duplicate default CApath lookups
[openssl.git] / Configurations / windows-makefile.tmpl
1 ##
2 ## Makefile for OpenSSL
3 ##
4 ## {- join("\n## ", @autowarntext) -}
5 {-
6  use File::Basename;
7
8  our $sover_dirname = platform->shlib_version_as_filename();
9
10  my $build_scheme = $target{build_scheme};
11  my $install_flavour = $build_scheme->[$#$build_scheme]; # last element
12  my $win_installenv =
13      $install_flavour eq "VC-WOW" ? "ProgramFiles(x86)"
14                                   : "ProgramW6432";
15  my $win_commonenv =
16      $install_flavour eq "VC-WOW" ? "CommonProgramFiles(x86)"
17                                   : "CommonProgramW6432";
18  our $win_installroot =
19      defined($ENV{$win_installenv}) ? $win_installenv : 'ProgramFiles';
20  our $win_commonroot =
21      defined($ENV{$win_commonenv}) ? $win_commonenv : 'CommonProgramFiles';
22
23  # expand variables early
24  $win_installroot = $ENV{$win_installroot};
25  $win_commonroot = $ENV{$win_commonroot};
26
27  # This makes sure things get built in the order they need
28  # to. You're welcome.
29  sub dependmagic {
30      my $target = shift;
31
32      return "$target: build_generated\n\t\$(MAKE) /\$(MAKEFLAGS) depend && \$(MAKE) /\$(MAKEFLAGS) _$target\n_$target";
33  }
34  '';
35 -}
36
37 PLATFORM={- $config{target} -}
38 SRCDIR={- $config{sourcedir} -}
39 BLDDIR={- $config{builddir} -}
40 FIPSKEY={- $config{FIPSKEY} -}
41
42 VERSION={- "$config{full_version}" -}
43 MAJOR={- $config{major} -}
44 MINOR={- $config{minor} -}
45
46 SHLIB_VERSION_NUMBER={- $config{shlib_version} -}
47
48 LIBS={- join(" ", map { ( platform->sharedlib_import($_), platform->staticlib($_) ) } @{$unified_info{libraries}}) -}
49 SHLIBS={- join(" ", map { platform->sharedlib($_) // () } @{$unified_info{libraries}}) -}
50 SHLIBPDBS={- join(" ", map { platform->sharedlibpdb($_) // () } @{$unified_info{libraries}}) -}
51 MODULES={- our @MODULES = map { platform->dso($_) } @{$unified_info{modules}};
52            join(" ", @MODULES) -}
53 MODULEPDBS={- join(" ", map { platform->dsopdb($_) } @{$unified_info{modules}}) -}
54 FIPSMODULENAME={- # We do some extra checking here, as there should be only one
55                   my @fipsmodules =
56                       grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
57                              && $unified_info{attributes}->{modules}->{$_}->{fips} }
58                       @{$unified_info{modules}};
59                   die "More that one FIPS module" if scalar @fipsmodules > 1;
60                   join(" ", map { basename platform->dso($_) } @fipsmodules) -}
61 PROGRAMS={- our @PROGRAMS = map { platform->bin($_) } @{$unified_info{programs}}; join(" ", @PROGRAMS) -}
62 PROGRAMPDBS={- join(" ", map { $_.".pdb" } @{$unified_info{programs}}) -}
63 SCRIPTS={- our @SCRIPTS = @{$unified_info{scripts}}; join(" ", @SCRIPTS) -}
64 {- output_off() if $disabled{makedepend}; "" -}
65 DEPS={- join(" ", map { platform->isobj($_) ? platform->dep($_) : () }
66                   grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
67                   keys %{$unified_info{sources}}); -}
68 {- output_on() if $disabled{makedepend}; "" -}
69 GENERATED_MANDATORY={- our @GENERATED_MANDATORY = @{$unified_info{depends}->{""}};
70                        join(" ", @GENERATED_MANDATORY) -}
71 GENERATED={- # common0.tmpl provides @generated
72              our @GENERATED = map { platform->convertext($_) } @generated;
73              join(" ", @GENERATED) -}
74
75 INSTALL_LIBS={-
76         join(" ", map { quotify1(platform->sharedlib_import($_)
77                                  // platform->staticlib($_)) }
78                   grep { !$unified_info{attributes}->{libraries}->{$_}->{noinst} }
79                   @{$unified_info{libraries}})
80 -}
81 INSTALL_SHLIBS={-
82         join(" ", map { my $x = platform->sharedlib($_);
83                         $x ? quotify_l($x) : () }
84                   grep { !$unified_info{attributes}->{libraries}->{$_}->{noinst} }
85                   @{$unified_info{libraries}})
86 -}
87 INSTALL_SHLIBPDBS={-
88         join(" ", map { my $x = platform->sharedlibpdb($_);
89                         $x ? quotify_l($x) : () }
90                   grep { !$unified_info{attributes}->{libraries}->{$_}->{noinst} }
91                   @{$unified_info{libraries}})
92 -}
93 INSTALL_ENGINES={-
94         join(" ", map { quotify1(platform->dso($_)) }
95                   grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
96                          && $unified_info{attributes}->{modules}->{$_}->{engine} }
97                   @{$unified_info{modules}})
98 -}
99 INSTALL_ENGINEPDBS={-
100         join(" ", map { quotify1(platform->dsopdb($_)) }
101                   grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
102                          && $unified_info{attributes}->{modules}->{$_}->{engine} }
103                   @{$unified_info{modules}})
104 -}
105 INSTALL_MODULES={-
106         join(" ", map { platform->dso($_) }
107                   grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
108                           && !$unified_info{attributes}->{modules}->{$_}->{engine} }
109                   @{$unified_info{modules}})
110 -}
111 INSTALL_MODULEPDBS={-
112         join(" ", map { quotify1(platform->dsopdb($_)) }
113                   grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
114                          && !$unified_info{attributes}->{modules}->{$_}->{engine} }
115                   @{$unified_info{modules}})
116 -}
117 INSTALL_PROGRAMS={-
118         join(" ", map { quotify1(platform->bin($_)) }
119                   grep { !$unified_info{attributes}->{programs}->{$_}->{noinst} }
120                   @{$unified_info{programs}})
121 -}
122 INSTALL_PROGRAMPDBS={-
123         join(" ", map { quotify1(platform->binpdb($_)) }
124                   grep { !$unified_info{attributes}->{programs}->{$_}->{noinst} }
125                   @{$unified_info{programs}})
126 -}
127 BIN_SCRIPTS={-
128         join(" ", map { quotify1($_) }
129                   grep { !$unified_info{attributes}->{scripts}->{$_}->{noinst}
130                          && !$unified_info{attributes}->{scripts}->{$_}->{misc} }
131                   @{$unified_info{scripts}})
132 -}
133 MISC_SCRIPTS={-
134         join(" ", map { quotify1($_) }
135                   grep { !$unified_info{attributes}->{scripts}->{$_}->{noinst}
136                          && $unified_info{attributes}->{scripts}->{$_}->{misc} }
137                   @{$unified_info{scripts}})
138 -}
139 HTMLDOCS1={- our @HTMLDOCS1 = @{$unified_info{htmldocs}->{man1}};
140              join(" ", @HTMLDOCS1) -}
141 HTMLDOCS3={- our @HTMLDOCS3 = @{$unified_info{htmldocs}->{man3}};
142              join(" ", @HTMLDOCS3) -}
143 HTMLDOCS5={- our @HTMLDOCS5 = @{$unified_info{htmldocs}->{man5}};
144              join(" ", @HTMLDOCS5) -}
145 HTMLDOCS7={- our @HTMLDOCS7 = @{$unified_info{htmldocs}->{man7}};
146              join(" ", @HTMLDOCS7) -}
147 HTMLDOCS1_BLDDIRS={- my %dirs = map { dirname($_) => 1 } @HTMLDOCS1;
148                      join(' ', sort keys %dirs) -}
149 HTMLDOCS3_BLDDIRS={- my %dirs = map { dirname($_) => 1 } @HTMLDOCS3;
150                      join(' ', sort keys %dirs) -}
151 HTMLDOCS5_BLDDIRS={- my %dirs = map { dirname($_) => 1 } @HTMLDOCS5;
152                      join(' ', sort keys %dirs) -}
153 HTMLDOCS7_BLDDIRS={- my %dirs = map { dirname($_) => 1 } @HTMLDOCS7;
154                      join(' ', sort keys %dirs) -}
155
156 APPS_OPENSSL="{- use File::Spec::Functions;
157                  catfile("apps","openssl") -}"
158
159 # Do not edit these manually. Use Configure with --prefix or --openssldir
160 # to change this!  Short explanation in the top comment in Configure
161 INSTALLTOP_dev={- # $prefix is used in the OPENSSLDIR perl snippet
162                   #
163                   use File::Spec::Functions qw(:DEFAULT splitpath);
164                   our $prefix = canonpath($config{prefix}
165                                           || "$win_installroot\\OpenSSL");
166                   our ($prefix_dev, $prefix_dir, $prefix_file) =
167                       splitpath($prefix, 1);
168                   $prefix_dev -}
169 INSTALLTOP_dir={- canonpath($prefix_dir) -}
170 OPENSSLDIR_dev={- #
171                   # The logic here is that if no --openssldir was given,
172                   # OPENSSLDIR will get the value "$win_commonroot\\SSL".
173                   # If --openssldir was given and the value is an absolute
174                   # path, OPENSSLDIR will get its value without change.
175                   # If the value from --openssldir is a relative path,
176                   # OPENSSLDIR will get $prefix with the --openssldir
177                   # value appended as a subdirectory.
178                   #
179                   use File::Spec::Functions qw(:DEFAULT splitpath);
180                   our $openssldir =
181                       $config{openssldir} ?
182                           (file_name_is_absolute($config{openssldir}) ?
183                                canonpath($config{openssldir})
184                                : catdir($prefix, $config{openssldir}))
185                           : canonpath("$win_commonroot\\SSL");
186                   our ($openssldir_dev, $openssldir_dir, $openssldir_file) =
187                       splitpath($openssldir, 1);
188                   $openssldir_dev -}
189 OPENSSLDIR_dir={- canonpath($openssldir_dir) -}
190 LIBDIR={- our $libdir = $config{libdir} || "lib";
191           file_name_is_absolute($libdir) ? "" : $libdir -}
192 MODULESDIR_dev={- use File::Spec::Functions qw(:DEFAULT splitpath catpath);
193                   our $modulesprefix = catdir($prefix,$libdir);
194                   our ($modulesprefix_dev, $modulesprefix_dir,
195                        $modulesprefix_file) =
196                       splitpath($modulesprefix, 1);
197                   our $modulesdir_dev = $modulesprefix_dev;
198                   our $modulesdir_dir =
199                       catdir($modulesprefix_dir, "ossl-modules");
200                   our $modulesdir = catpath($modulesdir_dev, $modulesdir_dir);
201                   our $enginesdir_dev = $modulesprefix_dev;
202                   our $enginesdir_dir =
203                       catdir($modulesprefix_dir, "engines-$sover_dirname");
204                   our $enginesdir = catpath($enginesdir_dev, $enginesdir_dir);
205                   $modulesdir_dev -}
206 MODULESDIR_dir={- canonpath($modulesdir_dir) -}
207 ENGINESDIR_dev={- $enginesdir_dev -}
208 ENGINESDIR_dir={- canonpath($enginesdir_dir) -}
209 !IF "$(DESTDIR)" != ""
210 INSTALLTOP=$(DESTDIR)$(INSTALLTOP_dir)
211 OPENSSLDIR=$(DESTDIR)$(OPENSSLDIR_dir)
212 ENGINESDIR=$(DESTDIR)$(ENGINESDIR_dir)
213 MODULESDIR=$(DESTDIR)$(MODULESDIR_dir)
214 !ELSE
215 INSTALLTOP=$(INSTALLTOP_dev)$(INSTALLTOP_dir)
216 OPENSSLDIR=$(OPENSSLDIR_dev)$(OPENSSLDIR_dir)
217 ENGINESDIR=$(ENGINESDIR_dev)$(ENGINESDIR_dir)
218 MODULESDIR=$(MODULESDIR_dev)$(MODULESDIR_dir)
219 !ENDIF
220
221 # $(libdir) is chosen to be compatible with the GNU coding standards
222 libdir={- file_name_is_absolute($libdir)
223           ? $libdir : '$(INSTALLTOP)\$(LIBDIR)' -}
224
225 ##### User defined commands and flags ################################
226
227 CC="{- $config{CC} -}"
228 CPP="{- $config{CPP} -}"
229 CPPFLAGS={- our $cppflags1 = join(" ",
230                                   (map { "-D".$_} @{$config{CPPDEFINES}}),
231                                   (map { " -I ".$_} @{$config{CPPINCLUDES}}),
232                                   @{$config{CPPFLAGS}}) -}
233 CFLAGS={- join(' ', @{$config{CFLAGS}}) -}
234 LD="{- $config{LD} -}"
235 LDFLAGS={- join(' ', @{$config{LDFLAGS}}) -}
236 EX_LIBS={- join(' ', @{$config{LDLIBS}}) -}
237
238 PERL={- $config{PERL} -}
239
240 AR="{- $config{AR} -}"
241 ARFLAGS= {- join(' ', @{$config{ARFLAGS}}) -}
242
243 MT="{- $config{MT} -}"
244 MTFLAGS= {- join(' ', @{$config{MTFLAGS}}) -}
245
246 AS="{- $config{AS} -}"
247 ASFLAGS={- join(' ', @{$config{ASFLAGS}}) -}
248
249 RC="{- $config{RC} -}"
250 RCFLAGS={- join(' ', @{$config{RCFLAGS}}) -}
251
252 ECHO="$(PERL)" "$(SRCDIR)\util\echo.pl"
253
254 ##### Special command flags ##########################################
255
256 COUTFLAG={- $target{coutflag} -}$(OSSL_EMPTY)
257 LDOUTFLAG={- $target{ldoutflag} -}$(OSSL_EMPTY)
258 AROUTFLAG={- $target{aroutflag} -}$(OSSL_EMPTY)
259 MTINFLAG={- $target{mtinflag} -}$(OSSL_EMPTY)
260 MTOUTFLAG={- $target{mtoutflag} -}$(OSSL_EMPTY)
261 ASOUTFLAG={- $target{asoutflag} -}$(OSSL_EMPTY)
262 RCOUTFLAG={- $target{rcoutflag} -}$(OSSL_EMPTY)
263
264 ##### Project flags ##################################################
265
266 # Variables starting with CNF_ are common variables for all product types
267
268 CNF_ASFLAGS={- join(' ', $target{asflags} || (),
269                          @{$config{asflags}}) -}
270 CNF_CPPFLAGS={- our $cppfags2 =
271                     join(' ', $target{cppflags} || (),
272                               (map { '-D'.quotify1($_) } @{$target{defines}},
273                                                          @{$config{defines}}),
274                               (map { '-I'.'"'.$_.'"' } @{$target{includes}},
275                                                        @{$config{includes}}),
276                               @{$config{cppflags}}) -}
277 CNF_CFLAGS={- join(' ', $target{cflags} || (),
278                         @{$config{cflags}}) -}
279 CNF_CXXFLAGS={- join(' ', $target{cxxflags} || (),
280                           @{$config{cxxflags}}) -}
281 CNF_LDFLAGS={- join(' ', $target{lflags} || (),
282                          @{$config{lflags}}) -}
283 CNF_EX_LIBS={- join(' ', $target{ex_libs} || (),
284                          @{$config{ex_libs}}) -}
285
286 # Variables starting with LIB_ are used to build library object files
287 # and shared libraries.
288 # Variables starting with DSO_ are used to build DSOs and their object files.
289 # Variables starting with BIN_ are used to build programs and their object
290 # files.
291
292 LIB_ASFLAGS={- join(' ', $target{lib_asflags} || (),
293                          @{$config{lib_asflags}},
294                          '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
295 LIB_CPPFLAGS={- our $lib_cppflags =
296                 join(' ', $target{lib_cppflags} || (),
297                           $target{shared_cppflag} || (),
298                           (map { '-D'.quotify1($_) }
299                                @{$target{lib_defines}},
300                                @{$target{shared_defines}},
301                                @{$config{lib_defines}},
302                                @{$config{shared_defines}}),
303                           (map { '-I'.quotify1($_) }
304                                @{$target{lib_includes}},
305                                @{$target{shared_includes}},
306                                @{$config{lib_includes}},
307                                @{$config{shared_includes}}),
308                           @{$config{lib_cppflags}},
309                           @{$config{shared_cppflag}});
310                 join(' ', $lib_cppflags,
311                           (map { '-D'.quotify1($_) }
312                                "OPENSSLDIR=\"$openssldir\"",
313                                "ENGINESDIR=\"$enginesdir\"",
314                                "MODULESDIR=\"$modulesdir\""),
315                           '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
316 LIB_CFLAGS={- join(' ', $target{lib_cflags} || (),
317                         $target{shared_cflag} || (),
318                         @{$config{lib_cflags}},
319                         @{$config{shared_cflag}},
320                         '$(CNF_CFLAGS)', '$(CFLAGS)') -}
321 LIB_LDFLAGS={- join(' ', $target{shared_ldflag} || (),
322                          $config{shared_ldflag} || (),
323                          '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
324 LIB_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
325 DSO_ASFLAGS={- join(' ', $target{dso_asflags} || (),
326                          $target{module_asflags} || (),
327                          @{$config{dso_asflags}},
328                          @{$config{module_asflags}},
329                          '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
330 DSO_CPPFLAGS={- join(' ', $target{dso_cppflags} || (),
331                           $target{module_cppflag} || (),
332                           (map { '-D'.quotify1($_) }
333                                @{$target{dso_defines}},
334                                @{$target{module_defines}},
335                                @{$config{dso_defines}},
336                                @{$config{module_defines}}),
337                           (map { '-I'.quotify1($_) }
338                                @{$target{dso_includes}},
339                                @{$target{module_includes}},
340                                @{$config{dso_includes}},
341                                @{$config{module_includes}}),
342                           @{$config{dso_cppflags}},
343                           @{$config{module_cppflags}},
344                           '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
345 DSO_CFLAGS={- join(' ', $target{dso_cflags} || (),
346                         $target{module_cflags} || (),
347                         @{$config{dso_cflags}},
348                         @{$config{module_cflags}},
349                         '$(CNF_CFLAGS)', '$(CFLAGS)') -}
350 DSO_LDFLAGS={- join(' ', $target{dso_lflags} || (),
351                          $target{module_ldflags} || (),
352                          @{$config{dso_lflags}},
353                          @{$config{module_ldflags}},
354                          '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
355 DSO_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
356 BIN_ASFLAGS={- join(' ', $target{bin_asflags} || (),
357                          @{$config{bin_asflags}},
358                          '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
359 BIN_CPPFLAGS={- join(' ', $target{bin_cppflags} || (),
360                           (map { '-D'.$_ } @{$config{bin_defines} || ()}),
361                           @{$config{bin_cppflags}},
362                           '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
363 BIN_CFLAGS={- join(' ', $target{bin_cflags} || (),
364                         @{$config{bin_cflags}},
365                         '$(CNF_CFLAGS)', '$(CFLAGS)') -}
366 BIN_LDFLAGS={- join(' ', $target{bin_lflags} || (),
367                          @{$config{bin_lflags}},
368                          '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
369 BIN_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
370
371 # CPPFLAGS_Q is used for one thing only: to build up buildinf.h
372 CPPFLAGS_Q={- $cppflags1 =~ s|([\\"])|\\$1|g;
373               $cppflags2 =~ s|([\\"])|\\$1|g;
374               join(' ', $lib_cppflags || (), $cppflags2 || (),
375                         $cppflags1 || ()) -}
376
377 PERLASM_SCHEME= {- $target{perlasm_scheme} -}
378
379 PROCESSOR= {- $config{processor} -}
380
381 # The main targets ###################################################
382
383 {- dependmagic('build_sw'); -}: build_libs_nodep build_modules_nodep build_programs_nodep copy-utils
384 {- dependmagic('build_libs'); -}: build_libs_nodep
385 {- dependmagic('build_modules'); -}: build_modules_nodep
386 {- dependmagic('build_programs'); -}: build_programs_nodep
387
388 build_docs: build_html_docs
389 build_html_docs: $(HTMLDOCS1) $(HTMLDOCS3) $(HTMLDOCS5) $(HTMLDOCS7)
390
391 build_generated: $(GENERATED_MANDATORY)
392 build_libs_nodep: $(LIBS) {- join(" ",map { platform->sharedlib_import($_) // () } @{$unified_info{libraries}}) -}
393 build_modules_nodep: $(MODULES)
394 build_programs_nodep: $(PROGRAMS) $(SCRIPTS)
395
396 # Kept around for backward compatibility
397 build_apps build_tests: build_programs
398
399 # Convenience target to prebuild all generated files, not just the mandatory
400 # ones
401 build_all_generated: $(GENERATED_MANDATORY) $(GENERATED) build_docs
402         @{- output_off() if $disabled{makedepend}; "" -}
403         @$(ECHO) "Warning: consider configuring with no-makedepend, because if"
404         @$(ECHO) "         target system doesn't have $(PERL),"
405         @$(ECHO) "         then make will fail..."
406         @{- output_on() if $disabled{makedepend}; "" -}
407
408 all: build_sw build_docs
409
410 test: tests
411 {- dependmagic('tests'); -}: build_programs_nodep build_modules_nodep copy-utils
412         @{- output_off() if $disabled{tests}; "" -}
413         set SRCTOP=$(SRCDIR)
414         set BLDTOP=$(BLDDIR)
415         set PERL=$(PERL)
416         set FIPSKEY=$(FIPSKEY)
417         "$(PERL)" "$(SRCDIR)\test\run_tests.pl" $(TESTS)
418         @{- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
419         @$(ECHO) "Tests are not supported with your chosen Configure options"
420         @{- output_on() if !$disabled{tests}; "" -}
421
422 list-tests:
423         @{- output_off() if $disabled{tests}; "" -}
424         @set SRCTOP=$(SRCDIR)
425         @"$(PERL)" "$(SRCDIR)\test\run_tests.pl" list
426         @{- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
427         @$(ECHO) "Tests are not supported with your chosen Configure options"
428         @{- output_on() if !$disabled{tests}; "" -}
429
430 install: install_sw install_ssldirs install_docs
431
432 uninstall: uninstall_docs uninstall_sw
433
434 libclean:
435         "$(PERL)" -e "map { m/(.*)\.dll$$/; unlink glob """{.,apps,test,fuzz}/$$1.*"""; } @ARGV" $(SHLIBS)
436         -del /Q /F $(LIBS) libcrypto.* libssl.* ossl_static.pdb
437
438 clean: libclean
439         -rmdir /Q /S $(HTMLDOCS1_BLDDIRS)
440         -rmdir /Q /S $(HTMLDOCS3_BLDDIRS)
441         -rmdir /Q /S $(HTMLDOCS5_BLDDIRS)
442         -rmdir /Q /S $(HTMLDOCS7_BLDDIRS)
443         {- join("\n\t", map { "-del /Q /F $_" } @PROGRAMS) -}
444         {- join("\n\t", map { "-del /Q /F $_" } @MODULES) -}
445         {- join("\n\t", map { "-del /Q /F $_" } @SCRIPTS) -}
446         {- join("\n\t", map { "-del /Q /F $_" } @GENERATED_MANDATORY) -}
447         {- join("\n\t", map { "-del /Q /F $_" } @GENERATED) -}
448         -del /Q /S /F *.d *.obj *.pdb *.ilk *.manifest
449         -del /Q /S /F engines\*.lib engines\*.exp
450         -del /Q /S /F apps\*.lib apps\*.rc apps\*.res apps\*.exp
451         -del /Q /S /F test\*.exp
452         -rmdir /Q /S test\test-runs
453
454 distclean: clean
455         -del /Q /F configdata.pm
456         -del /Q /F makefile
457
458 depend:
459         @ {- output_off() if $disabled{makedepend}; "" -}
460         @ "$(PERL)" "$(SRCDIR)\util\add-depends.pl" "VC"
461         @ {- output_on() if $disabled{makedepend}; "" -}
462
463 # Install helper targets #############################################
464
465 install_sw: install_dev install_engines install_modules install_runtime
466
467 uninstall_sw: uninstall_runtime uninstall_modules uninstall_engines uninstall_dev
468
469 install_docs: install_html_docs
470
471 uninstall_docs: uninstall_html_docs
472
473 install_fips: install_sw
474         @$(ECHO) "*** Installing FIPS module configuration"
475         @$(ECHO) "fipsinstall $(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME).cnf"
476         @openssl fipsinstall -module $(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME) \
477                 -out $(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME).cnf \
478                 -macopt "key:$(FIPSKEY)"
479
480 uninstall_fips: uninstall_sw
481         @$(ECHO) "*** Uninstalling FIPS module configuration"
482         @$(ECHO) "$(RM) $(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME).cnf"
483         @$(RM) $(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME).cnf
484
485 install_ssldirs:
486         @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\certs"
487         @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\private"
488         @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\misc"
489         @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\openssl.cnf" \
490                                         "$(OPENSSLDIR)\openssl.cnf.dist"
491         @IF NOT EXIST "$(OPENSSLDIR)\openssl.cnf" \
492          "$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\openssl.cnf" \
493                                         "$(OPENSSLDIR)\openssl.cnf"
494         @if not "$(MISC_SCRIPTS)"=="" \
495          "$(PERL)" "$(SRCDIR)\util\copy.pl" $(MISC_SCRIPTS) \
496                                         "$(OPENSSLDIR)\misc"
497         @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\ct_log_list.cnf" \
498                                         "$(OPENSSLDIR)\ct_log_list.cnf.dist"
499         @IF NOT EXIST "$(OPENSSLDIR)\ct_log_list.cnf" \
500          "$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\ct_log_list.cnf" \
501                                         "$(OPENSSLDIR)\ct_log_list.cnf"
502
503 install_dev: install_runtime_libs
504         @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
505         @$(ECHO) "*** Installing development files"
506         @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\include\openssl"
507         @{- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
508         @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\ms\applink.c" \
509                                        "$(INSTALLTOP)\include\openssl"
510         @{- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
511         @"$(PERL)" "$(SRCDIR)\util\copy.pl" "-exclude_re=/__DECC_" \
512                                        "$(SRCDIR)\include\openssl\*.h" \
513                                        "$(INSTALLTOP)\include\openssl"
514         @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(BLDDIR)\include\openssl\*.h" \
515                                        "$(INSTALLTOP)\include\openssl"
516         @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(libdir)"
517         @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_LIBS) "$(libdir)"
518         @if "$(SHLIBS)"=="" \
519          "$(PERL)" "$(SRCDIR)\util\copy.pl" ossl_static.pdb "$(libdir)"
520
521 uninstall_dev:
522
523 _install_modules_deps: install_runtime_libs build_modules
524
525 install_engines: _install_modules_deps
526         @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
527         @$(ECHO) "*** Installing engines"
528         @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(ENGINESDIR)"
529         @if not "$(INSTALL_ENGINES)"=="" \
530          "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINES) "$(ENGINESDIR)"
531         @if not "$(INSTALL_ENGINES)"=="" \
532          "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINEPDBS) "$(ENGINESDIR)"
533
534 uninstall_engines:
535
536 install_modules: _install_modules_deps
537         @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
538         @$(ECHO) "*** Installing modules"
539         @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(MODULESDIR)"
540         @if not "$(INSTALL_MODULES)"=="" \
541          "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_MODULES) "$(MODULESDIR)"
542         @if not "$(INSTALL_MODULES)"=="" \
543          "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_MODULEPDBS) "$(MODULESDIR)"
544
545 uninstall_modules:
546
547 install_runtime: install_programs
548
549 install_runtime_libs: build_libs
550         @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
551         @$(ECHO) "*** Installing runtime libraries"
552         @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\bin"
553         @if not "$(SHLIBS)"=="" \
554          "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_SHLIBS) "$(INSTALLTOP)\bin"
555         @if not "$(SHLIBS)"=="" \
556          "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_SHLIBPDBS) \
557                                         "$(INSTALLTOP)\bin"
558
559 install_programs: install_runtime_libs build_programs
560         @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
561         @$(ECHO) "*** Installing runtime programs"
562         @if not "$(INSTALL_PROGRAMS)"=="" \
563          "$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\bin"
564         @if not "$(INSTALL_PROGRAMS)"=="" \
565          "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMS) \
566                                         "$(INSTALLTOP)\bin"
567         @if not "$(INSTALL_PROGRAMS)"=="" \
568          "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMPDBS) \
569                                         "$(INSTALLTOP)\bin"
570         @if not "$(INSTALL_PROGRAMS)"=="" \
571          "$(PERL)" "$(SRCDIR)\util\copy.pl" $(BIN_SCRIPTS) \
572                                         "$(INSTALLTOP)\bin"
573
574 uninstall_runtime:
575
576 install_html_docs: build_html_docs
577         @if "$(INSTALLTOP)"=="" ( echo INSTALLTOP should not be empty & exit 1 )
578         @echo *** Installing HTML docs
579         @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\html\man1"
580         @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\html\man3"
581         @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\html\man5"
582         @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\html\man7"
583         @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BLDDIR)\doc\html\man1\*.html \
584                                         "$(INSTALLTOP)\html\man1"
585         @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BLDDIR)\doc\html\man3\*.html \
586                                         "$(INSTALLTOP)\html\man3"
587         @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BLDDIR)\doc\html\man5\*.html \
588                                         "$(INSTALLTOP)\html\man5"
589         @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BLDDIR)\doc\html\man7\*.html \
590                                         "$(INSTALLTOP)\html\man7"
591
592 uninstall_html_docs:
593
594 # Helper targets #####################################################
595
596 copy-utils: $(BLDDIR)\util\wrap.pl
597
598 $(BLDDIR)\util\wrap.pl: configdata.pm
599         @if NOT EXIST "$(BLDDIR)\util" mkdir "$(BLDDIR)\util"
600         @if NOT "$(SRCDIR)"=="$(BLDDIR)" copy "$(SRCDIR)\util\$(@F)" "$(BLDDIR)\util"
601
602 # Building targets ###################################################
603
604 configdata.pm: "$(SRCDIR)\Configure" {- join(" ", map { '"'.$_.'"' } @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
605         @$(ECHO) "Detected changed: $?"
606         "$(PERL)" configdata.pm -r
607         @$(ECHO) "**************************************************"
608         @$(ECHO) "***                                            ***"
609         @$(ECHO) "***   Please run the same make command again   ***"
610         @$(ECHO) "***                                            ***"
611         @$(ECHO) "**************************************************"
612         @exit 1
613
614 reconfigure reconf:
615         "$(PERL)" configdata.pm -r
616
617 {-
618  use File::Basename;
619  use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
620
621  # Helper function to figure out dependencies on libraries
622  # It takes a list of library names and outputs a list of dependencies
623  sub compute_lib_depends {
624      if ($disabled{shared}) {
625          return map { platform->staticlib($_) } @_;
626      }
627      return map { platform->sharedlib_import($_) // platform->staticlib($_) } @_;
628  }
629
630   sub generatesrc {
631       my %args = @_;
632       my ($gen0, @gens) = @{$args{generator}};
633       my $generator = '"'.$gen0.'"'.join('', map { " $_" } @gens);
634       my $generator_incs = join("", map { " -I \"$_\"" } @{$args{generator_incs}});
635       my $incs = join("", map { " -I \"$_\"" } @{$args{incs}});
636       my $defs = join("", map { " -D".$_ } @{$args{defs}});
637       my $deps = @{$args{deps}} ?
638           '"'.join('" "', @{$args{generator_deps}}, @{$args{deps}}).'"' : '';
639
640       if ($args{src} =~ /\.html$/) {
641           my $title = basename($args{src}, ".html");
642           my $pod = $args{generator}->[0];
643           return <<"EOF";
644 $args{src}: "$pod"
645         \$(PERL) \$(SRCDIR)/util/mkpod2html.pl -i "$pod" -o \$\@ -t "$title" -r "\$(SRCDIR)/doc"
646 EOF
647       } elsif (platform->isdef($args{src})) {
648           my $target = platform->def($args{src});
649           my $mkdef = abs2rel(rel2abs(catfile($config{sourcedir},
650                                               "util", "mkdef.pl")),
651                               rel2abs($config{builddir}));
652           my $ord_ver = $args{intent} eq 'lib' ? ' --version $(VERSION)' : '';
653           my $ord_name =
654               $args{generator}->[1] || platform->dsoname($args{product});
655           return <<"EOF";
656 $target: $args{generator}->[0] $deps $mkdef
657         "\$(PERL)" $mkdef$ord_ver --ordinals $args{generator}->[0] --name $ord_name --OS windows > $target
658 EOF
659       } elsif (!platform->isasm($args{src})) {
660           my $target = $args{src};
661           if ($args{generator}->[0] =~ m|^.*\.in$|) {
662               my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
663                                                    "util", "dofile.pl")),
664                                    rel2abs($config{builddir}));
665               my @modules = ( 'configdata.pm',
666                               grep { $_ =~ m|\.pm$| } @{$args{deps}} );
667               my %moduleincs = map { '"-I'.dirname($_).'"' => 1 } @modules;
668               @modules = map { "-M".basename($_, '.pm') } @modules;
669               my $modules = join(' ', '', sort keys %moduleincs, @modules);
670               return <<"EOF";
671 $target: "$args{generator}->[0]" $deps
672         "\$(PERL)"$modules "$dofile" "-o$target{build_file}" $generator > \$@
673 EOF
674           } else {
675               return <<"EOF";
676 $target: "$args{generator}->[0]" $deps
677         "\$(PERL)"$generator_incs $generator > \$@
678 EOF
679           }
680       } else {
681           my $cppflags = {
682               shlib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
683               lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
684               dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)',
685               bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
686           } -> {$args{intent}};
687           my $target = platform->asm($args{src});
688
689           if ($args{generator}->[0] =~ /\.pl$/) {
690               $generator = '"$(PERL)"'.$generator_incs.' '.$generator
691                   .' "$(PERLASM_SCHEME)"'.$incs.' '.$cppflags.$defs.' $(PROCESSSOR)';
692           } elsif ($args{generator}->[0] =~ /\.S$/) {
693               $generator = undef;
694           } else {
695               die "Generator type for $src unknown: $generator\n";
696           }
697
698           if (defined($generator)) {
699               # If the target is named foo.S in build.info, we want to
700               # end up generating foo.s in two steps.
701               if ($args{src} =~ /\.S$/) {
702                    return <<"EOF";
703 $target: "$args{generator}->[0]" $deps
704         set ASM=\$(AS)
705         $generator \$@.S
706         \$(CPP) $incs $cppflags $defs \$@.S > \$@.i && move /Y \$@.i \$@
707         del /Q \$@.S
708 EOF
709               }
710               # Otherwise....
711               return <<"EOF";
712 $target: "$args{generator}->[0]" $deps
713         set ASM=\$(AS)
714         $generator \$@
715 EOF
716           }
717           return <<"EOF";
718 $target: "$args{generator}->[0]" $deps
719         \$(CPP) $incs $cppflags $defs "$args{generator}->[0]" > \$@.i && move /Y \$@.i \$@
720 EOF
721       }
722   }
723
724  sub src2obj {
725      my $asmext = platform->asmext();
726      my %args = @_;
727      my @srcs =
728          map { my $x = $_;
729                (platform->isasm($x) && grep { $x eq $_ } @generated)
730                ? platform->asm($x) : $x }
731          ( @{$args{srcs}} );
732      my $srcs = '"'.join('" "',  @srcs).'"';
733      my $deps = '"'.join('" "', @srcs, @{$args{deps}}).'"';
734      my $incs = join("", map { ' -I "'.$_.'"' } @{$args{incs}});
735      my $defs = join("", map { " -D".$_ } @{$args{defs}});
736      my $cflags = { shlib => ' $(LIB_CFLAGS)',
737                     lib => ' $(LIB_CFLAGS)',
738                     dso => ' $(DSO_CFLAGS)',
739                     bin => ' $(BIN_CFLAGS)' } -> {$args{intent}};
740      $cflags .= $incs;
741      $cflags .= { shlib => ' $(LIB_CPPFLAGS)',
742                   lib => ' $(LIB_CPPFLAGS)',
743                   dso => ' $(DSO_CPPFLAGS)',
744                   bin => ' $(BIN_CPPFLAGS)' } -> {$args{intent}};
745      my $asflags = { shlib => ' $(LIB_ASFLAGS)',
746                      lib => ' $(LIB_ASFLAGS)',
747                      dso => ' $(DSO_ASFLAGS)',
748                      bin => ' $(BIN_ASFLAGS)' } -> {$args{intent}};
749      my $makedepprog = $config{makedepprog};
750      if ($srcs[0] =~ /\.rc$/) {
751          my $res = platform->res($args{obj});
752          return <<"EOF";
753 $res: $deps
754         \$(RC) \$(RCFLAGS) \$(RCOUTFLAG)\$\@ $srcs
755 EOF
756      }
757      my $obj = platform->obj($args{obj});
758      my $dep = platform->dep($args{obj});
759      if ($srcs[0] =~ /\Q${asmext}\E$/) {
760          return <<"EOF";
761 $obj: $deps
762         \$(AS) $asflags \$(ASOUTFLAG)\$\@ $srcs
763 EOF
764      } elsif ($srcs[0] =~ /.S$/) {
765          return <<"EOF";
766 $obj: $deps
767         \$(CC) /EP -D__ASSEMBLER__ $cflags $defs $srcs > \$@.asm && \$(AS) $asflags \$(ASOUTFLAG)\$\@ \$@.asm
768 EOF
769      }
770      my $recipe = <<"EOF";
771 $obj: $deps
772         \$(CC) $cflags $defs -c \$(COUTFLAG)\$\@ $srcs
773 EOF
774      $recipe .= <<"EOF" unless $disabled{makedepend};
775         \$(CC) $cflags $defs /Zs /showIncludes $srcs 2>&1 > $dep
776 EOF
777      return $recipe;
778  }
779
780  # We *know* this routine is only called when we've configure 'shared'.
781  # Also, note that even though the import library built here looks like
782  # a static library, it really isn't.
783  sub obj2shlib {
784      my %args = @_;
785      my $lib = $args{lib};
786      my @objs = map { platform->convertext($_) }
787                 grep { platform->isobj($_) || platform->isres($_) }
788                 @{$args{objs}};
789      my @defs = map { platform->def($_) }
790                 grep { platform->isdef($_) }
791                 @{$args{objs}};
792      my @deps = compute_lib_depends(@{$args{deps}});
793      die "More than one exported symbols list" if scalar @defs > 1;
794      my $linklibs = join("", map { "$_\n" } @deps);
795      my $objs = join("\n", @objs);
796      my $deps = join(" ", @objs, @defs, @deps);
797      my $import = platform->sharedlib_import($lib);
798      my $dll =  platform->sharedlib($lib);
799      my $shared_def = join("", map { " /def:$_" } @defs);
800      return <<"EOF"
801 # The import library may look like a static library, but it is not.
802 # We MUST make the import library depend on the DLL, in case someone
803 # mistakenly removes the latter.
804 $import: $dll
805 $dll: $deps
806         IF EXIST $full.manifest DEL /F /Q $full.manifest
807         IF EXIST \$@ DEL /F /Q \$@
808         \$(LD) \$(LDFLAGS) \$(LIB_LDFLAGS) \\
809                 /implib:$import \$(LDOUTFLAG)$dll$shared_def @<< || (DEL /Q \$(\@B).* $import && EXIT 1)
810 $objs
811 $linklibs\$(LIB_EX_LIBS)
812 <<
813         IF EXIST $dll.manifest \\
814            \$(MT) \$(MTFLAGS) \$(MTINFLAG)$dll.manifest \$(MTOUTFLAG)$dll
815         IF EXIST apps\\$dll DEL /Q /F apps\\$dll
816         IF EXIST test\\$dll DEL /Q /F test\\$dll
817         IF EXIST fuzz\\$dll DEL /Q /F fuzz\\$dll
818         COPY $dll apps
819         COPY $dll test
820         COPY $dll fuzz
821 EOF
822  }
823  sub obj2dso {
824      my %args = @_;
825      my $dso = platform->dso($args{module});
826      my $dso_n = platform->dsoname($args{module});
827      my @objs = map { platform->convertext($_) }
828                 grep { platform->isobj($_) || platform->isres($_) }
829                 @{$args{objs}};
830      my @defs = map { platform->def($_) }
831                 grep { platform->isdef($_) }
832                 @{$args{objs}};
833      my @deps = compute_lib_depends(@{$args{deps}});
834      my $objs = join("\n", @objs);
835      my $linklibs = join("", map { "$_\n" } @deps);
836      my $deps = join(" ", @objs, @defs, @deps);
837      my $shared_def = join("", map { " /def:$_" } @defs);
838      return <<"EOF";
839 $dso: $deps
840         IF EXIST $dso.manifest DEL /F /Q $dso.manifest
841         \$(LD) \$(LDFLAGS) \$(DSO_LDFLAGS) \\
842                 \$(LDOUTFLAG)$dso$shared_def @<< || (DEL /Q \$(\@B).* $dso_n.* && EXIT 1)
843 $objs
844 $linklibs \$(DSO_EX_LIBS)
845 <<
846         IF EXIST $dso.manifest \\
847            \$(MT) \$(MTFLAGS) \$(MTINFLAG)$dso.manifest \$(MTOUTFLAG)$dso
848 EOF
849  }
850  sub obj2lib {
851      my %args = @_;
852      my $lib = platform->staticlib($args{lib});
853      my @objs = map { platform->obj($_) } @{$args{objs}};
854      my $objs = join("\n", @objs);
855      my $deps = join(" ", @objs);
856      return <<"EOF";
857 $lib: $deps
858         \$(AR) \$(ARFLAGS) \$(AROUTFLAG)$lib @<<
859 $objs
860 <<
861 EOF
862  }
863  sub obj2bin {
864      my %args = @_;
865      my $bin = platform->bin($args{bin});
866      my @objs = map { platform->convertext($_) }
867                 grep { platform->isobj($_) || platform->isres($_) }
868                 @{$args{objs}};
869      my @deps = compute_lib_depends(@{$args{deps}});
870      my $objs = join("\n", @objs);
871      my $linklibs = join("", map { "$_\n" } @deps);
872      my $deps = join(" ", @objs, @deps);
873      return <<"EOF";
874 $bin: $deps
875         IF EXIST $bin.manifest DEL /F /Q $bin.manifest
876         \$(LD) \$(LDFLAGS) \$(BIN_LDFLAGS) \$(LDOUTFLAG)$bin @<<
877 $objs
878 setargv.obj
879 $linklibs\$(BIN_EX_LIBS)
880 <<
881         IF EXIST $bin.manifest \\
882            \$(MT) \$(MTFLAGS) \$(MTINFLAG)$bin.manifest \$(MTOUTFLAG)$bin
883 EOF
884   }
885   sub in2script {
886       my %args = @_;
887       my $script = $args{script};
888       my $sources = '"'.join('" "', @{$args{sources}}).'"';
889       my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
890                                            "util", "dofile.pl")),
891                            rel2abs($config{builddir}));
892       return <<"EOF";
893 $script: $sources
894         "\$(PERL)" "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
895             "-o$target{build_file}" $sources > "$script"
896 EOF
897   }
898   sub generatedir {
899       my %args = @_;
900       my $dir = $args{dir};
901       my @deps = map { platform->convertext($_) } @{$args{deps}};
902       my @actions = ();
903       my %extinfo = ( dso => platform->dsoext(),
904                       lib => platform->libext(),
905                       bin => platform->binext() );
906
907       # We already have a 'test' target, and the top directory is just plain
908       # silly
909       return if $dir eq "test" || $dir eq ".";
910
911       foreach my $type (("dso", "lib", "bin", "script")) {
912           next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type});
913           # For lib object files, we could update the library.  However,
914           # LIB on Windows doesn't work that way, so we won't create any
915           # actions for it, and the dependencies are already taken care of.
916           if ($type ne "lib") {
917               foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) {
918                   if (dirname($prod) eq $dir) {
919                       push @deps, $prod.$extinfo{$type};
920                   }
921               }
922           }
923       }
924
925       my $deps = join(" ", @deps);
926       my $actions = join("\n", "", @actions);
927       return <<"EOF";
928 $dir $dir\\ : $deps$actions
929 EOF
930   }
931   ""    # Important!  This becomes part of the template result.
932 -}