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 ################################
190 CC="{- $config{CC} -}"
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}}) -}
197 LD="{- $config{LD} -}"
198 LDFLAGS={- join(' ', @{$config{LDFLAGS}}) -}
199 EX_LIBS={- join(' ', @{$config{LDLIBS}}) -}
201 PERL={- $config{PERL} -}
203 AR="{- $config{AR} -}"
204 ARFLAGS= {- join(' ', @{$config{ARFLAGS}}) -}
206 MT="{- $config{MT} -}"
207 MTFLAGS= {- join(' ', @{$config{MTFLAGS}}) -}
209 AS="{- $config{AS} -}"
210 ASFLAGS={- join(' ', @{$config{ASFLAGS}}) -}
212 RC="{- $config{RC} -}"
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 @if not "$(MISC_SCRIPTS)"=="" \
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 @if not "$(INSTALL_PROGRAMS)"=="" \
503 "$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\bin"
504 @if not "$(INSTALL_PROGRAMS)"=="" \
505 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMS) \
507 @if not "$(INSTALL_PROGRAMS)"=="" \
508 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMPDBS) \
510 @if not "$(INSTALL_PROGRAMS)"=="" \
511 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(BIN_SCRIPTS) \
516 install_html_docs: build_html_docs
517 @if "$(INSTALLTOP)"=="" ( echo INSTALLTOP should not be empty & exit 1 )
518 @echo *** Installing HTML docs
519 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\html\man1"
520 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\html\man3"
521 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\html\man5"
522 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\html\man7"
523 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BLDDIR)\doc\html\man1\*.html \
524 "$(INSTALLTOP)\html\man1"
525 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BLDDIR)\doc\html\man3\*.html \
526 "$(INSTALLTOP)\html\man3"
527 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BLDDIR)\doc\html\man5\*.html \
528 "$(INSTALLTOP)\html\man5"
529 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BLDDIR)\doc\html\man7\*.html \
530 "$(INSTALLTOP)\html\man7"
534 # Building targets ###################################################
536 configdata.pm: "$(SRCDIR)\Configure" {- join(" ", map { '"'.$_.'"' } @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
537 @$(ECHO) "Detected changed: $?"
538 "$(PERL)" configdata.pm -r
539 @$(ECHO) "**************************************************"
541 @$(ECHO) "*** Please run the same make command again ***"
543 @$(ECHO) "**************************************************"
547 "$(PERL)" configdata.pm -r
551 use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
553 # Helper function to figure out dependencies on libraries
554 # It takes a list of library names and outputs a list of dependencies
555 sub compute_lib_depends {
556 if ($disabled{shared}) {
557 return map { platform->staticlib($_) } @_;
559 return map { platform->sharedlib_import($_) // platform->staticlib($_) } @_;
564 my ($gen0, @gens) = @{$args{generator}};
565 my $generator = '"'.$gen0.'"'.join('', map { " $_" } @gens);
566 my $generator_incs = join("", map { " -I \"$_\"" } @{$args{generator_incs}});
567 my $incs = join("", map { " -I \"$_\"" } @{$args{incs}});
568 my $defs = join("", map { " -D".$_ } @{$args{defs}});
569 my $deps = @{$args{deps}} ?
570 '"'.join('" "', @{$args{generator_deps}}, @{$args{deps}}).'"' : '';
572 if ($args{src} =~ /\.html$/) {
573 my $title = basename($args{src}, ".html");
575 $args{src}: $args{generator}->[0]
576 pod2html "--podroot=\$(SRCDIR)/doc" --htmldir=.. \\
577 --podpath=man1:man3:man5:man7 "--infile=\$<" "--title=$title" \\
578 | \$(PERL) -pe "s|href=\\"http://man\\.he\\.net/(man\d/[^\\"]+)(?:\\.html)?\\"|href=\\"../\$1.html|g;" \\
581 } elsif (platform->isdef($args{src})) {
582 my $target = platform->def($args{src});
583 my $mkdef = abs2rel(rel2abs(catfile($config{sourcedir},
584 "util", "mkdef.pl")),
585 rel2abs($config{builddir}));
586 my $ord_ver = $args{intent} eq 'lib' ? ' --version $(VERSION)' : '';
588 $args{generator}->[1] || platform->dsoname($args{product});
590 $target: $args{generator}->[0] $deps $mkdef
591 "\$(PERL)" $mkdef$ord_ver --ordinals $args{generator}->[0] --name $ord_name --OS windows > $target
593 } elsif (!platform->isasm($args{src})) {
594 my $target = $args{src};
595 if ($args{generator}->[0] =~ m|^.*\.in$|) {
596 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
597 "util", "dofile.pl")),
598 rel2abs($config{builddir}));
599 my @modules = ( 'configdata.pm',
600 grep { $_ =~ m|\.pm$| } @{$args{deps}} );
601 my %moduleincs = map { '"-I'.dirname($_).'"' => 1 } @modules;
602 @modules = map { "-M".basename($_, '.pm') } @modules;
603 my $modules = join(' ', '', sort keys %moduleincs, @modules);
605 $target: "$args{generator}->[0]" $deps
606 "\$(PERL)"$modules "$dofile" "-o$target{build_file}" $generator > \$@
610 $target: "$args{generator}->[0]" $deps
611 "\$(PERL)"$generator_incs $generator > \$@
616 shlib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
617 lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
618 dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)',
619 bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
620 } -> {$args{intent}};
621 my $target = platform->asm($args{src});
623 if ($args{generator}->[0] =~ /\.pl$/) {
624 $generator = '"$(PERL)"'.$generator_incs.' '.$generator
625 .' "$(PERLASM_SCHEME)"'.$incs.' '.$cppflags.$defs.' $(PROCESSSOR)';
626 } elsif ($args{generator}->[0] =~ /\.S$/) {
629 die "Generator type for $src unknown: $generator\n";
632 if (defined($generator)) {
633 # If the target is named foo.S in build.info, we want to
634 # end up generating foo.s in two steps.
635 if ($args{src} =~ /\.S$/) {
637 $target: "$args{generator}->[0]" $deps
640 \$(CPP) $incs $cppflags $defs \$@.S > \$@.i && move /Y \$@.i \$@
646 $target: "$args{generator}->[0]" $deps
652 $target: "$args{generator}->[0]" $deps
653 \$(CPP) $incs $cppflags $defs "$args{generator}->[0]" > \$@.i && move /Y \$@.i \$@
659 my $asmext = platform->asmext();
663 (platform->isasm($x) && grep { $x eq $_ } @generated)
664 ? platform->asm($x) : $x }
666 my $srcs = '"'.join('" "', @srcs).'"';
667 my $deps = '"'.join('" "', @srcs, @{$args{deps}}).'"';
668 my $incs = join("", map { ' -I "'.$_.'"' } @{$args{incs}});
669 my $defs = join("", map { " -D".$_ } @{$args{defs}});
670 my $cflags = { shlib => ' $(LIB_CFLAGS)',
671 lib => ' $(LIB_CFLAGS)',
672 dso => ' $(DSO_CFLAGS)',
673 bin => ' $(BIN_CFLAGS)' } -> {$args{intent}};
675 $cflags .= { shlib => ' $(LIB_CPPFLAGS)',
676 lib => ' $(LIB_CPPFLAGS)',
677 dso => ' $(DSO_CPPFLAGS)',
678 bin => ' $(BIN_CPPFLAGS)' } -> {$args{intent}};
679 my $asflags = { shlib => ' $(LIB_ASFLAGS)',
680 lib => ' $(LIB_ASFLAGS)',
681 dso => ' $(DSO_ASFLAGS)',
682 bin => ' $(BIN_ASFLAGS)' } -> {$args{intent}};
683 my $makedepprog = $config{makedepprog};
684 if ($srcs[0] =~ /\.rc$/) {
685 my $res = platform->res($args{obj});
688 \$(RC) \$(RCFLAGS) \$(RCOUTFLAG)\$\@ $srcs
691 my $obj = platform->obj($args{obj});
692 my $dep = platform->dep($args{obj});
693 if ($srcs[0] =~ /\Q${asmext}\E$/) {
696 \$(AS) $asflags \$(ASOUTFLAG)\$\@ $srcs
698 } elsif ($srcs[0] =~ /.S$/) {
701 \$(CC) /EP -D__ASSEMBLER__ $cflags $defs $srcs > \$@.asm && \$(AS) $asflags \$(ASOUTFLAG)\$\@ \$@.asm
704 my $recipe = <<"EOF";
706 \$(CC) $cflags $defs -c \$(COUTFLAG)\$\@ $srcs
708 $recipe .= <<"EOF" unless $disabled{makedepend};
709 \$(CC) $cflags $defs /Zs /showIncludes $srcs 2>&1 > $dep
714 # We *know* this routine is only called when we've configure 'shared'.
715 # Also, note that even though the import library built here looks like
716 # a static library, it really isn't.
719 my $lib = $args{lib};
720 my @objs = map { platform->convertext($_) }
721 grep { platform->isobj($_) || platform->isres($_) }
723 my @defs = map { platform->def($_) }
724 grep { platform->isdef($_) }
726 my @deps = compute_lib_depends(@{$args{deps}});
727 die "More than one exported symbols list" if scalar @defs > 1;
728 my $linklibs = join("", map { "$_\n" } @deps);
729 my $objs = join("\n", @objs);
730 my $deps = join(" ", @objs, @defs, @deps);
731 my $import = platform->sharedlib_import($lib);
732 my $dll = platform->sharedlib($lib);
733 my $shared_def = join("", map { " /def:$_" } @defs);
735 # The import library may look like a static library, but it is not.
736 # We MUST make the import library depend on the DLL, in case someone
737 # mistakenly removes the latter.
740 IF EXIST $full.manifest DEL /F /Q $full.manifest
741 IF EXIST \$@ DEL /F /Q \$@
742 \$(LD) \$(LDFLAGS) \$(LIB_LDFLAGS) \\
743 /implib:$import \$(LDOUTFLAG)$dll$shared_def @<< || (DEL /Q \$(\@B).* $import && EXIT 1)
745 $linklibs\$(LIB_EX_LIBS)
747 IF EXIST $dll.manifest \\
748 \$(MT) \$(MTFLAGS) \$(MTINFLAG)$dll.manifest \$(MTOUTFLAG)$dll
749 IF EXIST apps\\$dll DEL /Q /F apps\\$dll
750 IF EXIST test\\$dll DEL /Q /F test\\$dll
751 IF EXIST fuzz\\$dll DEL /Q /F fuzz\\$dll
759 my $dso = platform->dso($args{module});
760 my $dso_n = platform->dsoname($args{module});
761 my @objs = map { platform->convertext($_) }
762 grep { platform->isobj($_) || platform->isres($_) }
764 my @defs = map { platform->def($_) }
765 grep { platform->isdef($_) }
767 my @deps = compute_lib_depends(@{$args{deps}});
768 my $objs = join("\n", @objs);
769 my $linklibs = join("", map { "$_\n" } @deps);
770 my $deps = join(" ", @objs, @defs, @deps);
771 my $shared_def = join("", map { " /def:$_" } @defs);
774 IF EXIST $dso.manifest DEL /F /Q $dso.manifest
775 \$(LD) \$(LDFLAGS) \$(DSO_LDFLAGS) \\
776 \$(LDOUTFLAG)$dso$shared_def @<< || (DEL /Q \$(\@B).* $dso_n.* && EXIT 1)
778 $linklibs \$(DSO_EX_LIBS)
780 IF EXIST $dso.manifest \\
781 \$(MT) \$(MTFLAGS) \$(MTINFLAG)$dso.manifest \$(MTOUTFLAG)$dso
786 my $lib = platform->staticlib($args{lib});
787 my @objs = map { platform->obj($_) } @{$args{objs}};
788 my $objs = join("\n", @objs);
789 my $deps = join(" ", @objs);
792 \$(AR) \$(ARFLAGS) \$(AROUTFLAG)$lib @<<
799 my $bin = platform->bin($args{bin});
800 my @objs = map { platform->convertext($_) }
801 grep { platform->isobj($_) || platform->isres($_) }
803 my @deps = compute_lib_depends(@{$args{deps}});
804 my $objs = join("\n", @objs);
805 my $linklibs = join("", map { "$_\n" } @deps);
806 my $deps = join(" ", @objs, @deps);
809 IF EXIST $bin.manifest DEL /F /Q $bin.manifest
810 \$(LD) \$(LDFLAGS) \$(BIN_LDFLAGS) \$(LDOUTFLAG)$bin @<<
813 $linklibs\$(BIN_EX_LIBS)
815 IF EXIST $bin.manifest \\
816 \$(MT) \$(MTFLAGS) \$(MTINFLAG)$bin.manifest \$(MTOUTFLAG)$bin
821 my $script = $args{script};
822 my $sources = '"'.join('" "', @{$args{sources}}).'"';
823 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
824 "util", "dofile.pl")),
825 rel2abs($config{builddir}));
828 "\$(PERL)" "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
829 "-o$target{build_file}" $sources > "$script"
834 my $dir = $args{dir};
835 my @deps = map { platform->convertext($_) } @{$args{deps}};
837 my %extinfo = ( dso => platform->dsoext(),
838 lib => platform->libext(),
839 bin => platform->binext() );
841 # We already have a 'test' target, and the top directory is just plain
843 return if $dir eq "test" || $dir eq ".";
845 foreach my $type (("dso", "lib", "bin", "script")) {
846 next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type});
847 # For lib object files, we could update the library. However,
848 # LIB on Windows doesn't work that way, so we won't create any
849 # actions for it, and the dependencies are already taken care of.
850 if ($type ne "lib") {
851 foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) {
852 if (dirname($prod) eq $dir) {
853 push @deps, $prod.$extinfo{$type};
859 my $deps = join(" ", @deps);
860 my $actions = join("\n", "", @actions);
862 $dir $dir\\ : $deps$actions
865 "" # Important! This becomes part of the template result.