Display the library building flags
[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 $resext = $target{res_extension} || ".res";
8  our $depext = $target{dep_extension} || ".d";
9  our $exeext = $target{exe_extension} || ".exe";
10  our $libext = $target{lib_extension} || ".lib";
11  our $shlibext = $target{shared_extension} || ".dll";
12  our $shlibextimport = $target{shared_import_extension} || ".lib";
13  our $dsoext = $target{dso_extension} || ".dll";
14
15  (our $sover_dirname = $config{shlib_version_number}) =~ s|\.|_|g;
16
17  my $win_installenv =
18      $target{build_scheme}->[2] eq "VC-W32" ?
19      "ProgramFiles(x86)" : "ProgramW6432";
20  my $win_commonenv =
21      $target{build_scheme}->[2] eq "VC-W32"
22      ? "CommonProgramFiles(x86)" : "CommonProgramW6432";
23  our $win_installroot =
24      defined($ENV{$win_installenv})
25      ? $win_installenv : 'ProgramFiles';
26  our $win_commonroot =
27      defined($ENV{$win_commonenv})
28      ? $win_commonenv : 'CommonProgramFiles';
29
30  # expand variables early
31  $win_installroot = $ENV{$win_installroot};
32  $win_commonroot = $ENV{$win_commonroot};
33
34  sub shlib {
35      my $lib = shift;
36      return () if $disabled{shared} || $lib =~ /\.a$/;
37      return () unless defined $unified_info{sharednames}->{$lib};
38      return $unified_info{sharednames}->{$lib} . $shlibext;
39  }
40
41  sub lib {
42      (my $lib = shift) =~ s/\.a$//;
43      return $lib . $libext;
44  }
45
46  sub shlib_import {
47      my $lib = shift;
48      return () if $disabled{shared} || $lib =~ /\.a$/;
49      return $lib . $shlibextimport;
50  }
51
52  sub dso {
53      my $dso = shift;
54
55      return $dso . $dsoext;
56  }
57  # This makes sure things get built in the order they need
58  # to. You're welcome.
59  sub dependmagic {
60      my $target = shift;
61
62      return "$target: build_generated\n\t\$(MAKE) /\$(MAKEFLAGS) depend && \$(MAKE) /\$(MAKEFLAGS) _$target\n_$target";
63  }
64  '';
65 -}
66
67 PLATFORM={- $config{target} -}
68 SRCDIR={- $config{sourcedir} -}
69 BLDDIR={- $config{builddir} -}
70
71 VERSION={- $config{version} -}
72 MAJOR={- $config{major} -}
73 MINOR={- $config{minor} -}
74
75 SHLIB_VERSION_NUMBER={- $config{shlib_version_number} -}
76
77 LIBS={- join(" ", map { lib($_) } @{$unified_info{libraries}}) -}
78 SHLIBS={- join(" ", map { shlib($_) } @{$unified_info{libraries}}) -}
79 SHLIBPDBS={- join(" ", map { local $shlibext = ".pdb"; shlib($_) } @{$unified_info{libraries}}) -}
80 ENGINES={- join(" ", map { dso($_) } @{$unified_info{engines}}) -}
81 ENGINEPDBS={- join(" ", map { local $dsoext = ".pdb"; dso($_) } @{$unified_info{engines}}) -}
82 PROGRAMS={- our @PROGRAMS = map { $_.$exeext } @{$unified_info{programs}}; join(" ", @PROGRAMS) -}
83 PROGRAMPDBS={- join(" ", map { $_.".pdb" } @{$unified_info{programs}}) -}
84 SCRIPTS={- join(" ", @{$unified_info{scripts}}) -}
85 {- output_off() if $disabled{makedepend}; "" -}
86 DEPS={- join(" ", map { (my $x = $_) =~ s|\.o$|$depext|; $x; }
87                   grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
88                   keys %{$unified_info{sources}}); -}
89 {- output_on() if $disabled{makedepend}; "" -}
90 GENERATED_MANDATORY={- join(" ", @{$unified_info{depends}->{""}} ) -}
91 GENERATED={- join(" ",
92                   ( map { (my $x = $_) =~ s|\.[sS]$|\.asm|; $x }
93                     grep { defined $unified_info{generate}->{$_} }
94                     map { @{$unified_info{sources}->{$_}} }
95                     grep { /\.o$/ } keys %{$unified_info{sources}} ),
96                   ( grep { /\.h$/ } keys %{$unified_info{generate}} )) -}
97
98 INSTALL_LIBS={- join(" ", map { lib($_) } @{$unified_info{install}->{libraries}}) -}
99 INSTALL_SHLIBS={- join(" ", map { shlib($_) } @{$unified_info{install}->{libraries}}) -}
100 INSTALL_SHLIBPDBS={- join(" ", map { local $shlibext = ".pdb"; shlib($_) } @{$unified_info{install}->{libraries}}) -}
101 INSTALL_ENGINES={- join(" ", map { dso($_) } @{$unified_info{install}->{engines}}) -}
102 INSTALL_ENGINEPDBS={- join(" ", map { local $dsoext = ".pdb"; dso($_) } @{$unified_info{install}->{engines}}) -}
103 INSTALL_PROGRAMS={- join(" ", map { $_.$exeext } grep { !m|^test\\| } @{$unified_info{install}->{programs}}) -}
104 INSTALL_PROGRAMPDBS={- join(" ", map { $_.".pdb" } grep { !m|^test\\| } @{$unified_info{install}->{programs}}) -}
105 {- output_off() if $disabled{apps}; "" -}
106 BIN_SCRIPTS=$(BLDDIR)\tools\c_rehash.pl
107 MISC_SCRIPTS=$(BLDDIR)\apps\CA.pl $(BLDDIR)\apps\tsget.pl
108 {- output_on() if $disabled{apps}; "" -}
109
110 APPS_OPENSSL={- use File::Spec::Functions;
111                 catfile("apps","openssl") -}
112
113 # Do not edit these manually. Use Configure with --prefix or --openssldir
114 # to change this!  Short explanation in the top comment in Configure
115 INSTALLTOP_dev={- # $prefix is used in the OPENSSLDIR perl snippet
116                   #
117                   use File::Spec::Functions qw(:DEFAULT splitpath);
118                   our $prefix = canonpath($config{prefix}
119                                           || "$win_installroot\\OpenSSL");
120                   our ($prefix_dev, $prefix_dir, $prefix_file) =
121                       splitpath($prefix, 1);
122                   $prefix_dev -}
123 INSTALLTOP_dir={- canonpath($prefix_dir) -}
124 OPENSSLDIR_dev={- #
125                   # The logic here is that if no --openssldir was given,
126                   # OPENSSLDIR will get the value "$win_commonroot\\SSL".
127                   # If --openssldir was given and the value is an absolute
128                   # path, OPENSSLDIR will get its value without change.
129                   # If the value from --openssldir is a relative path,
130                   # OPENSSLDIR will get $prefix with the --openssldir
131                   # value appended as a subdirectory.
132                   #
133                   use File::Spec::Functions qw(:DEFAULT splitpath);
134                   our $openssldir =
135                       $config{openssldir} ?
136                           (file_name_is_absolute($config{openssldir}) ?
137                                canonpath($config{openssldir})
138                                : catdir($prefix, $config{openssldir}))
139                           : canonpath("$win_commonroot\\SSL");
140                   our ($openssldir_dev, $openssldir_dir, $openssldir_file) =
141                       splitpath($openssldir, 1);
142                   $openssldir_dev -}
143 OPENSSLDIR_dir={- canonpath($openssldir_dir) -}
144 LIBDIR={- our $libdir = $config{libdir} || "lib";
145           file_name_is_absolute($libdir) ? "" : $libdir -}
146 ENGINESDIR_dev={- use File::Spec::Functions qw(:DEFAULT splitpath);
147                   our $enginesdir = catdir($prefix,$libdir,"engines-$sover_dirname");
148                   our ($enginesdir_dev, $enginesdir_dir, $enginesdir_file) =
149                       splitpath($enginesdir, 1);
150                   $enginesdir_dev -}
151 ENGINESDIR_dir={- canonpath($enginesdir_dir) -}
152 !IF "$(DESTDIR)" != ""
153 INSTALLTOP=$(DESTDIR)$(INSTALLTOP_dir)
154 OPENSSLDIR=$(DESTDIR)$(OPENSSLDIR_dir)
155 ENGINESDIR=$(DESTDIR)$(ENGINESDIR_dir)
156 !ELSE
157 INSTALLTOP=$(INSTALLTOP_dev)$(INSTALLTOP_dir)
158 OPENSSLDIR=$(OPENSSLDIR_dev)$(OPENSSLDIR_dir)
159 ENGINESDIR=$(ENGINESDIR_dev)$(ENGINESDIR_dir)
160 !ENDIF
161
162 # $(libdir) is chosen to be compatible with the GNU coding standards
163 libdir={- file_name_is_absolute($libdir)
164           ? $libdir : '$(INSTALLTOP)\$(LIBDIR)' -}
165
166 ##### User defined commands and flags ################################
167
168 CC={- $config{CC} -}
169 CPP={- $config{CPP} -}
170 CPPFLAGS={- our $cppflags1 = join(" ",
171                                   (map { "-D".$_} @{$config{CPPDEFINES}}),
172                                   (map { " /I ".$_} @{$config{CPPINCLUDES}}),
173                                   @{$config{CPPFLAGS}}) -}
174 CFLAGS={- join(' ', @{$config{CFLAGS}}) -}
175 LD={- $config{LD} -}
176 LDFLAGS={- join(' ', @{$config{LDFLAGS}}) -}
177 EX_LIBS={- join(' ', @{$config{LDLIBS}}) -}
178
179 PERL={- $config{perl} -}
180
181 AR={- $config{AR} -}
182 ARFLAGS= {- join(' ', @{$config{ARFLAGS}}) -}
183
184 MT={- $config{MT} -}
185 MTFLAGS= {- join(' ', @{$config{MTFLAGS}}) -}
186
187 AS={- $config{AS} -}
188 ASFLAGS={- join(' ', @{$config{ASFLAGS}}) -}
189
190 RC={- $config{RC} -}
191
192 ##### Special command flags ##########################################
193
194 COUTFLAG={- $target{coutflag} -}$(OSSL_EMPTY)
195 LDOUTFLAG={- $target{ldoutflag} -}$(OSSL_EMPTY)
196 AROUTFLAG={- $target{aroutflag} -}$(OSSL_EMPTY)
197 MTINFLAG={- $target{mtinflag} -}$(OSSL_EMPTY)
198 MTOUTFLAG={- $target{mtoutflag} -}$(OSSL_EMPTY)
199 ASOUTFLAG={- $target{asoutflag} -}$(OSSL_EMPTY)
200 RCOUTFLAG={- $target{rcoutflag} -}$(OSSL_EMPTY)
201
202 ##### Project flags ##################################################
203
204 # Variables starting with CNF_ are common variables for all product types
205
206 CNF_ASFLAGS={- join(' ', $target{asflags} || (),
207                          @{$config{asflags}}) -}
208 CNF_CPPFLAGS={- our $cppfags2 =
209                     join(' ', $target{cppflags} || (),
210                               (map { quotify_l("-D".$_) } @{$target{defines}},
211                                                           @{$config{defines}}),
212                               (map { quotify_l("-I".$_) } @{$target{includes}},
213                                                           @{$config{includes}}),
214                               @{$config{cppflags}}) -}
215 CNF_CFLAGS={- join(' ', $target{cflags} || (),
216                         @{$config{cflags}}) -}
217 CNF_CXXFLAGS={- join(' ', $target{cxxflags} || (),
218                           @{$config{cxxflags}}) -}
219 CNF_LDFLAGS={- join(' ', $target{lflags} || (),
220                          @{$config{lflags}}) -}
221 CNF_EX_LIBS={- join(' ', $target{ex_libs} || (),
222                          @{$config{ex_libs}}) -}
223
224 # Variables starting with LIB_ are used to build library object files
225 # and shared libraries.
226 # Variables starting with DSO_ are used to build DSOs and their object files.
227 # Variables starting with BIN_ are used to build programs and their object
228 # files.
229
230 LIB_ASFLAGS={- join(' ', $target{lib_asflags} || (),
231                          @{$config{lib_asflags}},
232                          '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
233 LIB_CPPFLAGS={- our $lib_cppflags =
234                 join(' ', $target{lib_cppflags} || (),
235                           $target{shared_cppflag} || (),
236                           (map { quotify_l("-D".$_) }
237                                @{$target{lib_defines}},
238                                @{$target{shared_defines}},
239                                @{$config{lib_defines}},
240                                @{$config{shared_defines}}),
241                           (map { quotify_l("-I".$_) }
242                                @{$target{lib_includes}},
243                                @{$target{shared_includes}},
244                                @{$config{lib_includes}},
245                                @{$config{shared_includes}}),
246                           @{$config{lib_cppflags}},
247                           @{$config{shared_cppflag}});
248                 join(' ', $lib_cppflags,
249                           (map { quotify_l("-D".$_) }
250                                "OPENSSLDIR=\"$openssldir\"",
251                                "ENGINESDIR=\"$enginesdir\""),
252                           '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
253 LIB_CFLAGS={- join(' ', $target{lib_cflags} || (),
254                         $target{shared_cflag} || (),
255                         @{$config{lib_cflags}},
256                         @{$config{shared_cflag}},
257                         '$(CNF_CFLAGS)', '$(CFLAGS)') -}
258 LIB_LDFLAGS={- join(' ', $target{shared_ldflag} || (),
259                          $config{shared_ldflag} || (),
260                          '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
261 LIB_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
262 DSO_ASFLAGS={- join(' ', $target{dso_asflags} || (),
263                          $target{module_asflags} || (),
264                          @{$config{dso_asflags}},
265                          @{$config{module_asflags}},
266                          '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
267 DSO_CPPFLAGS={- join(' ', $target{dso_cppflags} || (),
268                           $target{module_cppflags} || (),
269                           @{$config{dso_cppflags}},
270                           @{$config{module_cppflags}},
271                           '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
272 DSO_CFLAGS={- join(' ', $target{dso_cflags} || (),
273                         $target{module_cflags} || (),
274                         @{$config{dso_cflags}},
275                         @{$config{module_cflags}},
276                         '$(CNF_CFLAGS)', '$(CFLAGS)') -}
277 DSO_LDFLAGS={- join(' ', $target{dso_lflags} || (),
278                          $target{module_ldflags} || (),
279                          @{$config{dso_lflags}},
280                          @{$config{module_ldflags}},
281                          '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
282 DSO_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
283 BIN_ASFLAGS={- join(' ', $target{bin_asflags} || (),
284                          @{$config{bin_asflags}},
285                          '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
286 BIN_CPPFLAGS={- join(' ', $target{bin_cppflags} || (),
287                           @{$config{bin_cppflags}},
288                           '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
289 BIN_CFLAGS={- join(' ', $target{bin_cflags} || (),
290                         @{$config{bin_cflags}},
291                         '$(CNF_CFLAGS)', '$(CFLAGS)') -}
292 BIN_LDFLAGS={- join(' ', $target{bin_lflags} || (),
293                          @{$config{bin_lflags}},
294                          '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
295 BIN_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
296
297 # CPPFLAGS_Q is used for one thing only: to build up buildinf.h
298 CPPFLAGS_Q={- $cppflags1 =~ s|([\\"])|\\$1|g;
299               $cppflags2 =~ s|([\\"])|\\$1|g;
300               join(' ', $lib_cppflags || (), $cppflags2 || (),
301                         $cppflags1 || ()) -}
302
303 PERLASM_SCHEME= {- $target{perlasm_scheme} -}
304
305 PROCESSOR= {- $config{processor} -}
306
307 # The main targets ###################################################
308
309 {- dependmagic('all'); -}: build_libs_nodep build_engines_nodep build_programs_nodep
310 {- dependmagic('build_libs'); -}: build_libs_nodep
311 {- dependmagic('build_engines'); -}: build_engines_nodep
312 {- dependmagic('build_programs'); -}: build_programs_nodep
313
314 build_generated: $(GENERATED_MANDATORY)
315 build_libs_nodep: $(LIBS) {- join(" ",map { shlib_import($_) } @{$unified_info{libraries}}) -}
316 build_engines_nodep: $(ENGINES)
317 build_programs_nodep: $(PROGRAMS) $(SCRIPTS)
318
319 # Kept around for backward compatibility
320 build_apps build_tests: build_programs
321
322 # Convenience target to prebuild all generated files, not just the mandatory
323 # ones
324 build_all_generated: $(GENERATED_MANDATORY) $(GENERATED)
325
326 test: tests
327 {- dependmagic('tests'); -}: build_programs_nodep build_engines_nodep
328         @rem {- output_off() if $disabled{tests}; "" -}
329         -mkdir $(BLDDIR)\test\test-runs
330         set SRCTOP=$(SRCDIR)
331         set BLDTOP=$(BLDDIR)
332         set RESULT_D=$(BLDDIR)\test\test-runs
333         set PERL=$(PERL)
334         set OPENSSL_ENGINES=$(MAKEDIR)\engines
335         set OPENSSL_DEBUG_MEMORY=on
336         "$(PERL)" "$(SRCDIR)\test\run_tests.pl" $(TESTS)
337         @rem {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
338         @echo "Tests are not supported with your chosen Configure options"
339         @rem {- output_on() if !$disabled{tests}; "" -}
340
341 list-tests:
342         @rem {- output_off() if $disabled{tests}; "" -}
343         @set SRCTOP=$(SRCDIR)
344         @"$(PERL)" "$(SRCDIR)\test\run_tests.pl" list
345         @rem {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
346         @echo "Tests are not supported with your chosen Configure options"
347         @rem {- output_on() if !$disabled{tests}; "" -}
348
349 install: install_sw install_ssldirs install_docs
350
351 uninstall: uninstall_docs uninstall_sw
352
353 libclean:
354         "$(PERL)" -e "map { m/(.*)\.dll$$/; unlink glob """$$1.*"""; } @ARGV" $(SHLIBS)
355         "$(PERL)" -e "map { m/(.*)\.dll$$/; unlink glob """apps/$$1.*"""; } @ARGV" $(SHLIBS)
356         "$(PERL)" -e "map { m/(.*)\.dll$$/; unlink glob """test/$$1.*"""; } @ARGV" $(SHLIBS)
357         "$(PERL)" -e "map { m/(.*)\.dll$$/; unlink glob """fuzz/$$1.*"""; } @ARGV" $(SHLIBS)
358         -del /Q /F $(LIBS)
359         -del /Q ossl_static.pdb
360
361 clean: libclean
362         {- join("\n\t", map { "-del /Q /F $_" } @PROGRAMS) -}
363         -del /Q /F $(ENGINES)
364         -del /Q /F $(SCRIPTS)
365         -del /Q /F $(GENERATED)
366         -del /Q /S /F *.d
367         -del /Q /S /F *.obj
368         -del /Q /S /F *.pdb
369         -del /Q /F *.exp
370         -del /Q /F apps\*.exp
371         -del /Q /F engines\*.exp
372         -del /Q /S /F engines\*.ilk
373         -del /Q /S /F engines\*.lib
374         -del /Q /S /F apps\*.lib
375         -del /Q /S /F engines\*.manifest
376         -del /Q /S /F apps\*.manifest
377         -del /Q /S /F test\*.manifest
378
379 distclean: clean
380         -del /Q /F configdata.pm
381         -del /Q /F makefile
382
383 depend:
384
385 # Install helper targets #############################################
386
387 install_sw: all install_dev install_engines install_runtime
388
389 uninstall_sw: uninstall_runtime uninstall_engines uninstall_dev
390
391 install_docs: install_html_docs
392
393 uninstall_docs: uninstall_html_docs
394
395 install_ssldirs:
396         @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\certs"
397         @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\private"
398         @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\misc"
399         @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\openssl.cnf" \
400                                         "$(OPENSSLDIR)\openssl.cnf.dist"
401         @IF NOT EXIST "$(OPENSSLDIR)\openssl.cnf" \
402          "$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\openssl.cnf" \
403                                         "$(OPENSSLDIR)\openssl.cnf"
404         @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(MISC_SCRIPTS) \
405                                         "$(OPENSSLDIR)\misc"
406         @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\ct_log_list.cnf" \
407                                         "$(OPENSSLDIR)\ct_log_list.cnf.dist"
408         @IF NOT EXIST "$(OPENSSLDIR)\ct_log_list.cnf" \
409          "$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\ct_log_list.cnf" \
410                                         "$(OPENSSLDIR)\ct_log_list.cnf"
411
412 install_dev:
413         @if "$(INSTALLTOP)"=="" ( echo INSTALLTOP should not be empty & exit 1 )
414         @echo *** Installing development files
415         @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\include\openssl"
416         @rem {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$config{defines}}; "" -}
417         @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\ms\applink.c" \
418                                        "$(INSTALLTOP)\include\openssl"
419         @rem {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$config{defines}}; "" -}
420         @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\include\openssl\*.h" \
421                                        "$(INSTALLTOP)\include\openssl"
422         @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BLDDIR)\include\openssl\*.h \
423                                        "$(INSTALLTOP)\include\openssl"
424         @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(libdir)"
425         @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_LIBS) "$(libdir)"
426         @if "$(SHLIBS)"=="" \
427          "$(PERL)" "$(SRCDIR)\util\copy.pl" ossl_static.pdb "$(libdir)"
428
429 uninstall_dev:
430
431 install_engines:
432         @if "$(INSTALLTOP)"=="" ( echo INSTALLTOP should not be empty & exit 1 )
433         @echo *** Installing engines
434         @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(ENGINESDIR)"
435         @if not "$(ENGINES)"=="" \
436          "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINES) "$(ENGINESDIR)"
437         @if not "$(ENGINES)"=="" \
438          "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINEPDBS) "$(ENGINESDIR)"
439
440 uninstall_engines:
441
442 install_runtime:
443         @if "$(INSTALLTOP)"=="" ( echo INSTALLTOP should not be empty & exit 1 )
444         @echo *** Installing runtime files
445         @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\bin"
446         @if not "$(SHLIBS)"=="" \
447          "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_SHLIBS) "$(INSTALLTOP)\bin"
448         @if not "$(SHLIBS)"=="" \
449          "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_SHLIBPDBS) \
450                                         "$(INSTALLTOP)\bin"
451         @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMS) \
452                                         "$(INSTALLTOP)\bin"
453         @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMPDBS) \
454                                         "$(INSTALLTOP)\bin"
455         @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BIN_SCRIPTS) \
456                                         "$(INSTALLTOP)\bin"
457
458 uninstall_runtime:
459
460 install_html_docs:
461         "$(PERL)" "$(SRCDIR)\util\process_docs.pl" \
462                 "--destdir=$(INSTALLTOP)\html" --type=html
463
464 uninstall_html_docs:
465
466 # Building targets ###################################################
467
468 configdata.pm: "$(SRCDIR)\Configure" {- join(" ", map { '"'.$_.'"' } @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
469         @echo "Detected changed: $?"
470         "$(PERL)" configdata.pm -r
471         @echo "**************************************************"
472         @echo "***                                            ***"
473         @echo "***   Please run the same make command again   ***"
474         @echo "***                                            ***"
475         @echo "**************************************************"
476         @exit 1
477
478 reconfigure reconf:
479         "$(PERL)" configdata.pm -r
480
481 {-
482  use File::Basename;
483  use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
484
485  # Helper function to figure out dependencies on libraries
486  # It takes a list of library names and outputs a list of dependencies
487  sub compute_lib_depends {
488      if ($disabled{shared}) {
489          return map { lib($_) } @_;
490      }
491      foreach (@_) {
492          (my $l = $_) =~ s/\.a$//;
493          die "Linking with static variants of shared libraries is not supported in this configuration\n"
494              if $l ne $_ && shlib($l);
495      }
496      return map { shlib_import($_) or lib($_) } @_;
497  }
498
499   sub generatesrc {
500       my %args = @_;
501       (my $target = $args{src}) =~ s/\.[sS]$/.asm/;
502       my ($gen0, @gens) = @{$args{generator}};
503       my $generator = '"'.$gen0.'"'.join('', map { " $_" } @gens);
504       my $generator_incs = join("", map { " -I \"$_\"" } @{$args{generator_incs}});
505       my $incs = join("", map { " /I \"$_\"" } @{$args{incs}});
506       my $deps = @{$args{deps}} ?
507           '"'.join('" "', @{$args{generator_deps}}, @{$args{deps}}).'"' : '';
508
509       if ($target !~ /\.asm$/) {
510           if ($args{generator}->[0] =~ m|^.*\.in$|) {
511               my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
512                                                    "util", "dofile.pl")),
513                                    rel2abs($config{builddir}));
514               return <<"EOF";
515 $target: "$args{generator}->[0]" $deps
516         "\$(PERL)" "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
517             "-o$target{build_file}" $generator > \$@
518 EOF
519           } else {
520               return <<"EOF";
521 $target: "$args{generator}->[0]" $deps
522         "\$(PERL)"$generator_incs $generator > \$@
523 EOF
524           }
525       } else {
526           if ($args{generator}->[0] =~ /\.pl$/) {
527               $generator = '"$(PERL)"'.$generator_incs.' '.$generator;
528           } elsif ($args{generator}->[0] =~ /\.S$/) {
529               $generator = undef;
530           } else {
531               die "Generator type for $src unknown: $generator\n";
532           }
533
534           my $cppflags = $incs;
535           $cppflags .= {
536               lib => ' $(LIB_CFLAGS) $(LIB_CPPFLAGS)',
537               dso => ' $(DSO_CFLAGS) $(DSO_CPPFLAGS)',
538               bin => ' $(BIN_CFLAGS) $(BIN_CPPFLAGS)'
539           } -> {$args{intent}};
540           if (defined($generator)) {
541               # If the target is named foo.S in build.info, we want to
542               # end up generating foo.s in two steps.
543               if ($args{src} =~ /\.S$/) {
544                    return <<"EOF";
545 $target: "$args{generator}->[0]" $deps
546         set ASM=\$(AS)
547         $generator \$@.S
548         \$(CPP) $cppflags \$@.S > \$@.i && move /Y \$@.i \$@
549         del /Q \$@.S
550 EOF
551               }
552               # Otherwise....
553               return <<"EOF";
554 $target: "$args{generator}->[0]" $deps
555         set ASM=\$(AS)
556         $generator \$@
557 EOF
558           }
559           return <<"EOF";
560 $target: "$args{generator}->[0]" $deps
561         \$(CPP) $incs $cppflags "$args{generator}->[0]" > \$@.i && move /Y \$@.i \$@
562 EOF
563       }
564   }
565
566  sub src2obj {
567      my %args = @_;
568      my @srcs = map { (my $x = $_) =~ s/\.s$/.asm/; $x
569                     } ( @{$args{srcs}} );
570      my $srcs = '"'.join('" "',  @srcs).'"';
571      my $deps = '"'.join('" "', @srcs, @{$args{deps}}).'"';
572      my $incs = join("", map { ' /I "'.$_.'"' } @{$args{incs}});
573      my $cflags = { lib => ' $(LIB_CFLAGS)',
574                     dso => ' $(DSO_CFLAGS)',
575                     bin => ' $(BIN_CFLAGS)' } -> {$args{intent}};
576      $cflags .= $incs;
577      $cflags .= { lib => ' $(LIB_CPPFLAGS)',
578                   dso => ' $(DSO_CPPFLAGS)',
579                   bin => ' $(BIN_CPPFLAGS)' } -> {$args{intent}};
580      my $asflags = { lib => ' $(LIB_ASFLAGS)',
581                      dso => ' $(DSO_ASFLAGS)',
582                      bin => ' $(BIN_ASFLAGS)' } -> {$args{intent}};
583      my $makedepprog = $config{makedepprog};
584      if ($srcs[0] =~ /\.rc$/) {
585          return <<"EOF";
586 $args{obj}: $deps
587         \$(RC) \$(RCOUTFLAG)\$\@ $srcs
588 EOF
589      }
590      (my $obj = $args{obj}) =~ s|\.o$||;
591      if ($srcs[0] =~ /\.asm$/) {
592          return <<"EOF";
593 $obj$objext: $deps
594         \$(AS) $asflags \$(ASOUTFLAG)\$\@ $srcs
595 EOF
596      }
597      return <<"EOF"     if (!$disabled{makedepend});
598 $obj$depext: $deps
599         \$(CC) $cflags /Zs /showIncludes $srcs 2>&1 | \\
600             "\$(PERL)" -n << > $obj$depext
601 chomp;
602 s/^Note: including file: *//;
603 \$\$collect{\$\$_} = 1;
604 END { print '$obj$objext: ',join(" ", sort keys \%collect),"\\n" }
605 <<
606 $obj$objext: $obj$depext
607         \$(CC) $cflags -c \$(COUTFLAG)\$\@ @<<
608 $srcs
609 <<
610 EOF
611     return <<"EOF"      if ($disabled{makedepend});
612 $obj$objext: $deps
613         \$(CC) $cflags -c \$(COUTFLAG)\$\@ $srcs
614 EOF
615  }
616
617  # On Unix, we build shlibs from static libs, so we're ignoring the
618  # object file array.  We *know* this routine is only called when we've
619  # configure 'shared'.
620  sub libobj2shlib {
621      my %args = @_;
622      my $lib = $args{lib};
623      my $shlib = $args{shlib};
624      my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x }
625                 grep { $_ =~ m/\.(?:o|res)$/ }
626                 @{$args{objs}};
627      my @defs = grep { $_ =~ /\.def$/ } @{$args{objs}};
628      my @deps = compute_lib_depends(@{$args{deps}});
629      die "More than one exported symbols list" if scalar @defs > 1;
630      my $linklibs = join("", map { "$_\n" } @deps);
631      my $objs = join("\n", @objs);
632      my $deps = join(" ", @objs, @defs, @deps);
633      my $target = shlib_import($lib);
634      my $shared_def = join("", map { " /def:$_" } @defs);
635      return <<"EOF"
636 $target: $deps
637         IF EXIST $shlib$shlibext.manifest DEL /F /Q $shlib$shlibext.manifest
638         \$(LD) \$(LDFLAGS) \$(LIB_LDFLAGS) \\
639                 /implib:\$@ \$(LDOUTFLAG)$shlib$shlibext$shared_def @<< || (DEL /Q \$(\@B).* $shlib.* && EXIT 1)
640 $objs
641 $linklibs\$(LIB_EX_LIBS)
642 <<
643         IF EXIST $shlib$shlibext.manifest \\
644            \$(MT) \$(MTFLAGS) \$(MTINFLAG)$shlib$shlibext.manifest \$(MTOUTFLAG)$shlib$shlibext
645         IF EXIST apps\\$shlib$shlibext DEL /Q /F apps\\$shlib$shlibext
646         IF EXIST test\\$shlib$shlibext DEL /Q /F test\\$shlib$shlibext
647         IF EXIST fuzz\\$shlib$shlibext DEL /Q /F fuzz\\$shlib$shlibext
648         COPY $shlib$shlibext apps
649         COPY $shlib$shlibext test
650         COPY $shlib$shlibext fuzz
651 EOF
652  }
653  sub obj2dso {
654      my %args = @_;
655      my $dso = $args{lib};
656      my $dso_n = basename($dso);
657      my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
658      my @deps = compute_lib_depends(@{$args{deps}});
659      my $objs = join("\n", @objs);
660      my $linklibs = join("", map { "$_\n" } @deps);
661      my $deps = join(" ", @objs, @deps);
662      return <<"EOF";
663 $dso$dsoext: $deps
664         IF EXIST $dso$dsoext.manifest DEL /F /Q $dso$dsoext.manifest
665         \$(LD) \$(LDFLAGS) \$(DSO_LDFLAGS) \$(LDOUTFLAG)$dso$dsoext /def:<< @<<
666 LIBRARY         $dso_n
667 EXPORTS
668     bind_engine         @1
669     v_check             @2
670 <<
671 $objs
672 $linklibs \$(DSO_EX_LIBS)
673 <<
674         IF EXIST $dso$dsoext.manifest \\
675            \$(MT) \$(MTFLAGS) \$(MTINFLAG)$dso$dsoext.manifest \$(MTOUTFLAG)$dso$dsoext
676 EOF
677  }
678  sub obj2lib {
679      my %args = @_;
680      my $lib = $args{lib};
681
682      # Because static libs and import libs are both named the same in native
683      # Windows, we can't have both.  We skip the static lib in that case,
684      # as the shared libs are what we use anyway.
685      return "" unless $disabled{"shared"} || $lib =~ /\.a$/;
686
687      $lib =~ s/\.a$//;
688      my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
689      my $objs = join("\n", @objs);
690      my $deps = join(" ", @objs);
691      return <<"EOF";
692 $lib$libext: $deps
693         \$(AR) \$(ARFLAGS) \$(AROUTFLAG)$lib$libext @<<
694 $objs
695 <<
696 EOF
697  }
698  sub obj2bin {
699      my %args = @_;
700      my $bin = $args{bin};
701      my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
702      my @deps = compute_lib_depends(@{$args{deps}});
703      my $objs = join("\n", @objs);
704      my $linklibs = join("", map { "$_\n" } @deps);
705      my $deps = join(" ", @objs, @deps);
706      return <<"EOF";
707 $bin$exeext: $deps
708         IF EXIST $bin$exeext.manifest DEL /F /Q $bin$exeext.manifest
709         \$(LD) \$(LDFLAGS) \$(BIN_LDFLAGS) \$(LDOUTFLAG)$bin$exeext @<<
710 $objs
711 setargv.obj
712 $linklibs\$(BIN_EX_LIBS)
713 <<
714         IF EXIST $bin$exeext.manifest \\
715            \$(MT) \$(MTFLAGS) \$(MTINFLAG)$bin$exeext.manifest \$(MTOUTFLAG)$bin$exeext
716 EOF
717   }
718   sub in2script {
719       my %args = @_;
720       my $script = $args{script};
721       my $sources = '"'.join('" "', @{$args{sources}}).'"';
722       my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
723                                            "util", "dofile.pl")),
724                            rel2abs($config{builddir}));
725       return <<"EOF";
726 $script: $sources
727         "\$(PERL)" "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
728             "-o$target{build_file}" $sources > "$script"
729 EOF
730   }
731   sub generatedir {
732       my %args = @_;
733       my $dir = $args{dir};
734       my @deps = map { s|\.o$|$objext|; $_ } @{$args{deps}};
735       my @actions = ();
736       my %extinfo = ( dso => $dsoext,
737                       lib => $libext,
738                       bin => $exeext );
739
740       foreach my $type (("dso", "lib", "bin", "script")) {
741           next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type});
742           # For lib object files, we could update the library.  However,
743           # LIB on Windows doesn't work that way, so we won't create any
744           # actions for it, and the dependencies are already taken care of.
745           if ($type ne "lib") {
746               foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) {
747                   if (dirname($prod) eq $dir) {
748                       push @deps, $prod.$extinfo{$type};
749                   } else {
750                       push @actions, "\t@rem No support to produce $type ".join(", ", @{$unified_info{dirinfo}->{$dir}->{products}->{$type}});
751                   }
752               }
753           }
754       }
755
756       my $deps = join(" ", @deps);
757       my $actions = join("\n", "", @actions);
758       return <<"EOF";
759 $args{dir} $args{dir}\\ : $deps$actions
760 EOF
761   }
762   ""    # Important!  This becomes part of the template result.
763 -}