2 ## Makefile for OpenSSL
4 ## {- join("\n## ", @autowarntext) -}
6 our $sover_dirname = platform->shlib_version_as_filename();
8 my $build_scheme = $target{build_scheme};
9 my $install_flavour = $build_scheme->[$#$build_scheme]; # last element
11 $install_flavour eq "VC-WOW" ? "ProgramFiles(x86)"
14 $install_flavour eq "VC-WOW" ? "CommonProgramFiles(x86)"
15 : "CommonProgramW6432";
16 our $win_installroot =
17 defined($ENV{$win_installenv}) ? $win_installenv : 'ProgramFiles';
19 defined($ENV{$win_commonenv}) ? $win_commonenv : 'CommonProgramFiles';
21 # expand variables early
22 $win_installroot = $ENV{$win_installroot};
23 $win_commonroot = $ENV{$win_commonroot};
25 # This makes sure things get built in the order they need
30 return "$target: build_generated\n\t\$(MAKE) /\$(MAKEFLAGS) depend && \$(MAKE) /\$(MAKEFLAGS) _$target\n_$target";
35 PLATFORM={- $config{target} -}
36 SRCDIR={- $config{sourcedir} -}
37 BLDDIR={- $config{builddir} -}
39 VERSION={- "$config{full_version}" -}
40 MAJOR={- $config{major} -}
41 MINOR={- $config{minor} -}
43 SHLIB_VERSION_NUMBER={- $config{shlib_version} -}
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) -}
62 INSTALL_LIBS={- join(" ", map { quotify1(platform->sharedlib_import($_) // platform->staticlib($_)) } @{$unified_info{install}->{libraries}}) -}
63 INSTALL_SHLIBS={- join(" ", map { my $x = platform->sharedlib($_);
64 $x ? quotify_l($x) : () } @{$unified_info{install}->{libraries}}) -}
65 INSTALL_SHLIBPDBS={- join(" ", map { my $x = platform->sharedlibpdb($_);
66 $x ? quotify_l($x) : () } @{$unified_info{install}->{libraries}}) -}
67 INSTALL_ENGINES={- join(" ", map { quotify1(platform->dso($_)) } @{$unified_info{install}->{engines}}) -}
68 INSTALL_ENGINEPDBS={- join(" ", map { quotify1(platform->dsopdb($_)) } @{$unified_info{install}->{engines}}) -}
69 INSTALL_PROGRAMS={- join(" ", map { quotify1(platform->bin($_)) } grep { !m|^test\\| } @{$unified_info{install}->{programs}}) -}
70 INSTALL_PROGRAMPDBS={- join(" ", map { quotify1(platform->binpdb($_)) } grep { !m|^test\\| } @{$unified_info{install}->{programs}}) -}
71 {- output_off() if $disabled{apps}; "" -}
72 BIN_SCRIPTS="$(BLDDIR)\tools\c_rehash.pl"
73 MISC_SCRIPTS="$(BLDDIR)\apps\CA.pl" "$(BLDDIR)\apps\tsget.pl"
74 {- output_on() if $disabled{apps}; "" -}
76 APPS_OPENSSL={- use File::Spec::Functions;
77 "\"".catfile("apps","openssl")."\"" -}
79 # Do not edit these manually. Use Configure with --prefix or --openssldir
80 # to change this! Short explanation in the top comment in Configure
81 INSTALLTOP_dev={- # $prefix is used in the OPENSSLDIR perl snippet
83 use File::Spec::Functions qw(:DEFAULT splitpath);
84 our $prefix = canonpath($config{prefix}
85 || "$win_installroot\\OpenSSL");
86 our ($prefix_dev, $prefix_dir, $prefix_file) =
87 splitpath($prefix, 1);
89 INSTALLTOP_dir={- canonpath($prefix_dir) -}
91 # The logic here is that if no --openssldir was given,
92 # OPENSSLDIR will get the value "$win_commonroot\\SSL".
93 # If --openssldir was given and the value is an absolute
94 # path, OPENSSLDIR will get its value without change.
95 # If the value from --openssldir is a relative path,
96 # OPENSSLDIR will get $prefix with the --openssldir
97 # value appended as a subdirectory.
99 use File::Spec::Functions qw(:DEFAULT splitpath);
101 $config{openssldir} ?
102 (file_name_is_absolute($config{openssldir}) ?
103 canonpath($config{openssldir})
104 : catdir($prefix, $config{openssldir}))
105 : canonpath("$win_commonroot\\SSL");
106 our ($openssldir_dev, $openssldir_dir, $openssldir_file) =
107 splitpath($openssldir, 1);
109 OPENSSLDIR_dir={- canonpath($openssldir_dir) -}
110 LIBDIR={- our $libdir = $config{libdir} || "lib";
111 file_name_is_absolute($libdir) ? "" : $libdir -}
112 ENGINESDIR_dev={- use File::Spec::Functions qw(:DEFAULT splitpath);
113 our $enginesdir = catdir($prefix,$libdir,"engines-$sover_dirname");
114 our ($enginesdir_dev, $enginesdir_dir, $enginesdir_file) =
115 splitpath($enginesdir, 1);
117 ENGINESDIR_dir={- canonpath($enginesdir_dir) -}
118 !IF "$(DESTDIR)" != ""
119 INSTALLTOP=$(DESTDIR)$(INSTALLTOP_dir)
120 OPENSSLDIR=$(DESTDIR)$(OPENSSLDIR_dir)
121 ENGINESDIR=$(DESTDIR)$(ENGINESDIR_dir)
123 INSTALLTOP=$(INSTALLTOP_dev)$(INSTALLTOP_dir)
124 OPENSSLDIR=$(OPENSSLDIR_dev)$(OPENSSLDIR_dir)
125 ENGINESDIR=$(ENGINESDIR_dev)$(ENGINESDIR_dir)
128 # $(libdir) is chosen to be compatible with the GNU coding standards
129 libdir={- file_name_is_absolute($libdir)
130 ? $libdir : '$(INSTALLTOP)\$(LIBDIR)' -}
132 ##### User defined commands and flags ################################
135 CPP={- $config{CPP} -}
136 CPPFLAGS={- our $cppflags1 = join(" ",
137 (map { "-D".$_} @{$config{CPPDEFINES}}),
138 (map { " /I ".$_} @{$config{CPPINCLUDES}}),
139 @{$config{CPPFLAGS}}) -}
140 CFLAGS={- join(' ', @{$config{CFLAGS}}) -}
142 LDFLAGS={- join(' ', @{$config{LDFLAGS}}) -}
143 EX_LIBS={- join(' ', @{$config{LDLIBS}}) -}
145 PERL={- $config{PERL} -}
148 ARFLAGS= {- join(' ', @{$config{ARFLAGS}}) -}
151 MTFLAGS= {- join(' ', @{$config{MTFLAGS}}) -}
154 ASFLAGS={- join(' ', @{$config{ASFLAGS}}) -}
158 ECHO="$(PERL)" "$(SRCDIR)\util\echo.pl"
160 ##### Special command flags ##########################################
162 COUTFLAG={- $target{coutflag} -}$(OSSL_EMPTY)
163 LDOUTFLAG={- $target{ldoutflag} -}$(OSSL_EMPTY)
164 AROUTFLAG={- $target{aroutflag} -}$(OSSL_EMPTY)
165 MTINFLAG={- $target{mtinflag} -}$(OSSL_EMPTY)
166 MTOUTFLAG={- $target{mtoutflag} -}$(OSSL_EMPTY)
167 ASOUTFLAG={- $target{asoutflag} -}$(OSSL_EMPTY)
168 RCOUTFLAG={- $target{rcoutflag} -}$(OSSL_EMPTY)
170 ##### Project flags ##################################################
172 # Variables starting with CNF_ are common variables for all product types
174 CNF_ASFLAGS={- join(' ', $target{asflags} || (),
175 @{$config{asflags}}) -}
176 CNF_CPPFLAGS={- our $cppfags2 =
177 join(' ', $target{cppflags} || (),
178 (map { '-D'.quotify1($_) } @{$target{defines}},
179 @{$config{defines}}),
180 (map { '-I'.quotify1($_) } @{$target{includes}},
181 @{$config{includes}}),
182 @{$config{cppflags}}) -}
183 CNF_CFLAGS={- join(' ', $target{cflags} || (),
184 @{$config{cflags}}) -}
185 CNF_CXXFLAGS={- join(' ', $target{cxxflags} || (),
186 @{$config{cxxflags}}) -}
187 CNF_LDFLAGS={- join(' ', $target{lflags} || (),
188 @{$config{lflags}}) -}
189 CNF_EX_LIBS={- join(' ', $target{ex_libs} || (),
190 @{$config{ex_libs}}) -}
192 # Variables starting with LIB_ are used to build library object files
193 # and shared libraries.
194 # Variables starting with DSO_ are used to build DSOs and their object files.
195 # Variables starting with BIN_ are used to build programs and their object
198 LIB_ASFLAGS={- join(' ', $target{lib_asflags} || (),
199 @{$config{lib_asflags}},
200 '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
201 LIB_CPPFLAGS={- our $lib_cppflags =
202 join(' ', $target{lib_cppflags} || (),
203 $target{shared_cppflag} || (),
204 (map { '-D'.quotify1($_) }
205 @{$target{lib_defines}},
206 @{$target{shared_defines}},
207 @{$config{lib_defines}},
208 @{$config{shared_defines}}),
209 (map { '-I'.quotify1($_) }
210 @{$target{lib_includes}},
211 @{$target{shared_includes}},
212 @{$config{lib_includes}},
213 @{$config{shared_includes}}),
214 @{$config{lib_cppflags}},
215 @{$config{shared_cppflag}});
216 join(' ', $lib_cppflags,
217 (map { '-D'.quotify1($_) }
218 "OPENSSLDIR=\"$openssldir\"",
219 "ENGINESDIR=\"$enginesdir\""),
220 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
221 LIB_CFLAGS={- join(' ', $target{lib_cflags} || (),
222 $target{shared_cflag} || (),
223 @{$config{lib_cflags}},
224 @{$config{shared_cflag}},
225 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
226 LIB_LDFLAGS={- join(' ', $target{shared_ldflag} || (),
227 $config{shared_ldflag} || (),
228 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
229 LIB_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
230 DSO_ASFLAGS={- join(' ', $target{dso_asflags} || (),
231 $target{module_asflags} || (),
232 @{$config{dso_asflags}},
233 @{$config{module_asflags}},
234 '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
235 DSO_CPPFLAGS={- join(' ', $target{dso_cppflags} || (),
236 $target{module_cppflags} || (),
237 @{$config{dso_cppflags}},
238 @{$config{module_cppflags}},
239 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
240 DSO_CFLAGS={- join(' ', $target{dso_cflags} || (),
241 $target{module_cflags} || (),
242 @{$config{dso_cflags}},
243 @{$config{module_cflags}},
244 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
245 DSO_LDFLAGS={- join(' ', $target{dso_lflags} || (),
246 $target{module_ldflags} || (),
247 @{$config{dso_lflags}},
248 @{$config{module_ldflags}},
249 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
250 DSO_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
251 BIN_ASFLAGS={- join(' ', $target{bin_asflags} || (),
252 @{$config{bin_asflags}},
253 '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
254 BIN_CPPFLAGS={- join(' ', $target{bin_cppflags} || (),
255 @{$config{bin_cppflags}},
256 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
257 BIN_CFLAGS={- join(' ', $target{bin_cflags} || (),
258 @{$config{bin_cflags}},
259 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
260 BIN_LDFLAGS={- join(' ', $target{bin_lflags} || (),
261 @{$config{bin_lflags}},
262 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
263 BIN_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
265 # CPPFLAGS_Q is used for one thing only: to build up buildinf.h
266 CPPFLAGS_Q={- $cppflags1 =~ s|([\\"])|\\$1|g;
267 $cppflags2 =~ s|([\\"])|\\$1|g;
268 join(' ', $lib_cppflags || (), $cppflags2 || (),
271 PERLASM_SCHEME= {- $target{perlasm_scheme} -}
273 PROCESSOR= {- $config{processor} -}
275 # The main targets ###################################################
277 {- dependmagic('all'); -}: build_libs_nodep build_engines_nodep build_programs_nodep
278 {- dependmagic('build_libs'); -}: build_libs_nodep
279 {- dependmagic('build_engines'); -}: build_engines_nodep
280 {- dependmagic('build_programs'); -}: build_programs_nodep
282 build_generated: $(GENERATED_MANDATORY)
283 build_libs_nodep: $(LIBS) {- join(" ",map { platform->sharedlib_import($_) // () } @{$unified_info{libraries}}) -}
284 build_engines_nodep: $(ENGINES)
285 build_programs_nodep: $(PROGRAMS) $(SCRIPTS)
287 # Kept around for backward compatibility
288 build_apps build_tests: build_programs
290 # Convenience target to prebuild all generated files, not just the mandatory
292 build_all_generated: $(GENERATED_MANDATORY) $(GENERATED)
293 @{- output_off() if $disabled{makedepend}; "" -}
294 @$(ECHO) "Warning: consider configuring with no-makedepend, because if"
295 @$(ECHO) " target system doesn't have $(PERL),"
296 @$(ECHO) " then make will fail..."
297 @{- output_on() if $disabled{makedepend}; "" -}
300 {- dependmagic('tests'); -}: build_programs_nodep build_engines_nodep
301 @{- output_off() if $disabled{tests}; "" -}
302 -mkdir $(BLDDIR)\test\test-runs
305 set RESULT_D=$(BLDDIR)\test\test-runs
307 set OPENSSL_ENGINES=$(MAKEDIR)\engines
308 set OPENSSL_DEBUG_MEMORY=on
309 "$(PERL)" "$(SRCDIR)\test\run_tests.pl" $(TESTS)
310 @{- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
311 @$(ECHO) "Tests are not supported with your chosen Configure options"
312 @{- output_on() if !$disabled{tests}; "" -}
315 @{- output_off() if $disabled{tests}; "" -}
316 @set SRCTOP=$(SRCDIR)
317 @"$(PERL)" "$(SRCDIR)\test\run_tests.pl" list
318 @{- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
319 @$(ECHO) "Tests are not supported with your chosen Configure options"
320 @{- output_on() if !$disabled{tests}; "" -}
322 install: install_sw install_ssldirs install_docs
324 uninstall: uninstall_docs uninstall_sw
327 "$(PERL)" -e "map { m/(.*)\.dll$$/; unlink glob """{.,apps,test,fuzz}/$$1.*"""; } @ARGV" $(SHLIBS)
328 -del /Q /F $(LIBS) libcrypto.* libssl.* ossl_static.pdb
331 {- join("\n\t", map { "-del /Q /F $_" } @PROGRAMS) -}
332 -del /Q /F $(ENGINES)
333 -del /Q /F $(SCRIPTS)
334 -del /Q /F $(GENERATED_MANDATORY)
335 -del /Q /F $(GENERATED)
336 -del /Q /S /F *.d *.obj *.pdb *.ilk *.manifest
337 -del /Q /S /F engines\*.lib engines\*.exp
338 -del /Q /S /F apps\*.lib apps\*.rc apps\*.res apps\*.exp
339 -del /Q /S /F test\*.exp
340 -rmdir /Q /S test\test-runs
343 -del /Q /F configdata.pm
347 @ {- output_off() if $disabled{makedepend}; "" -}
348 @ "$(PERL)" "$(SRCDIR)\util\add-depends.pl" "VC"
349 @ {- output_on() if $disabled{makedepend}; "" -}
351 # Install helper targets #############################################
353 install_sw: install_dev install_engines install_runtime
355 uninstall_sw: uninstall_runtime uninstall_engines uninstall_dev
357 install_docs: install_html_docs
359 uninstall_docs: uninstall_html_docs
362 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\certs"
363 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\private"
364 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\misc"
365 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\openssl.cnf" \
366 "$(OPENSSLDIR)\openssl.cnf.dist"
367 @IF NOT EXIST "$(OPENSSLDIR)\openssl.cnf" \
368 "$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\openssl.cnf" \
369 "$(OPENSSLDIR)\openssl.cnf"
370 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(MISC_SCRIPTS) \
372 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\ct_log_list.cnf" \
373 "$(OPENSSLDIR)\ct_log_list.cnf.dist"
374 @IF NOT EXIST "$(OPENSSLDIR)\ct_log_list.cnf" \
375 "$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\ct_log_list.cnf" \
376 "$(OPENSSLDIR)\ct_log_list.cnf"
378 install_dev: install_runtime_libs
379 @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
380 @$(ECHO) "*** Installing development files"
381 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\include\openssl"
382 @{- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
383 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\ms\applink.c" \
384 "$(INSTALLTOP)\include\openssl"
385 @{- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
386 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "-exclude_re=/__DECC_" \
387 "$(SRCDIR)\include\openssl\*.h" \
388 "$(INSTALLTOP)\include\openssl"
389 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(BLDDIR)\include\openssl\*.h" \
390 "$(INSTALLTOP)\include\openssl"
391 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(libdir)"
392 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_LIBS) "$(libdir)"
393 @if "$(SHLIBS)"=="" \
394 "$(PERL)" "$(SRCDIR)\util\copy.pl" ossl_static.pdb "$(libdir)"
398 install_engines: install_runtime_libs build_engines
399 @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
400 @$(ECHO) "*** Installing engines"
401 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(ENGINESDIR)"
402 @if not "$(ENGINES)"=="" \
403 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINES) "$(ENGINESDIR)"
404 @if not "$(ENGINES)"=="" \
405 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINEPDBS) "$(ENGINESDIR)"
409 install_runtime: install_programs
411 install_runtime_libs: build_libs
412 @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
413 @$(ECHO) "*** Installing runtime libraries"
414 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\bin"
415 @if not "$(SHLIBS)"=="" \
416 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_SHLIBS) "$(INSTALLTOP)\bin"
417 @if not "$(SHLIBS)"=="" \
418 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_SHLIBPDBS) \
421 install_programs: install_runtime_libs build_programs
422 @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
423 @$(ECHO) "*** Installing runtime programs"
424 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\bin"
425 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMS) \
427 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMPDBS) \
429 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BIN_SCRIPTS) \
435 "$(PERL)" "$(SRCDIR)\util\process_docs.pl" \
436 "--destdir=$(INSTALLTOP)\html" --type=html
440 # Building targets ###################################################
442 configdata.pm: "$(SRCDIR)\Configure" {- join(" ", map { '"'.$_.'"' } @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
443 @$(ECHO) "Detected changed: $?"
444 "$(PERL)" configdata.pm -r
445 @$(ECHO) "**************************************************"
447 @$(ECHO) "*** Please run the same make command again ***"
449 @$(ECHO) "**************************************************"
453 "$(PERL)" configdata.pm -r
457 use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
459 # Helper function to figure out dependencies on libraries
460 # It takes a list of library names and outputs a list of dependencies
461 sub compute_lib_depends {
462 if ($disabled{shared}) {
463 return map { platform->staticlib($_) } @_;
465 return map { platform->sharedlib_import($_) // platform->staticlib($_) } @_;
470 my ($gen0, @gens) = @{$args{generator}};
471 my $generator = '"'.$gen0.'"'.join('', map { " $_" } @gens);
472 my $generator_incs = join("", map { " -I \"$_\"" } @{$args{generator_incs}});
473 my $incs = join("", map { " /I \"$_\"" } @{$args{incs}});
474 my $defs = join("", map { " /D".$_ } @{$args{defs}});
475 my $deps = @{$args{deps}} ?
476 '"'.join('" "', @{$args{generator_deps}}, @{$args{deps}}).'"' : '';
478 if (platform->isdef($args{src})) {
479 my $target = platform->def($args{src});
480 my $mkdef = abs2rel(rel2abs(catfile($config{sourcedir},
481 "util", "mkdef.pl")),
482 rel2abs($config{builddir}));
483 my $ord_ver = $args{intent} eq 'lib' ? ' --version $(VERSION)' : '';
485 $args{generator}->[1] || platform->dsoname($args{product});
487 $target: $args{generator}->[0] $deps $mkdef
488 \$(PERL) $mkdef$ord_ver --ordinals $args{generator}->[0] --name $ord_name --OS windows > $target
490 } elsif (!platform->isasm($args{src})) {
491 my $target = $args{src};
492 if ($args{generator}->[0] =~ m|^.*\.in$|) {
493 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
494 "util", "dofile.pl")),
495 rel2abs($config{builddir}));
497 $target: "$args{generator}->[0]" $deps
498 "\$(PERL)" "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
499 "-o$target{build_file}" $generator > \$@
503 $target: "$args{generator}->[0]" $deps
504 "\$(PERL)"$generator_incs $generator > \$@
508 my $target = platform->asm($args{src});
509 if ($args{generator}->[0] =~ /\.pl$/) {
510 $generator = '"$(PERL)"'.$generator_incs.' '.$generator;
511 } elsif ($args{generator}->[0] =~ /\.S$/) {
514 die "Generator type for $src unknown: $generator\n";
517 my $cppflags = $incs;
519 shlib => ' $(LIB_CFLAGS) $(LIB_CPPFLAGS)',
520 lib => ' $(LIB_CFLAGS) $(LIB_CPPFLAGS)',
521 dso => ' $(DSO_CFLAGS) $(DSO_CPPFLAGS)',
522 bin => ' $(BIN_CFLAGS) $(BIN_CPPFLAGS)'
523 } -> {$args{intent}};
524 if (defined($generator)) {
525 # If the target is named foo.S in build.info, we want to
526 # end up generating foo.s in two steps.
527 if ($args{src} =~ /\.S$/) {
529 $target: "$args{generator}->[0]" $deps
532 \$(CPP) $cppflags $defs \$@.S > \$@.i && move /Y \$@.i \$@
538 $target: "$args{generator}->[0]" $deps
544 $target: "$args{generator}->[0]" $deps
545 \$(CPP) $incs $cppflags $defs "$args{generator}->[0]" > \$@.i && move /Y \$@.i \$@
552 my @srcs = map { (my $x = $_) =~ s/\.s$/.asm/; $x } ( @{$args{srcs}} );
553 my $srcs = '"'.join('" "', @srcs).'"';
554 my $deps = '"'.join('" "', @srcs, @{$args{deps}}).'"';
555 my $incs = join("", map { ' /I "'.$_.'"' } @{$args{incs}});
556 my $defs = join("", map { " /D".$_ } @{$args{defs}});
557 my $cflags = { shlib => ' $(LIB_CFLAGS)',
558 lib => ' $(LIB_CFLAGS)',
559 dso => ' $(DSO_CFLAGS)',
560 bin => ' $(BIN_CFLAGS)' } -> {$args{intent}};
562 $cflags .= { shlib => ' $(LIB_CPPFLAGS)',
563 lib => ' $(LIB_CPPFLAGS)',
564 dso => ' $(DSO_CPPFLAGS)',
565 bin => ' $(BIN_CPPFLAGS)' } -> {$args{intent}};
566 my $asflags = { shlib => ' $(LIB_ASFLAGS)',
567 lib => ' $(LIB_ASFLAGS)',
568 dso => ' $(DSO_ASFLAGS)',
569 bin => ' $(BIN_ASFLAGS)' } -> {$args{intent}};
570 my $makedepprog = $config{makedepprog};
571 if ($srcs[0] =~ /\.rc$/) {
572 my $res = platform->res($args{obj});
575 \$(RC) \$(RCOUTFLAG)\$\@ $srcs
578 my $obj = platform->obj($args{obj});
579 if ($srcs[0] =~ /\.asm$/) {
582 \$(AS) $asflags \$(ASOUTFLAG)\$\@ $srcs
584 } elsif ($srcs[0] =~ /.S$/) {
587 \$(CC) /EP /D__ASSEMBLER__ $cflags $defs $srcs > \$@.asm && \$(AS) $asflags \$(ASOUTFLAG)\$\@ \$@.asm
590 my $recipe = <<"EOF";
592 \$(CC) $cflags $defs -c \$(COUTFLAG)\$\@ $srcs
594 $recipe .= <<"EOF" unless $disabled{makedepend};
595 \$(CC) $cflags $defs /Zs /showIncludes $srcs 2>&1 > $dep
600 # We *know* this routine is only called when we've configure 'shared'.
601 # Also, note that even though the import library built here looks like
602 # a static library, it really isn't.
605 my $lib = $args{lib};
606 my @objs = map { platform->convertext($_) }
607 grep { platform->isobj($_) || platform->isres($_) }
609 my @defs = map { platform->def($_) }
610 grep { platform->isdef($_) }
612 my @deps = compute_lib_depends(@{$args{deps}});
613 die "More than one exported symbols list" if scalar @defs > 1;
614 my $linklibs = join("", map { "$_\n" } @deps);
615 my $objs = join("\n", @objs);
616 my $deps = join(" ", @objs, @defs, @deps);
617 my $import = platform->sharedlib_import($lib);
618 my $dll = platform->sharedlib($lib);
619 my $shared_def = join("", map { " /def:$_" } @defs);
621 # The import library may look like a static library, but it is not.
622 # We MUST make the import library depend on the DLL, in case someone
623 # mistakenly removes the latter.
626 IF EXIST $full.manifest DEL /F /Q $full.manifest
627 IF EXIST \$@ DEL /F /Q \$@
628 \$(LD) \$(LDFLAGS) \$(LIB_LDFLAGS) \\
629 /implib:$import \$(LDOUTFLAG)$dll$shared_def @<< || (DEL /Q \$(\@B).* $import && EXIT 1)
631 $linklibs\$(LIB_EX_LIBS)
633 IF EXIST $dll.manifest \\
634 \$(MT) \$(MTFLAGS) \$(MTINFLAG)$dll.manifest \$(MTOUTFLAG)$dll
635 IF EXIST apps\\$dll DEL /Q /F apps\\$dll
636 IF EXIST test\\$dll DEL /Q /F test\\$dll
637 IF EXIST fuzz\\$dll DEL /Q /F fuzz\\$dll
645 my $dso = platform->dso($args{lib});
646 my $dso_n = platform->dsoname($args{lib});
647 my @objs = map { platform->convertext($_) }
648 grep { platform->isobj($_) || platform->isres($_) }
650 my @defs = map { platform->def($_) }
651 grep { platform->isdef($_) }
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, @defs, @deps);
657 my $shared_def = join("", map { " /def:$_" } @defs);
660 IF EXIST $dso.manifest DEL /F /Q $dso.manifest
661 \$(LD) \$(LDFLAGS) \$(DSO_LDFLAGS) \\
662 \$(LDOUTFLAG)$dso$shared_def @<< || (DEL /Q \$(\@B).* $dso_n.* && EXIT 1)
664 $linklibs \$(DSO_EX_LIBS)
666 IF EXIST $dso.manifest \\
667 \$(MT) \$(MTFLAGS) \$(MTINFLAG)$dso.manifest \$(MTOUTFLAG)$dso
672 my $lib = platform->staticlib($args{lib});
673 my @objs = map { platform->obj($_) } @{$args{objs}};
674 my $objs = join("\n", @objs);
675 my $deps = join(" ", @objs);
678 \$(AR) \$(ARFLAGS) \$(AROUTFLAG)$lib @<<
685 my $bin = platform->bin($args{bin});
686 my @objs = map { platform->convertext($_) }
687 grep { platform->isobj($_) || platform->isres($_) }
689 my @deps = compute_lib_depends(@{$args{deps}});
690 my $objs = join("\n", @objs);
691 my $linklibs = join("", map { "$_\n" } @deps);
692 my $deps = join(" ", @objs, @deps);
695 IF EXIST $bin.manifest DEL /F /Q $bin.manifest
696 \$(LD) \$(LDFLAGS) \$(BIN_LDFLAGS) \$(LDOUTFLAG)$bin @<<
699 $linklibs\$(BIN_EX_LIBS)
701 IF EXIST $bin.manifest \\
702 \$(MT) \$(MTFLAGS) \$(MTINFLAG)$bin.manifest \$(MTOUTFLAG)$bin
707 my $script = $args{script};
708 my $sources = '"'.join('" "', @{$args{sources}}).'"';
709 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
710 "util", "dofile.pl")),
711 rel2abs($config{builddir}));
714 "\$(PERL)" "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
715 "-o$target{build_file}" $sources > "$script"
720 my $dir = $args{dir};
721 my @deps = map { platform->convertext($_) } @{$args{deps}};
723 my %extinfo = ( dso => platform->dsoext(),
724 lib => platform->libext(),
725 bin => platform->binext() );
727 # We already have a 'test' target, and the top directory is just plain
729 return if $dir eq "test" || $dir eq ".";
731 foreach my $type (("dso", "lib", "bin", "script")) {
732 next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type});
733 # For lib object files, we could update the library. However,
734 # LIB on Windows doesn't work that way, so we won't create any
735 # actions for it, and the dependencies are already taken care of.
736 if ($type ne "lib") {
737 foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) {
738 if (dirname($prod) eq $dir) {
739 push @deps, $prod.$extinfo{$type};
745 my $deps = join(" ", @deps);
746 my $actions = join("\n", "", @actions);
748 $dir $dir\\ : $deps$actions
751 "" # Important! This becomes part of the template result.