2 ## Makefile for OpenSSL
4 ## {- join("\n## ", @autowarntext) -}
6 our $sover_dirname = platform->shlib_version_as_filename();
8 my $build_scheme = $target{build_scheme};
9 my $install_flavour = $build_scheme->[$#$build_scheme]; # last element
11 $install_flavour eq "VC-WOW" ? "ProgramFiles(x86)"
14 $install_flavour eq "VC-WOW" ? "CommonProgramFiles(x86)"
15 : "CommonProgramW6432";
16 our $win_installroot =
17 defined($ENV{$win_installenv}) ? $win_installenv : 'ProgramFiles';
19 defined($ENV{$win_commonenv}) ? $win_commonenv : 'CommonProgramFiles';
21 # expand variables early
22 $win_installroot = $ENV{$win_installroot};
23 $win_commonroot = $ENV{$win_commonroot};
25 # This makes sure things get built in the order they need
30 return "$target: build_generated\n\t\$(MAKE) /\$(MAKEFLAGS) depend && \$(MAKE) /\$(MAKEFLAGS) _$target\n_$target";
35 PLATFORM={- $config{target} -}
36 SRCDIR={- $config{sourcedir} -}
37 BLDDIR={- $config{builddir} -}
39 VERSION={- "$config{full_version}" -}
40 MAJOR={- $config{major} -}
41 MINOR={- $config{minor} -}
43 SHLIB_VERSION_NUMBER={- $config{shlib_version} -}
45 LIBS={- join(" ", map { ( platform->sharedlib_import($_), platform->staticlib($_) ) } @{$unified_info{libraries}}) -}
46 SHLIBS={- join(" ", map { platform->sharedlib($_) // () } @{$unified_info{libraries}}) -}
47 SHLIBPDBS={- join(" ", map { platform->sharedlibpdb($_) // () } @{$unified_info{libraries}}) -}
48 MODULES={- join(" ", map { platform->dso($_) } @{$unified_info{modules}}) -}
49 MODULEPDBS={- join(" ", map { platform->dsopdb($_) } @{$unified_info{modules}}) -}
50 PROGRAMS={- our @PROGRAMS = map { platform->bin($_) } @{$unified_info{programs}}; join(" ", @PROGRAMS) -}
51 PROGRAMPDBS={- join(" ", map { $_.".pdb" } @{$unified_info{programs}}) -}
52 SCRIPTS={- join(" ", @{$unified_info{scripts}}) -}
53 {- output_off() if $disabled{makedepend}; "" -}
54 DEPS={- join(" ", map { platform->isobj($_) ? platform->dep($_) : () }
55 grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
56 keys %{$unified_info{sources}}); -}
57 {- output_on() if $disabled{makedepend}; "" -}
58 GENERATED_MANDATORY={- join(" ", @{$unified_info{depends}->{""}} ) -}
59 GENERATED={- # common0.tmpl provides @generated
60 join(" ", map { platform->convertext($_) } @generated) -}
63 join(" ", map { quotify1(platform->sharedlib_import($_)
64 // platform->staticlib($_)) }
65 grep { !$unified_info{attributes}->{$_}->{noinst} }
66 @{$unified_info{libraries}})
69 join(" ", map { my $x = platform->sharedlib($_);
70 $x ? quotify_l($x) : () }
71 grep { !$unified_info{attributes}->{$_}->{noinst} }
72 @{$unified_info{libraries}})
75 join(" ", map { my $x = platform->sharedlibpdb($_);
76 $x ? quotify_l($x) : () }
77 grep { !$unified_info{attributes}->{$_}->{noinst} }
78 @{$unified_info{libraries}})
81 join(" ", map { quotify1(platform->dso($_)) }
82 grep { !$unified_info{attributes}->{$_}->{noinst}
83 && $unified_info{attributes}->{$_}->{engine} }
84 @{$unified_info{modules}})
87 join(" ", map { quotify1(platform->dsopdb($_)) }
88 grep { !$unified_info{attributes}->{$_}->{noinst}
89 && $unified_info{attributes}->{$_}->{engine} }
90 @{$unified_info{modules}})
93 join(" ", map { quotify1(platform->bin($_)) }
94 grep { !$unified_info{attributes}->{$_}->{noinst} }
95 @{$unified_info{programs}})
97 INSTALL_PROGRAMPDBS={-
98 join(" ", map { quotify1(platform->binpdb($_)) }
99 grep { !$unified_info{attributes}->{$_}->{noinst} }
100 @{$unified_info{programs}})
103 join(" ", map { quotify1($_) }
104 grep { !$unified_info{attributes}->{$_}->{noinst}
105 && !$unified_info{attributes}->{$_}->{misc} }
106 @{$unified_info{scripts}})
109 join(" ", map { quotify1($_) }
110 grep { !$unified_info{attributes}->{$_}->{noinst}
111 && $unified_info{attributes}->{$_}->{misc} }
112 @{$unified_info{scripts}})
115 APPS_OPENSSL={- use File::Spec::Functions;
116 "\"".catfile("apps","openssl")."\"" -}
118 # Do not edit these manually. Use Configure with --prefix or --openssldir
119 # to change this! Short explanation in the top comment in Configure
120 INSTALLTOP_dev={- # $prefix is used in the OPENSSLDIR perl snippet
122 use File::Spec::Functions qw(:DEFAULT splitpath);
123 our $prefix = canonpath($config{prefix}
124 || "$win_installroot\\OpenSSL");
125 our ($prefix_dev, $prefix_dir, $prefix_file) =
126 splitpath($prefix, 1);
128 INSTALLTOP_dir={- canonpath($prefix_dir) -}
130 # The logic here is that if no --openssldir was given,
131 # OPENSSLDIR will get the value "$win_commonroot\\SSL".
132 # If --openssldir was given and the value is an absolute
133 # path, OPENSSLDIR will get its value without change.
134 # If the value from --openssldir is a relative path,
135 # OPENSSLDIR will get $prefix with the --openssldir
136 # value appended as a subdirectory.
138 use File::Spec::Functions qw(:DEFAULT splitpath);
140 $config{openssldir} ?
141 (file_name_is_absolute($config{openssldir}) ?
142 canonpath($config{openssldir})
143 : catdir($prefix, $config{openssldir}))
144 : canonpath("$win_commonroot\\SSL");
145 our ($openssldir_dev, $openssldir_dir, $openssldir_file) =
146 splitpath($openssldir, 1);
148 OPENSSLDIR_dir={- canonpath($openssldir_dir) -}
149 LIBDIR={- our $libdir = $config{libdir} || "lib";
150 file_name_is_absolute($libdir) ? "" : $libdir -}
151 ENGINESDIR_dev={- use File::Spec::Functions qw(:DEFAULT splitpath);
152 our $enginesdir = catdir($prefix,$libdir,"engines-$sover_dirname");
153 our ($enginesdir_dev, $enginesdir_dir, $enginesdir_file) =
154 splitpath($enginesdir, 1);
156 ENGINESDIR_dir={- canonpath($enginesdir_dir) -}
157 !IF "$(DESTDIR)" != ""
158 INSTALLTOP=$(DESTDIR)$(INSTALLTOP_dir)
159 OPENSSLDIR=$(DESTDIR)$(OPENSSLDIR_dir)
160 ENGINESDIR=$(DESTDIR)$(ENGINESDIR_dir)
162 INSTALLTOP=$(INSTALLTOP_dev)$(INSTALLTOP_dir)
163 OPENSSLDIR=$(OPENSSLDIR_dev)$(OPENSSLDIR_dir)
164 ENGINESDIR=$(ENGINESDIR_dev)$(ENGINESDIR_dir)
167 # $(libdir) is chosen to be compatible with the GNU coding standards
168 libdir={- file_name_is_absolute($libdir)
169 ? $libdir : '$(INSTALLTOP)\$(LIBDIR)' -}
171 ##### User defined commands and flags ################################
174 CPP={- $config{CPP} -}
175 CPPFLAGS={- our $cppflags1 = join(" ",
176 (map { "-D".$_} @{$config{CPPDEFINES}}),
177 (map { " /I ".$_} @{$config{CPPINCLUDES}}),
178 @{$config{CPPFLAGS}}) -}
179 CFLAGS={- join(' ', @{$config{CFLAGS}}) -}
181 LDFLAGS={- join(' ', @{$config{LDFLAGS}}) -}
182 EX_LIBS={- join(' ', @{$config{LDLIBS}}) -}
184 PERL={- $config{PERL} -}
187 ARFLAGS= {- join(' ', @{$config{ARFLAGS}}) -}
190 MTFLAGS= {- join(' ', @{$config{MTFLAGS}}) -}
193 ASFLAGS={- join(' ', @{$config{ASFLAGS}}) -}
197 ECHO="$(PERL)" "$(SRCDIR)\util\echo.pl"
199 ##### Special command flags ##########################################
201 COUTFLAG={- $target{coutflag} -}$(OSSL_EMPTY)
202 LDOUTFLAG={- $target{ldoutflag} -}$(OSSL_EMPTY)
203 AROUTFLAG={- $target{aroutflag} -}$(OSSL_EMPTY)
204 MTINFLAG={- $target{mtinflag} -}$(OSSL_EMPTY)
205 MTOUTFLAG={- $target{mtoutflag} -}$(OSSL_EMPTY)
206 ASOUTFLAG={- $target{asoutflag} -}$(OSSL_EMPTY)
207 RCOUTFLAG={- $target{rcoutflag} -}$(OSSL_EMPTY)
209 ##### Project flags ##################################################
211 # Variables starting with CNF_ are common variables for all product types
213 CNF_ASFLAGS={- join(' ', $target{asflags} || (),
214 @{$config{asflags}}) -}
215 CNF_CPPFLAGS={- our $cppfags2 =
216 join(' ', $target{cppflags} || (),
217 (map { '-D'.quotify1($_) } @{$target{defines}},
218 @{$config{defines}}),
219 (map { '-I'.quotify1($_) } @{$target{includes}},
220 @{$config{includes}}),
221 @{$config{cppflags}}) -}
222 CNF_CFLAGS={- join(' ', $target{cflags} || (),
223 @{$config{cflags}}) -}
224 CNF_CXXFLAGS={- join(' ', $target{cxxflags} || (),
225 @{$config{cxxflags}}) -}
226 CNF_LDFLAGS={- join(' ', $target{lflags} || (),
227 @{$config{lflags}}) -}
228 CNF_EX_LIBS={- join(' ', $target{ex_libs} || (),
229 @{$config{ex_libs}}) -}
231 # Variables starting with LIB_ are used to build library object files
232 # and shared libraries.
233 # Variables starting with DSO_ are used to build DSOs and their object files.
234 # Variables starting with BIN_ are used to build programs and their object
237 LIB_ASFLAGS={- join(' ', $target{lib_asflags} || (),
238 @{$config{lib_asflags}},
239 '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
240 LIB_CPPFLAGS={- our $lib_cppflags =
241 join(' ', $target{lib_cppflags} || (),
242 $target{shared_cppflag} || (),
243 (map { '-D'.quotify1($_) }
244 @{$target{lib_defines}},
245 @{$target{shared_defines}},
246 @{$config{lib_defines}},
247 @{$config{shared_defines}}),
248 (map { '-I'.quotify1($_) }
249 @{$target{lib_includes}},
250 @{$target{shared_includes}},
251 @{$config{lib_includes}},
252 @{$config{shared_includes}}),
253 @{$config{lib_cppflags}},
254 @{$config{shared_cppflag}});
255 join(' ', $lib_cppflags,
256 (map { '-D'.quotify1($_) }
257 "OPENSSLDIR=\"$openssldir\"",
258 "ENGINESDIR=\"$enginesdir\""),
259 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
260 LIB_CFLAGS={- join(' ', $target{lib_cflags} || (),
261 $target{shared_cflag} || (),
262 @{$config{lib_cflags}},
263 @{$config{shared_cflag}},
264 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
265 LIB_LDFLAGS={- join(' ', $target{shared_ldflag} || (),
266 $config{shared_ldflag} || (),
267 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
268 LIB_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
269 DSO_ASFLAGS={- join(' ', $target{dso_asflags} || (),
270 $target{module_asflags} || (),
271 @{$config{dso_asflags}},
272 @{$config{module_asflags}},
273 '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
274 DSO_CPPFLAGS={- join(' ', $target{dso_cppflags} || (),
275 $target{module_cppflags} || (),
276 @{$config{dso_cppflags}},
277 @{$config{module_cppflags}},
278 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
279 DSO_CFLAGS={- join(' ', $target{dso_cflags} || (),
280 $target{module_cflags} || (),
281 @{$config{dso_cflags}},
282 @{$config{module_cflags}},
283 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
284 DSO_LDFLAGS={- join(' ', $target{dso_lflags} || (),
285 $target{module_ldflags} || (),
286 @{$config{dso_lflags}},
287 @{$config{module_ldflags}},
288 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
289 DSO_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
290 BIN_ASFLAGS={- join(' ', $target{bin_asflags} || (),
291 @{$config{bin_asflags}},
292 '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
293 BIN_CPPFLAGS={- join(' ', $target{bin_cppflags} || (),
294 @{$config{bin_cppflags}},
295 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
296 BIN_CFLAGS={- join(' ', $target{bin_cflags} || (),
297 @{$config{bin_cflags}},
298 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
299 BIN_LDFLAGS={- join(' ', $target{bin_lflags} || (),
300 @{$config{bin_lflags}},
301 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
302 BIN_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
304 # CPPFLAGS_Q is used for one thing only: to build up buildinf.h
305 CPPFLAGS_Q={- $cppflags1 =~ s|([\\"])|\\$1|g;
306 $cppflags2 =~ s|([\\"])|\\$1|g;
307 join(' ', $lib_cppflags || (), $cppflags2 || (),
310 PERLASM_SCHEME= {- $target{perlasm_scheme} -}
312 PROCESSOR= {- $config{processor} -}
314 # The main targets ###################################################
316 {- dependmagic('all'); -}: build_libs_nodep build_modules_nodep build_programs_nodep
317 {- dependmagic('build_libs'); -}: build_libs_nodep
318 {- dependmagic('build_modules'); -}: build_modules_nodep
319 {- dependmagic('build_programs'); -}: build_programs_nodep
321 build_generated: $(GENERATED_MANDATORY)
322 build_libs_nodep: $(LIBS) {- join(" ",map { platform->sharedlib_import($_) // () } @{$unified_info{libraries}}) -}
323 build_modules_nodep: $(MODULES)
324 build_programs_nodep: $(PROGRAMS) $(SCRIPTS)
326 # Kept around for backward compatibility
327 build_apps build_tests: build_programs
329 # Convenience target to prebuild all generated files, not just the mandatory
331 build_all_generated: $(GENERATED_MANDATORY) $(GENERATED)
332 @{- output_off() if $disabled{makedepend}; "" -}
333 @$(ECHO) "Warning: consider configuring with no-makedepend, because if"
334 @$(ECHO) " target system doesn't have $(PERL),"
335 @$(ECHO) " then make will fail..."
336 @{- output_on() if $disabled{makedepend}; "" -}
339 {- dependmagic('tests'); -}: build_programs_nodep build_modules_nodep
340 @{- output_off() if $disabled{tests}; "" -}
341 -mkdir $(BLDDIR)\test\test-runs
344 set RESULT_D=$(BLDDIR)\test\test-runs
346 set OPENSSL_ENGINES=$(MAKEDIR)\engines
347 set OPENSSL_DEBUG_MEMORY=on
348 "$(PERL)" "$(SRCDIR)\test\run_tests.pl" $(TESTS)
349 @{- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
350 @$(ECHO) "Tests are not supported with your chosen Configure options"
351 @{- output_on() if !$disabled{tests}; "" -}
354 @{- output_off() if $disabled{tests}; "" -}
355 @set SRCTOP=$(SRCDIR)
356 @"$(PERL)" "$(SRCDIR)\test\run_tests.pl" list
357 @{- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
358 @$(ECHO) "Tests are not supported with your chosen Configure options"
359 @{- output_on() if !$disabled{tests}; "" -}
361 install: install_sw install_ssldirs install_docs
363 uninstall: uninstall_docs uninstall_sw
366 "$(PERL)" -e "map { m/(.*)\.dll$$/; unlink glob """{.,apps,test,fuzz}/$$1.*"""; } @ARGV" $(SHLIBS)
367 -del /Q /F $(LIBS) libcrypto.* libssl.* ossl_static.pdb
370 {- join("\n\t", map { "-del /Q /F $_" } @PROGRAMS) -}
371 -del /Q /F $(MODULES)
372 -del /Q /F $(SCRIPTS)
373 -del /Q /F $(GENERATED_MANDATORY)
374 -del /Q /F $(GENERATED)
375 -del /Q /S /F *.d *.obj *.pdb *.ilk *.manifest
376 -del /Q /S /F engines\*.lib engines\*.exp
377 -del /Q /S /F apps\*.lib apps\*.rc apps\*.res apps\*.exp
378 -del /Q /S /F test\*.exp
379 -rmdir /Q /S test\test-runs
382 -del /Q /F configdata.pm
386 @ {- output_off() if $disabled{makedepend}; "" -}
387 @ "$(PERL)" "$(SRCDIR)\util\add-depends.pl" "VC"
388 @ {- output_on() if $disabled{makedepend}; "" -}
390 # Install helper targets #############################################
392 install_sw: install_dev install_engines install_runtime
394 uninstall_sw: uninstall_runtime uninstall_engines uninstall_dev
396 install_docs: install_html_docs
398 uninstall_docs: uninstall_html_docs
401 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\certs"
402 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\private"
403 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\misc"
404 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\openssl.cnf" \
405 "$(OPENSSLDIR)\openssl.cnf.dist"
406 @IF NOT EXIST "$(OPENSSLDIR)\openssl.cnf" \
407 "$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\openssl.cnf" \
408 "$(OPENSSLDIR)\openssl.cnf"
409 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(MISC_SCRIPTS) \
411 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\ct_log_list.cnf" \
412 "$(OPENSSLDIR)\ct_log_list.cnf.dist"
413 @IF NOT EXIST "$(OPENSSLDIR)\ct_log_list.cnf" \
414 "$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\ct_log_list.cnf" \
415 "$(OPENSSLDIR)\ct_log_list.cnf"
417 install_dev: install_runtime_libs
418 @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
419 @$(ECHO) "*** Installing development files"
420 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\include\openssl"
421 @{- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
422 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\ms\applink.c" \
423 "$(INSTALLTOP)\include\openssl"
424 @{- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
425 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "-exclude_re=/__DECC_" \
426 "$(SRCDIR)\include\openssl\*.h" \
427 "$(INSTALLTOP)\include\openssl"
428 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(BLDDIR)\include\openssl\*.h" \
429 "$(INSTALLTOP)\include\openssl"
430 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(libdir)"
431 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_LIBS) "$(libdir)"
432 @if "$(SHLIBS)"=="" \
433 "$(PERL)" "$(SRCDIR)\util\copy.pl" ossl_static.pdb "$(libdir)"
437 install_engines: install_runtime_libs build_modules
438 @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
439 @$(ECHO) "*** Installing ENGINE modules"
440 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(ENGINESDIR)"
441 @if not "$(INSTALL_ENGINES)"=="" \
442 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINES) "$(ENGINESDIR)"
443 @if not "$(INSTALL_ENGINES)"=="" \
444 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINEPDBS) "$(ENGINESDIR)"
448 install_runtime: install_programs
450 install_runtime_libs: build_libs
451 @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
452 @$(ECHO) "*** Installing runtime libraries"
453 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\bin"
454 @if not "$(SHLIBS)"=="" \
455 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_SHLIBS) "$(INSTALLTOP)\bin"
456 @if not "$(SHLIBS)"=="" \
457 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_SHLIBPDBS) \
460 install_programs: install_runtime_libs build_programs
461 @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
462 @$(ECHO) "*** Installing runtime programs"
463 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\bin"
464 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMS) \
466 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMPDBS) \
468 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BIN_SCRIPTS) \
474 "$(PERL)" "$(SRCDIR)\util\process_docs.pl" \
475 "--destdir=$(INSTALLTOP)\html" --type=html
479 # Building targets ###################################################
481 configdata.pm: "$(SRCDIR)\Configure" {- join(" ", map { '"'.$_.'"' } @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
482 @$(ECHO) "Detected changed: $?"
483 "$(PERL)" configdata.pm -r
484 @$(ECHO) "**************************************************"
486 @$(ECHO) "*** Please run the same make command again ***"
488 @$(ECHO) "**************************************************"
492 "$(PERL)" configdata.pm -r
496 use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
498 # Helper function to figure out dependencies on libraries
499 # It takes a list of library names and outputs a list of dependencies
500 sub compute_lib_depends {
501 if ($disabled{shared}) {
502 return map { platform->staticlib($_) } @_;
504 return map { platform->sharedlib_import($_) // platform->staticlib($_) } @_;
509 my ($gen0, @gens) = @{$args{generator}};
510 my $generator = '"'.$gen0.'"'.join('', map { " $_" } @gens);
511 my $generator_incs = join("", map { " -I \"$_\"" } @{$args{generator_incs}});
512 my $incs = join("", map { " /I \"$_\"" } @{$args{incs}});
513 my $defs = join("", map { " /D".$_ } @{$args{defs}});
514 my $deps = @{$args{deps}} ?
515 '"'.join('" "', @{$args{generator_deps}}, @{$args{deps}}).'"' : '';
517 if (platform->isdef($args{src})) {
518 my $target = platform->def($args{src});
519 my $mkdef = abs2rel(rel2abs(catfile($config{sourcedir},
520 "util", "mkdef.pl")),
521 rel2abs($config{builddir}));
522 my $ord_ver = $args{intent} eq 'lib' ? ' --version $(VERSION)' : '';
524 $args{generator}->[1] || platform->dsoname($args{product});
526 $target: $args{generator}->[0] $deps $mkdef
527 \$(PERL) $mkdef$ord_ver --ordinals $args{generator}->[0] --name $ord_name --OS windows > $target
529 } elsif (!platform->isasm($args{src})) {
530 my $target = $args{src};
531 if ($args{generator}->[0] =~ m|^.*\.in$|) {
532 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
533 "util", "dofile.pl")),
534 rel2abs($config{builddir}));
536 $target: "$args{generator}->[0]" $deps
537 "\$(PERL)" "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
538 "-o$target{build_file}" $generator > \$@
542 $target: "$args{generator}->[0]" $deps
543 "\$(PERL)"$generator_incs $generator > \$@
547 my $target = platform->asm($args{src});
548 if ($args{generator}->[0] =~ /\.pl$/) {
549 $generator = '"$(PERL)"'.$generator_incs.' '.$generator;
550 } elsif ($args{generator}->[0] =~ /\.S$/) {
553 die "Generator type for $src unknown: $generator\n";
556 my $cppflags = $incs;
558 shlib => ' $(LIB_CFLAGS) $(LIB_CPPFLAGS)',
559 lib => ' $(LIB_CFLAGS) $(LIB_CPPFLAGS)',
560 dso => ' $(DSO_CFLAGS) $(DSO_CPPFLAGS)',
561 bin => ' $(BIN_CFLAGS) $(BIN_CPPFLAGS)'
562 } -> {$args{intent}};
563 if (defined($generator)) {
564 # If the target is named foo.S in build.info, we want to
565 # end up generating foo.s in two steps.
566 if ($args{src} =~ /\.S$/) {
568 $target: "$args{generator}->[0]" $deps
571 \$(CPP) $cppflags $defs \$@.S > \$@.i && move /Y \$@.i \$@
577 $target: "$args{generator}->[0]" $deps
583 $target: "$args{generator}->[0]" $deps
584 \$(CPP) $incs $cppflags $defs "$args{generator}->[0]" > \$@.i && move /Y \$@.i \$@
591 my @srcs = map { (my $x = $_) =~ s/\.s$/.asm/; $x } ( @{$args{srcs}} );
592 my $srcs = '"'.join('" "', @srcs).'"';
593 my $deps = '"'.join('" "', @srcs, @{$args{deps}}).'"';
594 my $incs = join("", map { ' /I "'.$_.'"' } @{$args{incs}});
595 my $defs = join("", map { " /D".$_ } @{$args{defs}});
596 my $cflags = { shlib => ' $(LIB_CFLAGS)',
597 lib => ' $(LIB_CFLAGS)',
598 dso => ' $(DSO_CFLAGS)',
599 bin => ' $(BIN_CFLAGS)' } -> {$args{intent}};
601 $cflags .= { shlib => ' $(LIB_CPPFLAGS)',
602 lib => ' $(LIB_CPPFLAGS)',
603 dso => ' $(DSO_CPPFLAGS)',
604 bin => ' $(BIN_CPPFLAGS)' } -> {$args{intent}};
605 my $asflags = { shlib => ' $(LIB_ASFLAGS)',
606 lib => ' $(LIB_ASFLAGS)',
607 dso => ' $(DSO_ASFLAGS)',
608 bin => ' $(BIN_ASFLAGS)' } -> {$args{intent}};
609 my $makedepprog = $config{makedepprog};
610 if ($srcs[0] =~ /\.rc$/) {
611 my $res = platform->res($args{obj});
614 \$(RC) \$(RCOUTFLAG)\$\@ $srcs
617 my $obj = platform->obj($args{obj});
618 my $dep = platform->dep($args{obj});
619 if ($srcs[0] =~ /\.asm$/) {
622 \$(AS) $asflags \$(ASOUTFLAG)\$\@ $srcs
624 } elsif ($srcs[0] =~ /.S$/) {
627 \$(CC) /EP /D__ASSEMBLER__ $cflags $defs $srcs > \$@.asm && \$(AS) $asflags \$(ASOUTFLAG)\$\@ \$@.asm
630 my $recipe = <<"EOF";
632 \$(CC) $cflags $defs -c \$(COUTFLAG)\$\@ $srcs
634 $recipe .= <<"EOF" unless $disabled{makedepend};
635 \$(CC) $cflags $defs /Zs /showIncludes $srcs 2>&1 > $dep
640 # We *know* this routine is only called when we've configure 'shared'.
641 # Also, note that even though the import library built here looks like
642 # a static library, it really isn't.
645 my $lib = $args{lib};
646 my @objs = map { platform->convertext($_) }
647 grep { platform->isobj($_) || platform->isres($_) }
649 my @defs = map { platform->def($_) }
650 grep { platform->isdef($_) }
652 my @deps = compute_lib_depends(@{$args{deps}});
653 die "More than one exported symbols list" if scalar @defs > 1;
654 my $linklibs = join("", map { "$_\n" } @deps);
655 my $objs = join("\n", @objs);
656 my $deps = join(" ", @objs, @defs, @deps);
657 my $import = platform->sharedlib_import($lib);
658 my $dll = platform->sharedlib($lib);
659 my $shared_def = join("", map { " /def:$_" } @defs);
661 # The import library may look like a static library, but it is not.
662 # We MUST make the import library depend on the DLL, in case someone
663 # mistakenly removes the latter.
666 IF EXIST $full.manifest DEL /F /Q $full.manifest
667 IF EXIST \$@ DEL /F /Q \$@
668 \$(LD) \$(LDFLAGS) \$(LIB_LDFLAGS) \\
669 /implib:$import \$(LDOUTFLAG)$dll$shared_def @<< || (DEL /Q \$(\@B).* $import && EXIT 1)
671 $linklibs\$(LIB_EX_LIBS)
673 IF EXIST $dll.manifest \\
674 \$(MT) \$(MTFLAGS) \$(MTINFLAG)$dll.manifest \$(MTOUTFLAG)$dll
675 IF EXIST apps\\$dll DEL /Q /F apps\\$dll
676 IF EXIST test\\$dll DEL /Q /F test\\$dll
677 IF EXIST fuzz\\$dll DEL /Q /F fuzz\\$dll
685 my $dso = platform->dso($args{lib});
686 my $dso_n = platform->dsoname($args{lib});
687 my @objs = map { platform->convertext($_) }
688 grep { platform->isobj($_) || platform->isres($_) }
690 my @defs = map { platform->def($_) }
691 grep { platform->isdef($_) }
693 my @deps = compute_lib_depends(@{$args{deps}});
694 my $objs = join("\n", @objs);
695 my $linklibs = join("", map { "$_\n" } @deps);
696 my $deps = join(" ", @objs, @defs, @deps);
697 my $shared_def = join("", map { " /def:$_" } @defs);
700 IF EXIST $dso.manifest DEL /F /Q $dso.manifest
701 \$(LD) \$(LDFLAGS) \$(DSO_LDFLAGS) \\
702 \$(LDOUTFLAG)$dso$shared_def @<< || (DEL /Q \$(\@B).* $dso_n.* && EXIT 1)
704 $linklibs \$(DSO_EX_LIBS)
706 IF EXIST $dso.manifest \\
707 \$(MT) \$(MTFLAGS) \$(MTINFLAG)$dso.manifest \$(MTOUTFLAG)$dso
712 my $lib = platform->staticlib($args{lib});
713 my @objs = map { platform->obj($_) } @{$args{objs}};
714 my $objs = join("\n", @objs);
715 my $deps = join(" ", @objs);
718 \$(AR) \$(ARFLAGS) \$(AROUTFLAG)$lib @<<
725 my $bin = platform->bin($args{bin});
726 my @objs = map { platform->convertext($_) }
727 grep { platform->isobj($_) || platform->isres($_) }
729 my @deps = compute_lib_depends(@{$args{deps}});
730 my $objs = join("\n", @objs);
731 my $linklibs = join("", map { "$_\n" } @deps);
732 my $deps = join(" ", @objs, @deps);
735 IF EXIST $bin.manifest DEL /F /Q $bin.manifest
736 \$(LD) \$(LDFLAGS) \$(BIN_LDFLAGS) \$(LDOUTFLAG)$bin @<<
739 $linklibs\$(BIN_EX_LIBS)
741 IF EXIST $bin.manifest \\
742 \$(MT) \$(MTFLAGS) \$(MTINFLAG)$bin.manifest \$(MTOUTFLAG)$bin
747 my $script = $args{script};
748 my $sources = '"'.join('" "', @{$args{sources}}).'"';
749 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
750 "util", "dofile.pl")),
751 rel2abs($config{builddir}));
754 "\$(PERL)" "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
755 "-o$target{build_file}" $sources > "$script"
760 my $dir = $args{dir};
761 my @deps = map { platform->convertext($_) } @{$args{deps}};
763 my %extinfo = ( dso => platform->dsoext(),
764 lib => platform->libext(),
765 bin => platform->binext() );
767 # We already have a 'test' target, and the top directory is just plain
769 return if $dir eq "test" || $dir eq ".";
771 foreach my $type (("dso", "lib", "bin", "script")) {
772 next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type});
773 # For lib object files, we could update the library. However,
774 # LIB on Windows doesn't work that way, so we won't create any
775 # actions for it, and the dependencies are already taken care of.
776 if ($type ne "lib") {
777 foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) {
778 if (dirname($prod) eq $dir) {
779 push @deps, $prod.$extinfo{$type};
785 my $deps = join(" ", @deps);
786 my $actions = join("\n", "", @actions);
788 $dir $dir\\ : $deps$actions
791 "" # Important! This becomes part of the template result.