Build: Change all _NO_INST to use attributes instead.
[openssl.git] / Configurations / windows-makefile.tmpl
1 ##
2 ## Makefile for OpenSSL
3 ##
4 ## {- join("\n## ", @autowarntext) -}
5 {-
6  our $sover_dirname = platform->shlib_version_as_filename();
7
8  my $build_scheme = $target{build_scheme};
9  my $install_flavour = $build_scheme->[$#$build_scheme]; # last element
10  my $win_installenv =
11      $install_flavour eq "VC-WOW" ? "ProgramFiles(x86)"
12                                   : "ProgramW6432";
13  my $win_commonenv =
14      $install_flavour eq "VC-WOW" ? "CommonProgramFiles(x86)"
15                                   : "CommonProgramW6432";
16  our $win_installroot =
17      defined($ENV{$win_installenv}) ? $win_installenv : 'ProgramFiles';
18  our $win_commonroot =
19      defined($ENV{$win_commonenv}) ? $win_commonenv : 'CommonProgramFiles';
20
21  # expand variables early
22  $win_installroot = $ENV{$win_installroot};
23  $win_commonroot = $ENV{$win_commonroot};
24
25  # This makes sure things get built in the order they need
26  # to. You're welcome.
27  sub dependmagic {
28      my $target = shift;
29
30      return "$target: build_generated\n\t\$(MAKE) /\$(MAKEFLAGS) depend && \$(MAKE) /\$(MAKEFLAGS) _$target\n_$target";
31  }
32  '';
33 -}
34
35 PLATFORM={- $config{target} -}
36 SRCDIR={- $config{sourcedir} -}
37 BLDDIR={- $config{builddir} -}
38
39 VERSION={- "$config{full_version}" -}
40 MAJOR={- $config{major} -}
41 MINOR={- $config{minor} -}
42
43 SHLIB_VERSION_NUMBER={- $config{shlib_version} -}
44
45 LIBS={- join(" ", map { ( platform->sharedlib_import($_), platform->staticlib($_) ) } @{$unified_info{libraries}}) -}
46 SHLIBS={- join(" ", map { platform->sharedlib($_) // () } @{$unified_info{libraries}}) -}
47 SHLIBPDBS={- join(" ", map { platform->sharedlibpdb($_) // () } @{$unified_info{libraries}}) -}
48 ENGINES={- join(" ", map { platform->dso($_) } @{$unified_info{engines}}) -}
49 ENGINEPDBS={- join(" ", map { platform->dsopdb($_) } @{$unified_info{engines}}) -}
50 PROGRAMS={- our @PROGRAMS = map { platform->bin($_) } @{$unified_info{programs}}; join(" ", @PROGRAMS) -}
51 PROGRAMPDBS={- join(" ", map { $_.".pdb" } @{$unified_info{programs}}) -}
52 SCRIPTS={- join(" ", @{$unified_info{scripts}}) -}
53 {- output_off() if $disabled{makedepend}; "" -}
54 DEPS={- join(" ", map { platform->isobj($_) ? platform->dep($_) : () }
55                   grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
56                   keys %{$unified_info{sources}}); -}
57 {- output_on() if $disabled{makedepend}; "" -}
58 GENERATED_MANDATORY={- join(" ", @{$unified_info{depends}->{""}} ) -}
59 GENERATED={- # common0.tmpl provides @generated
60              join(" ", map { platform->convertext($_) } @generated) -}
61
62 INSTALL_LIBS={-
63         join(" ", map { quotify1(platform->sharedlib_import($_)
64                                  // platform->staticlib($_)) }
65                   grep { !$unified_info{attributes}->{$_}->{noinst} }
66                   @{$unified_info{libraries}})
67 -}
68 INSTALL_SHLIBS={-
69         join(" ", map { my $x = platform->sharedlib($_);
70                         $x ? quotify_l($x) : () }
71                   grep { !$unified_info{attributes}->{$_}->{noinst} }
72                   @{$unified_info{libraries}})
73 -}
74 INSTALL_SHLIBPDBS={-
75         join(" ", map { my $x = platform->sharedlibpdb($_);
76                         $x ? quotify_l($x) : () }
77                   grep { !$unified_info{attributes}->{$_}->{noinst} }
78                   @{$unified_info{libraries}})
79 -}
80 INSTALL_ENGINES={-
81         join(" ", map { quotify1(platform->dso($_)) }
82                   grep { !$unified_info{attributes}->{$_}->{noinst} }
83                   @{$unified_info{engines}})
84 -}
85 INSTALL_ENGINEPDBS={-
86         join(" ", map { quotify1(platform->dsopdb($_)) }
87                   grep { !$unified_info{attributes}->{$_}->{noinst} }
88                   @{$unified_info{engines}})
89 -}
90 INSTALL_PROGRAMS={-
91         join(" ", map { quotify1(platform->bin($_)) }
92                   grep { !$unified_info{attributes}->{$_}->{noinst} }
93                   @{$unified_info{programs}})
94 -}
95 INSTALL_PROGRAMPDBS={-
96         join(" ", map { quotify1(platform->binpdb($_)) }
97                   grep { !$unified_info{attributes}->{$_}->{noinst} }
98                   @{$unified_info{programs}})
99 -}
100 {- output_off() if $disabled{apps}; "" -}
101 BIN_SCRIPTS="$(BLDDIR)\tools\c_rehash.pl"
102 MISC_SCRIPTS="$(BLDDIR)\apps\CA.pl" "$(BLDDIR)\apps\tsget.pl"
103 {- output_on() if $disabled{apps}; "" -}
104
105 APPS_OPENSSL={- use File::Spec::Functions;
106                 "\"".catfile("apps","openssl")."\"" -}
107
108 # Do not edit these manually. Use Configure with --prefix or --openssldir
109 # to change this!  Short explanation in the top comment in Configure
110 INSTALLTOP_dev={- # $prefix is used in the OPENSSLDIR perl snippet
111                   #
112                   use File::Spec::Functions qw(:DEFAULT splitpath);
113                   our $prefix = canonpath($config{prefix}
114                                           || "$win_installroot\\OpenSSL");
115                   our ($prefix_dev, $prefix_dir, $prefix_file) =
116                       splitpath($prefix, 1);
117                   $prefix_dev -}
118 INSTALLTOP_dir={- canonpath($prefix_dir) -}
119 OPENSSLDIR_dev={- #
120                   # The logic here is that if no --openssldir was given,
121                   # OPENSSLDIR will get the value "$win_commonroot\\SSL".
122                   # If --openssldir was given and the value is an absolute
123                   # path, OPENSSLDIR will get its value without change.
124                   # If the value from --openssldir is a relative path,
125                   # OPENSSLDIR will get $prefix with the --openssldir
126                   # value appended as a subdirectory.
127                   #
128                   use File::Spec::Functions qw(:DEFAULT splitpath);
129                   our $openssldir =
130                       $config{openssldir} ?
131                           (file_name_is_absolute($config{openssldir}) ?
132                                canonpath($config{openssldir})
133                                : catdir($prefix, $config{openssldir}))
134                           : canonpath("$win_commonroot\\SSL");
135                   our ($openssldir_dev, $openssldir_dir, $openssldir_file) =
136                       splitpath($openssldir, 1);
137                   $openssldir_dev -}
138 OPENSSLDIR_dir={- canonpath($openssldir_dir) -}
139 LIBDIR={- our $libdir = $config{libdir} || "lib";
140           file_name_is_absolute($libdir) ? "" : $libdir -}
141 ENGINESDIR_dev={- use File::Spec::Functions qw(:DEFAULT splitpath);
142                   our $enginesdir = catdir($prefix,$libdir,"engines-$sover_dirname");
143                   our ($enginesdir_dev, $enginesdir_dir, $enginesdir_file) =
144                       splitpath($enginesdir, 1);
145                   $enginesdir_dev -}
146 ENGINESDIR_dir={- canonpath($enginesdir_dir) -}
147 !IF "$(DESTDIR)" != ""
148 INSTALLTOP=$(DESTDIR)$(INSTALLTOP_dir)
149 OPENSSLDIR=$(DESTDIR)$(OPENSSLDIR_dir)
150 ENGINESDIR=$(DESTDIR)$(ENGINESDIR_dir)
151 !ELSE
152 INSTALLTOP=$(INSTALLTOP_dev)$(INSTALLTOP_dir)
153 OPENSSLDIR=$(OPENSSLDIR_dev)$(OPENSSLDIR_dir)
154 ENGINESDIR=$(ENGINESDIR_dev)$(ENGINESDIR_dir)
155 !ENDIF
156
157 # $(libdir) is chosen to be compatible with the GNU coding standards
158 libdir={- file_name_is_absolute($libdir)
159           ? $libdir : '$(INSTALLTOP)\$(LIBDIR)' -}
160
161 ##### User defined commands and flags ################################
162
163 CC={- $config{CC} -}
164 CPP={- $config{CPP} -}
165 CPPFLAGS={- our $cppflags1 = join(" ",
166                                   (map { "-D".$_} @{$config{CPPDEFINES}}),
167                                   (map { " /I ".$_} @{$config{CPPINCLUDES}}),
168                                   @{$config{CPPFLAGS}}) -}
169 CFLAGS={- join(' ', @{$config{CFLAGS}}) -}
170 LD={- $config{LD} -}
171 LDFLAGS={- join(' ', @{$config{LDFLAGS}}) -}
172 EX_LIBS={- join(' ', @{$config{LDLIBS}}) -}
173
174 PERL={- $config{PERL} -}
175
176 AR={- $config{AR} -}
177 ARFLAGS= {- join(' ', @{$config{ARFLAGS}}) -}
178
179 MT={- $config{MT} -}
180 MTFLAGS= {- join(' ', @{$config{MTFLAGS}}) -}
181
182 AS={- $config{AS} -}
183 ASFLAGS={- join(' ', @{$config{ASFLAGS}}) -}
184
185 RC={- $config{RC} -}
186
187 ECHO="$(PERL)" "$(SRCDIR)\util\echo.pl"
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 { platform->sharedlib_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         @{- 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         @{- output_on() if $disabled{makedepend}; "" -}
327
328 test: tests
329 {- dependmagic('tests'); -}: build_programs_nodep build_engines_nodep
330         @{- 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         @{- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
340         @$(ECHO) "Tests are not supported with your chosen Configure options"
341         @{- output_on() if !$disabled{tests}; "" -}
342
343 list-tests:
344         @{- output_off() if $disabled{tests}; "" -}
345         @set SRCTOP=$(SRCDIR)
346         @"$(PERL)" "$(SRCDIR)\test\run_tests.pl" list
347         @{- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
348         @$(ECHO) "Tests are not supported with your chosen Configure options"
349         @{- 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         @ {- output_off() if $disabled{makedepend}; "" -}
377         @ "$(PERL)" "$(SRCDIR)\util\add-depends.pl" "VC"
378         @ {- output_on() if $disabled{makedepend}; "" -}
379
380 # Install helper targets #############################################
381
382 install_sw: 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: install_runtime_libs
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         @{- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
412         @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\ms\applink.c" \
413                                        "$(INSTALLTOP)\include\openssl"
414         @{- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
415         @"$(PERL)" "$(SRCDIR)\util\copy.pl" "-exclude_re=/__DECC_" \
416                                        "$(SRCDIR)\include\openssl\*.h" \
417                                        "$(INSTALLTOP)\include\openssl"
418         @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(BLDDIR)\include\openssl\*.h" \
419                                        "$(INSTALLTOP)\include\openssl"
420         @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(libdir)"
421         @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_LIBS) "$(libdir)"
422         @if "$(SHLIBS)"=="" \
423          "$(PERL)" "$(SRCDIR)\util\copy.pl" ossl_static.pdb "$(libdir)"
424
425 uninstall_dev:
426
427 install_engines: install_runtime_libs build_engines
428         @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
429         @$(ECHO) "*** Installing engines"
430         @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(ENGINESDIR)"
431         @if not "$(ENGINES)"=="" \
432          "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINES) "$(ENGINESDIR)"
433         @if not "$(ENGINES)"=="" \
434          "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINEPDBS) "$(ENGINESDIR)"
435
436 uninstall_engines:
437
438 install_runtime: install_programs
439
440 install_runtime_libs: build_libs
441         @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
442         @$(ECHO) "*** Installing runtime libraries"
443         @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\bin"
444         @if not "$(SHLIBS)"=="" \
445          "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_SHLIBS) "$(INSTALLTOP)\bin"
446         @if not "$(SHLIBS)"=="" \
447          "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_SHLIBPDBS) \
448                                         "$(INSTALLTOP)\bin"
449
450 install_programs: install_runtime_libs build_programs
451         @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
452         @$(ECHO) "*** Installing runtime programs"
453         @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\bin"
454         @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMS) \
455                                         "$(INSTALLTOP)\bin"
456         @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMPDBS) \
457                                         "$(INSTALLTOP)\bin"
458         @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BIN_SCRIPTS) \
459                                         "$(INSTALLTOP)\bin"
460
461 uninstall_runtime:
462
463 install_html_docs:
464         "$(PERL)" "$(SRCDIR)\util\process_docs.pl" \
465                 "--destdir=$(INSTALLTOP)\html" --type=html
466
467 uninstall_html_docs:
468
469 # Building targets ###################################################
470
471 configdata.pm: "$(SRCDIR)\Configure" {- join(" ", map { '"'.$_.'"' } @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
472         @$(ECHO) "Detected changed: $?"
473         "$(PERL)" configdata.pm -r
474         @$(ECHO) "**************************************************"
475         @$(ECHO) "***                                            ***"
476         @$(ECHO) "***   Please run the same make command again   ***"
477         @$(ECHO) "***                                            ***"
478         @$(ECHO) "**************************************************"
479         @exit 1
480
481 reconfigure reconf:
482         "$(PERL)" configdata.pm -r
483
484 {-
485  use File::Basename;
486  use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
487
488  # Helper function to figure out dependencies on libraries
489  # It takes a list of library names and outputs a list of dependencies
490  sub compute_lib_depends {
491      if ($disabled{shared}) {
492          return map { platform->staticlib($_) } @_;
493      }
494      return map { platform->sharedlib_import($_) // platform->staticlib($_) } @_;
495  }
496
497   sub generatesrc {
498       my %args = @_;
499       my ($gen0, @gens) = @{$args{generator}};
500       my $generator = '"'.$gen0.'"'.join('', map { " $_" } @gens);
501       my $generator_incs = join("", map { " -I \"$_\"" } @{$args{generator_incs}});
502       my $incs = join("", map { " /I \"$_\"" } @{$args{incs}});
503       my $defs = join("", map { " /D".$_ } @{$args{defs}});
504       my $deps = @{$args{deps}} ?
505           '"'.join('" "', @{$args{generator_deps}}, @{$args{deps}}).'"' : '';
506
507       if (platform->isdef($args{src})) {
508           my $target = platform->def($args{src});
509           my $mkdef = abs2rel(rel2abs(catfile($config{sourcedir},
510                                               "util", "mkdef.pl")),
511                               rel2abs($config{builddir}));
512           my $ord_ver = $args{intent} eq 'lib' ? ' --version $(VERSION)' : '';
513           my $ord_name =
514               $args{generator}->[1] || platform->dsoname($args{product});
515           return <<"EOF";
516 $target: $args{generator}->[0] $deps $mkdef
517         \$(PERL) $mkdef$ord_ver --ordinals $args{generator}->[0] --name $ord_name --OS windows > $target
518 EOF
519       } elsif (!platform->isasm($args{src})) {
520           my $target = $args{src};
521           if ($args{generator}->[0] =~ m|^.*\.in$|) {
522               my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
523                                                    "util", "dofile.pl")),
524                                    rel2abs($config{builddir}));
525               return <<"EOF";
526 $target: "$args{generator}->[0]" $deps
527         "\$(PERL)" "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
528             "-o$target{build_file}" $generator > \$@
529 EOF
530           } else {
531               return <<"EOF";
532 $target: "$args{generator}->[0]" $deps
533         "\$(PERL)"$generator_incs $generator > \$@
534 EOF
535           }
536       } else {
537           my $target = platform->asm($args{src});
538           if ($args{generator}->[0] =~ /\.pl$/) {
539               $generator = '"$(PERL)"'.$generator_incs.' '.$generator;
540           } elsif ($args{generator}->[0] =~ /\.S$/) {
541               $generator = undef;
542           } else {
543               die "Generator type for $src unknown: $generator\n";
544           }
545
546           my $cppflags = $incs;
547           $cppflags .= {
548               shlib => ' $(LIB_CFLAGS) $(LIB_CPPFLAGS)',
549               lib => ' $(LIB_CFLAGS) $(LIB_CPPFLAGS)',
550               dso => ' $(DSO_CFLAGS) $(DSO_CPPFLAGS)',
551               bin => ' $(BIN_CFLAGS) $(BIN_CPPFLAGS)'
552           } -> {$args{intent}};
553           if (defined($generator)) {
554               # If the target is named foo.S in build.info, we want to
555               # end up generating foo.s in two steps.
556               if ($args{src} =~ /\.S$/) {
557                    return <<"EOF";
558 $target: "$args{generator}->[0]" $deps
559         set ASM=\$(AS)
560         $generator \$@.S
561         \$(CPP) $cppflags $defs \$@.S > \$@.i && move /Y \$@.i \$@
562         del /Q \$@.S
563 EOF
564               }
565               # Otherwise....
566               return <<"EOF";
567 $target: "$args{generator}->[0]" $deps
568         set ASM=\$(AS)
569         $generator \$@
570 EOF
571           }
572           return <<"EOF";
573 $target: "$args{generator}->[0]" $deps
574         \$(CPP) $incs $cppflags $defs "$args{generator}->[0]" > \$@.i && move /Y \$@.i \$@
575 EOF
576       }
577   }
578
579  sub src2obj {
580      my %args = @_;
581      my @srcs = map { (my $x = $_) =~ s/\.s$/.asm/; $x } ( @{$args{srcs}} );
582      my $srcs = '"'.join('" "',  @srcs).'"';
583      my $deps = '"'.join('" "', @srcs, @{$args{deps}}).'"';
584      my $incs = join("", map { ' /I "'.$_.'"' } @{$args{incs}});
585      my $defs = join("", map { " /D".$_ } @{$args{defs}});
586      my $cflags = { shlib => ' $(LIB_CFLAGS)',
587                     lib => ' $(LIB_CFLAGS)',
588                     dso => ' $(DSO_CFLAGS)',
589                     bin => ' $(BIN_CFLAGS)' } -> {$args{intent}};
590      $cflags .= $incs;
591      $cflags .= { shlib => ' $(LIB_CPPFLAGS)',
592                   lib => ' $(LIB_CPPFLAGS)',
593                   dso => ' $(DSO_CPPFLAGS)',
594                   bin => ' $(BIN_CPPFLAGS)' } -> {$args{intent}};
595      my $asflags = { shlib => ' $(LIB_ASFLAGS)',
596                      lib => ' $(LIB_ASFLAGS)',
597                      dso => ' $(DSO_ASFLAGS)',
598                      bin => ' $(BIN_ASFLAGS)' } -> {$args{intent}};
599      my $makedepprog = $config{makedepprog};
600      if ($srcs[0] =~ /\.rc$/) {
601          my $res = platform->res($args{obj});
602          return <<"EOF";
603 $res: $deps
604         \$(RC) \$(RCOUTFLAG)\$\@ $srcs
605 EOF
606      }
607      my $obj = platform->obj($args{obj});
608      if ($srcs[0] =~ /\.asm$/) {
609          return <<"EOF";
610 $obj: $deps
611         \$(AS) $asflags \$(ASOUTFLAG)\$\@ $srcs
612 EOF
613      } elsif ($srcs[0] =~ /.S$/) {
614          return <<"EOF";
615 $obj: $deps
616         \$(CC) /EP /D__ASSEMBLER__ $cflags $defs $srcs > \$@.asm && \$(AS) $asflags \$(ASOUTFLAG)\$\@ \$@.asm
617 EOF
618      }
619      my $recipe = <<"EOF";
620 $obj: $deps
621         \$(CC) $cflags $defs -c \$(COUTFLAG)\$\@ $srcs
622 EOF
623      $recipe .= <<"EOF" unless $disabled{makedepend};
624         \$(CC) $cflags $defs /Zs /showIncludes $srcs 2>&1 > $dep
625 EOF
626      return $recipe;
627  }
628
629  # We *know* this routine is only called when we've configure 'shared'.
630  # Also, note that even though the import library built here looks like
631  # a static library, it really isn't.
632  sub obj2shlib {
633      my %args = @_;
634      my $lib = $args{lib};
635      my @objs = map { platform->convertext($_) }
636                 grep { platform->isobj($_) || platform->isres($_) }
637                 @{$args{objs}};
638      my @defs = map { platform->def($_) }
639                 grep { platform->isdef($_) }
640                 @{$args{objs}};
641      my @deps = compute_lib_depends(@{$args{deps}});
642      die "More than one exported symbols list" if scalar @defs > 1;
643      my $linklibs = join("", map { "$_\n" } @deps);
644      my $objs = join("\n", @objs);
645      my $deps = join(" ", @objs, @defs, @deps);
646      my $import = platform->sharedlib_import($lib);
647      my $dll =  platform->sharedlib($lib);
648      my $shared_def = join("", map { " /def:$_" } @defs);
649      return <<"EOF"
650 # The import library may look like a static library, but it is not.
651 # We MUST make the import library depend on the DLL, in case someone
652 # mistakenly removes the latter.
653 $import: $dll
654 $dll: $deps
655         IF EXIST $full.manifest DEL /F /Q $full.manifest
656         IF EXIST \$@ DEL /F /Q \$@
657         \$(LD) \$(LDFLAGS) \$(LIB_LDFLAGS) \\
658                 /implib:$import \$(LDOUTFLAG)$dll$shared_def @<< || (DEL /Q \$(\@B).* $import && EXIT 1)
659 $objs
660 $linklibs\$(LIB_EX_LIBS)
661 <<
662         IF EXIST $dll.manifest \\
663            \$(MT) \$(MTFLAGS) \$(MTINFLAG)$dll.manifest \$(MTOUTFLAG)$dll
664         IF EXIST apps\\$dll DEL /Q /F apps\\$dll
665         IF EXIST test\\$dll DEL /Q /F test\\$dll
666         IF EXIST fuzz\\$dll DEL /Q /F fuzz\\$dll
667         COPY $dll apps
668         COPY $dll test
669         COPY $dll fuzz
670 EOF
671  }
672  sub obj2dso {
673      my %args = @_;
674      my $dso = platform->dso($args{lib});
675      my $dso_n = platform->dsoname($args{lib});
676      my @objs = map { platform->convertext($_) }
677                 grep { platform->isobj($_) || platform->isres($_) }
678                 @{$args{objs}};
679      my @defs = map { platform->def($_) }
680                 grep { platform->isdef($_) }
681                 @{$args{objs}};
682      my @deps = compute_lib_depends(@{$args{deps}});
683      my $objs = join("\n", @objs);
684      my $linklibs = join("", map { "$_\n" } @deps);
685      my $deps = join(" ", @objs, @defs, @deps);
686      my $shared_def = join("", map { " /def:$_" } @defs);
687      return <<"EOF";
688 $dso: $deps
689         IF EXIST $dso.manifest DEL /F /Q $dso.manifest
690         \$(LD) \$(LDFLAGS) \$(DSO_LDFLAGS) \\
691                 \$(LDOUTFLAG)$dso$shared_def @<< || (DEL /Q \$(\@B).* $dso_n.* && EXIT 1)
692 $objs
693 $linklibs \$(DSO_EX_LIBS)
694 <<
695         IF EXIST $dso.manifest \\
696            \$(MT) \$(MTFLAGS) \$(MTINFLAG)$dso.manifest \$(MTOUTFLAG)$dso
697 EOF
698  }
699  sub obj2lib {
700      my %args = @_;
701      my $lib = platform->staticlib($args{lib});
702      my @objs = map { platform->obj($_) } @{$args{objs}};
703      my $objs = join("\n", @objs);
704      my $deps = join(" ", @objs);
705      return <<"EOF";
706 $lib: $deps
707         \$(AR) \$(ARFLAGS) \$(AROUTFLAG)$lib @<<
708 $objs
709 <<
710 EOF
711  }
712  sub obj2bin {
713      my %args = @_;
714      my $bin = platform->bin($args{bin});
715      my @objs = map { platform->convertext($_) }
716                 grep { platform->isobj($_) || platform->isres($_) }
717                 @{$args{objs}};
718      my @deps = compute_lib_depends(@{$args{deps}});
719      my $objs = join("\n", @objs);
720      my $linklibs = join("", map { "$_\n" } @deps);
721      my $deps = join(" ", @objs, @deps);
722      return <<"EOF";
723 $bin: $deps
724         IF EXIST $bin.manifest DEL /F /Q $bin.manifest
725         \$(LD) \$(LDFLAGS) \$(BIN_LDFLAGS) \$(LDOUTFLAG)$bin @<<
726 $objs
727 setargv.obj
728 $linklibs\$(BIN_EX_LIBS)
729 <<
730         IF EXIST $bin.manifest \\
731            \$(MT) \$(MTFLAGS) \$(MTINFLAG)$bin.manifest \$(MTOUTFLAG)$bin
732 EOF
733   }
734   sub in2script {
735       my %args = @_;
736       my $script = $args{script};
737       my $sources = '"'.join('" "', @{$args{sources}}).'"';
738       my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
739                                            "util", "dofile.pl")),
740                            rel2abs($config{builddir}));
741       return <<"EOF";
742 $script: $sources
743         "\$(PERL)" "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
744             "-o$target{build_file}" $sources > "$script"
745 EOF
746   }
747   sub generatedir {
748       my %args = @_;
749       my $dir = $args{dir};
750       my @deps = map { platform->convertext($_) } @{$args{deps}};
751       my @actions = ();
752       my %extinfo = ( dso => platform->dsoext(),
753                       lib => platform->libext(),
754                       bin => platform->binext() );
755
756       # We already have a 'test' target, and the top directory is just plain
757       # silly
758       return if $dir eq "test" || $dir eq ".";
759
760       foreach my $type (("dso", "lib", "bin", "script")) {
761           next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type});
762           # For lib object files, we could update the library.  However,
763           # LIB on Windows doesn't work that way, so we won't create any
764           # actions for it, and the dependencies are already taken care of.
765           if ($type ne "lib") {
766               foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) {
767                   if (dirname($prod) eq $dir) {
768                       push @deps, $prod.$extinfo{$type};
769                   }
770               }
771           }
772       }
773
774       my $deps = join(" ", @deps);
775       my $actions = join("\n", "", @actions);
776       return <<"EOF";
777 $dir $dir\\ : $deps$actions
778 EOF
779   }
780   ""    # Important!  This becomes part of the template result.
781 -}