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$//;
44 if (defined $unified_info{sharednames}->{$lib});
45 return $lib . $libext;
50 return () if $disabled{shared} || $lib =~ /\.a$/;
51 return $lib . $shlibextimport;
57 return $dso . $dsoext;
59 # This makes sure things get built in the order they need
64 return "$target: build_generated\n\t\$(MAKE) /\$(MAKEFLAGS) depend && \$(MAKE) /\$(MAKEFLAGS) _$target\n_$target";
69 PLATFORM={- $config{target} -}
70 SRCDIR={- $config{sourcedir} -}
71 BLDDIR={- $config{builddir} -}
73 VERSION={- $config{version} -}
74 MAJOR={- $config{major} -}
75 MINOR={- $config{minor} -}
77 SHLIB_VERSION_NUMBER={- $config{shlib_version_number} -}
79 LIBS={- join(" ", map { ( shlib_import($_), lib($_) ) } @{$unified_info{libraries}}) -}
80 SHLIBS={- join(" ", map { shlib($_) } @{$unified_info{libraries}}) -}
81 SHLIBPDBS={- join(" ", map { local $shlibext = ".pdb"; shlib($_) } @{$unified_info{libraries}}) -}
82 ENGINES={- join(" ", map { dso($_) } @{$unified_info{engines}}) -}
83 ENGINEPDBS={- join(" ", map { local $dsoext = ".pdb"; dso($_) } @{$unified_info{engines}}) -}
84 PROGRAMS={- our @PROGRAMS = map { $_.$exeext } @{$unified_info{programs}}; join(" ", @PROGRAMS) -}
85 PROGRAMPDBS={- join(" ", map { $_.".pdb" } @{$unified_info{programs}}) -}
86 SCRIPTS={- join(" ", @{$unified_info{scripts}}) -}
87 {- output_off() if $disabled{makedepend}; "" -}
88 DEPS={- join(" ", map { (my $x = $_) =~ s|\.o$|$depext|; $x; }
89 grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
90 keys %{$unified_info{sources}}); -}
91 {- output_on() if $disabled{makedepend}; "" -}
92 GENERATED_MANDATORY={- join(" ", @{$unified_info{depends}->{""}} ) -}
93 GENERATED={- # common0.tmpl provides @generated
94 join(" ", map { (my $x = $_) =~ s|\.[sS]$|.asm|; $x }
97 INSTALL_LIBS={- join(" ", map { quotify1(shlib_import($_) or lib($_)) } @{$unified_info{install}->{libraries}}) -}
98 INSTALL_SHLIBS={- join(" ", map { quotify_l(shlib($_)) } @{$unified_info{install}->{libraries}}) -}
99 INSTALL_SHLIBPDBS={- join(" ", map { local $shlibext = ".pdb"; quotify_l(shlib($_)) } @{$unified_info{install}->{libraries}}) -}
100 INSTALL_ENGINES={- join(" ", map { quotify1(dso($_)) } @{$unified_info{install}->{engines}}) -}
101 INSTALL_ENGINEPDBS={- join(" ", map { local $dsoext = ".pdb"; quotify1(dso($_)) } @{$unified_info{install}->{engines}}) -}
102 INSTALL_PROGRAMS={- join(" ", map { quotify1($_.$exeext) } grep { !m|^test\\| } @{$unified_info{install}->{programs}}) -}
103 INSTALL_PROGRAMPDBS={- join(" ", map { quotify1($_.".pdb") } grep { !m|^test\\| } @{$unified_info{install}->{programs}}) -}
104 {- output_off() if $disabled{apps}; "" -}
105 BIN_SCRIPTS="$(BLDDIR)\tools\c_rehash.pl"
106 MISC_SCRIPTS="$(BLDDIR)\apps\CA.pl" "$(BLDDIR)\apps\tsget.pl"
107 {- output_on() if $disabled{apps}; "" -}
109 APPS_OPENSSL={- use File::Spec::Functions;
110 "\"".catfile("apps","openssl")."\"" -}
112 # Do not edit these manually. Use Configure with --prefix or --openssldir
113 # to change this! Short explanation in the top comment in Configure
114 INSTALLTOP_dev={- # $prefix is used in the OPENSSLDIR perl snippet
116 use File::Spec::Functions qw(:DEFAULT splitpath);
117 our $prefix = canonpath($config{prefix}
118 || "$win_installroot\\OpenSSL");
119 our ($prefix_dev, $prefix_dir, $prefix_file) =
120 splitpath($prefix, 1);
122 INSTALLTOP_dir={- canonpath($prefix_dir) -}
124 # The logic here is that if no --openssldir was given,
125 # OPENSSLDIR will get the value "$win_commonroot\\SSL".
126 # If --openssldir was given and the value is an absolute
127 # path, OPENSSLDIR will get its value without change.
128 # If the value from --openssldir is a relative path,
129 # OPENSSLDIR will get $prefix with the --openssldir
130 # value appended as a subdirectory.
132 use File::Spec::Functions qw(:DEFAULT splitpath);
134 $config{openssldir} ?
135 (file_name_is_absolute($config{openssldir}) ?
136 canonpath($config{openssldir})
137 : catdir($prefix, $config{openssldir}))
138 : canonpath("$win_commonroot\\SSL");
139 our ($openssldir_dev, $openssldir_dir, $openssldir_file) =
140 splitpath($openssldir, 1);
142 OPENSSLDIR_dir={- canonpath($openssldir_dir) -}
143 LIBDIR={- our $libdir = $config{libdir} || "lib";
144 file_name_is_absolute($libdir) ? "" : $libdir -}
145 ENGINESDIR_dev={- use File::Spec::Functions qw(:DEFAULT splitpath);
146 our $enginesdir = catdir($prefix,$libdir,"engines-$sover_dirname");
147 our ($enginesdir_dev, $enginesdir_dir, $enginesdir_file) =
148 splitpath($enginesdir, 1);
150 ENGINESDIR_dir={- canonpath($enginesdir_dir) -}
151 !IF "$(DESTDIR)" != ""
152 INSTALLTOP=$(DESTDIR)$(INSTALLTOP_dir)
153 OPENSSLDIR=$(DESTDIR)$(OPENSSLDIR_dir)
154 ENGINESDIR=$(DESTDIR)$(ENGINESDIR_dir)
156 INSTALLTOP=$(INSTALLTOP_dev)$(INSTALLTOP_dir)
157 OPENSSLDIR=$(OPENSSLDIR_dev)$(OPENSSLDIR_dir)
158 ENGINESDIR=$(ENGINESDIR_dev)$(ENGINESDIR_dir)
161 # $(libdir) is chosen to be compatible with the GNU coding standards
162 libdir={- file_name_is_absolute($libdir)
163 ? $libdir : '$(INSTALLTOP)\$(LIBDIR)' -}
165 ##### User defined commands and flags ################################
168 CPP={- $config{CPP} -}
169 CPPFLAGS={- our $cppflags1 = join(" ",
170 (map { "-D".$_} @{$config{CPPDEFINES}}),
171 (map { " /I ".$_} @{$config{CPPINCLUDES}}),
172 @{$config{CPPFLAGS}}) -}
173 CFLAGS={- join(' ', @{$config{CFLAGS}}) -}
175 LDFLAGS={- join(' ', @{$config{LDFLAGS}}) -}
176 EX_LIBS={- join(' ', @{$config{LDLIBS}}) -}
178 PERL={- $config{PERL} -}
181 ARFLAGS= {- join(' ', @{$config{ARFLAGS}}) -}
184 MTFLAGS= {- join(' ', @{$config{MTFLAGS}}) -}
187 ASFLAGS={- join(' ', @{$config{ASFLAGS}}) -}
191 ECHO="$(PERL)" "$(SRCDIR)\util\echo.pl"
193 ##### Special command flags ##########################################
195 COUTFLAG={- $target{coutflag} -}$(OSSL_EMPTY)
196 LDOUTFLAG={- $target{ldoutflag} -}$(OSSL_EMPTY)
197 AROUTFLAG={- $target{aroutflag} -}$(OSSL_EMPTY)
198 MTINFLAG={- $target{mtinflag} -}$(OSSL_EMPTY)
199 MTOUTFLAG={- $target{mtoutflag} -}$(OSSL_EMPTY)
200 ASOUTFLAG={- $target{asoutflag} -}$(OSSL_EMPTY)
201 RCOUTFLAG={- $target{rcoutflag} -}$(OSSL_EMPTY)
203 ##### Project flags ##################################################
205 # Variables starting with CNF_ are common variables for all product types
207 CNF_ASFLAGS={- join(' ', $target{asflags} || (),
208 @{$config{asflags}}) -}
209 CNF_CPPFLAGS={- our $cppfags2 =
210 join(' ', $target{cppflags} || (),
211 (map { '-D'.quotify1($_) } @{$target{defines}},
212 @{$config{defines}}),
213 (map { '-I'.quotify1($_) } @{$target{includes}},
214 @{$config{includes}}),
215 @{$config{cppflags}}) -}
216 CNF_CFLAGS={- join(' ', $target{cflags} || (),
217 @{$config{cflags}}) -}
218 CNF_CXXFLAGS={- join(' ', $target{cxxflags} || (),
219 @{$config{cxxflags}}) -}
220 CNF_LDFLAGS={- join(' ', $target{lflags} || (),
221 @{$config{lflags}}) -}
222 CNF_EX_LIBS={- join(' ', $target{ex_libs} || (),
223 @{$config{ex_libs}}) -}
225 # Variables starting with LIB_ are used to build library object files
226 # and shared libraries.
227 # Variables starting with DSO_ are used to build DSOs and their object files.
228 # Variables starting with BIN_ are used to build programs and their object
231 LIB_ASFLAGS={- join(' ', $target{lib_asflags} || (),
232 @{$config{lib_asflags}},
233 '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
234 LIB_CPPFLAGS={- our $lib_cppflags =
235 join(' ', $target{lib_cppflags} || (),
236 $target{shared_cppflag} || (),
237 (map { '-D'.quotify1($_) }
238 @{$target{lib_defines}},
239 @{$target{shared_defines}},
240 @{$config{lib_defines}},
241 @{$config{shared_defines}}),
242 (map { '-I'.quotify1($_) }
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 join(' ', $lib_cppflags,
250 (map { '-D'.quotify1($_) }
251 "OPENSSLDIR=\"$openssldir\"",
252 "ENGINESDIR=\"$enginesdir\""),
253 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
254 LIB_CFLAGS={- join(' ', $target{lib_cflags} || (),
255 $target{shared_cflag} || (),
256 @{$config{lib_cflags}},
257 @{$config{shared_cflag}},
258 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
259 LIB_LDFLAGS={- join(' ', $target{shared_ldflag} || (),
260 $config{shared_ldflag} || (),
261 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
262 LIB_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
263 DSO_ASFLAGS={- join(' ', $target{dso_asflags} || (),
264 $target{module_asflags} || (),
265 @{$config{dso_asflags}},
266 @{$config{module_asflags}},
267 '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
268 DSO_CPPFLAGS={- join(' ', $target{dso_cppflags} || (),
269 $target{module_cppflags} || (),
270 @{$config{dso_cppflags}},
271 @{$config{module_cppflags}},
272 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
273 DSO_CFLAGS={- join(' ', $target{dso_cflags} || (),
274 $target{module_cflags} || (),
275 @{$config{dso_cflags}},
276 @{$config{module_cflags}},
277 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
278 DSO_LDFLAGS={- join(' ', $target{dso_lflags} || (),
279 $target{module_ldflags} || (),
280 @{$config{dso_lflags}},
281 @{$config{module_ldflags}},
282 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
283 DSO_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
284 BIN_ASFLAGS={- join(' ', $target{bin_asflags} || (),
285 @{$config{bin_asflags}},
286 '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
287 BIN_CPPFLAGS={- join(' ', $target{bin_cppflags} || (),
288 @{$config{bin_cppflags}},
289 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
290 BIN_CFLAGS={- join(' ', $target{bin_cflags} || (),
291 @{$config{bin_cflags}},
292 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
293 BIN_LDFLAGS={- join(' ', $target{bin_lflags} || (),
294 @{$config{bin_lflags}},
295 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
296 BIN_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
298 # CPPFLAGS_Q is used for one thing only: to build up buildinf.h
299 CPPFLAGS_Q={- $cppflags1 =~ s|([\\"])|\\$1|g;
300 $cppflags2 =~ s|([\\"])|\\$1|g;
301 join(' ', $lib_cppflags || (), $cppflags2 || (),
304 PERLASM_SCHEME= {- $target{perlasm_scheme} -}
306 PROCESSOR= {- $config{processor} -}
308 # The main targets ###################################################
310 {- dependmagic('all'); -}: build_libs_nodep build_engines_nodep build_programs_nodep
311 {- dependmagic('build_libs'); -}: build_libs_nodep
312 {- dependmagic('build_engines'); -}: build_engines_nodep
313 {- dependmagic('build_programs'); -}: build_programs_nodep
315 build_generated: $(GENERATED_MANDATORY)
316 build_libs_nodep: $(LIBS) {- join(" ",map { shlib_import($_) } @{$unified_info{libraries}}) -}
317 build_engines_nodep: $(ENGINES)
318 build_programs_nodep: $(PROGRAMS) $(SCRIPTS)
320 # Kept around for backward compatibility
321 build_apps build_tests: build_programs
323 # Convenience target to prebuild all generated files, not just the mandatory
325 build_all_generated: $(GENERATED_MANDATORY) $(GENERATED)
326 @{- output_off() if $disabled{makedepend}; "" -}
327 @$(ECHO) "Warning: consider configuring with no-makedepend, because if"
328 @$(ECHO) " target system doesn't have $(PERL),"
329 @$(ECHO) " then make will fail..."
330 @{- output_on() if $disabled{makedepend}; "" -}
333 {- dependmagic('tests'); -}: build_programs_nodep build_engines_nodep
334 @{- output_off() if $disabled{tests}; "" -}
335 -mkdir $(BLDDIR)\test\test-runs
338 set RESULT_D=$(BLDDIR)\test\test-runs
340 set OPENSSL_ENGINES=$(MAKEDIR)\engines
341 set OPENSSL_DEBUG_MEMORY=on
342 "$(PERL)" "$(SRCDIR)\test\run_tests.pl" $(TESTS)
343 @{- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
344 @$(ECHO) "Tests are not supported with your chosen Configure options"
345 @{- output_on() if !$disabled{tests}; "" -}
348 @{- output_off() if $disabled{tests}; "" -}
349 @set SRCTOP=$(SRCDIR)
350 @"$(PERL)" "$(SRCDIR)\test\run_tests.pl" list
351 @{- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
352 @$(ECHO) "Tests are not supported with your chosen Configure options"
353 @{- output_on() if !$disabled{tests}; "" -}
355 install: install_sw install_ssldirs install_docs
357 uninstall: uninstall_docs uninstall_sw
360 "$(PERL)" -e "map { m/(.*)\.dll$$/; unlink glob """{.,apps,test,fuzz}/$$1.*"""; } @ARGV" $(SHLIBS)
361 -del /Q /F $(LIBS) libcrypto.* libssl.* ossl_static.pdb
364 {- join("\n\t", map { "-del /Q /F $_" } @PROGRAMS) -}
365 -del /Q /F $(ENGINES)
366 -del /Q /F $(SCRIPTS)
367 -del /Q /F $(GENERATED_MANDATORY)
368 -del /Q /F $(GENERATED)
369 -del /Q /S /F *.d *.obj *.pdb *.ilk *.manifest
370 -del /Q /S /F engines\*.lib engines\*.exp
371 -del /Q /S /F apps\*.lib apps\*.rc apps\*.res apps\*.exp
372 -del /Q /S /F test\*.exp
373 -rmdir /Q /S test\test-runs
376 -del /Q /F configdata.pm
380 @ {- output_off() if $disabled{makedepend}; "" -}
381 @ "$(PERL)" "$(SRCDIR)\util\add-depends.pl" "VC"
382 @ {- output_on() if $disabled{makedepend}; "" -}
384 # Install helper targets #############################################
386 install_sw: install_dev install_engines install_runtime
388 uninstall_sw: uninstall_runtime uninstall_engines uninstall_dev
390 install_docs: install_html_docs
392 uninstall_docs: uninstall_html_docs
395 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\certs"
396 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\private"
397 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\misc"
398 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\openssl.cnf" \
399 "$(OPENSSLDIR)\openssl.cnf.dist"
400 @IF NOT EXIST "$(OPENSSLDIR)\openssl.cnf" \
401 "$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\openssl.cnf" \
402 "$(OPENSSLDIR)\openssl.cnf"
403 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(MISC_SCRIPTS) \
405 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\ct_log_list.cnf" \
406 "$(OPENSSLDIR)\ct_log_list.cnf.dist"
407 @IF NOT EXIST "$(OPENSSLDIR)\ct_log_list.cnf" \
408 "$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\ct_log_list.cnf" \
409 "$(OPENSSLDIR)\ct_log_list.cnf"
411 install_dev: install_runtime_libs
412 @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
413 @$(ECHO) "*** Installing development files"
414 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\include\openssl"
415 @{- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
416 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\ms\applink.c" \
417 "$(INSTALLTOP)\include\openssl"
418 @{- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
419 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "-exclude_re=/__DECC_" \
420 "$(SRCDIR)\include\openssl\*.h" \
421 "$(INSTALLTOP)\include\openssl"
422 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(BLDDIR)\include\openssl\*.h" \
423 "$(INSTALLTOP)\include\openssl"
424 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(libdir)"
425 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_LIBS) "$(libdir)"
426 @if "$(SHLIBS)"=="" \
427 "$(PERL)" "$(SRCDIR)\util\copy.pl" ossl_static.pdb "$(libdir)"
431 install_engines: install_runtime_libs build_engines
432 @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
433 @$(ECHO) "*** Installing engines"
434 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(ENGINESDIR)"
435 @if not "$(ENGINES)"=="" \
436 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINES) "$(ENGINESDIR)"
437 @if not "$(ENGINES)"=="" \
438 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINEPDBS) "$(ENGINESDIR)"
442 install_runtime: install_programs
444 install_runtime_libs: build_libs
445 @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
446 @$(ECHO) "*** Installing runtime libraries"
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) \
454 install_programs: install_runtime_libs build_programs
455 @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
456 @$(ECHO) "*** Installing runtime programs"
457 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\bin"
458 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMS) \
460 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMPDBS) \
462 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BIN_SCRIPTS) \
468 "$(PERL)" "$(SRCDIR)\util\process_docs.pl" \
469 "--destdir=$(INSTALLTOP)\html" --type=html
473 # Building targets ###################################################
475 configdata.pm: "$(SRCDIR)\Configure" {- join(" ", map { '"'.$_.'"' } @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
476 @$(ECHO) "Detected changed: $?"
477 "$(PERL)" configdata.pm -r
478 @$(ECHO) "**************************************************"
480 @$(ECHO) "*** Please run the same make command again ***"
482 @$(ECHO) "**************************************************"
486 "$(PERL)" configdata.pm -r
490 use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
492 # Helper function to figure out dependencies on libraries
493 # It takes a list of library names and outputs a list of dependencies
494 sub compute_lib_depends {
495 if ($disabled{shared}) {
496 return map { lib($_) } @_;
498 return map { shlib_import($_) or lib($_) } @_;
503 (my $target = $args{src}) =~ s/\.[sS]$/.asm/;
504 my ($gen0, @gens) = @{$args{generator}};
505 my $generator = '"'.$gen0.'"'.join('', map { " $_" } @gens);
506 my $generator_incs = join("", map { " -I \"$_\"" } @{$args{generator_incs}});
507 my $incs = join("", map { " /I \"$_\"" } @{$args{incs}});
508 my $deps = @{$args{deps}} ?
509 '"'.join('" "', @{$args{generator_deps}}, @{$args{deps}}).'"' : '';
511 if ($target !~ /\.asm$/) {
512 if ($args{generator}->[0] =~ m|^.*\.in$|) {
513 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
514 "util", "dofile.pl")),
515 rel2abs($config{builddir}));
517 $target: "$args{generator}->[0]" $deps
518 "\$(PERL)" "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
519 "-o$target{build_file}" $generator > \$@
523 $target: "$args{generator}->[0]" $deps
524 "\$(PERL)"$generator_incs $generator > \$@
528 if ($args{generator}->[0] =~ /\.pl$/) {
529 $generator = '"$(PERL)"'.$generator_incs.' '.$generator;
530 } elsif ($args{generator}->[0] =~ /\.S$/) {
533 die "Generator type for $src unknown: $generator\n";
536 my $cppflags = $incs;
538 lib => ' $(LIB_CFLAGS) $(LIB_CPPFLAGS)',
539 dso => ' $(DSO_CFLAGS) $(DSO_CPPFLAGS)',
540 bin => ' $(BIN_CFLAGS) $(BIN_CPPFLAGS)'
541 } -> {$args{intent}};
542 if (defined($generator)) {
543 # If the target is named foo.S in build.info, we want to
544 # end up generating foo.s in two steps.
545 if ($args{src} =~ /\.S$/) {
547 $target: "$args{generator}->[0]" $deps
550 \$(CPP) $cppflags \$@.S > \$@.i && move /Y \$@.i \$@
556 $target: "$args{generator}->[0]" $deps
562 $target: "$args{generator}->[0]" $deps
563 \$(CPP) $incs $cppflags "$args{generator}->[0]" > \$@.i && move /Y \$@.i \$@
570 my @srcs = map { (my $x = $_) =~ s/\.s$/.asm/; $x
571 } ( @{$args{srcs}} );
572 my $srcs = '"'.join('" "', @srcs).'"';
573 my $deps = '"'.join('" "', @srcs, @{$args{deps}}).'"';
574 my $incs = join("", map { ' /I "'.$_.'"' } @{$args{incs}});
575 my $cflags = { lib => ' $(LIB_CFLAGS)',
576 dso => ' $(DSO_CFLAGS)',
577 bin => ' $(BIN_CFLAGS)' } -> {$args{intent}};
579 $cflags .= { lib => ' $(LIB_CPPFLAGS)',
580 dso => ' $(DSO_CPPFLAGS)',
581 bin => ' $(BIN_CPPFLAGS)' } -> {$args{intent}};
582 my $asflags = { lib => ' $(LIB_ASFLAGS)',
583 dso => ' $(DSO_ASFLAGS)',
584 bin => ' $(BIN_ASFLAGS)' } -> {$args{intent}};
585 my $makedepprog = $config{makedepprog};
586 if ($srcs[0] =~ /\.rc$/) {
589 \$(RC) \$(RCOUTFLAG)\$\@ $srcs
592 (my $obj = $args{obj}) =~ s|\.o$||;
593 if ($srcs[0] =~ /\.asm$/) {
596 \$(AS) $asflags \$(ASOUTFLAG)\$\@ $srcs
598 } elsif ($srcs[0] =~ /.S$/) {
601 \$(CC) /EP /D__ASSEMBLER__ $cflags $srcs > \$@.asm && \$(AS) $asflags \$(ASOUTFLAG)\$\@ \$@.asm
604 my $recipe = <<"EOF";
606 \$(CC) $cflags -c \$(COUTFLAG)\$\@ $srcs
608 $recipe .= <<"EOF" unless $disabled{makedepend};
609 \$(CC) $cflags /Zs /showIncludes $srcs 2>&1 > $obj$depext
614 # We *know* this routine is only called when we've configure 'shared'.
615 # Also, note that even though the import library built here looks like
616 # a static library, it really isn't.
619 my $lib = $args{lib};
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 $import = shlib_import($lib);
630 my $dll = shlib($lib);
631 my $shared_def = join("", map { " /def:$_" } @defs);
633 # The import library may look like a static library, but it is not.
634 # We MUST make the import library depend on the DLL, in case someone
635 # mistakenly removes the latter.
638 IF EXIST $full.manifest DEL /F /Q $full.manifest
639 IF EXIST \$@ DEL /F /Q \$@
640 \$(LD) \$(LDFLAGS) \$(LIB_LDFLAGS) \\
641 /implib:$import \$(LDOUTFLAG)$dll$shared_def @<< || (DEL /Q \$(\@B).* $import && EXIT 1)
643 $linklibs\$(LIB_EX_LIBS)
645 IF EXIST $dll.manifest \\
646 \$(MT) \$(MTFLAGS) \$(MTINFLAG)$dll.manifest \$(MTOUTFLAG)$dll
647 IF EXIST apps\\$dll DEL /Q /F apps\\$dll
648 IF EXIST test\\$dll DEL /Q /F test\\$dll
649 IF EXIST fuzz\\$dll DEL /Q /F fuzz\\$dll
657 my $dso = $args{lib};
658 my $dso_n = basename($dso);
659 my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
660 my @deps = compute_lib_depends(@{$args{deps}});
661 my $objs = join("\n", @objs);
662 my $linklibs = join("", map { "$_\n" } @deps);
663 my $deps = join(" ", @objs, @deps);
666 IF EXIST $dso$dsoext.manifest DEL /F /Q $dso$dsoext.manifest
667 \$(LD) \$(LDFLAGS) \$(DSO_LDFLAGS) \$(LDOUTFLAG)$dso$dsoext /def:<< @<<
674 $linklibs \$(DSO_EX_LIBS)
676 IF EXIST $dso$dsoext.manifest \\
677 \$(MT) \$(MTFLAGS) \$(MTINFLAG)$dso$dsoext.manifest \$(MTOUTFLAG)$dso$dsoext
682 my $lib = lib($args{lib});
683 my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
684 my $objs = join("\n", @objs);
685 my $deps = join(" ", @objs);
688 \$(AR) \$(ARFLAGS) \$(AROUTFLAG)$lib @<<
695 my $bin = $args{bin};
696 my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
697 my @deps = compute_lib_depends(@{$args{deps}});
698 my $objs = join("\n", @objs);
699 my $linklibs = join("", map { "$_\n" } @deps);
700 my $deps = join(" ", @objs, @deps);
703 IF EXIST $bin$exeext.manifest DEL /F /Q $bin$exeext.manifest
704 \$(LD) \$(LDFLAGS) \$(BIN_LDFLAGS) \$(LDOUTFLAG)$bin$exeext @<<
707 $linklibs\$(BIN_EX_LIBS)
709 IF EXIST $bin$exeext.manifest \\
710 \$(MT) \$(MTFLAGS) \$(MTINFLAG)$bin$exeext.manifest \$(MTOUTFLAG)$bin$exeext
715 my $script = $args{script};
716 my $sources = '"'.join('" "', @{$args{sources}}).'"';
717 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
718 "util", "dofile.pl")),
719 rel2abs($config{builddir}));
722 "\$(PERL)" "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
723 "-o$target{build_file}" $sources > "$script"
728 my $dir = $args{dir};
729 my @deps = map { s|\.o$|$objext|; $_ } @{$args{deps}};
731 my %extinfo = ( dso => $dsoext,
735 # We already have a 'test' target, and the top directory is just plain
737 return if $dir eq "test" || $dir eq ".";
739 foreach my $type (("dso", "lib", "bin", "script")) {
740 next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type});
741 # For lib object files, we could update the library. However,
742 # LIB on Windows doesn't work that way, so we won't create any
743 # actions for it, and the dependencies are already taken care of.
744 if ($type ne "lib") {
745 foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) {
746 if (dirname($prod) eq $dir) {
747 push @deps, $prod.$extinfo{$type};
753 my $deps = join(" ", @deps);
754 my $actions = join("\n", "", @actions);
756 $dir $dir\\ : $deps$actions
759 "" # Important! This becomes part of the template result.