Rename the rand_drbg_st data member "pool" to "seed_pool"
[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      $lib .= '_static'
44          if (defined $unified_info{sharednames}->{$lib});
45      return $lib . $libext;
46  }
47
48  sub shlib_import {
49      my $lib = shift;
50      return () if $disabled{shared} || $lib =~ /\.a$/;
51      return $lib . $shlibextimport;
52  }
53
54  sub dso {
55      my $dso = shift;
56
57      return $dso . $dsoext;
58  }
59  # This makes sure things get built in the order they need
60  # to. You're welcome.
61  sub dependmagic {
62      my $target = shift;
63
64      return "$target: build_generated\n\t\$(MAKE) /\$(MAKEFLAGS) depend && \$(MAKE) /\$(MAKEFLAGS) _$target\n_$target";
65  }
66  '';
67 -}
68
69 PLATFORM={- $config{target} -}
70 SRCDIR={- $config{sourcedir} -}
71 BLDDIR={- $config{builddir} -}
72
73 VERSION={- $config{version} -}
74 MAJOR={- $config{major} -}
75 MINOR={- $config{minor} -}
76
77 SHLIB_VERSION_NUMBER={- $config{shlib_version_number} -}
78
79 LIBS={- join(" ", map { ( shlib_import($_), lib($_) ) } @{$unified_info{libraries}}) -}
80 SHLIBS={- join(" ", map { shlib($_) } @{$unified_info{libraries}}) -}
81 SHLIBPDBS={- join(" ", map { local $shlibext = ".pdb"; shlib($_) } @{$unified_info{libraries}}) -}
82 ENGINES={- join(" ", map { dso($_) } @{$unified_info{engines}}) -}
83 ENGINEPDBS={- join(" ", map { local $dsoext = ".pdb"; dso($_) } @{$unified_info{engines}}) -}
84 PROGRAMS={- our @PROGRAMS = map { $_.$exeext } @{$unified_info{programs}}; join(" ", @PROGRAMS) -}
85 PROGRAMPDBS={- join(" ", map { $_.".pdb" } @{$unified_info{programs}}) -}
86 SCRIPTS={- join(" ", @{$unified_info{scripts}}) -}
87 {- output_off() if $disabled{makedepend}; "" -}
88 DEPS={- join(" ", map { (my $x = $_) =~ s|\.o$|$depext|; $x; }
89                   grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
90                   keys %{$unified_info{sources}}); -}
91 {- output_on() if $disabled{makedepend}; "" -}
92 GENERATED_MANDATORY={- join(" ", @{$unified_info{depends}->{""}} ) -}
93 GENERATED={- # common0.tmpl provides @generated
94              join(" ", map { (my $x = $_) =~ s|\.[sS]$|.asm|; $x }
95                        @generated) -}
96
97 INSTALL_LIBS={- join(" ", map { quotify1(shlib_import($_) or lib($_)) } @{$unified_info{install}->{libraries}}) -}
98 INSTALL_SHLIBS={- join(" ", map { quotify_l(shlib($_)) } @{$unified_info{install}->{libraries}}) -}
99 INSTALL_SHLIBPDBS={- join(" ", map { local $shlibext = ".pdb"; quotify_l(shlib($_)) } @{$unified_info{install}->{libraries}}) -}
100 INSTALL_ENGINES={- join(" ", map { quotify1(dso($_)) } @{$unified_info{install}->{engines}}) -}
101 INSTALL_ENGINEPDBS={- join(" ", map { local $dsoext = ".pdb"; quotify1(dso($_)) } @{$unified_info{install}->{engines}}) -}
102 INSTALL_PROGRAMS={- join(" ", map { quotify1($_.$exeext) } grep { !m|^test\\| } @{$unified_info{install}->{programs}}) -}
103 INSTALL_PROGRAMPDBS={- join(" ", map { quotify1($_.".pdb") } grep { !m|^test\\| } @{$unified_info{install}->{programs}}) -}
104 {- output_off() if $disabled{apps}; "" -}
105 BIN_SCRIPTS="$(BLDDIR)\tools\c_rehash.pl"
106 MISC_SCRIPTS="$(BLDDIR)\apps\CA.pl" "$(BLDDIR)\apps\tsget.pl"
107 {- output_on() if $disabled{apps}; "" -}
108
109 APPS_OPENSSL={- use File::Spec::Functions;
110                 "\"".catfile("apps","openssl")."\"" -}
111
112 # Do not edit these manually. Use Configure with --prefix or --openssldir
113 # to change this!  Short explanation in the top comment in Configure
114 INSTALLTOP_dev={- # $prefix is used in the OPENSSLDIR perl snippet
115                   #
116                   use File::Spec::Functions qw(:DEFAULT splitpath);
117                   our $prefix = canonpath($config{prefix}
118                                           || "$win_installroot\\OpenSSL");
119                   our ($prefix_dev, $prefix_dir, $prefix_file) =
120                       splitpath($prefix, 1);
121                   $prefix_dev -}
122 INSTALLTOP_dir={- canonpath($prefix_dir) -}
123 OPENSSLDIR_dev={- #
124                   # The logic here is that if no --openssldir was given,
125                   # OPENSSLDIR will get the value "$win_commonroot\\SSL".
126                   # If --openssldir was given and the value is an absolute
127                   # path, OPENSSLDIR will get its value without change.
128                   # If the value from --openssldir is a relative path,
129                   # OPENSSLDIR will get $prefix with the --openssldir
130                   # value appended as a subdirectory.
131                   #
132                   use File::Spec::Functions qw(:DEFAULT splitpath);
133                   our $openssldir =
134                       $config{openssldir} ?
135                           (file_name_is_absolute($config{openssldir}) ?
136                                canonpath($config{openssldir})
137                                : catdir($prefix, $config{openssldir}))
138                           : canonpath("$win_commonroot\\SSL");
139                   our ($openssldir_dev, $openssldir_dir, $openssldir_file) =
140                       splitpath($openssldir, 1);
141                   $openssldir_dev -}
142 OPENSSLDIR_dir={- canonpath($openssldir_dir) -}
143 LIBDIR={- our $libdir = $config{libdir} || "lib";
144           file_name_is_absolute($libdir) ? "" : $libdir -}
145 ENGINESDIR_dev={- use File::Spec::Functions qw(:DEFAULT splitpath);
146                   our $enginesdir = catdir($prefix,$libdir,"engines-$sover_dirname");
147                   our ($enginesdir_dev, $enginesdir_dir, $enginesdir_file) =
148                       splitpath($enginesdir, 1);
149                   $enginesdir_dev -}
150 ENGINESDIR_dir={- canonpath($enginesdir_dir) -}
151 !IF "$(DESTDIR)" != ""
152 INSTALLTOP=$(DESTDIR)$(INSTALLTOP_dir)
153 OPENSSLDIR=$(DESTDIR)$(OPENSSLDIR_dir)
154 ENGINESDIR=$(DESTDIR)$(ENGINESDIR_dir)
155 !ELSE
156 INSTALLTOP=$(INSTALLTOP_dev)$(INSTALLTOP_dir)
157 OPENSSLDIR=$(OPENSSLDIR_dev)$(OPENSSLDIR_dir)
158 ENGINESDIR=$(ENGINESDIR_dev)$(ENGINESDIR_dir)
159 !ENDIF
160
161 # $(libdir) is chosen to be compatible with the GNU coding standards
162 libdir={- file_name_is_absolute($libdir)
163           ? $libdir : '$(INSTALLTOP)\$(LIBDIR)' -}
164
165 ##### User defined commands and flags ################################
166
167 CC={- $config{CC} -}
168 CPP={- $config{CPP} -}
169 CPPFLAGS={- our $cppflags1 = join(" ",
170                                   (map { "-D".$_} @{$config{CPPDEFINES}}),
171                                   (map { " /I ".$_} @{$config{CPPINCLUDES}}),
172                                   @{$config{CPPFLAGS}}) -}
173 CFLAGS={- join(' ', @{$config{CFLAGS}}) -}
174 LD={- $config{LD} -}
175 LDFLAGS={- join(' ', @{$config{LDFLAGS}}) -}
176 EX_LIBS={- join(' ', @{$config{LDLIBS}}) -}
177
178 PERL={- $config{PERL} -}
179
180 AR={- $config{AR} -}
181 ARFLAGS= {- join(' ', @{$config{ARFLAGS}}) -}
182
183 MT={- $config{MT} -}
184 MTFLAGS= {- join(' ', @{$config{MTFLAGS}}) -}
185
186 AS={- $config{AS} -}
187 ASFLAGS={- join(' ', @{$config{ASFLAGS}}) -}
188
189 RC={- $config{RC} -}
190
191 ECHO="$(PERL)" "$(SRCDIR)\util\echo.pl"
192
193 ##### Special command flags ##########################################
194
195 COUTFLAG={- $target{coutflag} -}$(OSSL_EMPTY)
196 LDOUTFLAG={- $target{ldoutflag} -}$(OSSL_EMPTY)
197 AROUTFLAG={- $target{aroutflag} -}$(OSSL_EMPTY)
198 MTINFLAG={- $target{mtinflag} -}$(OSSL_EMPTY)
199 MTOUTFLAG={- $target{mtoutflag} -}$(OSSL_EMPTY)
200 ASOUTFLAG={- $target{asoutflag} -}$(OSSL_EMPTY)
201 RCOUTFLAG={- $target{rcoutflag} -}$(OSSL_EMPTY)
202
203 ##### Project flags ##################################################
204
205 # Variables starting with CNF_ are common variables for all product types
206
207 CNF_ASFLAGS={- join(' ', $target{asflags} || (),
208                          @{$config{asflags}}) -}
209 CNF_CPPFLAGS={- our $cppfags2 =
210                     join(' ', $target{cppflags} || (),
211                               (map { '-D'.quotify1($_) } @{$target{defines}},
212                                                          @{$config{defines}}),
213                               (map { '-I'.quotify1($_) } @{$target{includes}},
214                                                          @{$config{includes}}),
215                               @{$config{cppflags}}) -}
216 CNF_CFLAGS={- join(' ', $target{cflags} || (),
217                         @{$config{cflags}}) -}
218 CNF_CXXFLAGS={- join(' ', $target{cxxflags} || (),
219                           @{$config{cxxflags}}) -}
220 CNF_LDFLAGS={- join(' ', $target{lflags} || (),
221                          @{$config{lflags}}) -}
222 CNF_EX_LIBS={- join(' ', $target{ex_libs} || (),
223                          @{$config{ex_libs}}) -}
224
225 # Variables starting with LIB_ are used to build library object files
226 # and shared libraries.
227 # Variables starting with DSO_ are used to build DSOs and their object files.
228 # Variables starting with BIN_ are used to build programs and their object
229 # files.
230
231 LIB_ASFLAGS={- join(' ', $target{lib_asflags} || (),
232                          @{$config{lib_asflags}},
233                          '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
234 LIB_CPPFLAGS={- our $lib_cppflags =
235                 join(' ', $target{lib_cppflags} || (),
236                           $target{shared_cppflag} || (),
237                           (map { '-D'.quotify1($_) }
238                                @{$target{lib_defines}},
239                                @{$target{shared_defines}},
240                                @{$config{lib_defines}},
241                                @{$config{shared_defines}}),
242                           (map { '-I'.quotify1($_) }
243                                @{$target{lib_includes}},
244                                @{$target{shared_includes}},
245                                @{$config{lib_includes}},
246                                @{$config{shared_includes}}),
247                           @{$config{lib_cppflags}},
248                           @{$config{shared_cppflag}});
249                 join(' ', $lib_cppflags,
250                           (map { '-D'.quotify1($_) }
251                                "OPENSSLDIR=\"$openssldir\"",
252                                "ENGINESDIR=\"$enginesdir\""),
253                           '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
254 LIB_CFLAGS={- join(' ', $target{lib_cflags} || (),
255                         $target{shared_cflag} || (),
256                         @{$config{lib_cflags}},
257                         @{$config{shared_cflag}},
258                         '$(CNF_CFLAGS)', '$(CFLAGS)') -}
259 LIB_LDFLAGS={- join(' ', $target{shared_ldflag} || (),
260                          $config{shared_ldflag} || (),
261                          '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
262 LIB_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
263 DSO_ASFLAGS={- join(' ', $target{dso_asflags} || (),
264                          $target{module_asflags} || (),
265                          @{$config{dso_asflags}},
266                          @{$config{module_asflags}},
267                          '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
268 DSO_CPPFLAGS={- join(' ', $target{dso_cppflags} || (),
269                           $target{module_cppflags} || (),
270                           @{$config{dso_cppflags}},
271                           @{$config{module_cppflags}},
272                           '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
273 DSO_CFLAGS={- join(' ', $target{dso_cflags} || (),
274                         $target{module_cflags} || (),
275                         @{$config{dso_cflags}},
276                         @{$config{module_cflags}},
277                         '$(CNF_CFLAGS)', '$(CFLAGS)') -}
278 DSO_LDFLAGS={- join(' ', $target{dso_lflags} || (),
279                          $target{module_ldflags} || (),
280                          @{$config{dso_lflags}},
281                          @{$config{module_ldflags}},
282                          '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
283 DSO_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
284 BIN_ASFLAGS={- join(' ', $target{bin_asflags} || (),
285                          @{$config{bin_asflags}},
286                          '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
287 BIN_CPPFLAGS={- join(' ', $target{bin_cppflags} || (),
288                           @{$config{bin_cppflags}},
289                           '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
290 BIN_CFLAGS={- join(' ', $target{bin_cflags} || (),
291                         @{$config{bin_cflags}},
292                         '$(CNF_CFLAGS)', '$(CFLAGS)') -}
293 BIN_LDFLAGS={- join(' ', $target{bin_lflags} || (),
294                          @{$config{bin_lflags}},
295                          '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
296 BIN_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
297
298 # CPPFLAGS_Q is used for one thing only: to build up buildinf.h
299 CPPFLAGS_Q={- $cppflags1 =~ s|([\\"])|\\$1|g;
300               $cppflags2 =~ s|([\\"])|\\$1|g;
301               join(' ', $lib_cppflags || (), $cppflags2 || (),
302                         $cppflags1 || ()) -}
303
304 PERLASM_SCHEME= {- $target{perlasm_scheme} -}
305
306 PROCESSOR= {- $config{processor} -}
307
308 # The main targets ###################################################
309
310 {- dependmagic('all'); -}: build_libs_nodep build_engines_nodep build_programs_nodep
311 {- dependmagic('build_libs'); -}: build_libs_nodep
312 {- dependmagic('build_engines'); -}: build_engines_nodep
313 {- dependmagic('build_programs'); -}: build_programs_nodep
314
315 build_generated: $(GENERATED_MANDATORY)
316 build_libs_nodep: $(LIBS) {- join(" ",map { shlib_import($_) } @{$unified_info{libraries}}) -}
317 build_engines_nodep: $(ENGINES)
318 build_programs_nodep: $(PROGRAMS) $(SCRIPTS)
319
320 # Kept around for backward compatibility
321 build_apps build_tests: build_programs
322
323 # Convenience target to prebuild all generated files, not just the mandatory
324 # ones
325 build_all_generated: $(GENERATED_MANDATORY) $(GENERATED)
326         @{- output_off() if $disabled{makedepend}; "" -}
327         @$(ECHO) "Warning: consider configuring with no-makedepend, because if"
328         @$(ECHO) "         target system doesn't have $(PERL),"
329         @$(ECHO) "         then make will fail..."
330         @{- output_on() if $disabled{makedepend}; "" -}
331
332 test: tests
333 {- dependmagic('tests'); -}: build_programs_nodep build_engines_nodep
334         @{- output_off() if $disabled{tests}; "" -}
335         -mkdir $(BLDDIR)\test\test-runs
336         set SRCTOP=$(SRCDIR)
337         set BLDTOP=$(BLDDIR)
338         set RESULT_D=$(BLDDIR)\test\test-runs
339         set PERL=$(PERL)
340         set OPENSSL_ENGINES=$(MAKEDIR)\engines
341         set OPENSSL_DEBUG_MEMORY=on
342         "$(PERL)" "$(SRCDIR)\test\run_tests.pl" $(TESTS)
343         @{- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
344         @$(ECHO) "Tests are not supported with your chosen Configure options"
345         @{- output_on() if !$disabled{tests}; "" -}
346
347 list-tests:
348         @{- output_off() if $disabled{tests}; "" -}
349         @set SRCTOP=$(SRCDIR)
350         @"$(PERL)" "$(SRCDIR)\test\run_tests.pl" list
351         @{- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
352         @$(ECHO) "Tests are not supported with your chosen Configure options"
353         @{- output_on() if !$disabled{tests}; "" -}
354
355 install: install_sw install_ssldirs install_docs
356
357 uninstall: uninstall_docs uninstall_sw
358
359 libclean:
360         "$(PERL)" -e "map { m/(.*)\.dll$$/; unlink glob """{.,apps,test,fuzz}/$$1.*"""; } @ARGV" $(SHLIBS)
361         -del /Q /F $(LIBS) libcrypto.* libssl.* ossl_static.pdb
362
363 clean: libclean
364         {- join("\n\t", map { "-del /Q /F $_" } @PROGRAMS) -}
365         -del /Q /F $(ENGINES)
366         -del /Q /F $(SCRIPTS)
367         -del /Q /F $(GENERATED_MANDATORY)
368         -del /Q /F $(GENERATED)
369         -del /Q /S /F *.d *.obj *.pdb *.ilk *.manifest
370         -del /Q /S /F engines\*.lib engines\*.exp
371         -del /Q /S /F apps\*.lib apps\*.rc apps\*.res apps\*.exp
372         -del /Q /S /F test\*.exp
373         -rmdir /Q /S test\test-runs
374
375 distclean: clean
376         -del /Q /F configdata.pm
377         -del /Q /F makefile
378
379 depend:
380         @ {- output_off() if $disabled{makedepend}; "" -}
381         @ "$(PERL)" "$(SRCDIR)\util\add-depends.pl" "VC"
382         @ {- output_on() if $disabled{makedepend}; "" -}
383
384 # Install helper targets #############################################
385
386 install_sw: all install_dev install_engines install_runtime
387
388 uninstall_sw: uninstall_runtime uninstall_engines uninstall_dev
389
390 install_docs: install_html_docs
391
392 uninstall_docs: uninstall_html_docs
393
394 install_ssldirs:
395         @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\certs"
396         @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\private"
397         @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\misc"
398         @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\openssl.cnf" \
399                                         "$(OPENSSLDIR)\openssl.cnf.dist"
400         @IF NOT EXIST "$(OPENSSLDIR)\openssl.cnf" \
401          "$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\openssl.cnf" \
402                                         "$(OPENSSLDIR)\openssl.cnf"
403         @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(MISC_SCRIPTS) \
404                                         "$(OPENSSLDIR)\misc"
405         @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\ct_log_list.cnf" \
406                                         "$(OPENSSLDIR)\ct_log_list.cnf.dist"
407         @IF NOT EXIST "$(OPENSSLDIR)\ct_log_list.cnf" \
408          "$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\ct_log_list.cnf" \
409                                         "$(OPENSSLDIR)\ct_log_list.cnf"
410
411 install_dev:
412         @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
413         @$(ECHO) "*** Installing development files"
414         @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\include\openssl"
415         @{- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
416         @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\ms\applink.c" \
417                                        "$(INSTALLTOP)\include\openssl"
418         @{- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
419         @"$(PERL)" "$(SRCDIR)\util\copy.pl" "-exclude_re=/__DECC_" \
420                                        "$(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      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      my $recipe = <<"EOF";
598 $obj$objext: $deps
599         \$(CC) $cflags -c \$(COUTFLAG)\$\@ $srcs
600 EOF
601      $recipe .= <<"EOF" unless $disabled{makedepend};
602         \$(CC) $cflags /Zs /showIncludes $srcs 2>&1 > $obj$depext
603 EOF
604      return $recipe;
605  }
606
607  # We *know* this routine is only called when we've configure 'shared'.
608  # Also, note that even though the import library built here looks like
609  # a static library, it really isn't.
610  sub libobj2shlib {
611      my %args = @_;
612      my $lib = $args{lib};
613      my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x }
614                 grep { $_ =~ m/\.(?:o|res)$/ }
615                 @{$args{objs}};
616      my @defs = grep { $_ =~ /\.def$/ } @{$args{objs}};
617      my @deps = compute_lib_depends(@{$args{deps}});
618      die "More than one exported symbols list" if scalar @defs > 1;
619      my $linklibs = join("", map { "$_\n" } @deps);
620      my $objs = join("\n", @objs);
621      my $deps = join(" ", @objs, @defs, @deps);
622      my $import = shlib_import($lib);
623      my $dll =  shlib($lib);
624      my $shared_def = join("", map { " /def:$_" } @defs);
625      return <<"EOF"
626 # The import library may look like a static library, but it is not.
627 # We MUST make the import library depend on the DLL, in case someone
628 # mistakenly removes the latter.
629 $import: $dll
630 $dll: $deps
631         IF EXIST $full.manifest DEL /F /Q $full.manifest
632         IF EXIST \$@ DEL /F /Q \$@
633         \$(LD) \$(LDFLAGS) \$(LIB_LDFLAGS) \\
634                 /implib:$import \$(LDOUTFLAG)$dll$shared_def @<< || (DEL /Q \$(\@B).* $import && EXIT 1)
635 $objs
636 $linklibs\$(LIB_EX_LIBS)
637 <<
638         IF EXIST $dll.manifest \\
639            \$(MT) \$(MTFLAGS) \$(MTINFLAG)$dll.manifest \$(MTOUTFLAG)$dll
640         IF EXIST apps\\$dll DEL /Q /F apps\\$dll
641         IF EXIST test\\$dll DEL /Q /F test\\$dll
642         IF EXIST fuzz\\$dll DEL /Q /F fuzz\\$dll
643         COPY $dll apps
644         COPY $dll test
645         COPY $dll fuzz
646 EOF
647  }
648  sub obj2dso {
649      my %args = @_;
650      my $dso = $args{lib};
651      my $dso_n = basename($dso);
652      my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
653      my @deps = compute_lib_depends(@{$args{deps}});
654      my $objs = join("\n", @objs);
655      my $linklibs = join("", map { "$_\n" } @deps);
656      my $deps = join(" ", @objs, @deps);
657      return <<"EOF";
658 $dso$dsoext: $deps
659         IF EXIST $dso$dsoext.manifest DEL /F /Q $dso$dsoext.manifest
660         \$(LD) \$(LDFLAGS) \$(DSO_LDFLAGS) \$(LDOUTFLAG)$dso$dsoext /def:<< @<<
661 LIBRARY         $dso_n
662 EXPORTS
663     bind_engine         @1
664     v_check             @2
665 <<
666 $objs
667 $linklibs \$(DSO_EX_LIBS)
668 <<
669         IF EXIST $dso$dsoext.manifest \\
670            \$(MT) \$(MTFLAGS) \$(MTINFLAG)$dso$dsoext.manifest \$(MTOUTFLAG)$dso$dsoext
671 EOF
672  }
673  sub obj2lib {
674      my %args = @_;
675      my $lib = lib($args{lib});
676      my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
677      my $objs = join("\n", @objs);
678      my $deps = join(" ", @objs);
679      return <<"EOF";
680 $lib: $deps
681         \$(AR) \$(ARFLAGS) \$(AROUTFLAG)$lib @<<
682 $objs
683 <<
684 EOF
685  }
686  sub obj2bin {
687      my %args = @_;
688      my $bin = $args{bin};
689      my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
690      my @deps = compute_lib_depends(@{$args{deps}});
691      my $objs = join("\n", @objs);
692      my $linklibs = join("", map { "$_\n" } @deps);
693      my $deps = join(" ", @objs, @deps);
694      return <<"EOF";
695 $bin$exeext: $deps
696         IF EXIST $bin$exeext.manifest DEL /F /Q $bin$exeext.manifest
697         \$(LD) \$(LDFLAGS) \$(BIN_LDFLAGS) \$(LDOUTFLAG)$bin$exeext @<<
698 $objs
699 setargv.obj
700 $linklibs\$(BIN_EX_LIBS)
701 <<
702         IF EXIST $bin$exeext.manifest \\
703            \$(MT) \$(MTFLAGS) \$(MTINFLAG)$bin$exeext.manifest \$(MTOUTFLAG)$bin$exeext
704 EOF
705   }
706   sub in2script {
707       my %args = @_;
708       my $script = $args{script};
709       my $sources = '"'.join('" "', @{$args{sources}}).'"';
710       my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
711                                            "util", "dofile.pl")),
712                            rel2abs($config{builddir}));
713       return <<"EOF";
714 $script: $sources
715         "\$(PERL)" "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
716             "-o$target{build_file}" $sources > "$script"
717 EOF
718   }
719   sub generatedir {
720       my %args = @_;
721       my $dir = $args{dir};
722       my @deps = map { s|\.o$|$objext|; $_ } @{$args{deps}};
723       my @actions = ();
724       my %extinfo = ( dso => $dsoext,
725                       lib => $libext,
726                       bin => $exeext );
727
728       # We already have a 'test' target, and the top directory is just plain
729       # silly
730       return if $dir eq "test" || $dir eq ".";
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                   }
742               }
743           }
744       }
745
746       my $deps = join(" ", @deps);
747       my $actions = join("\n", "", @actions);
748       return <<"EOF";
749 $dir $dir\\ : $deps$actions
750 EOF
751   }
752   ""    # Important!  This becomes part of the template result.
753 -}