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}->{libraries}->{$_}->{noinst} }
66 @{$unified_info{libraries}})
69 join(" ", map { my $x = platform->sharedlib($_);
70 $x ? quotify_l($x) : () }
71 grep { !$unified_info{attributes}->{libraries}->{$_}->{noinst} }
72 @{$unified_info{libraries}})
75 join(" ", map { my $x = platform->sharedlibpdb($_);
76 $x ? quotify_l($x) : () }
77 grep { !$unified_info{attributes}->{libraries}->{$_}->{noinst} }
78 @{$unified_info{libraries}})
81 join(" ", map { quotify1(platform->dso($_)) }
82 grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
83 && $unified_info{attributes}->{modules}->{$_}->{engine} }
84 @{$unified_info{modules}})
87 join(" ", map { quotify1(platform->dsopdb($_)) }
88 grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
89 && $unified_info{attributes}->{modules}->{$_}->{engine} }
90 @{$unified_info{modules}})
93 join(" ", map { quotify1(platform->bin($_)) }
94 grep { !$unified_info{attributes}->{programs}->{$_}->{noinst} }
95 @{$unified_info{programs}})
97 INSTALL_PROGRAMPDBS={-
98 join(" ", map { quotify1(platform->binpdb($_)) }
99 grep { !$unified_info{attributes}->{programs}->{$_}->{noinst} }
100 @{$unified_info{programs}})
103 join(" ", map { quotify1($_) }
104 grep { !$unified_info{attributes}->{scripts}->{$_}->{noinst}
105 && !$unified_info{attributes}->{scripts}->{$_}->{misc} }
106 @{$unified_info{scripts}})
109 join(" ", map { quotify1($_) }
110 grep { !$unified_info{attributes}->{scripts}->{$_}->{noinst}
111 && $unified_info{attributes}->{scripts}->{$_}->{misc} }
112 @{$unified_info{scripts}})
114 HTMLDOCS1={- join(" ", @{$unified_info{htmldocs}->{man1}}) -}
115 HTMLDOCS3={- join(" ", @{$unified_info{htmldocs}->{man3}}) -}
116 HTMLDOCS5={- join(" ", @{$unified_info{htmldocs}->{man5}}) -}
117 HTMLDOCS7={- join(" ", @{$unified_info{htmldocs}->{man7}}) -}
119 APPS_OPENSSL={- use File::Spec::Functions;
120 "\"".catfile("apps","openssl")."\"" -}
122 # Do not edit these manually. Use Configure with --prefix or --openssldir
123 # to change this! Short explanation in the top comment in Configure
124 INSTALLTOP_dev={- # $prefix is used in the OPENSSLDIR perl snippet
126 use File::Spec::Functions qw(:DEFAULT splitpath);
127 our $prefix = canonpath($config{prefix}
128 || "$win_installroot\\OpenSSL");
129 our ($prefix_dev, $prefix_dir, $prefix_file) =
130 splitpath($prefix, 1);
132 INSTALLTOP_dir={- canonpath($prefix_dir) -}
134 # The logic here is that if no --openssldir was given,
135 # OPENSSLDIR will get the value "$win_commonroot\\SSL".
136 # If --openssldir was given and the value is an absolute
137 # path, OPENSSLDIR will get its value without change.
138 # If the value from --openssldir is a relative path,
139 # OPENSSLDIR will get $prefix with the --openssldir
140 # value appended as a subdirectory.
142 use File::Spec::Functions qw(:DEFAULT splitpath);
144 $config{openssldir} ?
145 (file_name_is_absolute($config{openssldir}) ?
146 canonpath($config{openssldir})
147 : catdir($prefix, $config{openssldir}))
148 : canonpath("$win_commonroot\\SSL");
149 our ($openssldir_dev, $openssldir_dir, $openssldir_file) =
150 splitpath($openssldir, 1);
152 OPENSSLDIR_dir={- canonpath($openssldir_dir) -}
153 LIBDIR={- our $libdir = $config{libdir} || "lib";
154 file_name_is_absolute($libdir) ? "" : $libdir -}
155 MODULESDIR_dev={- use File::Spec::Functions qw(:DEFAULT splitpath catpath);
156 our $modulesprefix = catdir($prefix,$libdir);
157 our ($modulesprefix_dev, $modulesprefix_dir,
158 $modulesprefix_file) =
159 splitpath($modulesprefix, 1);
160 our $modulesdir_dev = $modulesprefix_dev;
161 our $modulesdir_dir =
162 catdir($modulesprefix_dir, "ossl-modules");
163 our $modulesdir = catpath($modulesdir_dev, $modulesdir_dir);
164 our $enginesdir_dev = $modulesprefix_dev;
165 our $enginesdir_dir =
166 catdir($modulesprefix_dir, "engines-$sover_dirname");
167 our $enginesdir = catpath($enginesdir_dev, $enginesdir_dir);
169 MODULESDIR_dir={- canonpath($modulesdir_dir) -}
170 ENGINESDIR_dev={- $enginesdir_dev -}
171 ENGINESDIR_dir={- canonpath($enginesdir_dir) -}
172 !IF "$(DESTDIR)" != ""
173 INSTALLTOP=$(DESTDIR)$(INSTALLTOP_dir)
174 OPENSSLDIR=$(DESTDIR)$(OPENSSLDIR_dir)
175 ENGINESDIR=$(DESTDIR)$(ENGINESDIR_dir)
176 MODULESDIR=$(DESTDIR)$(MODULESDIR_dir)
178 INSTALLTOP=$(INSTALLTOP_dev)$(INSTALLTOP_dir)
179 OPENSSLDIR=$(OPENSSLDIR_dev)$(OPENSSLDIR_dir)
180 ENGINESDIR=$(ENGINESDIR_dev)$(ENGINESDIR_dir)
181 MODULESDIR=$(MODULESDIR_dev)$(MODULESDIR_dir)
184 # $(libdir) is chosen to be compatible with the GNU coding standards
185 libdir={- file_name_is_absolute($libdir)
186 ? $libdir : '$(INSTALLTOP)\$(LIBDIR)' -}
188 ##### User defined commands and flags ################################
191 CPP={- $config{CPP} -}
192 CPPFLAGS={- our $cppflags1 = join(" ",
193 (map { "-D".$_} @{$config{CPPDEFINES}}),
194 (map { " -I ".$_} @{$config{CPPINCLUDES}}),
195 @{$config{CPPFLAGS}}) -}
196 CFLAGS={- join(' ', @{$config{CFLAGS}}) -}
198 LDFLAGS={- join(' ', @{$config{LDFLAGS}}) -}
199 EX_LIBS={- join(' ', @{$config{LDLIBS}}) -}
201 PERL={- $config{PERL} -}
204 ARFLAGS= {- join(' ', @{$config{ARFLAGS}}) -}
207 MTFLAGS= {- join(' ', @{$config{MTFLAGS}}) -}
210 ASFLAGS={- join(' ', @{$config{ASFLAGS}}) -}
213 RCFLAGS={- join(' ', @{$config{RCFLAGS}}) -}
215 ECHO="$(PERL)" "$(SRCDIR)\util\echo.pl"
217 ##### Special command flags ##########################################
219 COUTFLAG={- $target{coutflag} -}$(OSSL_EMPTY)
220 LDOUTFLAG={- $target{ldoutflag} -}$(OSSL_EMPTY)
221 AROUTFLAG={- $target{aroutflag} -}$(OSSL_EMPTY)
222 MTINFLAG={- $target{mtinflag} -}$(OSSL_EMPTY)
223 MTOUTFLAG={- $target{mtoutflag} -}$(OSSL_EMPTY)
224 ASOUTFLAG={- $target{asoutflag} -}$(OSSL_EMPTY)
225 RCOUTFLAG={- $target{rcoutflag} -}$(OSSL_EMPTY)
227 ##### Project flags ##################################################
229 # Variables starting with CNF_ are common variables for all product types
231 CNF_ASFLAGS={- join(' ', $target{asflags} || (),
232 @{$config{asflags}}) -}
233 CNF_CPPFLAGS={- our $cppfags2 =
234 join(' ', $target{cppflags} || (),
235 (map { '-D'.quotify1($_) } @{$target{defines}},
236 @{$config{defines}}),
237 (map { '-I'.quotify1($_) } @{$target{includes}},
238 @{$config{includes}}),
239 @{$config{cppflags}}) -}
240 CNF_CFLAGS={- join(' ', $target{cflags} || (),
241 @{$config{cflags}}) -}
242 CNF_CXXFLAGS={- join(' ', $target{cxxflags} || (),
243 @{$config{cxxflags}}) -}
244 CNF_LDFLAGS={- join(' ', $target{lflags} || (),
245 @{$config{lflags}}) -}
246 CNF_EX_LIBS={- join(' ', $target{ex_libs} || (),
247 @{$config{ex_libs}}) -}
249 # Variables starting with LIB_ are used to build library object files
250 # and shared libraries.
251 # Variables starting with DSO_ are used to build DSOs and their object files.
252 # Variables starting with BIN_ are used to build programs and their object
255 LIB_ASFLAGS={- join(' ', $target{lib_asflags} || (),
256 @{$config{lib_asflags}},
257 '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
258 LIB_CPPFLAGS={- our $lib_cppflags =
259 join(' ', $target{lib_cppflags} || (),
260 $target{shared_cppflag} || (),
261 (map { '-D'.quotify1($_) }
262 @{$target{lib_defines}},
263 @{$target{shared_defines}},
264 @{$config{lib_defines}},
265 @{$config{shared_defines}}),
266 (map { '-I'.quotify1($_) }
267 @{$target{lib_includes}},
268 @{$target{shared_includes}},
269 @{$config{lib_includes}},
270 @{$config{shared_includes}}),
271 @{$config{lib_cppflags}},
272 @{$config{shared_cppflag}});
273 join(' ', $lib_cppflags,
274 (map { '-D'.quotify1($_) }
275 "OPENSSLDIR=\"$openssldir\"",
276 "ENGINESDIR=\"$enginesdir\"",
277 "MODULESDIR=\"$modulesdir\""),
278 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
279 LIB_CFLAGS={- join(' ', $target{lib_cflags} || (),
280 $target{shared_cflag} || (),
281 @{$config{lib_cflags}},
282 @{$config{shared_cflag}},
283 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
284 LIB_LDFLAGS={- join(' ', $target{shared_ldflag} || (),
285 $config{shared_ldflag} || (),
286 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
287 LIB_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
288 DSO_ASFLAGS={- join(' ', $target{dso_asflags} || (),
289 $target{module_asflags} || (),
290 @{$config{dso_asflags}},
291 @{$config{module_asflags}},
292 '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
293 DSO_CPPFLAGS={- join(' ', $target{dso_cppflags} || (),
294 $target{module_cppflag} || (),
295 (map { '-D'.quotify1($_) }
296 @{$target{dso_defines}},
297 @{$target{module_defines}},
298 @{$config{dso_defines}},
299 @{$config{module_defines}}),
300 (map { '-I'.quotify1($_) }
301 @{$target{dso_includes}},
302 @{$target{module_includes}},
303 @{$config{dso_includes}},
304 @{$config{module_includes}}),
305 @{$config{dso_cppflags}},
306 @{$config{module_cppflags}},
307 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
308 DSO_CFLAGS={- join(' ', $target{dso_cflags} || (),
309 $target{module_cflags} || (),
310 @{$config{dso_cflags}},
311 @{$config{module_cflags}},
312 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
313 DSO_LDFLAGS={- join(' ', $target{dso_lflags} || (),
314 $target{module_ldflags} || (),
315 @{$config{dso_lflags}},
316 @{$config{module_ldflags}},
317 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
318 DSO_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
319 BIN_ASFLAGS={- join(' ', $target{bin_asflags} || (),
320 @{$config{bin_asflags}},
321 '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
322 BIN_CPPFLAGS={- join(' ', $target{bin_cppflags} || (),
323 @{$config{bin_cppflags}},
324 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
325 BIN_CFLAGS={- join(' ', $target{bin_cflags} || (),
326 @{$config{bin_cflags}},
327 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
328 BIN_LDFLAGS={- join(' ', $target{bin_lflags} || (),
329 @{$config{bin_lflags}},
330 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
331 BIN_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
333 # CPPFLAGS_Q is used for one thing only: to build up buildinf.h
334 CPPFLAGS_Q={- $cppflags1 =~ s|([\\"])|\\$1|g;
335 $cppflags2 =~ s|([\\"])|\\$1|g;
336 join(' ', $lib_cppflags || (), $cppflags2 || (),
339 PERLASM_SCHEME= {- $target{perlasm_scheme} -}
341 PROCESSOR= {- $config{processor} -}
343 # The main targets ###################################################
345 {- dependmagic('build_sw'); -}: build_libs_nodep build_modules_nodep build_programs_nodep
346 {- dependmagic('build_libs'); -}: build_libs_nodep
347 {- dependmagic('build_modules'); -}: build_modules_nodep
348 {- dependmagic('build_programs'); -}: build_programs_nodep
350 build_docs: build_html_docs
351 build_html_docs: $(HTMLDOCS1) $(HTMLDOCS3) $(HTMLDOCS5) $(HTMLDOCS7)
353 build_generated: $(GENERATED_MANDATORY)
354 build_libs_nodep: $(LIBS) {- join(" ",map { platform->sharedlib_import($_) // () } @{$unified_info{libraries}}) -}
355 build_modules_nodep: $(MODULES)
356 build_programs_nodep: $(PROGRAMS) $(SCRIPTS)
358 # Kept around for backward compatibility
359 build_apps build_tests: build_programs
361 # Convenience target to prebuild all generated files, not just the mandatory
363 build_all_generated: $(GENERATED_MANDATORY) $(GENERATED) build_docs
364 @{- output_off() if $disabled{makedepend}; "" -}
365 @$(ECHO) "Warning: consider configuring with no-makedepend, because if"
366 @$(ECHO) " target system doesn't have $(PERL),"
367 @$(ECHO) " then make will fail..."
368 @{- output_on() if $disabled{makedepend}; "" -}
370 all: build_sw build_docs
373 {- dependmagic('tests'); -}: build_programs_nodep build_modules_nodep
374 @{- output_off() if $disabled{tests}; "" -}
375 -mkdir $(BLDDIR)\test\test-runs
378 set RESULT_D=$(BLDDIR)\test\test-runs
380 set OPENSSL_ENGINES=$(MAKEDIR)\engines
381 set OPENSSL_MODULES=$(MAKEDIR)\providers
382 set OPENSSL_DEBUG_MEMORY=on
383 "$(PERL)" "$(SRCDIR)\test\run_tests.pl" $(TESTS)
384 @{- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
385 @$(ECHO) "Tests are not supported with your chosen Configure options"
386 @{- output_on() if !$disabled{tests}; "" -}
389 @{- output_off() if $disabled{tests}; "" -}
390 @set SRCTOP=$(SRCDIR)
391 @"$(PERL)" "$(SRCDIR)\test\run_tests.pl" list
392 @{- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
393 @$(ECHO) "Tests are not supported with your chosen Configure options"
394 @{- output_on() if !$disabled{tests}; "" -}
396 install: install_sw install_ssldirs install_docs
398 uninstall: uninstall_docs uninstall_sw
401 "$(PERL)" -e "map { m/(.*)\.dll$$/; unlink glob """{.,apps,test,fuzz}/$$1.*"""; } @ARGV" $(SHLIBS)
402 -del /Q /F $(LIBS) libcrypto.* libssl.* ossl_static.pdb
405 -rmdir /Q /S $(HTMLDOCS1)
406 -rmdir /Q /S $(HTMLDOCS3)
407 -rmdir /Q /S $(HTMLDOCS5)
408 -rmdir /Q /S $(HTMLDOCS7)
409 {- join("\n\t", map { "-del /Q /F $_" } @PROGRAMS) -}
410 -del /Q /F $(MODULES)
411 -del /Q /F $(SCRIPTS)
412 -del /Q /F $(GENERATED_MANDATORY)
413 -del /Q /F $(GENERATED)
414 -del /Q /S /F *.d *.obj *.pdb *.ilk *.manifest
415 -del /Q /S /F engines\*.lib engines\*.exp
416 -del /Q /S /F apps\*.lib apps\*.rc apps\*.res apps\*.exp
417 -del /Q /S /F test\*.exp
418 -rmdir /Q /S test\test-runs
421 -del /Q /F configdata.pm
425 @ {- output_off() if $disabled{makedepend}; "" -}
426 @ "$(PERL)" "$(SRCDIR)\util\add-depends.pl" "VC"
427 @ {- output_on() if $disabled{makedepend}; "" -}
429 # Install helper targets #############################################
431 install_sw: install_dev install_engines install_runtime
433 uninstall_sw: uninstall_runtime uninstall_engines uninstall_dev
435 install_docs: install_html_docs
437 uninstall_docs: uninstall_html_docs
440 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\certs"
441 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\private"
442 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\misc"
443 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\openssl.cnf" \
444 "$(OPENSSLDIR)\openssl.cnf.dist"
445 @IF NOT EXIST "$(OPENSSLDIR)\openssl.cnf" \
446 "$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\openssl.cnf" \
447 "$(OPENSSLDIR)\openssl.cnf"
448 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(MISC_SCRIPTS) \
450 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\ct_log_list.cnf" \
451 "$(OPENSSLDIR)\ct_log_list.cnf.dist"
452 @IF NOT EXIST "$(OPENSSLDIR)\ct_log_list.cnf" \
453 "$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\ct_log_list.cnf" \
454 "$(OPENSSLDIR)\ct_log_list.cnf"
456 install_dev: install_runtime_libs
457 @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
458 @$(ECHO) "*** Installing development files"
459 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\include\openssl"
460 @{- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
461 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\ms\applink.c" \
462 "$(INSTALLTOP)\include\openssl"
463 @{- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
464 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "-exclude_re=/__DECC_" \
465 "$(SRCDIR)\include\openssl\*.h" \
466 "$(INSTALLTOP)\include\openssl"
467 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(BLDDIR)\include\openssl\*.h" \
468 "$(INSTALLTOP)\include\openssl"
469 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(libdir)"
470 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_LIBS) "$(libdir)"
471 @if "$(SHLIBS)"=="" \
472 "$(PERL)" "$(SRCDIR)\util\copy.pl" ossl_static.pdb "$(libdir)"
476 install_engines: install_runtime_libs build_modules
477 @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
478 @$(ECHO) "*** Installing ENGINE modules"
479 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(ENGINESDIR)"
480 @if not "$(INSTALL_ENGINES)"=="" \
481 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINES) "$(ENGINESDIR)"
482 @if not "$(INSTALL_ENGINES)"=="" \
483 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINEPDBS) "$(ENGINESDIR)"
487 install_runtime: install_programs
489 install_runtime_libs: build_libs
490 @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
491 @$(ECHO) "*** Installing runtime libraries"
492 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\bin"
493 @if not "$(SHLIBS)"=="" \
494 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_SHLIBS) "$(INSTALLTOP)\bin"
495 @if not "$(SHLIBS)"=="" \
496 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_SHLIBPDBS) \
499 install_programs: install_runtime_libs build_programs
500 @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
501 @$(ECHO) "*** Installing runtime programs"
502 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\bin"
503 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMS) \
505 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMPDBS) \
507 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BIN_SCRIPTS) \
512 install_html_docs: build_html_docs
513 @if "$(INSTALLTOP)"=="" ( echo INSTALLTOP should not be empty & exit 1 )
514 @echo *** Installing HTML docs
515 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\html\man1"
516 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\html\man3"
517 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\html\man5"
518 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\html\man7"
519 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BLDDIR)\doc\html\man1\*.html \
520 "$(INSTALLTOP)\html\man1"
521 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BLDDIR)\doc\html\man3\*.html \
522 "$(INSTALLTOP)\html\man3"
523 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BLDDIR)\doc\html\man5\*.html \
524 "$(INSTALLTOP)\html\man5"
525 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BLDDIR)\doc\html\man7\*.html \
526 "$(INSTALLTOP)\html\man7"
530 # Building targets ###################################################
532 configdata.pm: "$(SRCDIR)\Configure" {- join(" ", map { '"'.$_.'"' } @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
533 @$(ECHO) "Detected changed: $?"
534 "$(PERL)" configdata.pm -r
535 @$(ECHO) "**************************************************"
537 @$(ECHO) "*** Please run the same make command again ***"
539 @$(ECHO) "**************************************************"
543 "$(PERL)" configdata.pm -r
547 use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
549 # Helper function to figure out dependencies on libraries
550 # It takes a list of library names and outputs a list of dependencies
551 sub compute_lib_depends {
552 if ($disabled{shared}) {
553 return map { platform->staticlib($_) } @_;
555 return map { platform->sharedlib_import($_) // platform->staticlib($_) } @_;
560 my ($gen0, @gens) = @{$args{generator}};
561 my $generator = '"'.$gen0.'"'.join('', map { " $_" } @gens);
562 my $generator_incs = join("", map { " -I \"$_\"" } @{$args{generator_incs}});
563 my $incs = join("", map { " -I \"$_\"" } @{$args{incs}});
564 my $defs = join("", map { " -D".$_ } @{$args{defs}});
565 my $deps = @{$args{deps}} ?
566 '"'.join('" "', @{$args{generator_deps}}, @{$args{deps}}).'"' : '';
568 if ($args{src} =~ /\.html$/) {
569 my $title = basename($args{src}, ".html");
571 $args{src}: $args{generator}->[0]
572 pod2html "--podroot=\$(SRCDIR)/doc" --htmldir=.. \\
573 --podpath=man1:man3:man5:man7 "--infile=\$<" "--title=$title" \\
574 | \$(PERL) -pe "s|href=\\"http://man\\.he\\.net/(man\d/[^\\"]+)(?:\\.html)?\\"|href=\\"../\$1.html|g;" \\
577 } elsif (platform->isdef($args{src})) {
578 my $target = platform->def($args{src});
579 my $mkdef = abs2rel(rel2abs(catfile($config{sourcedir},
580 "util", "mkdef.pl")),
581 rel2abs($config{builddir}));
582 my $ord_ver = $args{intent} eq 'lib' ? ' --version $(VERSION)' : '';
584 $args{generator}->[1] || platform->dsoname($args{product});
586 $target: $args{generator}->[0] $deps $mkdef
587 "\$(PERL)" $mkdef$ord_ver --ordinals $args{generator}->[0] --name $ord_name --OS windows > $target
589 } elsif (!platform->isasm($args{src})) {
590 my $target = $args{src};
591 if ($args{generator}->[0] =~ m|^.*\.in$|) {
592 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
593 "util", "dofile.pl")),
594 rel2abs($config{builddir}));
595 my @modules = ( 'configdata.pm',
596 grep { $_ =~ m|\.pm$| } @{$args{deps}} );
597 my %moduleincs = map { '"-I'.dirname($_).'"' => 1 } @modules;
598 @modules = map { "-M".basename($_, '.pm') } @modules;
599 my $modules = join(' ', '', sort keys %moduleincs, @modules);
601 $target: "$args{generator}->[0]" $deps
602 "\$(PERL)"$modules "$dofile" "-o$target{build_file}" $generator > \$@
606 $target: "$args{generator}->[0]" $deps
607 "\$(PERL)"$generator_incs $generator > \$@
612 shlib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
613 lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
614 dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)',
615 bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
616 } -> {$args{intent}};
617 my $target = platform->asm($args{src});
619 if ($args{generator}->[0] =~ /\.pl$/) {
620 $generator = '"$(PERL)"'.$generator_incs.' '.$generator
621 .' "$(PERLASM_SCHEME)"'.$incs.' '.$cppflags.$defs.' $(PROCESSSOR)';
622 } elsif ($args{generator}->[0] =~ /\.S$/) {
625 die "Generator type for $src unknown: $generator\n";
628 if (defined($generator)) {
629 # If the target is named foo.S in build.info, we want to
630 # end up generating foo.s in two steps.
631 if ($args{src} =~ /\.S$/) {
633 $target: "$args{generator}->[0]" $deps
636 \$(CPP) $incs $cppflags $defs \$@.S > \$@.i && move /Y \$@.i \$@
642 $target: "$args{generator}->[0]" $deps
648 $target: "$args{generator}->[0]" $deps
649 \$(CPP) $incs $cppflags $defs "$args{generator}->[0]" > \$@.i && move /Y \$@.i \$@
655 my $asmext = platform->asmext();
659 (platform->isasm($x) && grep { $x eq $_ } @generated)
660 ? platform->asm($x) : $x }
662 my $srcs = '"'.join('" "', @srcs).'"';
663 my $deps = '"'.join('" "', @srcs, @{$args{deps}}).'"';
664 my $incs = join("", map { ' -I "'.$_.'"' } @{$args{incs}});
665 my $defs = join("", map { " -D".$_ } @{$args{defs}});
666 my $cflags = { shlib => ' $(LIB_CFLAGS)',
667 lib => ' $(LIB_CFLAGS)',
668 dso => ' $(DSO_CFLAGS)',
669 bin => ' $(BIN_CFLAGS)' } -> {$args{intent}};
671 $cflags .= { shlib => ' $(LIB_CPPFLAGS)',
672 lib => ' $(LIB_CPPFLAGS)',
673 dso => ' $(DSO_CPPFLAGS)',
674 bin => ' $(BIN_CPPFLAGS)' } -> {$args{intent}};
675 my $asflags = { shlib => ' $(LIB_ASFLAGS)',
676 lib => ' $(LIB_ASFLAGS)',
677 dso => ' $(DSO_ASFLAGS)',
678 bin => ' $(BIN_ASFLAGS)' } -> {$args{intent}};
679 my $makedepprog = $config{makedepprog};
680 if ($srcs[0] =~ /\.rc$/) {
681 my $res = platform->res($args{obj});
684 \$(RC) \$(RCFLAGS) \$(RCOUTFLAG)\$\@ $srcs
687 my $obj = platform->obj($args{obj});
688 my $dep = platform->dep($args{obj});
689 if ($srcs[0] =~ /\Q${asmext}\E$/) {
692 \$(AS) $asflags \$(ASOUTFLAG)\$\@ $srcs
694 } elsif ($srcs[0] =~ /.S$/) {
697 \$(CC) /EP -D__ASSEMBLER__ $cflags $defs $srcs > \$@.asm && \$(AS) $asflags \$(ASOUTFLAG)\$\@ \$@.asm
700 my $recipe = <<"EOF";
702 \$(CC) $cflags $defs -c \$(COUTFLAG)\$\@ $srcs
704 $recipe .= <<"EOF" unless $disabled{makedepend};
705 \$(CC) $cflags $defs /Zs /showIncludes $srcs 2>&1 > $dep
710 # We *know* this routine is only called when we've configure 'shared'.
711 # Also, note that even though the import library built here looks like
712 # a static library, it really isn't.
715 my $lib = $args{lib};
716 my @objs = map { platform->convertext($_) }
717 grep { platform->isobj($_) || platform->isres($_) }
719 my @defs = map { platform->def($_) }
720 grep { platform->isdef($_) }
722 my @deps = compute_lib_depends(@{$args{deps}});
723 die "More than one exported symbols list" if scalar @defs > 1;
724 my $linklibs = join("", map { "$_\n" } @deps);
725 my $objs = join("\n", @objs);
726 my $deps = join(" ", @objs, @defs, @deps);
727 my $import = platform->sharedlib_import($lib);
728 my $dll = platform->sharedlib($lib);
729 my $shared_def = join("", map { " /def:$_" } @defs);
731 # The import library may look like a static library, but it is not.
732 # We MUST make the import library depend on the DLL, in case someone
733 # mistakenly removes the latter.
736 IF EXIST $full.manifest DEL /F /Q $full.manifest
737 IF EXIST \$@ DEL /F /Q \$@
738 \$(LD) \$(LDFLAGS) \$(LIB_LDFLAGS) \\
739 /implib:$import \$(LDOUTFLAG)$dll$shared_def @<< || (DEL /Q \$(\@B).* $import && EXIT 1)
741 $linklibs\$(LIB_EX_LIBS)
743 IF EXIST $dll.manifest \\
744 \$(MT) \$(MTFLAGS) \$(MTINFLAG)$dll.manifest \$(MTOUTFLAG)$dll
745 IF EXIST apps\\$dll DEL /Q /F apps\\$dll
746 IF EXIST test\\$dll DEL /Q /F test\\$dll
747 IF EXIST fuzz\\$dll DEL /Q /F fuzz\\$dll
755 my $dso = platform->dso($args{module});
756 my $dso_n = platform->dsoname($args{module});
757 my @objs = map { platform->convertext($_) }
758 grep { platform->isobj($_) || platform->isres($_) }
760 my @defs = map { platform->def($_) }
761 grep { platform->isdef($_) }
763 my @deps = compute_lib_depends(@{$args{deps}});
764 my $objs = join("\n", @objs);
765 my $linklibs = join("", map { "$_\n" } @deps);
766 my $deps = join(" ", @objs, @defs, @deps);
767 my $shared_def = join("", map { " /def:$_" } @defs);
770 IF EXIST $dso.manifest DEL /F /Q $dso.manifest
771 \$(LD) \$(LDFLAGS) \$(DSO_LDFLAGS) \\
772 \$(LDOUTFLAG)$dso$shared_def @<< || (DEL /Q \$(\@B).* $dso_n.* && EXIT 1)
774 $linklibs \$(DSO_EX_LIBS)
776 IF EXIST $dso.manifest \\
777 \$(MT) \$(MTFLAGS) \$(MTINFLAG)$dso.manifest \$(MTOUTFLAG)$dso
782 my $lib = platform->staticlib($args{lib});
783 my @objs = map { platform->obj($_) } @{$args{objs}};
784 my $objs = join("\n", @objs);
785 my $deps = join(" ", @objs);
788 \$(AR) \$(ARFLAGS) \$(AROUTFLAG)$lib @<<
795 my $bin = platform->bin($args{bin});
796 my @objs = map { platform->convertext($_) }
797 grep { platform->isobj($_) || platform->isres($_) }
799 my @deps = compute_lib_depends(@{$args{deps}});
800 my $objs = join("\n", @objs);
801 my $linklibs = join("", map { "$_\n" } @deps);
802 my $deps = join(" ", @objs, @deps);
805 IF EXIST $bin.manifest DEL /F /Q $bin.manifest
806 \$(LD) \$(LDFLAGS) \$(BIN_LDFLAGS) \$(LDOUTFLAG)$bin @<<
809 $linklibs\$(BIN_EX_LIBS)
811 IF EXIST $bin.manifest \\
812 \$(MT) \$(MTFLAGS) \$(MTINFLAG)$bin.manifest \$(MTOUTFLAG)$bin
817 my $script = $args{script};
818 my $sources = '"'.join('" "', @{$args{sources}}).'"';
819 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
820 "util", "dofile.pl")),
821 rel2abs($config{builddir}));
824 "\$(PERL)" "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
825 "-o$target{build_file}" $sources > "$script"
830 my $dir = $args{dir};
831 my @deps = map { platform->convertext($_) } @{$args{deps}};
833 my %extinfo = ( dso => platform->dsoext(),
834 lib => platform->libext(),
835 bin => platform->binext() );
837 # We already have a 'test' target, and the top directory is just plain
839 return if $dir eq "test" || $dir eq ".";
841 foreach my $type (("dso", "lib", "bin", "script")) {
842 next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type});
843 # For lib object files, we could update the library. However,
844 # LIB on Windows doesn't work that way, so we won't create any
845 # actions for it, and the dependencies are already taken care of.
846 if ($type ne "lib") {
847 foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) {
848 if (dirname($prod) eq $dir) {
849 push @deps, $prod.$extinfo{$type};
855 my $deps = join(" ", @deps);
856 my $actions = join("\n", "", @actions);
858 $dir $dir\\ : $deps$actions
861 "" # Important! This becomes part of the template result.