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 $defext = $target{dep_extension} || ".def";
10 our $exeext = $target{exe_extension} || ".exe";
11 our $libext = $target{lib_extension} || ".lib";
12 our $shlibext = $target{shared_extension} || ".dll";
13 our $shlibextimport = $target{shared_import_extension} || ".lib";
14 our $dsoext = $target{dso_extension} || ".dll";
16 (our $sover_dirname = $config{shlib_version_number}) =~ s|\.|_|g;
18 my $build_scheme = $target{build_scheme};
19 my $install_flavour = $build_scheme->[$#$build_scheme]; # last element
21 $install_flavour eq "VC-WOW" ? "ProgramFiles(x86)"
24 $install_flavour eq "VC-WOW" ? "CommonProgramFiles(x86)"
25 : "CommonProgramW6432";
26 our $win_installroot =
27 defined($ENV{$win_installenv}) ? $win_installenv : 'ProgramFiles';
29 defined($ENV{$win_commonenv}) ? $win_commonenv : 'CommonProgramFiles';
31 # expand variables early
32 $win_installroot = $ENV{$win_installroot};
33 $win_commonroot = $ENV{$win_commonroot};
37 return () if $disabled{shared} || $lib =~ /\.a$/;
38 return () unless defined $unified_info{sharednames}->{$lib};
39 return $unified_info{sharednames}->{$lib} . $shlibext;
43 (my $lib = shift) =~ s/\.a$//;
44 return $lib . $libext;
49 return () if $disabled{shared} || $lib =~ /\.a$/;
50 return $lib . $shlibextimport;
56 return $dso . $dsoext;
58 # This makes sure things get built in the order they need
63 return "$target: build_generated\n\t\$(MAKE) /\$(MAKEFLAGS) depend && \$(MAKE) /\$(MAKEFLAGS) _$target\n_$target";
68 PLATFORM={- $config{target} -}
69 SRCDIR={- $config{sourcedir} -}
70 BLDDIR={- $config{builddir} -}
72 VERSION={- $config{version} -}
73 MAJOR={- $config{major} -}
74 MINOR={- $config{minor} -}
76 SHLIB_VERSION_NUMBER={- $config{shlib_version_number} -}
78 LIBS={- join(" ", map { lib($_) } @{$unified_info{libraries}}) -}
79 SHLIBS={- join(" ", map { shlib($_) } @{$unified_info{libraries}}) -}
80 SHLIBPDBS={- join(" ", map { local $shlibext = ".pdb"; shlib($_) } @{$unified_info{libraries}}) -}
81 ENGINES={- join(" ", map { dso($_) } @{$unified_info{engines}}) -}
82 ENGINEPDBS={- join(" ", map { local $dsoext = ".pdb"; dso($_) } @{$unified_info{engines}}) -}
83 PROGRAMS={- our @PROGRAMS = map { $_.$exeext } @{$unified_info{programs}}; join(" ", @PROGRAMS) -}
84 PROGRAMPDBS={- join(" ", map { $_.".pdb" } @{$unified_info{programs}}) -}
85 SCRIPTS={- join(" ", @{$unified_info{scripts}}) -}
86 {- output_off() if $disabled{makedepend}; "" -}
87 DEPS={- join(" ", map { (my $x = $_) =~ s|\.o$|$depext|; $x; }
88 grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
89 keys %{$unified_info{sources}}); -}
90 {- output_on() if $disabled{makedepend}; "" -}
91 GENERATED_MANDATORY={- join(" ", @{$unified_info{depends}->{""}} ) -}
92 GENERATED={- # common0.tmpl provides @generated
93 join(" ", map { my $x = $_;
94 $x =~ s|\.[sS]$|.asm|;
95 $x =~ s|\.ld$|$defext|;
99 INSTALL_LIBS={- join(" ", map { quotify1(lib($_)) } @{$unified_info{install}->{libraries}}) -}
100 INSTALL_SHLIBS={- join(" ", map { quotify_l(shlib($_)) } @{$unified_info{install}->{libraries}}) -}
101 INSTALL_SHLIBPDBS={- join(" ", map { local $shlibext = ".pdb"; quotify_l(shlib($_)) } @{$unified_info{install}->{libraries}}) -}
102 INSTALL_ENGINES={- join(" ", map { quotify1(dso($_)) } @{$unified_info{install}->{engines}}) -}
103 INSTALL_ENGINEPDBS={- join(" ", map { local $dsoext = ".pdb"; quotify1(dso($_)) } @{$unified_info{install}->{engines}}) -}
104 INSTALL_PROGRAMS={- join(" ", map { quotify1($_.$exeext) } grep { !m|^test\\| } @{$unified_info{install}->{programs}}) -}
105 INSTALL_PROGRAMPDBS={- join(" ", map { quotify1($_.".pdb") } grep { !m|^test\\| } @{$unified_info{install}->{programs}}) -}
106 {- output_off() if $disabled{apps}; "" -}
107 BIN_SCRIPTS="$(BLDDIR)\tools\c_rehash.pl"
108 MISC_SCRIPTS="$(BLDDIR)\apps\CA.pl" "$(BLDDIR)\apps\tsget.pl"
109 {- output_on() if $disabled{apps}; "" -}
111 APPS_OPENSSL={- use File::Spec::Functions;
112 "\"".catfile("apps","openssl")."\"" -}
114 # Do not edit these manually. Use Configure with --prefix or --openssldir
115 # to change this! Short explanation in the top comment in Configure
116 INSTALLTOP_dev={- # $prefix is used in the OPENSSLDIR perl snippet
118 use File::Spec::Functions qw(:DEFAULT splitpath);
119 our $prefix = canonpath($config{prefix}
120 || "$win_installroot\\OpenSSL");
121 our ($prefix_dev, $prefix_dir, $prefix_file) =
122 splitpath($prefix, 1);
124 INSTALLTOP_dir={- canonpath($prefix_dir) -}
126 # The logic here is that if no --openssldir was given,
127 # OPENSSLDIR will get the value "$win_commonroot\\SSL".
128 # If --openssldir was given and the value is an absolute
129 # path, OPENSSLDIR will get its value without change.
130 # If the value from --openssldir is a relative path,
131 # OPENSSLDIR will get $prefix with the --openssldir
132 # value appended as a subdirectory.
134 use File::Spec::Functions qw(:DEFAULT splitpath);
136 $config{openssldir} ?
137 (file_name_is_absolute($config{openssldir}) ?
138 canonpath($config{openssldir})
139 : catdir($prefix, $config{openssldir}))
140 : canonpath("$win_commonroot\\SSL");
141 our ($openssldir_dev, $openssldir_dir, $openssldir_file) =
142 splitpath($openssldir, 1);
144 OPENSSLDIR_dir={- canonpath($openssldir_dir) -}
145 LIBDIR={- our $libdir = $config{libdir} || "lib";
146 file_name_is_absolute($libdir) ? "" : $libdir -}
147 ENGINESDIR_dev={- use File::Spec::Functions qw(:DEFAULT splitpath);
148 our $enginesdir = catdir($prefix,$libdir,"engines-$sover_dirname");
149 our ($enginesdir_dev, $enginesdir_dir, $enginesdir_file) =
150 splitpath($enginesdir, 1);
152 ENGINESDIR_dir={- canonpath($enginesdir_dir) -}
153 !IF "$(DESTDIR)" != ""
154 INSTALLTOP=$(DESTDIR)$(INSTALLTOP_dir)
155 OPENSSLDIR=$(DESTDIR)$(OPENSSLDIR_dir)
156 ENGINESDIR=$(DESTDIR)$(ENGINESDIR_dir)
158 INSTALLTOP=$(INSTALLTOP_dev)$(INSTALLTOP_dir)
159 OPENSSLDIR=$(OPENSSLDIR_dev)$(OPENSSLDIR_dir)
160 ENGINESDIR=$(ENGINESDIR_dev)$(ENGINESDIR_dir)
163 # $(libdir) is chosen to be compatible with the GNU coding standards
164 libdir={- file_name_is_absolute($libdir)
165 ? $libdir : '$(INSTALLTOP)\$(LIBDIR)' -}
167 ##### User defined commands and flags ################################
170 CPP={- $config{CPP} -}
171 CPPFLAGS={- our $cppflags1 = join(" ",
172 (map { "-D".$_} @{$config{CPPDEFINES}}),
173 (map { " /I ".$_} @{$config{CPPINCLUDES}}),
174 @{$config{CPPFLAGS}}) -}
175 CFLAGS={- join(' ', @{$config{CFLAGS}}) -}
177 LDFLAGS={- join(' ', @{$config{LDFLAGS}}) -}
178 EX_LIBS={- join(' ', @{$config{LDLIBS}}) -}
180 PERL={- $config{PERL} -}
183 ARFLAGS= {- join(' ', @{$config{ARFLAGS}}) -}
186 MTFLAGS= {- join(' ', @{$config{MTFLAGS}}) -}
189 ASFLAGS={- join(' ', @{$config{ASFLAGS}}) -}
193 ECHO="$(PERL)" "$(SRCDIR)\util\echo.pl"
195 ##### Special command flags ##########################################
197 COUTFLAG={- $target{coutflag} -}$(OSSL_EMPTY)
198 LDOUTFLAG={- $target{ldoutflag} -}$(OSSL_EMPTY)
199 AROUTFLAG={- $target{aroutflag} -}$(OSSL_EMPTY)
200 MTINFLAG={- $target{mtinflag} -}$(OSSL_EMPTY)
201 MTOUTFLAG={- $target{mtoutflag} -}$(OSSL_EMPTY)
202 ASOUTFLAG={- $target{asoutflag} -}$(OSSL_EMPTY)
203 RCOUTFLAG={- $target{rcoutflag} -}$(OSSL_EMPTY)
205 ##### Project flags ##################################################
207 # Variables starting with CNF_ are common variables for all product types
209 CNF_ASFLAGS={- join(' ', $target{asflags} || (),
210 @{$config{asflags}}) -}
211 CNF_CPPFLAGS={- our $cppfags2 =
212 join(' ', $target{cppflags} || (),
213 (map { '-D'.quotify1($_) } @{$target{defines}},
214 @{$config{defines}}),
215 (map { '-I'.quotify1($_) } @{$target{includes}},
216 @{$config{includes}}),
217 @{$config{cppflags}}) -}
218 CNF_CFLAGS={- join(' ', $target{cflags} || (),
219 @{$config{cflags}}) -}
220 CNF_CXXFLAGS={- join(' ', $target{cxxflags} || (),
221 @{$config{cxxflags}}) -}
222 CNF_LDFLAGS={- join(' ', $target{lflags} || (),
223 @{$config{lflags}}) -}
224 CNF_EX_LIBS={- join(' ', $target{ex_libs} || (),
225 @{$config{ex_libs}}) -}
227 # Variables starting with LIB_ are used to build library object files
228 # and shared libraries.
229 # Variables starting with DSO_ are used to build DSOs and their object files.
230 # Variables starting with BIN_ are used to build programs and their object
233 LIB_ASFLAGS={- join(' ', $target{lib_asflags} || (),
234 @{$config{lib_asflags}},
235 '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
236 LIB_CPPFLAGS={- our $lib_cppflags =
237 join(' ', $target{lib_cppflags} || (),
238 $target{shared_cppflag} || (),
239 (map { '-D'.quotify1($_) }
240 @{$target{lib_defines}},
241 @{$target{shared_defines}},
242 @{$config{lib_defines}},
243 @{$config{shared_defines}}),
244 (map { '-I'.quotify1($_) }
245 @{$target{lib_includes}},
246 @{$target{shared_includes}},
247 @{$config{lib_includes}},
248 @{$config{shared_includes}}),
249 @{$config{lib_cppflags}},
250 @{$config{shared_cppflag}});
251 join(' ', $lib_cppflags,
252 (map { '-D'.quotify1($_) }
253 "OPENSSLDIR=\"$openssldir\"",
254 "ENGINESDIR=\"$enginesdir\""),
255 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
256 LIB_CFLAGS={- join(' ', $target{lib_cflags} || (),
257 $target{shared_cflag} || (),
258 @{$config{lib_cflags}},
259 @{$config{shared_cflag}},
260 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
261 LIB_LDFLAGS={- join(' ', $target{shared_ldflag} || (),
262 $config{shared_ldflag} || (),
263 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
264 LIB_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
265 DSO_ASFLAGS={- join(' ', $target{dso_asflags} || (),
266 $target{module_asflags} || (),
267 @{$config{dso_asflags}},
268 @{$config{module_asflags}},
269 '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
270 DSO_CPPFLAGS={- join(' ', $target{dso_cppflags} || (),
271 $target{module_cppflags} || (),
272 @{$config{dso_cppflags}},
273 @{$config{module_cppflags}},
274 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
275 DSO_CFLAGS={- join(' ', $target{dso_cflags} || (),
276 $target{module_cflags} || (),
277 @{$config{dso_cflags}},
278 @{$config{module_cflags}},
279 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
280 DSO_LDFLAGS={- join(' ', $target{dso_lflags} || (),
281 $target{module_ldflags} || (),
282 @{$config{dso_lflags}},
283 @{$config{module_ldflags}},
284 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
285 DSO_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
286 BIN_ASFLAGS={- join(' ', $target{bin_asflags} || (),
287 @{$config{bin_asflags}},
288 '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
289 BIN_CPPFLAGS={- join(' ', $target{bin_cppflags} || (),
290 @{$config{bin_cppflags}},
291 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
292 BIN_CFLAGS={- join(' ', $target{bin_cflags} || (),
293 @{$config{bin_cflags}},
294 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
295 BIN_LDFLAGS={- join(' ', $target{bin_lflags} || (),
296 @{$config{bin_lflags}},
297 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
298 BIN_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
300 # CPPFLAGS_Q is used for one thing only: to build up buildinf.h
301 CPPFLAGS_Q={- $cppflags1 =~ s|([\\"])|\\$1|g;
302 $cppflags2 =~ s|([\\"])|\\$1|g;
303 join(' ', $lib_cppflags || (), $cppflags2 || (),
306 PERLASM_SCHEME= {- $target{perlasm_scheme} -}
308 PROCESSOR= {- $config{processor} -}
310 # The main targets ###################################################
312 {- dependmagic('all'); -}: build_libs_nodep build_engines_nodep build_programs_nodep
313 {- dependmagic('build_libs'); -}: build_libs_nodep
314 {- dependmagic('build_engines'); -}: build_engines_nodep
315 {- dependmagic('build_programs'); -}: build_programs_nodep
317 build_generated: $(GENERATED_MANDATORY)
318 build_libs_nodep: $(LIBS) {- join(" ",map { shlib_import($_) } @{$unified_info{libraries}}) -}
319 build_engines_nodep: $(ENGINES)
320 build_programs_nodep: $(PROGRAMS) $(SCRIPTS)
322 # Kept around for backward compatibility
323 build_apps build_tests: build_programs
325 # Convenience target to prebuild all generated files, not just the mandatory
327 build_all_generated: $(GENERATED_MANDATORY) $(GENERATED)
328 @{- output_off() if $disabled{makedepend}; "" -}
329 @$(ECHO) "Warning: consider configuring with no-makedepend, because if"
330 @$(ECHO) " target system doesn't have $(PERL),"
331 @$(ECHO) " then make will fail..."
332 @{- output_on() if $disabled{makedepend}; "" -}
335 {- dependmagic('tests'); -}: build_programs_nodep build_engines_nodep
336 @{- output_off() if $disabled{tests}; "" -}
337 -mkdir $(BLDDIR)\test\test-runs
340 set RESULT_D=$(BLDDIR)\test\test-runs
342 set OPENSSL_ENGINES=$(MAKEDIR)\engines
343 set OPENSSL_DEBUG_MEMORY=on
344 "$(PERL)" "$(SRCDIR)\test\run_tests.pl" $(TESTS)
345 @{- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
346 @$(ECHO) "Tests are not supported with your chosen Configure options"
347 @{- output_on() if !$disabled{tests}; "" -}
350 @{- output_off() if $disabled{tests}; "" -}
351 @set SRCTOP=$(SRCDIR)
352 @"$(PERL)" "$(SRCDIR)\test\run_tests.pl" list
353 @{- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
354 @$(ECHO) "Tests are not supported with your chosen Configure options"
355 @{- output_on() if !$disabled{tests}; "" -}
357 install: install_sw install_ssldirs install_docs
359 uninstall: uninstall_docs uninstall_sw
362 "$(PERL)" -e "map { m/(.*)\.dll$$/; unlink glob """{.,apps,test,fuzz}/$$1.*"""; } @ARGV" $(SHLIBS)
363 -del /Q /F $(LIBS) libcrypto.* libssl.* ossl_static.pdb
366 {- join("\n\t", map { "-del /Q /F $_" } @PROGRAMS) -}
367 -del /Q /F $(ENGINES)
368 -del /Q /F $(SCRIPTS)
369 -del /Q /F $(GENERATED_MANDATORY)
370 -del /Q /F $(GENERATED)
371 -del /Q /S /F *.d *.obj *.pdb *.ilk *.manifest
372 -del /Q /S /F engines\*.lib engines\*.exp
373 -del /Q /S /F apps\*.lib apps\*.rc apps\*.res apps\*.exp
374 -del /Q /S /F test\*.exp
375 -rmdir /Q /S test\test-runs
378 -del /Q /F configdata.pm
382 @ {- output_off() if $disabled{makedepend}; "" -}
383 @ "$(PERL)" "$(SRCDIR)\util\add-depends.pl" "VC"
384 @ {- output_on() if $disabled{makedepend}; "" -}
386 # Install helper targets #############################################
388 install_sw: all install_dev install_engines install_runtime
390 uninstall_sw: uninstall_runtime uninstall_engines uninstall_dev
392 install_docs: install_html_docs
394 uninstall_docs: uninstall_html_docs
397 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\certs"
398 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\private"
399 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\misc"
400 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\openssl.cnf" \
401 "$(OPENSSLDIR)\openssl.cnf.dist"
402 @IF NOT EXIST "$(OPENSSLDIR)\openssl.cnf" \
403 "$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\openssl.cnf" \
404 "$(OPENSSLDIR)\openssl.cnf"
405 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(MISC_SCRIPTS) \
407 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\ct_log_list.cnf" \
408 "$(OPENSSLDIR)\ct_log_list.cnf.dist"
409 @IF NOT EXIST "$(OPENSSLDIR)\ct_log_list.cnf" \
410 "$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\ct_log_list.cnf" \
411 "$(OPENSSLDIR)\ct_log_list.cnf"
414 @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
415 @$(ECHO) "*** Installing development files"
416 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\include\openssl"
417 @{- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
418 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\ms\applink.c" \
419 "$(INSTALLTOP)\include\openssl"
420 @{- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
421 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "-exclude_re=/__DECC_" \
422 "$(SRCDIR)\include\openssl\*.h" \
423 "$(INSTALLTOP)\include\openssl"
424 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(BLDDIR)\include\openssl\*.h" \
425 "$(INSTALLTOP)\include\openssl"
426 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(libdir)"
427 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_LIBS) "$(libdir)"
428 @if "$(SHLIBS)"=="" \
429 "$(PERL)" "$(SRCDIR)\util\copy.pl" ossl_static.pdb "$(libdir)"
434 @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
435 @$(ECHO) "*** Installing engines"
436 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(ENGINESDIR)"
437 @if not "$(ENGINES)"=="" \
438 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINES) "$(ENGINESDIR)"
439 @if not "$(ENGINES)"=="" \
440 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINEPDBS) "$(ENGINESDIR)"
445 @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
446 @$(ECHO) "*** Installing runtime files"
447 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\bin"
448 @if not "$(SHLIBS)"=="" \
449 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_SHLIBS) "$(INSTALLTOP)\bin"
450 @if not "$(SHLIBS)"=="" \
451 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_SHLIBPDBS) \
453 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMS) \
455 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMPDBS) \
457 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BIN_SCRIPTS) \
463 "$(PERL)" "$(SRCDIR)\util\process_docs.pl" \
464 "--destdir=$(INSTALLTOP)\html" --type=html
468 # Building targets ###################################################
470 configdata.pm: "$(SRCDIR)\Configure" {- join(" ", map { '"'.$_.'"' } @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
471 @$(ECHO) "Detected changed: $?"
472 "$(PERL)" configdata.pm -r
473 @$(ECHO) "**************************************************"
475 @$(ECHO) "*** Please run the same make command again ***"
477 @$(ECHO) "**************************************************"
481 "$(PERL)" configdata.pm -r
485 use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
487 # Helper function to figure out dependencies on libraries
488 # It takes a list of library names and outputs a list of dependencies
489 sub compute_lib_depends {
490 if ($disabled{shared}) {
491 return map { lib($_) } @_;
494 (my $l = $_) =~ s/\.a$//;
495 die "Linking with static variants of shared libraries is not supported in this configuration\n"
496 if $l ne $_ && shlib($l);
498 return map { shlib_import($_) or lib($_) } @_;
503 my ($gen0, @gens) = @{$args{generator}};
504 my $generator = '"'.$gen0.'"'.join('', map { " $_" } @gens);
505 my $generator_incs = join("", map { " -I \"$_\"" } @{$args{generator_incs}});
506 my $incs = join("", map { " /I \"$_\"" } @{$args{incs}});
507 my $deps = @{$args{deps}} ?
508 '"'.join('" "', @{$args{generator_deps}}, @{$args{deps}}).'"' : '';
510 if ($args{src} =~ /\.ld$/) {
511 (my $target = $args{src}) =~ s/\.ld$/$defext/;
512 my $mkdef = abs2rel(rel2abs(catfile($config{sourcedir},
513 "util", "mkdef.pl")),
514 rel2abs($config{builddir}));
515 my $ord_ver = $args{intent} eq 'lib' ? ' --version $(VERSION)' : '';
517 $args{generator}->[1] || basename($args{product}, $dsoext);
519 $target: $args{generator}->[0] $deps $mkdef
520 \$(PERL) $mkdef$ord_ver --ordinals $args{generator}->[0] --name $ord_name --OS windows > $target
522 } elsif ($args{src} !~ /\.[sS]$/) {
523 my $target = $args{src};
524 if ($args{generator}->[0] =~ m|^.*\.in$|) {
525 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
526 "util", "dofile.pl")),
527 rel2abs($config{builddir}));
529 $target: "$args{generator}->[0]" $deps
530 "\$(PERL)" "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
531 "-o$target{build_file}" $generator > \$@
535 $target: "$args{generator}->[0]" $deps
536 "\$(PERL)"$generator_incs $generator > \$@
540 (my $target = $args{src}) =~ s/\.[sS]$/.asm/;
541 if ($args{generator}->[0] =~ /\.pl$/) {
542 $generator = '"$(PERL)"'.$generator_incs.' '.$generator;
543 } elsif ($args{generator}->[0] =~ /\.S$/) {
546 die "Generator type for $src unknown: $generator\n";
549 my $cppflags = $incs;
551 shlib => ' $(LIB_CFLAGS) $(LIB_CPPFLAGS)',
552 lib => ' $(LIB_CFLAGS) $(LIB_CPPFLAGS)',
553 dso => ' $(DSO_CFLAGS) $(DSO_CPPFLAGS)',
554 bin => ' $(BIN_CFLAGS) $(BIN_CPPFLAGS)'
555 } -> {$args{intent}};
556 if (defined($generator)) {
557 # If the target is named foo.S in build.info, we want to
558 # end up generating foo.s in two steps.
559 if ($args{src} =~ /\.S$/) {
561 $target: "$args{generator}->[0]" $deps
564 \$(CPP) $cppflags \$@.S > \$@.i && move /Y \$@.i \$@
570 $target: "$args{generator}->[0]" $deps
576 $target: "$args{generator}->[0]" $deps
577 \$(CPP) $incs $cppflags "$args{generator}->[0]" > \$@.i && move /Y \$@.i \$@
584 my @srcs = map { (my $x = $_) =~ s/\.s$/.asm/; $x
585 } ( @{$args{srcs}} );
586 my $srcs = '"'.join('" "', @srcs).'"';
587 my $deps = '"'.join('" "', @srcs, @{$args{deps}}).'"';
588 my $incs = join("", map { ' /I "'.$_.'"' } @{$args{incs}});
589 my $cflags = { shlib => ' $(LIB_CFLAGS)',
590 lib => ' $(LIB_CFLAGS)',
591 dso => ' $(DSO_CFLAGS)',
592 bin => ' $(BIN_CFLAGS)' } -> {$args{intent}};
594 $cflags .= { shlib => ' $(LIB_CPPFLAGS)',
595 lib => ' $(LIB_CPPFLAGS)',
596 dso => ' $(DSO_CPPFLAGS)',
597 bin => ' $(BIN_CPPFLAGS)' } -> {$args{intent}};
598 my $asflags = { shlib => ' $(LIB_ASFLAGS)',
599 lib => ' $(LIB_ASFLAGS)',
600 dso => ' $(DSO_ASFLAGS)',
601 bin => ' $(BIN_ASFLAGS)' } -> {$args{intent}};
602 my $makedepprog = $config{makedepprog};
603 if ($srcs[0] =~ /\.rc$/) {
606 \$(RC) \$(RCOUTFLAG)\$\@ $srcs
609 (my $obj = $args{obj}) =~ s|\.o$||;
610 if ($srcs[0] =~ /\.asm$/) {
613 \$(AS) $asflags \$(ASOUTFLAG)\$\@ $srcs
615 } elsif ($srcs[0] =~ /.S$/) {
618 \$(CC) /EP /D__ASSEMBLER__ $cflags $srcs > \$@.asm && \$(AS) $asflags \$(ASOUTFLAG)\$\@ \$@.asm
621 return <<"EOF" if (!$disabled{makedepend});
623 \$(CC) $cflags /Zs /showIncludes $srcs 2>&1 > $obj$depext
624 $obj$objext: $obj$depext
625 \$(CC) $cflags -c \$(COUTFLAG)\$\@ $srcs
627 return <<"EOF" if ($disabled{makedepend});
629 \$(CC) $cflags -c \$(COUTFLAG)\$\@ $srcs
633 # We *know* this routine is only called when we've configure 'shared'.
634 # Also, note that even though the import library built here looks like
635 # a static library, it really isn't.
638 my $lib = $args{lib};
639 my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x }
640 grep { $_ =~ m/\.(?:o|res)$/ }
642 my @defs = map { (my $x = $_) =~ s|\.ld$||; "$x$defext" }
643 grep { $_ =~ /\.ld$/ }
645 my @deps = compute_lib_depends(@{$args{deps}});
646 die "More than one exported symbols list" if scalar @defs > 1;
647 my $linklibs = join("", map { "$_\n" } @deps);
648 my $objs = join("\n", @objs);
649 my $deps = join(" ", @objs, @defs, @deps);
650 my $import = shlib_import($lib);
651 my $dll = shlib($lib);
652 my $shared_def = join("", map { " /def:$_" } @defs);
654 # The import library may look like a static library, but it is not.
655 # We MUST make the import library depend on the DLL, in case someone
656 # mistakenly removes the latter.
659 IF EXIST $full.manifest DEL /F /Q $full.manifest
660 IF EXIST \$@ DEL /F /Q \$@
661 \$(LD) \$(LDFLAGS) \$(LIB_LDFLAGS) \\
662 /implib:$import \$(LDOUTFLAG)$dll$shared_def @<< || (DEL /Q \$(\@B).* $import && EXIT 1)
664 $linklibs\$(LIB_EX_LIBS)
666 IF EXIST $dll.manifest \\
667 \$(MT) \$(MTFLAGS) \$(MTINFLAG)$dll.manifest \$(MTOUTFLAG)$dll
668 IF EXIST apps\\$dll DEL /Q /F apps\\$dll
669 IF EXIST test\\$dll DEL /Q /F test\\$dll
670 IF EXIST fuzz\\$dll DEL /Q /F fuzz\\$dll
678 my $dso = $args{lib};
679 my $dso_n = basename($dso);
680 my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x }
681 grep { $_ =~ m/\.(?:o|res)$/ }
683 my @defs = map { (my $x = $_) =~ s|\.ld$|$defext|; $x }
684 grep { $_ =~ /\.ld$/ }
686 my @deps = compute_lib_depends(@{$args{deps}});
687 my $objs = join("\n", @objs);
688 my $linklibs = join("", map { "$_\n" } @deps);
689 my $deps = join(" ", @objs, @defs, @deps);
690 my $shared_def = join("", map { " /def:$_" } @defs);
693 IF EXIST $dso$dsoext.manifest DEL /F /Q $dso$dsoext.manifest
694 \$(LD) \$(LDFLAGS) \$(DSO_LDFLAGS) \\
695 \$(LDOUTFLAG)$dso$dsoext$shared_def @<< || (DEL /Q \$(\@B).* $dso.* && EXIT 1)
697 $linklibs \$(DSO_EX_LIBS)
699 IF EXIST $dso$dsoext.manifest \\
700 \$(MT) \$(MTFLAGS) \$(MTINFLAG)$dso$dsoext.manifest \$(MTOUTFLAG)$dso$dsoext
705 my $lib = $args{lib};
707 # Because static libs and import libs are both named the same in native
708 # Windows, we can't have both. We skip the static lib in that case,
709 # as the shared libs are what we use anyway.
710 return "" unless $disabled{"shared"} || $lib =~ /\.a$/;
713 my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
714 my $objs = join("\n", @objs);
715 my $deps = join(" ", @objs);
718 \$(AR) \$(ARFLAGS) \$(AROUTFLAG)$lib$libext @<<
725 my $bin = $args{bin};
726 my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
727 my @deps = compute_lib_depends(@{$args{deps}});
728 my $objs = join("\n", @objs);
729 my $linklibs = join("", map { "$_\n" } @deps);
730 my $deps = join(" ", @objs, @deps);
733 IF EXIST $bin$exeext.manifest DEL /F /Q $bin$exeext.manifest
734 \$(LD) \$(LDFLAGS) \$(BIN_LDFLAGS) \$(LDOUTFLAG)$bin$exeext @<<
737 $linklibs\$(BIN_EX_LIBS)
739 IF EXIST $bin$exeext.manifest \\
740 \$(MT) \$(MTFLAGS) \$(MTINFLAG)$bin$exeext.manifest \$(MTOUTFLAG)$bin$exeext
745 my $script = $args{script};
746 my $sources = '"'.join('" "', @{$args{sources}}).'"';
747 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
748 "util", "dofile.pl")),
749 rel2abs($config{builddir}));
752 "\$(PERL)" "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
753 "-o$target{build_file}" $sources > "$script"
758 my $dir = $args{dir};
759 my @deps = map { s|\.o$|$objext|; $_ } @{$args{deps}};
761 my %extinfo = ( dso => $dsoext,
765 foreach my $type (("dso", "lib", "bin", "script")) {
766 next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type});
767 # For lib object files, we could update the library. However,
768 # LIB on Windows doesn't work that way, so we won't create any
769 # actions for it, and the dependencies are already taken care of.
770 if ($type ne "lib") {
771 foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) {
772 if (dirname($prod) eq $dir) {
773 push @deps, $prod.$extinfo{$type};
779 my $deps = join(" ", @deps);
780 my $actions = join("\n", "", @actions);
782 $args{dir} $args{dir}\\ : $deps$actions
785 "" # Important! This becomes part of the template result.