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