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 "$(PERL)" "$(SRCDIR)\test\run_tests.pl" $(TESTS)
383 @{- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
384 @$(ECHO) "Tests are not supported with your chosen Configure options"
385 @{- output_on() if !$disabled{tests}; "" -}
388 @{- output_off() if $disabled{tests}; "" -}
389 @set SRCTOP=$(SRCDIR)
390 @"$(PERL)" "$(SRCDIR)\test\run_tests.pl" list
391 @{- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
392 @$(ECHO) "Tests are not supported with your chosen Configure options"
393 @{- output_on() if !$disabled{tests}; "" -}
395 install: install_sw install_ssldirs install_docs
397 uninstall: uninstall_docs uninstall_sw
400 "$(PERL)" -e "map { m/(.*)\.dll$$/; unlink glob """{.,apps,test,fuzz}/$$1.*"""; } @ARGV" $(SHLIBS)
401 -del /Q /F $(LIBS) libcrypto.* libssl.* ossl_static.pdb
404 -rmdir /Q /S $(HTMLDOCS1)
405 -rmdir /Q /S $(HTMLDOCS3)
406 -rmdir /Q /S $(HTMLDOCS5)
407 -rmdir /Q /S $(HTMLDOCS7)
408 {- join("\n\t", map { "-del /Q /F $_" } @PROGRAMS) -}
409 -del /Q /F $(MODULES)
410 -del /Q /F $(SCRIPTS)
411 -del /Q /F $(GENERATED_MANDATORY)
412 -del /Q /F $(GENERATED)
413 -del /Q /S /F *.d *.obj *.pdb *.ilk *.manifest
414 -del /Q /S /F engines\*.lib engines\*.exp
415 -del /Q /S /F apps\*.lib apps\*.rc apps\*.res apps\*.exp
416 -del /Q /S /F test\*.exp
417 -rmdir /Q /S test\test-runs
420 -del /Q /F configdata.pm
424 @ {- output_off() if $disabled{makedepend}; "" -}
425 @ "$(PERL)" "$(SRCDIR)\util\add-depends.pl" "VC"
426 @ {- output_on() if $disabled{makedepend}; "" -}
428 # Install helper targets #############################################
430 install_sw: install_dev install_engines install_runtime
432 uninstall_sw: uninstall_runtime uninstall_engines uninstall_dev
434 install_docs: install_html_docs
436 uninstall_docs: uninstall_html_docs
439 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\certs"
440 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\private"
441 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\misc"
442 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\openssl.cnf" \
443 "$(OPENSSLDIR)\openssl.cnf.dist"
444 @IF NOT EXIST "$(OPENSSLDIR)\openssl.cnf" \
445 "$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\openssl.cnf" \
446 "$(OPENSSLDIR)\openssl.cnf"
447 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(MISC_SCRIPTS) \
449 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\ct_log_list.cnf" \
450 "$(OPENSSLDIR)\ct_log_list.cnf.dist"
451 @IF NOT EXIST "$(OPENSSLDIR)\ct_log_list.cnf" \
452 "$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\ct_log_list.cnf" \
453 "$(OPENSSLDIR)\ct_log_list.cnf"
455 install_dev: install_runtime_libs
456 @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
457 @$(ECHO) "*** Installing development files"
458 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\include\openssl"
459 @{- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
460 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\ms\applink.c" \
461 "$(INSTALLTOP)\include\openssl"
462 @{- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
463 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "-exclude_re=/__DECC_" \
464 "$(SRCDIR)\include\openssl\*.h" \
465 "$(INSTALLTOP)\include\openssl"
466 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(BLDDIR)\include\openssl\*.h" \
467 "$(INSTALLTOP)\include\openssl"
468 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(libdir)"
469 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_LIBS) "$(libdir)"
470 @if "$(SHLIBS)"=="" \
471 "$(PERL)" "$(SRCDIR)\util\copy.pl" ossl_static.pdb "$(libdir)"
475 install_engines: install_runtime_libs build_modules
476 @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
477 @$(ECHO) "*** Installing ENGINE modules"
478 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(ENGINESDIR)"
479 @if not "$(INSTALL_ENGINES)"=="" \
480 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINES) "$(ENGINESDIR)"
481 @if not "$(INSTALL_ENGINES)"=="" \
482 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINEPDBS) "$(ENGINESDIR)"
486 install_runtime: install_programs
488 install_runtime_libs: build_libs
489 @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
490 @$(ECHO) "*** Installing runtime libraries"
491 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\bin"
492 @if not "$(SHLIBS)"=="" \
493 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_SHLIBS) "$(INSTALLTOP)\bin"
494 @if not "$(SHLIBS)"=="" \
495 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_SHLIBPDBS) \
498 install_programs: install_runtime_libs build_programs
499 @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
500 @$(ECHO) "*** Installing runtime programs"
501 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\bin"
502 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMS) \
504 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMPDBS) \
506 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BIN_SCRIPTS) \
511 install_html_docs: build_html_docs
512 @if "$(INSTALLTOP)"=="" ( echo INSTALLTOP should not be empty & exit 1 )
513 @echo *** Installing HTML docs
514 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\html\man1"
515 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\html\man3"
516 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\html\man5"
517 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\html\man7"
518 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BLDDIR)\doc\html\man1\*.html \
519 "$(INSTALLTOP)\html\man1"
520 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BLDDIR)\doc\html\man3\*.html \
521 "$(INSTALLTOP)\html\man3"
522 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BLDDIR)\doc\html\man5\*.html \
523 "$(INSTALLTOP)\html\man5"
524 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BLDDIR)\doc\html\man7\*.html \
525 "$(INSTALLTOP)\html\man7"
529 # Building targets ###################################################
531 configdata.pm: "$(SRCDIR)\Configure" {- join(" ", map { '"'.$_.'"' } @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
532 @$(ECHO) "Detected changed: $?"
533 "$(PERL)" configdata.pm -r
534 @$(ECHO) "**************************************************"
536 @$(ECHO) "*** Please run the same make command again ***"
538 @$(ECHO) "**************************************************"
542 "$(PERL)" configdata.pm -r
546 use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
548 # Helper function to figure out dependencies on libraries
549 # It takes a list of library names and outputs a list of dependencies
550 sub compute_lib_depends {
551 if ($disabled{shared}) {
552 return map { platform->staticlib($_) } @_;
554 return map { platform->sharedlib_import($_) // platform->staticlib($_) } @_;
559 my ($gen0, @gens) = @{$args{generator}};
560 my $generator = '"'.$gen0.'"'.join('', map { " $_" } @gens);
561 my $generator_incs = join("", map { " -I \"$_\"" } @{$args{generator_incs}});
562 my $incs = join("", map { " -I \"$_\"" } @{$args{incs}});
563 my $defs = join("", map { " -D".$_ } @{$args{defs}});
564 my $deps = @{$args{deps}} ?
565 '"'.join('" "', @{$args{generator_deps}}, @{$args{deps}}).'"' : '';
567 if ($args{src} =~ /\.html$/) {
568 my $title = basename($args{src}, ".html");
570 $args{src}: $args{generator}->[0]
571 pod2html "--podroot=\$(SRCDIR)/doc" --htmldir=.. \\
572 --podpath=man1:man3:man5:man7 "--infile=\$<" "--title=$title" \\
573 | \$(PERL) -pe "s|href=\\"http://man\\.he\\.net/(man\d/[^\\"]+)(?:\\.html)?\\"|href=\\"../\$1.html|g;" \\
576 } elsif (platform->isdef($args{src})) {
577 my $target = platform->def($args{src});
578 my $mkdef = abs2rel(rel2abs(catfile($config{sourcedir},
579 "util", "mkdef.pl")),
580 rel2abs($config{builddir}));
581 my $ord_ver = $args{intent} eq 'lib' ? ' --version $(VERSION)' : '';
583 $args{generator}->[1] || platform->dsoname($args{product});
585 $target: $args{generator}->[0] $deps $mkdef
586 "\$(PERL)" $mkdef$ord_ver --ordinals $args{generator}->[0] --name $ord_name --OS windows > $target
588 } elsif (!platform->isasm($args{src})) {
589 my $target = $args{src};
590 if ($args{generator}->[0] =~ m|^.*\.in$|) {
591 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
592 "util", "dofile.pl")),
593 rel2abs($config{builddir}));
594 my @modules = ( 'configdata.pm',
595 grep { $_ =~ m|\.pm$| } @{$args{deps}} );
596 my %moduleincs = map { '"-I'.dirname($_).'"' => 1 } @modules;
597 @modules = map { "-M".basename($_, '.pm') } @modules;
598 my $modules = join(' ', '', sort keys %moduleincs, @modules);
600 $target: "$args{generator}->[0]" $deps
601 "\$(PERL)"$modules "$dofile" "-o$target{build_file}" $generator > \$@
605 $target: "$args{generator}->[0]" $deps
606 "\$(PERL)"$generator_incs $generator > \$@
611 shlib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
612 lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
613 dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)',
614 bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
615 } -> {$args{intent}};
616 my $target = platform->asm($args{src});
618 if ($args{generator}->[0] =~ /\.pl$/) {
619 $generator = '"$(PERL)"'.$generator_incs.' '.$generator
620 .' "$(PERLASM_SCHEME)"'.$incs.' '.$cppflags.$defs.' $(PROCESSSOR)';
621 } elsif ($args{generator}->[0] =~ /\.S$/) {
624 die "Generator type for $src unknown: $generator\n";
627 if (defined($generator)) {
628 # If the target is named foo.S in build.info, we want to
629 # end up generating foo.s in two steps.
630 if ($args{src} =~ /\.S$/) {
632 $target: "$args{generator}->[0]" $deps
635 \$(CPP) $incs $cppflags $defs \$@.S > \$@.i && move /Y \$@.i \$@
641 $target: "$args{generator}->[0]" $deps
647 $target: "$args{generator}->[0]" $deps
648 \$(CPP) $incs $cppflags $defs "$args{generator}->[0]" > \$@.i && move /Y \$@.i \$@
654 my $asmext = platform->asmext();
658 (platform->isasm($x) && grep { $x eq $_ } @generated)
659 ? platform->asm($x) : $x }
661 my $srcs = '"'.join('" "', @srcs).'"';
662 my $deps = '"'.join('" "', @srcs, @{$args{deps}}).'"';
663 my $incs = join("", map { ' -I "'.$_.'"' } @{$args{incs}});
664 my $defs = join("", map { " -D".$_ } @{$args{defs}});
665 my $cflags = { shlib => ' $(LIB_CFLAGS)',
666 lib => ' $(LIB_CFLAGS)',
667 dso => ' $(DSO_CFLAGS)',
668 bin => ' $(BIN_CFLAGS)' } -> {$args{intent}};
670 $cflags .= { shlib => ' $(LIB_CPPFLAGS)',
671 lib => ' $(LIB_CPPFLAGS)',
672 dso => ' $(DSO_CPPFLAGS)',
673 bin => ' $(BIN_CPPFLAGS)' } -> {$args{intent}};
674 my $asflags = { shlib => ' $(LIB_ASFLAGS)',
675 lib => ' $(LIB_ASFLAGS)',
676 dso => ' $(DSO_ASFLAGS)',
677 bin => ' $(BIN_ASFLAGS)' } -> {$args{intent}};
678 my $makedepprog = $config{makedepprog};
679 if ($srcs[0] =~ /\.rc$/) {
680 my $res = platform->res($args{obj});
683 \$(RC) \$(RCFLAGS) \$(RCOUTFLAG)\$\@ $srcs
686 my $obj = platform->obj($args{obj});
687 my $dep = platform->dep($args{obj});
688 if ($srcs[0] =~ /\Q${asmext}\E$/) {
691 \$(AS) $asflags \$(ASOUTFLAG)\$\@ $srcs
693 } elsif ($srcs[0] =~ /.S$/) {
696 \$(CC) /EP -D__ASSEMBLER__ $cflags $defs $srcs > \$@.asm && \$(AS) $asflags \$(ASOUTFLAG)\$\@ \$@.asm
699 my $recipe = <<"EOF";
701 \$(CC) $cflags $defs -c \$(COUTFLAG)\$\@ $srcs
703 $recipe .= <<"EOF" unless $disabled{makedepend};
704 \$(CC) $cflags $defs /Zs /showIncludes $srcs 2>&1 > $dep
709 # We *know* this routine is only called when we've configure 'shared'.
710 # Also, note that even though the import library built here looks like
711 # a static library, it really isn't.
714 my $lib = $args{lib};
715 my @objs = map { platform->convertext($_) }
716 grep { platform->isobj($_) || platform->isres($_) }
718 my @defs = map { platform->def($_) }
719 grep { platform->isdef($_) }
721 my @deps = compute_lib_depends(@{$args{deps}});
722 die "More than one exported symbols list" if scalar @defs > 1;
723 my $linklibs = join("", map { "$_\n" } @deps);
724 my $objs = join("\n", @objs);
725 my $deps = join(" ", @objs, @defs, @deps);
726 my $import = platform->sharedlib_import($lib);
727 my $dll = platform->sharedlib($lib);
728 my $shared_def = join("", map { " /def:$_" } @defs);
730 # The import library may look like a static library, but it is not.
731 # We MUST make the import library depend on the DLL, in case someone
732 # mistakenly removes the latter.
735 IF EXIST $full.manifest DEL /F /Q $full.manifest
736 IF EXIST \$@ DEL /F /Q \$@
737 \$(LD) \$(LDFLAGS) \$(LIB_LDFLAGS) \\
738 /implib:$import \$(LDOUTFLAG)$dll$shared_def @<< || (DEL /Q \$(\@B).* $import && EXIT 1)
740 $linklibs\$(LIB_EX_LIBS)
742 IF EXIST $dll.manifest \\
743 \$(MT) \$(MTFLAGS) \$(MTINFLAG)$dll.manifest \$(MTOUTFLAG)$dll
744 IF EXIST apps\\$dll DEL /Q /F apps\\$dll
745 IF EXIST test\\$dll DEL /Q /F test\\$dll
746 IF EXIST fuzz\\$dll DEL /Q /F fuzz\\$dll
754 my $dso = platform->dso($args{module});
755 my $dso_n = platform->dsoname($args{module});
756 my @objs = map { platform->convertext($_) }
757 grep { platform->isobj($_) || platform->isres($_) }
759 my @defs = map { platform->def($_) }
760 grep { platform->isdef($_) }
762 my @deps = compute_lib_depends(@{$args{deps}});
763 my $objs = join("\n", @objs);
764 my $linklibs = join("", map { "$_\n" } @deps);
765 my $deps = join(" ", @objs, @defs, @deps);
766 my $shared_def = join("", map { " /def:$_" } @defs);
769 IF EXIST $dso.manifest DEL /F /Q $dso.manifest
770 \$(LD) \$(LDFLAGS) \$(DSO_LDFLAGS) \\
771 \$(LDOUTFLAG)$dso$shared_def @<< || (DEL /Q \$(\@B).* $dso_n.* && EXIT 1)
773 $linklibs \$(DSO_EX_LIBS)
775 IF EXIST $dso.manifest \\
776 \$(MT) \$(MTFLAGS) \$(MTINFLAG)$dso.manifest \$(MTOUTFLAG)$dso
781 my $lib = platform->staticlib($args{lib});
782 my @objs = map { platform->obj($_) } @{$args{objs}};
783 my $objs = join("\n", @objs);
784 my $deps = join(" ", @objs);
787 \$(AR) \$(ARFLAGS) \$(AROUTFLAG)$lib @<<
794 my $bin = platform->bin($args{bin});
795 my @objs = map { platform->convertext($_) }
796 grep { platform->isobj($_) || platform->isres($_) }
798 my @deps = compute_lib_depends(@{$args{deps}});
799 my $objs = join("\n", @objs);
800 my $linklibs = join("", map { "$_\n" } @deps);
801 my $deps = join(" ", @objs, @deps);
804 IF EXIST $bin.manifest DEL /F /Q $bin.manifest
805 \$(LD) \$(LDFLAGS) \$(BIN_LDFLAGS) \$(LDOUTFLAG)$bin @<<
808 $linklibs\$(BIN_EX_LIBS)
810 IF EXIST $bin.manifest \\
811 \$(MT) \$(MTFLAGS) \$(MTINFLAG)$bin.manifest \$(MTOUTFLAG)$bin
816 my $script = $args{script};
817 my $sources = '"'.join('" "', @{$args{sources}}).'"';
818 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
819 "util", "dofile.pl")),
820 rel2abs($config{builddir}));
823 "\$(PERL)" "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
824 "-o$target{build_file}" $sources > "$script"
829 my $dir = $args{dir};
830 my @deps = map { platform->convertext($_) } @{$args{deps}};
832 my %extinfo = ( dso => platform->dsoext(),
833 lib => platform->libext(),
834 bin => platform->binext() );
836 # We already have a 'test' target, and the top directory is just plain
838 return if $dir eq "test" || $dir eq ".";
840 foreach my $type (("dso", "lib", "bin", "script")) {
841 next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type});
842 # For lib object files, we could update the library. However,
843 # LIB on Windows doesn't work that way, so we won't create any
844 # actions for it, and the dependencies are already taken care of.
845 if ($type ne "lib") {
846 foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) {
847 if (dirname($prod) eq $dir) {
848 push @deps, $prod.$extinfo{$type};
854 my $deps = join(" ", @deps);
855 my $actions = join("\n", "", @actions);
857 $dir $dir\\ : $deps$actions
860 "" # Important! This becomes part of the template result.