2 ## Makefile for OpenSSL
4 ## {- join("\n## ", @autowarntext) -}
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";
15 (our $sover_dirname = $config{shlib_version_number}) =~ s|\.|_|g;
18 $target{build_scheme}->[2] eq "VC-W32" ?
19 "ProgramFiles(x86)" : "ProgramW6432";
21 $target{build_scheme}->[2] eq "VC-W32"
22 ? "CommonProgramFiles(x86)" : "CommonProgramW6432";
23 our $win_installroot =
24 defined($ENV{$win_installenv})
25 ? $win_installenv : 'ProgramFiles';
27 defined($ENV{$win_commonenv})
28 ? $win_commonenv : 'CommonProgramFiles';
30 # expand variables early
31 $win_installroot = $ENV{$win_installroot};
32 $win_commonroot = $ENV{$win_commonroot};
36 return () if $disabled{shared} || $lib =~ /\.a$/;
37 return () unless defined $unified_info{sharednames}->{$lib};
38 return $unified_info{sharednames}->{$lib} . $shlibext;
42 (my $lib = shift) =~ s/\.a$//;
43 return $lib . $libext;
48 return () if $disabled{shared} || $lib =~ /\.a$/;
49 return $lib . $shlibextimport;
55 return $dso . $dsoext;
57 # This makes sure things get built in the order they need
62 return "$target: build_generated\n\t\$(MAKE) /\$(MAKEFLAGS) depend && \$(MAKE) /\$(MAKEFLAGS) _$target\n_$target";
67 PLATFORM={- $config{target} -}
68 SRCDIR={- $config{sourcedir} -}
69 BLDDIR={- $config{builddir} -}
71 VERSION={- $config{version} -}
72 MAJOR={- $config{major} -}
73 MINOR={- $config{minor} -}
75 SHLIB_VERSION_NUMBER={- $config{shlib_version_number} -}
77 LIBS={- join(" ", map { lib($_) } @{$unified_info{libraries}}) -}
78 SHLIBS={- join(" ", map { shlib($_) } @{$unified_info{libraries}}) -}
79 SHLIBPDBS={- join(" ", map { local $shlibext = ".pdb"; shlib($_) } @{$unified_info{libraries}}) -}
80 ENGINES={- join(" ", map { dso($_) } @{$unified_info{engines}}) -}
81 ENGINEPDBS={- join(" ", map { local $dsoext = ".pdb"; dso($_) } @{$unified_info{engines}}) -}
82 PROGRAMS={- our @PROGRAMS = map { $_.$exeext } @{$unified_info{programs}}; join(" ", @PROGRAMS) -}
83 PROGRAMPDBS={- join(" ", map { $_.".pdb" } @{$unified_info{programs}}) -}
84 SCRIPTS={- join(" ", @{$unified_info{scripts}}) -}
85 {- output_off() if $disabled{makedepend}; "" -}
86 DEPS={- join(" ", map { (my $x = $_) =~ s|\.o$|$depext|; $x; }
87 grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
88 keys %{$unified_info{sources}}); -}
89 {- output_on() if $disabled{makedepend}; "" -}
90 GENERATED_MANDATORY={- join(" ", @{$unified_info{depends}->{""}} ) -}
91 GENERATED={- join(" ",
92 ( map { (my $x = $_) =~ s|\.[sS]$|\.asm|; $x }
93 grep { defined $unified_info{generate}->{$_} }
94 map { @{$unified_info{sources}->{$_}} }
95 grep { /\.o$/ } keys %{$unified_info{sources}} ),
96 ( grep { /\.h$/ } keys %{$unified_info{generate}} )) -}
98 INSTALL_LIBS={- join(" ", map { lib($_) } @{$unified_info{install}->{libraries}}) -}
99 INSTALL_SHLIBS={- join(" ", map { shlib($_) } @{$unified_info{install}->{libraries}}) -}
100 INSTALL_SHLIBPDBS={- join(" ", map { local $shlibext = ".pdb"; shlib($_) } @{$unified_info{install}->{libraries}}) -}
101 INSTALL_ENGINES={- join(" ", map { dso($_) } @{$unified_info{install}->{engines}}) -}
102 INSTALL_ENGINEPDBS={- join(" ", map { local $dsoext = ".pdb"; dso($_) } @{$unified_info{install}->{engines}}) -}
103 INSTALL_PROGRAMS={- join(" ", map { $_.$exeext } grep { !m|^test\\| } @{$unified_info{install}->{programs}}) -}
104 INSTALL_PROGRAMPDBS={- join(" ", map { $_.".pdb" } grep { !m|^test\\| } @{$unified_info{install}->{programs}}) -}
105 {- output_off() if $disabled{apps}; "" -}
106 BIN_SCRIPTS=$(BLDDIR)\tools\c_rehash.pl
107 MISC_SCRIPTS=$(BLDDIR)\apps\CA.pl $(BLDDIR)\apps\tsget.pl
108 {- output_on() if $disabled{apps}; "" -}
110 APPS_OPENSSL={- use File::Spec::Functions;
111 catfile("apps","openssl") -}
113 # Do not edit these manually. Use Configure with --prefix or --openssldir
114 # to change this! Short explanation in the top comment in Configure
115 INSTALLTOP_dev={- # $prefix is used in the OPENSSLDIR perl snippet
117 use File::Spec::Functions qw(:DEFAULT splitpath);
118 our $prefix = canonpath($config{prefix}
119 || "$win_installroot\\OpenSSL");
120 our ($prefix_dev, $prefix_dir, $prefix_file) =
121 splitpath($prefix, 1);
123 INSTALLTOP_dir={- canonpath($prefix_dir) -}
125 # The logic here is that if no --openssldir was given,
126 # OPENSSLDIR will get the value "$win_commonroot\\SSL".
127 # If --openssldir was given and the value is an absolute
128 # path, OPENSSLDIR will get its value without change.
129 # If the value from --openssldir is a relative path,
130 # OPENSSLDIR will get $prefix with the --openssldir
131 # value appended as a subdirectory.
133 use File::Spec::Functions qw(:DEFAULT splitpath);
135 $config{openssldir} ?
136 (file_name_is_absolute($config{openssldir}) ?
137 canonpath($config{openssldir})
138 : catdir($prefix, $config{openssldir}))
139 : canonpath("$win_commonroot\\SSL");
140 our ($openssldir_dev, $openssldir_dir, $openssldir_file) =
141 splitpath($openssldir, 1);
143 OPENSSLDIR_dir={- canonpath($openssldir_dir) -}
144 LIBDIR={- our $libdir = $config{libdir} || "lib";
145 file_name_is_absolute($libdir) ? "" : $libdir -}
146 ENGINESDIR_dev={- use File::Spec::Functions qw(:DEFAULT splitpath);
147 our $enginesdir = catdir($prefix,$libdir,"engines-$sover_dirname");
148 our ($enginesdir_dev, $enginesdir_dir, $enginesdir_file) =
149 splitpath($enginesdir, 1);
151 ENGINESDIR_dir={- canonpath($enginesdir_dir) -}
152 !IF "$(DESTDIR)" != ""
153 INSTALLTOP=$(DESTDIR)$(INSTALLTOP_dir)
154 OPENSSLDIR=$(DESTDIR)$(OPENSSLDIR_dir)
155 ENGINESDIR=$(DESTDIR)$(ENGINESDIR_dir)
157 INSTALLTOP=$(INSTALLTOP_dev)$(INSTALLTOP_dir)
158 OPENSSLDIR=$(OPENSSLDIR_dev)$(OPENSSLDIR_dir)
159 ENGINESDIR=$(ENGINESDIR_dev)$(ENGINESDIR_dir)
162 # $(libdir) is chosen to be compatible with the GNU coding standards
163 libdir={- file_name_is_absolute($libdir)
164 ? $libdir : '$(INSTALLTOP)\$(LIBDIR)' -}
166 ##### User defined commands and flags ################################
169 CPP={- $config{CPP} -}
170 CPPFLAGS={- our $cppflags1 = join(" ",
171 (map { "-D".$_} @{$config{CPPDEFINES}}),
172 (map { " /I ".$_} @{$config{CPPINCLUDES}}),
173 @{$config{CPPFLAGS}}) -}
174 CFLAGS={- join(' ', @{$config{CFLAGS}}) -}
176 LDFLAGS={- join(' ', @{$config{LDFLAGS}}) -}
177 EX_LIBS={- join(' ', @{$config{LDLIBS}}) -}
179 PERL={- $config{perl} -}
182 ARFLAGS= {- join(' ', @{$config{ARFLAGS}}) -}
185 MTFLAGS= {- join(' ', @{$config{MTFLAGS}}) -}
188 ASFLAGS={- join(' ', @{$config{ASFLAGS}}) -}
192 ##### Special command flags ##########################################
194 COUTFLAG={- $target{coutflag} -}$(OSSL_EMPTY)
195 LDOUTFLAG={- $target{ldoutflag} -}$(OSSL_EMPTY)
196 AROUTFLAG={- $target{aroutflag} -}$(OSSL_EMPTY)
197 MTINFLAG={- $target{mtinflag} -}$(OSSL_EMPTY)
198 MTOUTFLAG={- $target{mtoutflag} -}$(OSSL_EMPTY)
199 ASOUTFLAG={- $target{asoutflag} -}$(OSSL_EMPTY)
200 RCOUTFLAG={- $target{rcoutflag} -}$(OSSL_EMPTY)
202 ##### Project flags ##################################################
204 # Variables starting with CNF_ are common variables for all product types
206 CNF_ASFLAGS={- join(' ', $target{asflags} || (),
207 @{$config{asflags}}) -}
208 CNF_CPPFLAGS={- our $cppfags2 =
209 join(' ', $target{cppflags} || (),
210 (map { quotify_l("-D".$_) } @{$target{defines}},
211 @{$config{defines}}),
212 (map { quotify_l("-I".$_) } @{$target{includes}},
213 @{$config{includes}}),
214 @{$config{cppflags}}) -}
215 CNF_CFLAGS={- join(' ', $target{cflags} || (),
216 @{$config{cflags}}) -}
217 CNF_CXXFLAGS={- join(' ', $target{cxxflags} || (),
218 @{$config{cxxflags}}) -}
219 CNF_LDFLAGS={- join(' ', $target{lflags} || (),
220 @{$config{lflags}}) -}
221 CNF_EX_LIBS={- join(' ', $target{ex_libs} || (),
222 @{$config{ex_libs}}) -}
224 # Variables starting with LIB_ are used to build library object files
225 # and shared libraries.
226 # Variables starting with DSO_ are used to build DSOs and their object files.
227 # Variables starting with BIN_ are used to build programs and their object
230 LIB_ASFLAGS={- join(' ', $target{lib_asflags} || (),
231 @{$config{lib_asflags}},
232 '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
233 LIB_CPPFLAGS={- join(' ', $target{lib_cppflags} || (),
234 $target{shared_cppflag} || (),
235 (map { quotify_l("-D".$_) }
236 @{$target{lib_defines}},
237 @{$target{shared_defines}},
238 @{$config{lib_defines}},
239 @{$config{shared_defines}},
240 "OPENSSLDIR=\"$openssldir\"",
241 "ENGINESDIR=\"$enginesdir\""),
242 (map { quotify_l("-I".$_) }
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 '$(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)
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(' ', $cppflags1 || (), $cppflags2 || ()) -}
299 PERLASM_SCHEME= {- $target{perlasm_scheme} -}
301 PROCESSOR= {- $config{processor} -}
303 # The main targets ###################################################
305 {- dependmagic('all'); -}: build_libs_nodep build_engines_nodep build_programs_nodep
306 {- dependmagic('build_libs'); -}: build_libs_nodep
307 {- dependmagic('build_engines'); -}: build_engines_nodep
308 {- dependmagic('build_programs'); -}: build_programs_nodep
310 build_generated: $(GENERATED_MANDATORY)
311 build_libs_nodep: $(LIBS) {- join(" ",map { shlib_import($_) } @{$unified_info{libraries}}) -}
312 build_engines_nodep: $(ENGINES)
313 build_programs_nodep: $(PROGRAMS) $(SCRIPTS)
315 # Kept around for backward compatibility
316 build_apps build_tests: build_programs
318 # Convenience target to prebuild all generated files, not just the mandatory
320 build_all_generated: $(GENERATED_MANDATORY) $(GENERATED)
323 {- dependmagic('tests'); -}: build_programs_nodep build_engines_nodep
324 @rem {- output_off() if $disabled{tests}; "" -}
325 -mkdir $(BLDDIR)\test\test-runs
328 set RESULT_D=$(BLDDIR)\test\test-runs
330 set OPENSSL_ENGINES=$(MAKEDIR)\engines
331 set OPENSSL_DEBUG_MEMORY=on
332 "$(PERL)" "$(SRCDIR)\test\run_tests.pl" $(TESTS)
333 @rem {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
334 @echo "Tests are not supported with your chosen Configure options"
335 @rem {- output_on() if !$disabled{tests}; "" -}
338 @rem {- output_off() if $disabled{tests}; "" -}
339 @set SRCTOP=$(SRCDIR)
340 @"$(PERL)" "$(SRCDIR)\test\run_tests.pl" list
341 @rem {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
342 @echo "Tests are not supported with your chosen Configure options"
343 @rem {- output_on() if !$disabled{tests}; "" -}
345 install: install_sw install_ssldirs install_docs
347 uninstall: uninstall_docs uninstall_sw
350 "$(PERL)" -e "map { m/(.*)\.dll$$/; unlink glob """$$1.*"""; } @ARGV" $(SHLIBS)
351 "$(PERL)" -e "map { m/(.*)\.dll$$/; unlink glob """apps/$$1.*"""; } @ARGV" $(SHLIBS)
352 "$(PERL)" -e "map { m/(.*)\.dll$$/; unlink glob """test/$$1.*"""; } @ARGV" $(SHLIBS)
353 "$(PERL)" -e "map { m/(.*)\.dll$$/; unlink glob """fuzz/$$1.*"""; } @ARGV" $(SHLIBS)
355 -del /Q ossl_static.pdb
358 {- join("\n\t", map { "-del /Q /F $_" } @PROGRAMS) -}
359 -del /Q /F $(ENGINES)
360 -del /Q /F $(SCRIPTS)
361 -del /Q /F $(GENERATED)
366 -del /Q /F apps\*.exp
367 -del /Q /F engines\*.exp
368 -del /Q /S /F engines\*.ilk
369 -del /Q /S /F engines\*.lib
370 -del /Q /S /F apps\*.lib
371 -del /Q /S /F engines\*.manifest
372 -del /Q /S /F apps\*.manifest
373 -del /Q /S /F test\*.manifest
376 -del /Q /F configdata.pm
381 # Install helper targets #############################################
383 install_sw: all install_dev install_engines install_runtime
385 uninstall_sw: uninstall_runtime uninstall_engines uninstall_dev
387 install_docs: install_html_docs
389 uninstall_docs: uninstall_html_docs
392 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\certs"
393 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\private"
394 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\misc"
395 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\openssl.cnf" \
396 "$(OPENSSLDIR)\openssl.cnf.dist"
397 @IF NOT EXIST "$(OPENSSLDIR)\openssl.cnf" \
398 "$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\openssl.cnf" \
399 "$(OPENSSLDIR)\openssl.cnf"
400 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(MISC_SCRIPTS) \
402 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\ct_log_list.cnf" \
403 "$(OPENSSLDIR)\ct_log_list.cnf.dist"
404 @IF NOT EXIST "$(OPENSSLDIR)\ct_log_list.cnf" \
405 "$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\ct_log_list.cnf" \
406 "$(OPENSSLDIR)\ct_log_list.cnf"
409 @if "$(INSTALLTOP)"=="" ( echo INSTALLTOP should not be empty & exit 1 )
410 @echo *** Installing development files
411 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\include\openssl"
412 @rem {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$config{defines}}; "" -}
413 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\ms\applink.c" \
414 "$(INSTALLTOP)\include\openssl"
415 @rem {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$config{defines}}; "" -}
416 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(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)"
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)"
439 @if "$(INSTALLTOP)"=="" ( echo INSTALLTOP should not be empty & exit 1 )
440 @echo *** Installing runtime files
441 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\bin"
442 @if not "$(SHLIBS)"=="" \
443 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_SHLIBS) "$(INSTALLTOP)\bin"
444 @if not "$(SHLIBS)"=="" \
445 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_SHLIBPDBS) \
447 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMS) \
449 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMPDBS) \
451 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BIN_SCRIPTS) \
457 "$(PERL)" "$(SRCDIR)\util\process_docs.pl" \
458 "--destdir=$(INSTALLTOP)\html" --type=html
462 # Building targets ###################################################
464 configdata.pm: "$(SRCDIR)\Configure" {- join(" ", map { '"'.$_.'"' } @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
465 @echo "Detected changed: $?"
466 "$(PERL)" configdata.pm -r
467 @echo "**************************************************"
469 @echo "*** Please run the same make command again ***"
471 @echo "**************************************************"
475 "$(PERL)" configdata.pm -r
479 use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
481 # Helper function to figure out dependencies on libraries
482 # It takes a list of library names and outputs a list of dependencies
483 sub compute_lib_depends {
484 if ($disabled{shared}) {
485 return map { lib($_) } @_;
488 (my $l = $_) =~ s/\.a$//;
489 die "Linking with static variants of shared libraries is not supported in this configuration\n"
490 if $l ne $_ && shlib($l);
492 return map { shlib_import($_) or lib($_) } @_;
497 (my $target = $args{src}) =~ s/\.[sS]$/.asm/;
498 my ($gen0, @gens) = @{$args{generator}};
499 my $generator = '"'.$gen0.'"'.join('', map { " $_" } @gens);
500 my $generator_incs = join("", map { " -I \"$_\"" } @{$args{generator_incs}});
501 my $incs = join("", map { " /I \"$_\"" } @{$args{incs}});
502 my $deps = @{$args{deps}} ?
503 '"'.join('" "', @{$args{generator_deps}}, @{$args{deps}}).'"' : '';
505 if ($target !~ /\.asm$/) {
506 if ($args{generator}->[0] =~ m|^.*\.in$|) {
507 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
508 "util", "dofile.pl")),
509 rel2abs($config{builddir}));
511 $target: "$args{generator}->[0]" $deps
512 "\$(PERL)" "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
513 "-o$target{build_file}" $generator > \$@
517 $target: "$args{generator}->[0]" $deps
518 "\$(PERL)"$generator_incs $generator > \$@
522 if ($args{generator}->[0] =~ /\.pl$/) {
523 $generator = '"$(PERL)"'.$generator_incs.' '.$generator;
524 } elsif ($args{generator}->[0] =~ /\.S$/) {
527 die "Generator type for $src unknown: $generator\n";
530 my $cppflags = $incs;
532 lib => ' $(LIB_CFLAGS) $(LIB_CPPFLAGS)',
533 dso => ' $(DSO_CFLAGS) $(DSO_CPPFLAGS)',
534 bin => ' $(BIN_CFLAGS) $(BIN_CPPFLAGS)'
535 } -> {$args{intent}};
536 if (defined($generator)) {
537 # If the target is named foo.S in build.info, we want to
538 # end up generating foo.s in two steps.
539 if ($args{src} =~ /\.S$/) {
541 $target: "$args{generator}->[0]" $deps
544 \$(CPP) $cppflags \$@.S > \$@.i && move /Y \$@.i \$@
550 $target: "$args{generator}->[0]" $deps
556 $target: "$args{generator}->[0]" $deps
557 \$(CPP) $incs $cppflags "$args{generator}->[0]" > \$@.i && move /Y \$@.i \$@
564 my @srcs = map { (my $x = $_) =~ s/\.s$/.asm/; $x
565 } ( @{$args{srcs}} );
566 my $srcs = '"'.join('" "', @srcs).'"';
567 my $deps = '"'.join('" "', @srcs, @{$args{deps}}).'"';
568 my $incs = join("", map { ' /I "'.$_.'"' } @{$args{incs}});
569 my $cflags = { lib => ' $(LIB_CFLAGS)',
570 dso => ' $(DSO_CFLAGS)',
571 bin => ' $(BIN_CFLAGS)' } -> {$args{intent}};
573 $cflags .= { lib => ' $(LIB_CPPFLAGS)',
574 dso => ' $(DSO_CPPFLAGS)',
575 bin => ' $(BIN_CPPFLAGS)' } -> {$args{intent}};
576 my $asflags = { lib => ' $(LIB_ASFLAGS)',
577 dso => ' $(DSO_ASFLAGS)',
578 bin => ' $(BIN_ASFLAGS)' } -> {$args{intent}};
579 my $makedepprog = $config{makedepprog};
580 if ($srcs[0] =~ /\.rc$/) {
583 \$(RC) \$(RCOUTFLAG)\$\@ $srcs
586 (my $obj = $args{obj}) =~ s|\.o$||;
587 if ($srcs[0] =~ /\.asm$/) {
590 \$(AS) $asflags \$(ASOUTFLAG)\$\@ $srcs
593 return <<"EOF" if (!$disabled{makedepend});
595 \$(CC) $cflags /Zs /showIncludes $srcs 2>&1 | \\
596 "\$(PERL)" -n << > $obj$depext
598 s/^Note: including file: *//;
599 \$\$collect{\$\$_} = 1;
600 END { print '$obj$objext: ',join(" ", sort keys \%collect),"\\n" }
602 $obj$objext: $obj$depext
603 \$(CC) $cflags -c \$(COUTFLAG)\$\@ @<<
607 return <<"EOF" if ($disabled{makedepend});
609 \$(CC) $cflags -c \$(COUTFLAG)\$\@ $srcs
613 # On Unix, we build shlibs from static libs, so we're ignoring the
614 # object file array. We *know* this routine is only called when we've
615 # configure 'shared'.
618 my $lib = $args{lib};
619 my $shlib = $args{shlib};
620 my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x }
621 grep { $_ =~ m/\.(?:o|res)$/ }
623 my @defs = grep { $_ =~ /\.def$/ } @{$args{objs}};
624 my @deps = compute_lib_depends(@{$args{deps}});
625 die "More than one exported symbols list" if scalar @defs > 1;
626 my $linklibs = join("", map { "$_\n" } @deps);
627 my $objs = join("\n", @objs);
628 my $deps = join(" ", @objs, @defs, @deps);
629 my $target = shlib_import($lib);
630 my $shared_def = join("", map { " /def:$_" } @defs);
633 IF EXIST $shlib$shlibext.manifest DEL /F /Q $shlib$shlibext.manifest
634 \$(LD) \$(LDFLAGS) \$(LIB_LDFLAGS) \\
635 /implib:\$@ \$(LDOUTFLAG)$shlib$shlibext$shared_def @<< || (DEL /Q \$(\@B).* $shlib.* && EXIT 1)
637 $linklibs\$(LIB_EX_LIBS)
639 IF EXIST $shlib$shlibext.manifest \\
640 \$(MT) \$(MTFLAGS) \$(MTINFLAG)$shlib$shlibext.manifest \$(MTOUTFLAG)$shlib$shlibext
641 IF EXIST apps\\$shlib$shlibext DEL /Q /F apps\\$shlib$shlibext
642 IF EXIST test\\$shlib$shlibext DEL /Q /F test\\$shlib$shlibext
643 IF EXIST fuzz\\$shlib$shlibext DEL /Q /F fuzz\\$shlib$shlibext
644 COPY $shlib$shlibext apps
645 COPY $shlib$shlibext test
646 COPY $shlib$shlibext fuzz
651 my $dso = $args{lib};
652 my $dso_n = basename($dso);
653 my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
654 my @deps = compute_lib_depends(@{$args{deps}});
655 my $objs = join("\n", @objs);
656 my $linklibs = join("", map { "$_\n" } @deps);
657 my $deps = join(" ", @objs, @deps);
660 IF EXIST $dso$dsoext.manifest DEL /F /Q $dso$dsoext.manifest
661 \$(LD) \$(LDFLAGS) \$(DSO_LDFLAGS) \$(LDOUTFLAG)$dso$dsoext /def:<< @<<
668 $linklibs \$(DSO_EX_LIBS)
670 IF EXIST $dso$dsoext.manifest \\
671 \$(MT) \$(MTFLAGS) \$(MTINFLAG)$dso$dsoext.manifest \$(MTOUTFLAG)$dso$dsoext
676 my $lib = $args{lib};
678 # Because static libs and import libs are both named the same in native
679 # Windows, we can't have both. We skip the static lib in that case,
680 # as the shared libs are what we use anyway.
681 return "" unless $disabled{"shared"} || $lib =~ /\.a$/;
684 my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
685 my $objs = join("\n", @objs);
686 my $deps = join(" ", @objs);
689 \$(AR) \$(ARFLAGS) \$(AROUTFLAG)$lib$libext @<<
696 my $bin = $args{bin};
697 my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
698 my @deps = compute_lib_depends(@{$args{deps}});
699 my $objs = join("\n", @objs);
700 my $linklibs = join("", map { "$_\n" } @deps);
701 my $deps = join(" ", @objs, @deps);
704 IF EXIST $bin$exeext.manifest DEL /F /Q $bin$exeext.manifest
705 \$(LD) \$(LDFLAGS) \$(BIN_LDFLAGS) \$(LDOUTFLAG)$bin$exeext @<<
708 $linklibs\$(BIN_EX_LIBS)
710 IF EXIST $bin$exeext.manifest \\
711 \$(MT) \$(MTFLAGS) \$(MTINFLAG)$bin$exeext.manifest \$(MTOUTFLAG)$bin$exeext
716 my $script = $args{script};
717 my $sources = '"'.join('" "', @{$args{sources}}).'"';
718 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
719 "util", "dofile.pl")),
720 rel2abs($config{builddir}));
723 "\$(PERL)" "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
724 "-o$target{build_file}" $sources > "$script"
729 my $dir = $args{dir};
730 my @deps = map { s|\.o$|$objext|; $_ } @{$args{deps}};
732 my %extinfo = ( dso => $dsoext,
736 foreach my $type (("dso", "lib", "bin", "script")) {
737 next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type});
738 # For lib object files, we could update the library. However,
739 # LIB on Windows doesn't work that way, so we won't create any
740 # actions for it, and the dependencies are already taken care of.
741 if ($type ne "lib") {
742 foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) {
743 if (dirname($prod) eq $dir) {
744 push @deps, $prod.$extinfo{$type};
746 push @actions, "\t@rem No support to produce $type ".join(", ", @{$unified_info{dirinfo}->{$dir}->{products}->{$type}});
752 my $deps = join(" ", @deps);
753 my $actions = join("\n", "", @actions);
755 $args{dir} $args{dir}\\ : $deps$actions
758 "" # Important! This becomes part of the template result.