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 MODULESDIR_dev={- use File::Spec::Functions qw(:DEFAULT splitpath catpath);
152 our $modulesprefix = catdir($prefix,$libdir);
153 our ($modulesprefix_dev, $modulesprefix_dir,
154 $modulesprefix_file) =
155 splitpath($modulesprefix, 1);
156 our $modulesdir_dev = $modulesprefix_dev;
157 our $modulesdir_dir =
158 catdir($modulesprefix_dir, "ossl-modules");
159 our $modulesdir = catpath($modulesdir_dev, $modulesdir_dir);
160 our $enginesdir_dev = $modulesprefix_dev;
161 our $enginesdir_dir =
162 catdir($modulesprefix_dir, "engines-$sover_dirname");
163 our $enginesdir = catpath($enginesdir_dev, $enginesdir_dir);
165 MODULESDIR_dir={- canonpath($modulesdir_dir) -}
166 ENGINESDIR_dev={- $enginesdir_dev -}
167 ENGINESDIR_dir={- canonpath($enginesdir_dir) -}
168 !IF "$(DESTDIR)" != ""
169 INSTALLTOP=$(DESTDIR)$(INSTALLTOP_dir)
170 OPENSSLDIR=$(DESTDIR)$(OPENSSLDIR_dir)
171 ENGINESDIR=$(DESTDIR)$(ENGINESDIR_dir)
172 MODULESDIR=$(DESTDIR)$(MODULESDIR_dir)
174 INSTALLTOP=$(INSTALLTOP_dev)$(INSTALLTOP_dir)
175 OPENSSLDIR=$(OPENSSLDIR_dev)$(OPENSSLDIR_dir)
176 ENGINESDIR=$(ENGINESDIR_dev)$(ENGINESDIR_dir)
177 MODULESDIR=$(MODULESDIR_dev)$(MODULESDIR_dir)
180 # $(libdir) is chosen to be compatible with the GNU coding standards
181 libdir={- file_name_is_absolute($libdir)
182 ? $libdir : '$(INSTALLTOP)\$(LIBDIR)' -}
184 ##### User defined commands and flags ################################
187 CPP={- $config{CPP} -}
188 CPPFLAGS={- our $cppflags1 = join(" ",
189 (map { "-D".$_} @{$config{CPPDEFINES}}),
190 (map { " /I ".$_} @{$config{CPPINCLUDES}}),
191 @{$config{CPPFLAGS}}) -}
192 CFLAGS={- join(' ', @{$config{CFLAGS}}) -}
194 LDFLAGS={- join(' ', @{$config{LDFLAGS}}) -}
195 EX_LIBS={- join(' ', @{$config{LDLIBS}}) -}
197 PERL={- $config{PERL} -}
200 ARFLAGS= {- join(' ', @{$config{ARFLAGS}}) -}
203 MTFLAGS= {- join(' ', @{$config{MTFLAGS}}) -}
206 ASFLAGS={- join(' ', @{$config{ASFLAGS}}) -}
210 ECHO="$(PERL)" "$(SRCDIR)\util\echo.pl"
212 ##### Special command flags ##########################################
214 COUTFLAG={- $target{coutflag} -}$(OSSL_EMPTY)
215 LDOUTFLAG={- $target{ldoutflag} -}$(OSSL_EMPTY)
216 AROUTFLAG={- $target{aroutflag} -}$(OSSL_EMPTY)
217 MTINFLAG={- $target{mtinflag} -}$(OSSL_EMPTY)
218 MTOUTFLAG={- $target{mtoutflag} -}$(OSSL_EMPTY)
219 ASOUTFLAG={- $target{asoutflag} -}$(OSSL_EMPTY)
220 RCOUTFLAG={- $target{rcoutflag} -}$(OSSL_EMPTY)
222 ##### Project flags ##################################################
224 # Variables starting with CNF_ are common variables for all product types
226 CNF_ASFLAGS={- join(' ', $target{asflags} || (),
227 @{$config{asflags}}) -}
228 CNF_CPPFLAGS={- our $cppfags2 =
229 join(' ', $target{cppflags} || (),
230 (map { '-D'.quotify1($_) } @{$target{defines}},
231 @{$config{defines}}),
232 (map { '-I'.quotify1($_) } @{$target{includes}},
233 @{$config{includes}}),
234 @{$config{cppflags}}) -}
235 CNF_CFLAGS={- join(' ', $target{cflags} || (),
236 @{$config{cflags}}) -}
237 CNF_CXXFLAGS={- join(' ', $target{cxxflags} || (),
238 @{$config{cxxflags}}) -}
239 CNF_LDFLAGS={- join(' ', $target{lflags} || (),
240 @{$config{lflags}}) -}
241 CNF_EX_LIBS={- join(' ', $target{ex_libs} || (),
242 @{$config{ex_libs}}) -}
244 # Variables starting with LIB_ are used to build library object files
245 # and shared libraries.
246 # Variables starting with DSO_ are used to build DSOs and their object files.
247 # Variables starting with BIN_ are used to build programs and their object
250 LIB_ASFLAGS={- join(' ', $target{lib_asflags} || (),
251 @{$config{lib_asflags}},
252 '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
253 LIB_CPPFLAGS={- our $lib_cppflags =
254 join(' ', $target{lib_cppflags} || (),
255 $target{shared_cppflag} || (),
256 (map { '-D'.quotify1($_) }
257 @{$target{lib_defines}},
258 @{$target{shared_defines}},
259 @{$config{lib_defines}},
260 @{$config{shared_defines}}),
261 (map { '-I'.quotify1($_) }
262 @{$target{lib_includes}},
263 @{$target{shared_includes}},
264 @{$config{lib_includes}},
265 @{$config{shared_includes}}),
266 @{$config{lib_cppflags}},
267 @{$config{shared_cppflag}});
268 join(' ', $lib_cppflags,
269 (map { '-D'.quotify1($_) }
270 "OPENSSLDIR=\"$openssldir\"",
271 "ENGINESDIR=\"$enginesdir\"",
272 "MODULESDIR=\"$modulesdir\""),
273 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
274 LIB_CFLAGS={- join(' ', $target{lib_cflags} || (),
275 $target{shared_cflag} || (),
276 @{$config{lib_cflags}},
277 @{$config{shared_cflag}},
278 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
279 LIB_LDFLAGS={- join(' ', $target{shared_ldflag} || (),
280 $config{shared_ldflag} || (),
281 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
282 LIB_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
283 DSO_ASFLAGS={- join(' ', $target{dso_asflags} || (),
284 $target{module_asflags} || (),
285 @{$config{dso_asflags}},
286 @{$config{module_asflags}},
287 '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
288 DSO_CPPFLAGS={- join(' ', $target{dso_cppflags} || (),
289 $target{module_cppflags} || (),
290 @{$config{dso_cppflags}},
291 @{$config{module_cppflags}},
292 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
293 DSO_CFLAGS={- join(' ', $target{dso_cflags} || (),
294 $target{module_cflags} || (),
295 @{$config{dso_cflags}},
296 @{$config{module_cflags}},
297 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
298 DSO_LDFLAGS={- join(' ', $target{dso_lflags} || (),
299 $target{module_ldflags} || (),
300 @{$config{dso_lflags}},
301 @{$config{module_ldflags}},
302 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
303 DSO_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
304 BIN_ASFLAGS={- join(' ', $target{bin_asflags} || (),
305 @{$config{bin_asflags}},
306 '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
307 BIN_CPPFLAGS={- join(' ', $target{bin_cppflags} || (),
308 @{$config{bin_cppflags}},
309 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
310 BIN_CFLAGS={- join(' ', $target{bin_cflags} || (),
311 @{$config{bin_cflags}},
312 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
313 BIN_LDFLAGS={- join(' ', $target{bin_lflags} || (),
314 @{$config{bin_lflags}},
315 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
316 BIN_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
318 # CPPFLAGS_Q is used for one thing only: to build up buildinf.h
319 CPPFLAGS_Q={- $cppflags1 =~ s|([\\"])|\\$1|g;
320 $cppflags2 =~ s|([\\"])|\\$1|g;
321 join(' ', $lib_cppflags || (), $cppflags2 || (),
324 PERLASM_SCHEME= {- $target{perlasm_scheme} -}
326 PROCESSOR= {- $config{processor} -}
328 # The main targets ###################################################
330 {- dependmagic('all'); -}: build_libs_nodep build_modules_nodep build_programs_nodep
331 {- dependmagic('build_libs'); -}: build_libs_nodep
332 {- dependmagic('build_modules'); -}: build_modules_nodep
333 {- dependmagic('build_programs'); -}: build_programs_nodep
335 build_generated: $(GENERATED_MANDATORY)
336 build_libs_nodep: $(LIBS) {- join(" ",map { platform->sharedlib_import($_) // () } @{$unified_info{libraries}}) -}
337 build_modules_nodep: $(MODULES)
338 build_programs_nodep: $(PROGRAMS) $(SCRIPTS)
340 # Kept around for backward compatibility
341 build_apps build_tests: build_programs
343 # Convenience target to prebuild all generated files, not just the mandatory
345 build_all_generated: $(GENERATED_MANDATORY) $(GENERATED)
346 @{- output_off() if $disabled{makedepend}; "" -}
347 @$(ECHO) "Warning: consider configuring with no-makedepend, because if"
348 @$(ECHO) " target system doesn't have $(PERL),"
349 @$(ECHO) " then make will fail..."
350 @{- output_on() if $disabled{makedepend}; "" -}
353 {- dependmagic('tests'); -}: build_programs_nodep build_modules_nodep
354 @{- output_off() if $disabled{tests}; "" -}
355 -mkdir $(BLDDIR)\test\test-runs
358 set RESULT_D=$(BLDDIR)\test\test-runs
360 set OPENSSL_ENGINES=$(MAKEDIR)\engines
361 set OPENSSL_DEBUG_MEMORY=on
362 "$(PERL)" "$(SRCDIR)\test\run_tests.pl" $(TESTS)
363 @{- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
364 @$(ECHO) "Tests are not supported with your chosen Configure options"
365 @{- output_on() if !$disabled{tests}; "" -}
368 @{- output_off() if $disabled{tests}; "" -}
369 @set SRCTOP=$(SRCDIR)
370 @"$(PERL)" "$(SRCDIR)\test\run_tests.pl" list
371 @{- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
372 @$(ECHO) "Tests are not supported with your chosen Configure options"
373 @{- output_on() if !$disabled{tests}; "" -}
375 install: install_sw install_ssldirs install_docs
377 uninstall: uninstall_docs uninstall_sw
380 "$(PERL)" -e "map { m/(.*)\.dll$$/; unlink glob """{.,apps,test,fuzz}/$$1.*"""; } @ARGV" $(SHLIBS)
381 -del /Q /F $(LIBS) libcrypto.* libssl.* ossl_static.pdb
384 {- join("\n\t", map { "-del /Q /F $_" } @PROGRAMS) -}
385 -del /Q /F $(MODULES)
386 -del /Q /F $(SCRIPTS)
387 -del /Q /F $(GENERATED_MANDATORY)
388 -del /Q /F $(GENERATED)
389 -del /Q /S /F *.d *.obj *.pdb *.ilk *.manifest
390 -del /Q /S /F engines\*.lib engines\*.exp
391 -del /Q /S /F apps\*.lib apps\*.rc apps\*.res apps\*.exp
392 -del /Q /S /F test\*.exp
393 -rmdir /Q /S test\test-runs
396 -del /Q /F configdata.pm
400 @ {- output_off() if $disabled{makedepend}; "" -}
401 @ "$(PERL)" "$(SRCDIR)\util\add-depends.pl" "VC"
402 @ {- output_on() if $disabled{makedepend}; "" -}
404 # Install helper targets #############################################
406 install_sw: install_dev install_engines install_runtime
408 uninstall_sw: uninstall_runtime uninstall_engines uninstall_dev
410 install_docs: install_html_docs
412 uninstall_docs: uninstall_html_docs
415 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\certs"
416 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\private"
417 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\misc"
418 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\openssl.cnf" \
419 "$(OPENSSLDIR)\openssl.cnf.dist"
420 @IF NOT EXIST "$(OPENSSLDIR)\openssl.cnf" \
421 "$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\openssl.cnf" \
422 "$(OPENSSLDIR)\openssl.cnf"
423 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(MISC_SCRIPTS) \
425 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\ct_log_list.cnf" \
426 "$(OPENSSLDIR)\ct_log_list.cnf.dist"
427 @IF NOT EXIST "$(OPENSSLDIR)\ct_log_list.cnf" \
428 "$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\ct_log_list.cnf" \
429 "$(OPENSSLDIR)\ct_log_list.cnf"
431 install_dev: install_runtime_libs
432 @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
433 @$(ECHO) "*** Installing development files"
434 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\include\openssl"
435 @{- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
436 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\ms\applink.c" \
437 "$(INSTALLTOP)\include\openssl"
438 @{- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
439 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "-exclude_re=/__DECC_" \
440 "$(SRCDIR)\include\openssl\*.h" \
441 "$(INSTALLTOP)\include\openssl"
442 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(BLDDIR)\include\openssl\*.h" \
443 "$(INSTALLTOP)\include\openssl"
444 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(libdir)"
445 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_LIBS) "$(libdir)"
446 @if "$(SHLIBS)"=="" \
447 "$(PERL)" "$(SRCDIR)\util\copy.pl" ossl_static.pdb "$(libdir)"
451 install_engines: install_runtime_libs build_modules
452 @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
453 @$(ECHO) "*** Installing ENGINE modules"
454 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(ENGINESDIR)"
455 @if not "$(INSTALL_ENGINES)"=="" \
456 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINES) "$(ENGINESDIR)"
457 @if not "$(INSTALL_ENGINES)"=="" \
458 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINEPDBS) "$(ENGINESDIR)"
462 install_runtime: install_programs
464 install_runtime_libs: build_libs
465 @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
466 @$(ECHO) "*** Installing runtime libraries"
467 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\bin"
468 @if not "$(SHLIBS)"=="" \
469 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_SHLIBS) "$(INSTALLTOP)\bin"
470 @if not "$(SHLIBS)"=="" \
471 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_SHLIBPDBS) \
474 install_programs: install_runtime_libs build_programs
475 @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
476 @$(ECHO) "*** Installing runtime programs"
477 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\bin"
478 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMS) \
480 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMPDBS) \
482 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BIN_SCRIPTS) \
488 "$(PERL)" "$(SRCDIR)\util\process_docs.pl" \
489 "--destdir=$(INSTALLTOP)\html" --type=html
493 # Building targets ###################################################
495 configdata.pm: "$(SRCDIR)\Configure" {- join(" ", map { '"'.$_.'"' } @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
496 @$(ECHO) "Detected changed: $?"
497 "$(PERL)" configdata.pm -r
498 @$(ECHO) "**************************************************"
500 @$(ECHO) "*** Please run the same make command again ***"
502 @$(ECHO) "**************************************************"
506 "$(PERL)" configdata.pm -r
510 use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
512 # Helper function to figure out dependencies on libraries
513 # It takes a list of library names and outputs a list of dependencies
514 sub compute_lib_depends {
515 if ($disabled{shared}) {
516 return map { platform->staticlib($_) } @_;
518 return map { platform->sharedlib_import($_) // platform->staticlib($_) } @_;
523 my ($gen0, @gens) = @{$args{generator}};
524 my $generator = '"'.$gen0.'"'.join('', map { " $_" } @gens);
525 my $generator_incs = join("", map { " -I \"$_\"" } @{$args{generator_incs}});
526 my $incs = join("", map { " /I \"$_\"" } @{$args{incs}});
527 my $defs = join("", map { " /D".$_ } @{$args{defs}});
528 my $deps = @{$args{deps}} ?
529 '"'.join('" "', @{$args{generator_deps}}, @{$args{deps}}).'"' : '';
531 if (platform->isdef($args{src})) {
532 my $target = platform->def($args{src});
533 my $mkdef = abs2rel(rel2abs(catfile($config{sourcedir},
534 "util", "mkdef.pl")),
535 rel2abs($config{builddir}));
536 my $ord_ver = $args{intent} eq 'lib' ? ' --version $(VERSION)' : '';
538 $args{generator}->[1] || platform->dsoname($args{product});
540 $target: $args{generator}->[0] $deps $mkdef
541 \$(PERL) $mkdef$ord_ver --ordinals $args{generator}->[0] --name $ord_name --OS windows > $target
543 } elsif (!platform->isasm($args{src})) {
544 my $target = $args{src};
545 if ($args{generator}->[0] =~ m|^.*\.in$|) {
546 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
547 "util", "dofile.pl")),
548 rel2abs($config{builddir}));
550 $target: "$args{generator}->[0]" $deps
551 "\$(PERL)" "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
552 "-o$target{build_file}" $generator > \$@
556 $target: "$args{generator}->[0]" $deps
557 "\$(PERL)"$generator_incs $generator > \$@
561 my $target = platform->asm($args{src});
562 if ($args{generator}->[0] =~ /\.pl$/) {
563 $generator = '"$(PERL)"'.$generator_incs.' '.$generator;
564 } elsif ($args{generator}->[0] =~ /\.S$/) {
567 die "Generator type for $src unknown: $generator\n";
570 my $cppflags = $incs;
572 shlib => ' $(LIB_CFLAGS) $(LIB_CPPFLAGS)',
573 lib => ' $(LIB_CFLAGS) $(LIB_CPPFLAGS)',
574 dso => ' $(DSO_CFLAGS) $(DSO_CPPFLAGS)',
575 bin => ' $(BIN_CFLAGS) $(BIN_CPPFLAGS)'
576 } -> {$args{intent}};
577 if (defined($generator)) {
578 # If the target is named foo.S in build.info, we want to
579 # end up generating foo.s in two steps.
580 if ($args{src} =~ /\.S$/) {
582 $target: "$args{generator}->[0]" $deps
585 \$(CPP) $cppflags $defs \$@.S > \$@.i && move /Y \$@.i \$@
591 $target: "$args{generator}->[0]" $deps
597 $target: "$args{generator}->[0]" $deps
598 \$(CPP) $incs $cppflags $defs "$args{generator}->[0]" > \$@.i && move /Y \$@.i \$@
604 my $asmext = platform->asmext();
608 (platform->isasm($x) && grep { $x eq $_ } @generated)
609 ? platform->asm($x) : $x }
611 my $srcs = '"'.join('" "', @srcs).'"';
612 my $deps = '"'.join('" "', @srcs, @{$args{deps}}).'"';
613 my $incs = join("", map { ' /I "'.$_.'"' } @{$args{incs}});
614 my $defs = join("", map { " /D".$_ } @{$args{defs}});
615 my $cflags = { shlib => ' $(LIB_CFLAGS)',
616 lib => ' $(LIB_CFLAGS)',
617 dso => ' $(DSO_CFLAGS)',
618 bin => ' $(BIN_CFLAGS)' } -> {$args{intent}};
620 $cflags .= { shlib => ' $(LIB_CPPFLAGS)',
621 lib => ' $(LIB_CPPFLAGS)',
622 dso => ' $(DSO_CPPFLAGS)',
623 bin => ' $(BIN_CPPFLAGS)' } -> {$args{intent}};
624 my $asflags = { shlib => ' $(LIB_ASFLAGS)',
625 lib => ' $(LIB_ASFLAGS)',
626 dso => ' $(DSO_ASFLAGS)',
627 bin => ' $(BIN_ASFLAGS)' } -> {$args{intent}};
628 my $makedepprog = $config{makedepprog};
629 if ($srcs[0] =~ /\.rc$/) {
630 my $res = platform->res($args{obj});
633 \$(RC) \$(RCOUTFLAG)\$\@ $srcs
636 my $obj = platform->obj($args{obj});
637 my $dep = platform->dep($args{obj});
638 if ($srcs[0] =~ /\Q${asmext}\E$/) {
641 \$(AS) $asflags \$(ASOUTFLAG)\$\@ $srcs
643 } elsif ($srcs[0] =~ /.S$/) {
646 \$(CC) /EP /D__ASSEMBLER__ $cflags $defs $srcs > \$@.asm && \$(AS) $asflags \$(ASOUTFLAG)\$\@ \$@.asm
649 my $recipe = <<"EOF";
651 \$(CC) $cflags $defs -c \$(COUTFLAG)\$\@ $srcs
653 $recipe .= <<"EOF" unless $disabled{makedepend};
654 \$(CC) $cflags $defs /Zs /showIncludes $srcs 2>&1 > $dep
659 # We *know* this routine is only called when we've configure 'shared'.
660 # Also, note that even though the import library built here looks like
661 # a static library, it really isn't.
664 my $lib = $args{lib};
665 my @objs = map { platform->convertext($_) }
666 grep { platform->isobj($_) || platform->isres($_) }
668 my @defs = map { platform->def($_) }
669 grep { platform->isdef($_) }
671 my @deps = compute_lib_depends(@{$args{deps}});
672 die "More than one exported symbols list" if scalar @defs > 1;
673 my $linklibs = join("", map { "$_\n" } @deps);
674 my $objs = join("\n", @objs);
675 my $deps = join(" ", @objs, @defs, @deps);
676 my $import = platform->sharedlib_import($lib);
677 my $dll = platform->sharedlib($lib);
678 my $shared_def = join("", map { " /def:$_" } @defs);
680 # The import library may look like a static library, but it is not.
681 # We MUST make the import library depend on the DLL, in case someone
682 # mistakenly removes the latter.
685 IF EXIST $full.manifest DEL /F /Q $full.manifest
686 IF EXIST \$@ DEL /F /Q \$@
687 \$(LD) \$(LDFLAGS) \$(LIB_LDFLAGS) \\
688 /implib:$import \$(LDOUTFLAG)$dll$shared_def @<< || (DEL /Q \$(\@B).* $import && EXIT 1)
690 $linklibs\$(LIB_EX_LIBS)
692 IF EXIST $dll.manifest \\
693 \$(MT) \$(MTFLAGS) \$(MTINFLAG)$dll.manifest \$(MTOUTFLAG)$dll
694 IF EXIST apps\\$dll DEL /Q /F apps\\$dll
695 IF EXIST test\\$dll DEL /Q /F test\\$dll
696 IF EXIST fuzz\\$dll DEL /Q /F fuzz\\$dll
704 my $dso = platform->dso($args{lib});
705 my $dso_n = platform->dsoname($args{lib});
706 my @objs = map { platform->convertext($_) }
707 grep { platform->isobj($_) || platform->isres($_) }
709 my @defs = map { platform->def($_) }
710 grep { platform->isdef($_) }
712 my @deps = compute_lib_depends(@{$args{deps}});
713 my $objs = join("\n", @objs);
714 my $linklibs = join("", map { "$_\n" } @deps);
715 my $deps = join(" ", @objs, @defs, @deps);
716 my $shared_def = join("", map { " /def:$_" } @defs);
719 IF EXIST $dso.manifest DEL /F /Q $dso.manifest
720 \$(LD) \$(LDFLAGS) \$(DSO_LDFLAGS) \\
721 \$(LDOUTFLAG)$dso$shared_def @<< || (DEL /Q \$(\@B).* $dso_n.* && EXIT 1)
723 $linklibs \$(DSO_EX_LIBS)
725 IF EXIST $dso.manifest \\
726 \$(MT) \$(MTFLAGS) \$(MTINFLAG)$dso.manifest \$(MTOUTFLAG)$dso
731 my $lib = platform->staticlib($args{lib});
732 my @objs = map { platform->obj($_) } @{$args{objs}};
733 my $objs = join("\n", @objs);
734 my $deps = join(" ", @objs);
737 \$(AR) \$(ARFLAGS) \$(AROUTFLAG)$lib @<<
744 my $bin = platform->bin($args{bin});
745 my @objs = map { platform->convertext($_) }
746 grep { platform->isobj($_) || platform->isres($_) }
748 my @deps = compute_lib_depends(@{$args{deps}});
749 my $objs = join("\n", @objs);
750 my $linklibs = join("", map { "$_\n" } @deps);
751 my $deps = join(" ", @objs, @deps);
754 IF EXIST $bin.manifest DEL /F /Q $bin.manifest
755 \$(LD) \$(LDFLAGS) \$(BIN_LDFLAGS) \$(LDOUTFLAG)$bin @<<
758 $linklibs\$(BIN_EX_LIBS)
760 IF EXIST $bin.manifest \\
761 \$(MT) \$(MTFLAGS) \$(MTINFLAG)$bin.manifest \$(MTOUTFLAG)$bin
766 my $script = $args{script};
767 my $sources = '"'.join('" "', @{$args{sources}}).'"';
768 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
769 "util", "dofile.pl")),
770 rel2abs($config{builddir}));
773 "\$(PERL)" "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
774 "-o$target{build_file}" $sources > "$script"
779 my $dir = $args{dir};
780 my @deps = map { platform->convertext($_) } @{$args{deps}};
782 my %extinfo = ( dso => platform->dsoext(),
783 lib => platform->libext(),
784 bin => platform->binext() );
786 # We already have a 'test' target, and the top directory is just plain
788 return if $dir eq "test" || $dir eq ".";
790 foreach my $type (("dso", "lib", "bin", "script")) {
791 next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type});
792 # For lib object files, we could update the library. However,
793 # LIB on Windows doesn't work that way, so we won't create any
794 # actions for it, and the dependencies are already taken care of.
795 if ($type ne "lib") {
796 foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) {
797 if (dirname($prod) eq $dir) {
798 push @deps, $prod.$extinfo{$type};
804 my $deps = join(" ", @deps);
805 my $actions = join("\n", "", @actions);
807 $dir $dir\\ : $deps$actions
810 "" # Important! This becomes part of the template result.