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;
17 my $build_scheme = $target{build_scheme};
18 my $install_flavour = $build_scheme->[$#$build_scheme]; # last element
20 $install_flavour eq "VC-WOW" ? "ProgramFiles(x86)"
23 $install_flavour eq "VC-WOW" ? "CommonProgramFiles(x86)"
24 : "CommonProgramW6432";
25 our $win_installroot =
26 defined($ENV{$win_installenv}) ? $win_installenv : 'ProgramFiles';
28 defined($ENV{$win_commonenv}) ? $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={- # common0.tmpl provides @generated
92 join(" ", map { (my $x = $_) =~ s|\.[sS]$|.asm|; $x }
95 INSTALL_LIBS={- join(" ", map { lib($_) } @{$unified_info{install}->{libraries}}) -}
96 INSTALL_SHLIBS={- join(" ", map { shlib($_) } @{$unified_info{install}->{libraries}}) -}
97 INSTALL_SHLIBPDBS={- join(" ", map { local $shlibext = ".pdb"; shlib($_) } @{$unified_info{install}->{libraries}}) -}
98 INSTALL_ENGINES={- join(" ", map { dso($_) } @{$unified_info{install}->{engines}}) -}
99 INSTALL_ENGINEPDBS={- join(" ", map { local $dsoext = ".pdb"; dso($_) } @{$unified_info{install}->{engines}}) -}
100 INSTALL_PROGRAMS={- join(" ", map { $_.$exeext } grep { !m|^test\\| } @{$unified_info{install}->{programs}}) -}
101 INSTALL_PROGRAMPDBS={- join(" ", map { $_.".pdb" } grep { !m|^test\\| } @{$unified_info{install}->{programs}}) -}
102 {- output_off() if $disabled{apps}; "" -}
103 BIN_SCRIPTS=$(BLDDIR)\tools\c_rehash.pl
104 MISC_SCRIPTS=$(BLDDIR)\apps\CA.pl $(BLDDIR)\apps\tsget.pl
105 {- output_on() if $disabled{apps}; "" -}
107 APPS_OPENSSL={- use File::Spec::Functions;
108 catfile("apps","openssl") -}
110 # Do not edit these manually. Use Configure with --prefix or --openssldir
111 # to change this! Short explanation in the top comment in Configure
112 INSTALLTOP_dev={- # $prefix is used in the OPENSSLDIR perl snippet
114 use File::Spec::Functions qw(:DEFAULT splitpath);
115 our $prefix = canonpath($config{prefix}
116 || "$win_installroot\\OpenSSL");
117 our ($prefix_dev, $prefix_dir, $prefix_file) =
118 splitpath($prefix, 1);
120 INSTALLTOP_dir={- canonpath($prefix_dir) -}
122 # The logic here is that if no --openssldir was given,
123 # OPENSSLDIR will get the value "$win_commonroot\\SSL".
124 # If --openssldir was given and the value is an absolute
125 # path, OPENSSLDIR will get its value without change.
126 # If the value from --openssldir is a relative path,
127 # OPENSSLDIR will get $prefix with the --openssldir
128 # value appended as a subdirectory.
130 use File::Spec::Functions qw(:DEFAULT splitpath);
132 $config{openssldir} ?
133 (file_name_is_absolute($config{openssldir}) ?
134 canonpath($config{openssldir})
135 : catdir($prefix, $config{openssldir}))
136 : canonpath("$win_commonroot\\SSL");
137 our ($openssldir_dev, $openssldir_dir, $openssldir_file) =
138 splitpath($openssldir, 1);
140 OPENSSLDIR_dir={- canonpath($openssldir_dir) -}
141 LIBDIR={- our $libdir = $config{libdir} || "lib";
142 file_name_is_absolute($libdir) ? "" : $libdir -}
143 ENGINESDIR_dev={- use File::Spec::Functions qw(:DEFAULT splitpath);
144 our $enginesdir = catdir($prefix,$libdir,"engines-$sover_dirname");
145 our ($enginesdir_dev, $enginesdir_dir, $enginesdir_file) =
146 splitpath($enginesdir, 1);
148 ENGINESDIR_dir={- canonpath($enginesdir_dir) -}
149 !IF "$(DESTDIR)" != ""
150 INSTALLTOP=$(DESTDIR)$(INSTALLTOP_dir)
151 OPENSSLDIR=$(DESTDIR)$(OPENSSLDIR_dir)
152 ENGINESDIR=$(DESTDIR)$(ENGINESDIR_dir)
154 INSTALLTOP=$(INSTALLTOP_dev)$(INSTALLTOP_dir)
155 OPENSSLDIR=$(OPENSSLDIR_dev)$(OPENSSLDIR_dir)
156 ENGINESDIR=$(ENGINESDIR_dev)$(ENGINESDIR_dir)
159 # $(libdir) is chosen to be compatible with the GNU coding standards
160 libdir={- file_name_is_absolute($libdir)
161 ? $libdir : '$(INSTALLTOP)\$(LIBDIR)' -}
163 ##### User defined commands and flags ################################
166 CPP={- $config{CPP} -}
167 CPPFLAGS={- our $cppflags1 = join(" ",
168 (map { "-D".$_} @{$config{CPPDEFINES}}),
169 (map { " /I ".$_} @{$config{CPPINCLUDES}}),
170 @{$config{CPPFLAGS}}) -}
171 CFLAGS={- join(' ', @{$config{CFLAGS}}) -}
173 LDFLAGS={- join(' ', @{$config{LDFLAGS}}) -}
174 EX_LIBS={- join(' ', @{$config{LDLIBS}}) -}
176 PERL={- $config{perl} -}
179 ARFLAGS= {- join(' ', @{$config{ARFLAGS}}) -}
182 MTFLAGS= {- join(' ', @{$config{MTFLAGS}}) -}
185 ASFLAGS={- join(' ', @{$config{ASFLAGS}}) -}
189 ##### Special command flags ##########################################
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)
199 ##### Project flags ##################################################
201 # Variables starting with CNF_ are common variables for all product types
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}}) -}
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
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)
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 || (),
300 PERLASM_SCHEME= {- $target{perlasm_scheme} -}
302 PROCESSOR= {- $config{processor} -}
304 # The main targets ###################################################
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
311 build_generated: $(GENERATED_MANDATORY)
312 build_libs_nodep: $(LIBS) {- join(" ",map { shlib_import($_) } @{$unified_info{libraries}}) -}
313 build_engines_nodep: $(ENGINES)
314 build_programs_nodep: $(PROGRAMS) $(SCRIPTS)
316 # Kept around for backward compatibility
317 build_apps build_tests: build_programs
319 # Convenience target to prebuild all generated files, not just the mandatory
321 build_all_generated: $(GENERATED_MANDATORY) $(GENERATED)
324 {- dependmagic('tests'); -}: build_programs_nodep build_engines_nodep
325 @rem {- output_off() if $disabled{tests}; "" -}
326 -mkdir $(BLDDIR)\test\test-runs
329 set RESULT_D=$(BLDDIR)\test\test-runs
331 set OPENSSL_ENGINES=$(MAKEDIR)\engines
332 set OPENSSL_DEBUG_MEMORY=on
333 "$(PERL)" "$(SRCDIR)\test\run_tests.pl" $(TESTS)
334 @rem {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
335 @echo "Tests are not supported with your chosen Configure options"
336 @rem {- output_on() if !$disabled{tests}; "" -}
339 @rem {- output_off() if $disabled{tests}; "" -}
340 @set SRCTOP=$(SRCDIR)
341 @"$(PERL)" "$(SRCDIR)\test\run_tests.pl" list
342 @rem {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
343 @echo "Tests are not supported with your chosen Configure options"
344 @rem {- output_on() if !$disabled{tests}; "" -}
346 install: install_sw install_ssldirs install_docs
348 uninstall: uninstall_docs uninstall_sw
351 "$(PERL)" -e "map { m/(.*)\.dll$$/; unlink glob """{.,apps,test,fuzz}/$$1.*"""; } @ARGV" $(SHLIBS)
352 -del /Q /F $(LIBS) libcrypto.* libssl.* ossl_static.pdb
355 {- join("\n\t", map { "-del /Q /F $_" } @PROGRAMS) -}
356 -del /Q /F $(ENGINES)
357 -del /Q /F $(SCRIPTS)
358 -del /Q /F $(GENERATED)
359 -del /Q /S /F *.d *.obj *.pdb *.exp *.ilk *.manifest
360 -del /Q /S /F engines\*.lib
361 -del /Q /S /F apps\*.lib apps\*.rc apps\*.res
364 -del /Q /F configdata.pm
368 @ rem {- output_off() if $disabled{makedepend}; "" -}
369 @ "$(PERL)" "$(SRCDIR)\util\add-depends.pl" "VC"
370 @ rem {- output_on() if $disabled{makedepend}; "" -}
372 # Install helper targets #############################################
374 install_sw: all install_dev install_engines install_runtime
376 uninstall_sw: uninstall_runtime uninstall_engines uninstall_dev
378 install_docs: install_html_docs
380 uninstall_docs: uninstall_html_docs
383 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\certs"
384 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\private"
385 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\misc"
386 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\openssl.cnf" \
387 "$(OPENSSLDIR)\openssl.cnf.dist"
388 @IF NOT EXIST "$(OPENSSLDIR)\openssl.cnf" \
389 "$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\openssl.cnf" \
390 "$(OPENSSLDIR)\openssl.cnf"
391 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(MISC_SCRIPTS) \
393 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\ct_log_list.cnf" \
394 "$(OPENSSLDIR)\ct_log_list.cnf.dist"
395 @IF NOT EXIST "$(OPENSSLDIR)\ct_log_list.cnf" \
396 "$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\ct_log_list.cnf" \
397 "$(OPENSSLDIR)\ct_log_list.cnf"
400 @if "$(INSTALLTOP)"=="" ( echo INSTALLTOP should not be empty & exit 1 )
401 @echo *** Installing development files
402 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\include\openssl"
403 @rem {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$config{defines}}; "" -}
404 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\ms\applink.c" \
405 "$(INSTALLTOP)\include\openssl"
406 @rem {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$config{defines}}; "" -}
407 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\include\openssl\*.h" \
408 "$(INSTALLTOP)\include\openssl"
409 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BLDDIR)\include\openssl\*.h \
410 "$(INSTALLTOP)\include\openssl"
411 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(libdir)"
412 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_LIBS) "$(libdir)"
413 @if "$(SHLIBS)"=="" \
414 "$(PERL)" "$(SRCDIR)\util\copy.pl" ossl_static.pdb "$(libdir)"
419 @if "$(INSTALLTOP)"=="" ( echo INSTALLTOP should not be empty & exit 1 )
420 @echo *** Installing engines
421 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(ENGINESDIR)"
422 @if not "$(ENGINES)"=="" \
423 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINES) "$(ENGINESDIR)"
424 @if not "$(ENGINES)"=="" \
425 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINEPDBS) "$(ENGINESDIR)"
430 @if "$(INSTALLTOP)"=="" ( echo INSTALLTOP should not be empty & exit 1 )
431 @echo *** Installing runtime files
432 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\bin"
433 @if not "$(SHLIBS)"=="" \
434 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_SHLIBS) "$(INSTALLTOP)\bin"
435 @if not "$(SHLIBS)"=="" \
436 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_SHLIBPDBS) \
438 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMS) \
440 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMPDBS) \
442 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BIN_SCRIPTS) \
448 "$(PERL)" "$(SRCDIR)\util\process_docs.pl" \
449 "--destdir=$(INSTALLTOP)\html" --type=html
453 # Building targets ###################################################
455 configdata.pm: "$(SRCDIR)\Configure" {- join(" ", map { '"'.$_.'"' } @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
456 @echo "Detected changed: $?"
457 "$(PERL)" configdata.pm -r
458 @echo "**************************************************"
460 @echo "*** Please run the same make command again ***"
462 @echo "**************************************************"
466 "$(PERL)" configdata.pm -r
470 use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
472 # Helper function to figure out dependencies on libraries
473 # It takes a list of library names and outputs a list of dependencies
474 sub compute_lib_depends {
475 if ($disabled{shared}) {
476 return map { lib($_) } @_;
479 (my $l = $_) =~ s/\.a$//;
480 die "Linking with static variants of shared libraries is not supported in this configuration\n"
481 if $l ne $_ && shlib($l);
483 return map { shlib_import($_) or lib($_) } @_;
488 (my $target = $args{src}) =~ s/\.[sS]$/.asm/;
489 my ($gen0, @gens) = @{$args{generator}};
490 my $generator = '"'.$gen0.'"'.join('', map { " $_" } @gens);
491 my $generator_incs = join("", map { " -I \"$_\"" } @{$args{generator_incs}});
492 my $incs = join("", map { " /I \"$_\"" } @{$args{incs}});
493 my $deps = @{$args{deps}} ?
494 '"'.join('" "', @{$args{generator_deps}}, @{$args{deps}}).'"' : '';
496 if ($target !~ /\.asm$/) {
497 if ($args{generator}->[0] =~ m|^.*\.in$|) {
498 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
499 "util", "dofile.pl")),
500 rel2abs($config{builddir}));
502 $target: "$args{generator}->[0]" $deps
503 "\$(PERL)" "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
504 "-o$target{build_file}" $generator > \$@
508 $target: "$args{generator}->[0]" $deps
509 "\$(PERL)"$generator_incs $generator > \$@
513 if ($args{generator}->[0] =~ /\.pl$/) {
514 $generator = '"$(PERL)"'.$generator_incs.' '.$generator;
515 } elsif ($args{generator}->[0] =~ /\.S$/) {
518 die "Generator type for $src unknown: $generator\n";
521 my $cppflags = $incs;
523 lib => ' $(LIB_CFLAGS) $(LIB_CPPFLAGS)',
524 dso => ' $(DSO_CFLAGS) $(DSO_CPPFLAGS)',
525 bin => ' $(BIN_CFLAGS) $(BIN_CPPFLAGS)'
526 } -> {$args{intent}};
527 if (defined($generator)) {
528 # If the target is named foo.S in build.info, we want to
529 # end up generating foo.s in two steps.
530 if ($args{src} =~ /\.S$/) {
532 $target: "$args{generator}->[0]" $deps
535 \$(CPP) $cppflags \$@.S > \$@.i && move /Y \$@.i \$@
541 $target: "$args{generator}->[0]" $deps
547 $target: "$args{generator}->[0]" $deps
548 \$(CPP) $incs $cppflags "$args{generator}->[0]" > \$@.i && move /Y \$@.i \$@
555 my @srcs = map { (my $x = $_) =~ s/\.s$/.asm/; $x
556 } ( @{$args{srcs}} );
557 my $srcs = '"'.join('" "', @srcs).'"';
558 my $deps = '"'.join('" "', @srcs, @{$args{deps}}).'"';
559 my $incs = join("", map { ' /I "'.$_.'"' } @{$args{incs}});
560 my $cflags = { lib => ' $(LIB_CFLAGS)',
561 dso => ' $(DSO_CFLAGS)',
562 bin => ' $(BIN_CFLAGS)' } -> {$args{intent}};
564 $cflags .= { lib => ' $(LIB_CPPFLAGS)',
565 dso => ' $(DSO_CPPFLAGS)',
566 bin => ' $(BIN_CPPFLAGS)' } -> {$args{intent}};
567 my $asflags = { lib => ' $(LIB_ASFLAGS)',
568 dso => ' $(DSO_ASFLAGS)',
569 bin => ' $(BIN_ASFLAGS)' } -> {$args{intent}};
570 my $makedepprog = $config{makedepprog};
571 if ($srcs[0] =~ /\.rc$/) {
574 \$(RC) \$(RCOUTFLAG)\$\@ $srcs
577 (my $obj = $args{obj}) =~ s|\.o$||;
578 if ($srcs[0] =~ /\.asm$/) {
581 \$(AS) $asflags \$(ASOUTFLAG)\$\@ $srcs
584 return <<"EOF" if (!$disabled{makedepend});
586 \$(CC) $cflags /Zs /showIncludes $srcs 2>&1 > $obj$depext
587 $obj$objext: $obj$depext
588 \$(CC) $cflags -c \$(COUTFLAG)\$\@ $srcs
590 return <<"EOF" if ($disabled{makedepend});
592 \$(CC) $cflags -c \$(COUTFLAG)\$\@ $srcs
596 # On Unix, we build shlibs from static libs, so we're ignoring the
597 # object file array. We *know* this routine is only called when we've
598 # configure 'shared'.
601 my $lib = $args{lib};
602 my $shlib = $args{shlib};
603 my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x }
604 grep { $_ =~ m/\.(?:o|res)$/ }
606 my @defs = grep { $_ =~ /\.def$/ } @{$args{objs}};
607 my @deps = compute_lib_depends(@{$args{deps}});
608 die "More than one exported symbols list" if scalar @defs > 1;
609 my $linklibs = join("", map { "$_\n" } @deps);
610 my $objs = join("\n", @objs);
611 my $deps = join(" ", @objs, @defs, @deps);
612 my $target = shlib_import($lib);
613 my $shared_def = join("", map { " /def:$_" } @defs);
616 IF EXIST $shlib$shlibext.manifest DEL /F /Q $shlib$shlibext.manifest
617 \$(LD) \$(LDFLAGS) \$(LIB_LDFLAGS) \\
618 /implib:\$@ \$(LDOUTFLAG)$shlib$shlibext$shared_def @<< || (DEL /Q \$(\@B).* $shlib.* && EXIT 1)
620 $linklibs\$(LIB_EX_LIBS)
622 IF EXIST $shlib$shlibext.manifest \\
623 \$(MT) \$(MTFLAGS) \$(MTINFLAG)$shlib$shlibext.manifest \$(MTOUTFLAG)$shlib$shlibext
624 IF EXIST apps\\$shlib$shlibext DEL /Q /F apps\\$shlib$shlibext
625 IF EXIST test\\$shlib$shlibext DEL /Q /F test\\$shlib$shlibext
626 IF EXIST fuzz\\$shlib$shlibext DEL /Q /F fuzz\\$shlib$shlibext
627 COPY $shlib$shlibext apps
628 COPY $shlib$shlibext test
629 COPY $shlib$shlibext fuzz
634 my $dso = $args{lib};
635 my $dso_n = basename($dso);
636 my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
637 my @deps = compute_lib_depends(@{$args{deps}});
638 my $objs = join("\n", @objs);
639 my $linklibs = join("", map { "$_\n" } @deps);
640 my $deps = join(" ", @objs, @deps);
643 IF EXIST $dso$dsoext.manifest DEL /F /Q $dso$dsoext.manifest
644 \$(LD) \$(LDFLAGS) \$(DSO_LDFLAGS) \$(LDOUTFLAG)$dso$dsoext /def:<< @<<
651 $linklibs \$(DSO_EX_LIBS)
653 IF EXIST $dso$dsoext.manifest \\
654 \$(MT) \$(MTFLAGS) \$(MTINFLAG)$dso$dsoext.manifest \$(MTOUTFLAG)$dso$dsoext
659 my $lib = $args{lib};
661 # Because static libs and import libs are both named the same in native
662 # Windows, we can't have both. We skip the static lib in that case,
663 # as the shared libs are what we use anyway.
664 return "" unless $disabled{"shared"} || $lib =~ /\.a$/;
667 my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
668 my $objs = join("\n", @objs);
669 my $deps = join(" ", @objs);
672 \$(AR) \$(ARFLAGS) \$(AROUTFLAG)$lib$libext @<<
679 my $bin = $args{bin};
680 my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
681 my @deps = compute_lib_depends(@{$args{deps}});
682 my $objs = join("\n", @objs);
683 my $linklibs = join("", map { "$_\n" } @deps);
684 my $deps = join(" ", @objs, @deps);
687 IF EXIST $bin$exeext.manifest DEL /F /Q $bin$exeext.manifest
688 \$(LD) \$(LDFLAGS) \$(BIN_LDFLAGS) \$(LDOUTFLAG)$bin$exeext @<<
691 $linklibs\$(BIN_EX_LIBS)
693 IF EXIST $bin$exeext.manifest \\
694 \$(MT) \$(MTFLAGS) \$(MTINFLAG)$bin$exeext.manifest \$(MTOUTFLAG)$bin$exeext
699 my $script = $args{script};
700 my $sources = '"'.join('" "', @{$args{sources}}).'"';
701 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
702 "util", "dofile.pl")),
703 rel2abs($config{builddir}));
706 "\$(PERL)" "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
707 "-o$target{build_file}" $sources > "$script"
712 my $dir = $args{dir};
713 my @deps = map { s|\.o$|$objext|; $_ } @{$args{deps}};
715 my %extinfo = ( dso => $dsoext,
719 foreach my $type (("dso", "lib", "bin", "script")) {
720 next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type});
721 # For lib object files, we could update the library. However,
722 # LIB on Windows doesn't work that way, so we won't create any
723 # actions for it, and the dependencies are already taken care of.
724 if ($type ne "lib") {
725 foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) {
726 if (dirname($prod) eq $dir) {
727 push @deps, $prod.$extinfo{$type};
729 push @actions, "\t@rem No support to produce $type ".join(", ", @{$unified_info{dirinfo}->{$dir}->{products}->{$type}});
735 my $deps = join(" ", @deps);
736 my $actions = join("\n", "", @actions);
738 $args{dir} $args{dir}\\ : $deps$actions
741 "" # Important! This becomes part of the template result.