]> git.ipfire.org Git - thirdparty/openssl.git/blob - Configurations/windows-makefile.tmpl
Build file templates: rework how general dependencies are computed
[thirdparty/openssl.git] / Configurations / windows-makefile.tmpl
1 ##
2 ## Makefile for OpenSSL
3 ##
4 ## {- join("\n## ", @autowarntext) -}
5 {-
6 use File::Basename;
7 use OpenSSL::Util;
8
9 our $sover_dirname = platform->shlib_version_as_filename();
10
11 my $build_scheme = $target{build_scheme};
12 my $install_flavour = $build_scheme->[$#$build_scheme]; # last element
13 my $win_installenv =
14 $install_flavour eq "VC-WOW" ? "ProgramFiles(x86)"
15 : "ProgramW6432";
16 my $win_commonenv =
17 $install_flavour eq "VC-WOW" ? "CommonProgramFiles(x86)"
18 : "CommonProgramW6432";
19 our $win_installroot =
20 defined($ENV{$win_installenv}) ? $win_installenv : 'ProgramFiles';
21 our $win_commonroot =
22 defined($ENV{$win_commonenv}) ? $win_commonenv : 'CommonProgramFiles';
23
24 # expand variables early
25 $win_installroot = $ENV{$win_installroot};
26 $win_commonroot = $ENV{$win_commonroot};
27
28 # This makes sure things get built in the order they need
29 # to. You're welcome.
30 sub dependmagic {
31 my $target = shift;
32
33 return "$target: build_generated\n\t\$(MAKE) /\$(MAKEFLAGS) depend\n\t\$(MAKE) /\$(MAKEFLAGS) _$target\n_$target";
34 }
35 '';
36 -}
37
38 PLATFORM={- $config{target} -}
39 SRCDIR={- $config{sourcedir} -}
40 BLDDIR={- $config{builddir} -}
41 FIPSKEY={- $config{FIPSKEY} -}
42
43 VERSION={- "$config{full_version}" -}
44 MAJOR={- $config{major} -}
45 MINOR={- $config{minor} -}
46
47 SHLIB_VERSION_NUMBER={- $config{shlib_version} -}
48
49 LIBS={- join(" ", map { ( platform->sharedlib_import($_), platform->staticlib($_) ) } @{$unified_info{libraries}}) -}
50 SHLIBS={- join(" ", map { platform->sharedlib($_) // () } @{$unified_info{libraries}}) -}
51 SHLIBPDBS={- join(" ", map { platform->sharedlibpdb($_) // () } @{$unified_info{libraries}}) -}
52 MODULES={- our @MODULES = map { platform->dso($_) }
53 # Drop all modules that are dependencies, they will
54 # be processed through their dependents
55 grep { my $x = $_;
56 !grep { grep { $_ eq $x } @$_ }
57 values %{$unified_info{depends}} }
58 @{$unified_info{modules}};
59 join(" ", @MODULES) -}
60 MODULEPDBS={- join(" ", map { platform->dsopdb($_) } @{$unified_info{modules}}) -}
61 FIPSMODULE={- # We do some extra checking here, as there should be only one
62 use File::Basename;
63 our @fipsmodules =
64 grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
65 && $unified_info{attributes}->{modules}->{$_}->{fips} }
66 @{$unified_info{modules}};
67 die "More that one FIPS module" if scalar @fipsmodules > 1;
68 join(" ", map { basename(platform->dso($_)) } @fipsmodules) -}
69 FIPSMODULENAME={- die "More that one FIPS module" if scalar @fipsmodules > 1;
70 join(", ", map { basename(platform->dso($_)) } @fipsmodules) -}
71 PROGRAMS={- our @PROGRAMS = map { platform->bin($_) } @{$unified_info{programs}}; join(" ", @PROGRAMS) -}
72 PROGRAMPDBS={- join(" ", map { $_.".pdb" } @{$unified_info{programs}}) -}
73 SCRIPTS={- our @SCRIPTS = @{$unified_info{scripts}}; join(" ", @SCRIPTS) -}
74 {- output_off() if $disabled{makedepend}; "" -}
75 DEPS={- join(" ", map { platform->isobj($_) ? platform->dep($_) : () }
76 grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
77 keys %{$unified_info{sources}}); -}
78 {- output_on() if $disabled{makedepend}; "" -}
79 GENERATED_MANDATORY={- our @GENERATED_MANDATORY = @{$unified_info{depends}->{""}};
80 join(" ", @GENERATED_MANDATORY) -}
81 GENERATED={- # common0.tmpl provides @generated
82 our @GENERATED = map { platform->convertext($_) } @generated;
83 join(" ", @GENERATED) -}
84
85 INSTALL_LIBS={-
86 join(" ", map { quotify1(platform->sharedlib_import($_)
87 // platform->staticlib($_)) }
88 grep { !$unified_info{attributes}->{libraries}->{$_}->{noinst} }
89 @{$unified_info{libraries}})
90 -}
91 INSTALL_SHLIBS={-
92 join(" ", map { my $x = platform->sharedlib($_);
93 $x ? quotify_l($x) : () }
94 grep { !$unified_info{attributes}->{libraries}->{$_}->{noinst} }
95 @{$unified_info{libraries}})
96 -}
97 INSTALL_SHLIBPDBS={-
98 join(" ", map { my $x = platform->sharedlibpdb($_);
99 $x ? quotify_l($x) : () }
100 grep { !$unified_info{attributes}->{libraries}->{$_}->{noinst} }
101 @{$unified_info{libraries}})
102 -}
103 INSTALL_ENGINES={-
104 join(" ", map { quotify1(platform->dso($_)) }
105 grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
106 && $unified_info{attributes}->{modules}->{$_}->{engine} }
107 @{$unified_info{modules}})
108 -}
109 INSTALL_ENGINEPDBS={-
110 join(" ", map { quotify1(platform->dsopdb($_)) }
111 grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
112 && $unified_info{attributes}->{modules}->{$_}->{engine} }
113 @{$unified_info{modules}})
114 -}
115 INSTALL_FIPS={-
116 join(" ", map { quotify1(platform->dso($_)) }
117 grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
118 && $unified_info{attributes}->{modules}->{$_}->{fips} }
119 @{$unified_info{modules}})
120 -}
121 INSTALL_MODULES={-
122 join(" ", map { quotify1(platform->dso($_)) }
123 grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
124 && !$unified_info{attributes}->{modules}->{$_}->{engine}
125 && !$unified_info{attributes}->{modules}->{$_}->{fips} }
126 @{$unified_info{modules}})
127 -}
128 INSTALL_MODULEPDBS={-
129 join(" ", map { quotify1(platform->dsopdb($_)) }
130 grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
131 && !$unified_info{attributes}->{modules}->{$_}->{engine} }
132 @{$unified_info{modules}})
133 -}
134 INSTALL_PROGRAMS={-
135 join(" ", map { quotify1(platform->bin($_)) }
136 grep { !$unified_info{attributes}->{programs}->{$_}->{noinst} }
137 @{$unified_info{programs}})
138 -}
139 INSTALL_PROGRAMPDBS={-
140 join(" ", map { quotify1(platform->binpdb($_)) }
141 grep { !$unified_info{attributes}->{programs}->{$_}->{noinst} }
142 @{$unified_info{programs}})
143 -}
144 BIN_SCRIPTS={-
145 join(" ", map { quotify1($_) }
146 grep { !$unified_info{attributes}->{scripts}->{$_}->{noinst}
147 && !$unified_info{attributes}->{scripts}->{$_}->{misc} }
148 @{$unified_info{scripts}})
149 -}
150 MISC_SCRIPTS={-
151 join(" ", map { quotify1($_) }
152 grep { !$unified_info{attributes}->{scripts}->{$_}->{noinst}
153 && $unified_info{attributes}->{scripts}->{$_}->{misc} }
154 @{$unified_info{scripts}})
155 -}
156 IMAGEDOCS1={- our @IMAGEDOCS1 = @{$unified_info{imagedocs}->{man1}};
157 join(" ", @IMAGEDOCS1) -}
158 IMAGEDOCS3={- our @IMAGEDOCS3 = @{$unified_info{imagedocs}->{man3}};
159 join(" ", @IMAGEDOCS3) -}
160 IMAGEDOCS5={- our @IMAGEDOCS5 = @{$unified_info{imagedocs}->{man5}};
161 join(" ", @IMAGEDOCS5) -}
162 IMAGEDOCS7={- our @IMAGEDOCS7 = @{$unified_info{imagedocs}->{man7}};
163 join(" ", @IMAGEDOCS7) -}
164 HTMLDOCS1={- our @HTMLDOCS1 = @{$unified_info{htmldocs}->{man1}};
165 join(" ", @HTMLDOCS1) -}
166 HTMLDOCS3={- our @HTMLDOCS3 = @{$unified_info{htmldocs}->{man3}};
167 join(" ", @HTMLDOCS3) -}
168 HTMLDOCS5={- our @HTMLDOCS5 = @{$unified_info{htmldocs}->{man5}};
169 join(" ", @HTMLDOCS5) -}
170 HTMLDOCS7={- our @HTMLDOCS7 = @{$unified_info{htmldocs}->{man7}};
171 join(" ", @HTMLDOCS7) -}
172 HTMLDOCS1_BLDDIRS={- my %dirs = map { dirname($_) => 1 } @HTMLDOCS1;
173 join(' ', sort keys %dirs) -}
174 HTMLDOCS3_BLDDIRS={- my %dirs = map { dirname($_) => 1 } @HTMLDOCS3;
175 join(' ', sort keys %dirs) -}
176 HTMLDOCS5_BLDDIRS={- my %dirs = map { dirname($_) => 1 } @HTMLDOCS5;
177 join(' ', sort keys %dirs) -}
178 HTMLDOCS7_BLDDIRS={- my %dirs = map { dirname($_) => 1 } @HTMLDOCS7;
179 join(' ', sort keys %dirs) -}
180
181 APPS_OPENSSL="{- use File::Spec::Functions;
182 catfile("apps","openssl") -}"
183
184 # Do not edit these manually. Use Configure with --prefix or --openssldir
185 # to change this! Short explanation in the top comment in Configure
186 INSTALLTOP_dev={- # $prefix is used in the OPENSSLDIR perl snippet
187 #
188 use File::Spec::Functions qw(:DEFAULT splitpath);
189 our $prefix = canonpath($config{prefix}
190 || "$win_installroot\\OpenSSL");
191 our ($prefix_dev, $prefix_dir, $prefix_file) =
192 splitpath($prefix, 1);
193 $prefix_dev -}
194 INSTALLTOP_dir={- canonpath($prefix_dir) -}
195 OPENSSLDIR_dev={- #
196 # The logic here is that if no --openssldir was given,
197 # OPENSSLDIR will get the value "$win_commonroot\\SSL".
198 # If --openssldir was given and the value is an absolute
199 # path, OPENSSLDIR will get its value without change.
200 # If the value from --openssldir is a relative path,
201 # OPENSSLDIR will get $prefix with the --openssldir
202 # value appended as a subdirectory.
203 #
204 use File::Spec::Functions qw(:DEFAULT splitpath);
205 our $openssldir =
206 $config{openssldir} ?
207 (file_name_is_absolute($config{openssldir}) ?
208 canonpath($config{openssldir})
209 : catdir($prefix, $config{openssldir}))
210 : canonpath("$win_commonroot\\SSL");
211 our ($openssldir_dev, $openssldir_dir, $openssldir_file) =
212 splitpath($openssldir, 1);
213 $openssldir_dev -}
214 OPENSSLDIR_dir={- canonpath($openssldir_dir) -}
215 LIBDIR={- our $libdir = $config{libdir} || "lib";
216 file_name_is_absolute($libdir) ? "" : $libdir -}
217 MODULESDIR_dev={- use File::Spec::Functions qw(:DEFAULT splitpath catpath);
218 our $modulesprefix = catdir($prefix,$libdir);
219 our ($modulesprefix_dev, $modulesprefix_dir,
220 $modulesprefix_file) =
221 splitpath($modulesprefix, 1);
222 our $modulesdir_dev = $modulesprefix_dev;
223 our $modulesdir_dir =
224 catdir($modulesprefix_dir, "ossl-modules");
225 our $modulesdir = catpath($modulesdir_dev, $modulesdir_dir);
226 our $enginesdir_dev = $modulesprefix_dev;
227 our $enginesdir_dir =
228 catdir($modulesprefix_dir, "engines-$sover_dirname");
229 our $enginesdir = catpath($enginesdir_dev, $enginesdir_dir);
230 $modulesdir_dev -}
231 MODULESDIR_dir={- canonpath($modulesdir_dir) -}
232 ENGINESDIR_dev={- $enginesdir_dev -}
233 ENGINESDIR_dir={- canonpath($enginesdir_dir) -}
234 !IF "$(DESTDIR)" != ""
235 INSTALLTOP=$(DESTDIR)$(INSTALLTOP_dir)
236 OPENSSLDIR=$(DESTDIR)$(OPENSSLDIR_dir)
237 ENGINESDIR=$(DESTDIR)$(ENGINESDIR_dir)
238 MODULESDIR=$(DESTDIR)$(MODULESDIR_dir)
239 !ELSE
240 INSTALLTOP=$(INSTALLTOP_dev)$(INSTALLTOP_dir)
241 OPENSSLDIR=$(OPENSSLDIR_dev)$(OPENSSLDIR_dir)
242 ENGINESDIR=$(ENGINESDIR_dev)$(ENGINESDIR_dir)
243 MODULESDIR=$(MODULESDIR_dev)$(MODULESDIR_dir)
244 !ENDIF
245
246 # $(libdir) is chosen to be compatible with the GNU coding standards
247 libdir={- file_name_is_absolute($libdir)
248 ? $libdir : '$(INSTALLTOP)\$(LIBDIR)' -}
249
250 ##### User defined commands and flags ################################
251
252 CC="{- $config{CC} -}"
253 CPP={- $config{CPP} -}
254 CPPFLAGS={- our $cppflags1 = join(" ",
255 (map { "-D".$_} @{$config{CPPDEFINES}}),
256 (map { " -I".$_} @{$config{CPPINCLUDES}}),
257 @{$config{CPPFLAGS}}) -}
258 CFLAGS={- join(' ', @{$config{CFLAGS}}) -}
259 LD="{- $config{LD} -}"
260 LDFLAGS={- join(' ', @{$config{LDFLAGS}}) -}
261 EX_LIBS={- join(' ', @{$config{LDLIBS}}) -}
262
263 PERL={- $config{PERL} -}
264
265 AR="{- $config{AR} -}"
266 ARFLAGS= {- join(' ', @{$config{ARFLAGS}}) -}
267
268 MT="{- $config{MT} -}"
269 MTFLAGS= {- join(' ', @{$config{MTFLAGS}}) -}
270
271 AS="{- $config{AS} -}"
272 ASFLAGS={- join(' ', @{$config{ASFLAGS}}) -}
273
274 RC="{- $config{RC} -}"
275 RCFLAGS={- join(' ', @{$config{RCFLAGS}}) -}
276
277 ECHO="$(PERL)" "$(SRCDIR)\util\echo.pl"
278
279 ##### Special command flags ##########################################
280
281 COUTFLAG={- $target{coutflag} -}$(OSSL_EMPTY)
282 LDOUTFLAG={- $target{ldoutflag} -}$(OSSL_EMPTY)
283 AROUTFLAG={- $target{aroutflag} -}$(OSSL_EMPTY)
284 MTINFLAG={- $target{mtinflag} -}$(OSSL_EMPTY)
285 MTOUTFLAG={- $target{mtoutflag} -}$(OSSL_EMPTY)
286 ASOUTFLAG={- $target{asoutflag} -}$(OSSL_EMPTY)
287 RCOUTFLAG={- $target{rcoutflag} -}$(OSSL_EMPTY)
288
289 ##### Project flags ##################################################
290
291 # Variables starting with CNF_ are common variables for all product types
292
293 CNF_ASFLAGS={- join(' ', $target{asflags} || (),
294 @{$config{asflags}}) -}
295 CNF_CPPFLAGS={- our $cppfags2 =
296 join(' ', $target{cppflags} || (),
297 (map { '-D'.quotify1($_) } @{$target{defines}},
298 @{$config{defines}}),
299 (map { '-I'.'"'.$_.'"' } @{$target{includes}},
300 @{$config{includes}}),
301 @{$config{cppflags}}) -}
302 CNF_CFLAGS={- join(' ', $target{cflags} || (),
303 @{$config{cflags}}) -}
304 CNF_CXXFLAGS={- join(' ', $target{cxxflags} || (),
305 @{$config{cxxflags}}) -}
306 CNF_LDFLAGS={- join(' ', $target{lflags} || (),
307 @{$config{lflags}}) -}
308 CNF_EX_LIBS={- join(' ', $target{ex_libs} || (),
309 @{$config{ex_libs}}) -}
310
311 # Variables starting with LIB_ are used to build library object files
312 # and shared libraries.
313 # Variables starting with DSO_ are used to build DSOs and their object files.
314 # Variables starting with BIN_ are used to build programs and their object
315 # files.
316
317 LIB_ASFLAGS={- join(' ', $target{lib_asflags} || (),
318 @{$config{lib_asflags}},
319 '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
320 LIB_CPPFLAGS={- our $lib_cppflags =
321 join(' ', $target{lib_cppflags} || (),
322 $target{shared_cppflag} || (),
323 (map { '-D'.quotify1($_) }
324 @{$target{lib_defines}},
325 @{$target{shared_defines}},
326 @{$config{lib_defines}},
327 @{$config{shared_defines}}),
328 (map { '-I'.quotify1($_) }
329 @{$target{lib_includes}},
330 @{$target{shared_includes}},
331 @{$config{lib_includes}},
332 @{$config{shared_includes}}),
333 @{$config{lib_cppflags}},
334 @{$config{shared_cppflag}});
335 join(' ', $lib_cppflags,
336 (map { '-D'.quotify1($_) }
337 "OPENSSLDIR=\"$openssldir\"",
338 "ENGINESDIR=\"$enginesdir\"",
339 "MODULESDIR=\"$modulesdir\""),
340 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
341 LIB_CFLAGS={- join(' ', $target{lib_cflags} || (),
342 $target{shared_cflag} || (),
343 @{$config{lib_cflags}},
344 @{$config{shared_cflag}},
345 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
346 LIB_LDFLAGS={- join(' ', $target{shared_ldflag} || (),
347 $config{shared_ldflag} || (),
348 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
349 LIB_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
350 DSO_ASFLAGS={- join(' ', $target{dso_asflags} || (),
351 $target{module_asflags} || (),
352 @{$config{dso_asflags}},
353 @{$config{module_asflags}},
354 '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
355 DSO_CPPFLAGS={- join(' ', $target{dso_cppflags} || (),
356 $target{module_cppflag} || (),
357 (map { '-D'.quotify1($_) }
358 @{$target{dso_defines}},
359 @{$target{module_defines}},
360 @{$config{dso_defines}},
361 @{$config{module_defines}}),
362 (map { '-I'.quotify1($_) }
363 @{$target{dso_includes}},
364 @{$target{module_includes}},
365 @{$config{dso_includes}},
366 @{$config{module_includes}}),
367 @{$config{dso_cppflags}},
368 @{$config{module_cppflags}},
369 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
370 DSO_CFLAGS={- join(' ', $target{dso_cflags} || (),
371 $target{module_cflags} || (),
372 @{$config{dso_cflags}},
373 @{$config{module_cflags}},
374 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
375 DSO_LDFLAGS={- join(' ', $target{dso_lflags} || (),
376 $target{module_ldflags} || (),
377 @{$config{dso_lflags}},
378 @{$config{module_ldflags}},
379 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
380 DSO_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
381 BIN_ASFLAGS={- join(' ', $target{bin_asflags} || (),
382 @{$config{bin_asflags}},
383 '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
384 BIN_CPPFLAGS={- join(' ', $target{bin_cppflags} || (),
385 (map { '-D'.$_ } @{$config{bin_defines} || ()}),
386 @{$config{bin_cppflags}},
387 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
388 BIN_CFLAGS={- join(' ', $target{bin_cflags} || (),
389 @{$config{bin_cflags}},
390 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
391 BIN_LDFLAGS={- join(' ', $target{bin_lflags} || (),
392 @{$config{bin_lflags}},
393 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
394 BIN_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
395
396 # CPPFLAGS_Q is used for one thing only: to build up buildinf.h
397 CPPFLAGS_Q={- $cppflags1 =~ s|([\\"])|\\$1|g;
398 $cppflags2 =~ s|([\\"])|\\$1|g;
399 join(' ', $lib_cppflags || (), $cppflags2 || (),
400 $cppflags1 || ()) -}
401
402 PERLASM_SCHEME= {- $target{perlasm_scheme} -}
403
404 PROCESSOR= {- $config{processor} -}
405
406 # The main targets ###################################################
407
408 {- dependmagic('build_sw'); -}: build_libs_nodep build_modules_nodep build_programs_nodep copy-utils
409 {- dependmagic('build_libs'); -}: build_libs_nodep
410 {- dependmagic('build_modules'); -}: build_modules_nodep
411 {- dependmagic('build_programs'); -}: build_programs_nodep
412
413 build_docs: build_html_docs
414 build_html_docs: $(HTMLDOCS1) $(HTMLDOCS3) $(HTMLDOCS5) $(HTMLDOCS7)
415 @
416 build_generated: $(GENERATED_MANDATORY)
417 @
418 build_libs_nodep: $(LIBS) {- join(" ",map { platform->sharedlib_import($_) // () } @{$unified_info{libraries}}) -}
419 @
420 build_modules_nodep: $(MODULES)
421 @
422 build_programs_nodep: $(PROGRAMS) $(SCRIPTS)
423 @
424
425 # Kept around for backward compatibility
426 build_apps build_tests: build_programs
427
428 # Convenience target to prebuild all generated files, not just the mandatory
429 # ones
430 build_all_generated: $(GENERATED_MANDATORY) $(GENERATED) build_docs
431 @{- output_off() if $disabled{makedepend}; "" -}
432 @$(ECHO) "Warning: consider configuring with no-makedepend, because if"
433 @$(ECHO) " target system doesn't have $(PERL),"
434 @$(ECHO) " then make will fail..."
435 @{- output_on() if $disabled{makedepend}; "" -}
436
437 all: build_sw build_docs
438
439 test: tests
440 {- dependmagic('tests'); -}: build_programs_nodep build_modules_nodep copy-utils
441 @{- output_off() if $disabled{tests}; "" -}
442 cmd /C "set "SRCTOP=$(SRCDIR)" & set "BLDTOP=$(BLDDIR)" & set "PERL=$(PERL)" & set "FIPSKEY=$(FIPSKEY)" & "$(PERL)" "$(SRCDIR)\test\run_tests.pl" $(TESTS)"
443 @{- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
444 @$(ECHO) "Tests are not supported with your chosen Configure options"
445 @{- output_on() if !$disabled{tests}; "" -}
446
447 list-tests:
448 @{- output_off() if $disabled{tests}; "" -}
449 @cmd /C "set "SRCTOP=$(SRCDIR)" & "$(PERL)" "$(SRCDIR)\test\run_tests.pl" list"
450 @{- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
451 @$(ECHO) "Tests are not supported with your chosen Configure options"
452 @{- output_on() if !$disabled{tests}; "" -}
453
454 install: install_sw install_ssldirs install_docs
455
456 uninstall: uninstall_docs uninstall_sw
457
458 libclean:
459 "$(PERL)" -e "map { m/(.*)\.dll$$/; unlink glob """{.,apps,test,fuzz}/$$1.*"""; } @ARGV" $(SHLIBS)
460 -del /Q /F $(LIBS) libcrypto.* libssl.* ossl_static.pdb
461
462 clean: libclean
463 -rmdir /Q /S $(HTMLDOCS1_BLDDIRS)
464 -rmdir /Q /S $(HTMLDOCS3_BLDDIRS)
465 -rmdir /Q /S $(HTMLDOCS5_BLDDIRS)
466 -rmdir /Q /S $(HTMLDOCS7_BLDDIRS)
467 {- join("\n\t", map { "-del /Q /F $_" } @PROGRAMS) -}
468 {- join("\n\t", map { "-del /Q /F $_" } @MODULES) -}
469 {- join("\n\t", map { "-del /Q /F $_" } @SCRIPTS) -}
470 {- join("\n\t", map { "-del /Q /F $_" } @GENERATED_MANDATORY) -}
471 {- join("\n\t", map { "-del /Q /F $_" } @GENERATED) -}
472 -del /Q /S /F *.d *.obj *.pdb *.ilk *.manifest
473 -del /Q /S /F engines\*.lib engines\*.exp
474 -del /Q /S /F apps\*.lib apps\*.rc apps\*.res apps\*.exp
475 -del /Q /S /F test\*.exp
476 -rmdir /Q /S test\test-runs
477
478 distclean: clean
479 -del /Q /F configdata.pm
480 -del /Q /F makefile
481
482 depend:
483 @ {- output_off() if $disabled{makedepend}; "" -}
484 @ "$(PERL)" "$(SRCDIR)\util\add-depends.pl" "{- $target{makedep_scheme} -}"
485 @ {- output_on() if $disabled{makedepend}; "" -}
486
487 # Install helper targets #############################################
488
489 install_sw: install_dev install_engines install_modules install_runtime
490
491 uninstall_sw: uninstall_runtime uninstall_modules uninstall_engines uninstall_dev
492
493 install_docs: install_html_docs
494
495 uninstall_docs: uninstall_html_docs
496
497 {- output_off() if $disabled{fips}; "" -}
498 install_fips: build_sw providers\fipsmodule.cnf
499 # @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1)
500 @$(PERL) $(SRCDIR)\util\mkdir-p.pl $(MODULESDIR)
501 @$(ECHO) "*** Installing FIPS module"
502 @$(ECHO) "install $(INSTALL_FIPS) -> $(MODULESDIR)\$(FIPSMODULENAME)"
503 @copy "$(INSTALL_FIPS)" $(MODULESDIR)\$(FIPSMODULENAME).new
504 @move /Y $(MODULESDIR)\$(FIPSMODULENAME).new \
505 $(MODULESDIR)\$(FIPSMODULENAME)
506 @$(ECHO) "*** Installing FIPS module configuration"
507 @$(ECHO) "install providers\fipsmodule.cnf -> $(OPENSSLDIR)\fipsmodule.cnf"
508 @copy providers\fipsmodule.cnf "$(OPENSSLDIR)\fipsmodule.cnf"
509
510 uninstall_fips:
511 @$(ECHO) "*** Uninstalling FIPS module configuration"
512 $(RM) "$(OPENSSLDIR)\fipsmodule.cnf"
513 @$(ECHO) "*** Uninstalling FIPS module"
514 $(RM) "$(MODULESDIR)\$(FIPSMODULENAME)"
515 {- if ($disabled{fips}) { output_on(); } else { output_off(); } "" -}
516 install_fips:
517 @$(ECHO) "The 'install_fips' target requires the 'enable-fips' option"
518
519 uninstall_fips:
520 @$(ECHO) "The 'uninstall_fips' target requires the 'enable-fips' option"
521 {- output_on() if !$disabled{fips}; "" -}
522
523 install_ssldirs:
524 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\certs"
525 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\private"
526 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\misc"
527 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\openssl.cnf" \
528 "$(OPENSSLDIR)\openssl.cnf.dist"
529 @IF NOT EXIST "$(OPENSSLDIR)\openssl.cnf" \
530 "$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\openssl.cnf" \
531 "$(OPENSSLDIR)\openssl.cnf"
532 @if not "$(MISC_SCRIPTS)"=="" \
533 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(MISC_SCRIPTS) \
534 "$(OPENSSLDIR)\misc"
535 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\ct_log_list.cnf" \
536 "$(OPENSSLDIR)\ct_log_list.cnf.dist"
537 @IF NOT EXIST "$(OPENSSLDIR)\ct_log_list.cnf" \
538 "$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\ct_log_list.cnf" \
539 "$(OPENSSLDIR)\ct_log_list.cnf"
540
541 install_dev: install_runtime_libs
542 @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
543 @$(ECHO) "*** Installing development files"
544 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\include\openssl"
545 @{- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
546 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\ms\applink.c" \
547 "$(INSTALLTOP)\include\openssl"
548 @{- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
549 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "-exclude_re=/__DECC_" \
550 "$(SRCDIR)\include\openssl\*.h" \
551 "$(INSTALLTOP)\include\openssl"
552 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(BLDDIR)\include\openssl\*.h" \
553 "$(INSTALLTOP)\include\openssl"
554 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(libdir)"
555 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_LIBS) "$(libdir)"
556 @if "$(SHLIBS)"=="" \
557 "$(PERL)" "$(SRCDIR)\util\copy.pl" ossl_static.pdb "$(libdir)"
558
559 uninstall_dev:
560
561 _install_modules_deps: install_runtime_libs build_modules
562
563 install_engines: _install_modules_deps
564 @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
565 @$(ECHO) "*** Installing engines"
566 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(ENGINESDIR)"
567 @if not "$(INSTALL_ENGINES)"=="" \
568 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINES) "$(ENGINESDIR)"
569 @if not "$(INSTALL_ENGINES)"=="" \
570 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINEPDBS) "$(ENGINESDIR)"
571
572 uninstall_engines:
573
574 install_modules: _install_modules_deps
575 @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
576 @$(ECHO) "*** Installing modules"
577 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(MODULESDIR)"
578 @if not "$(INSTALL_MODULES)"=="" \
579 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_MODULES) "$(MODULESDIR)"
580 @if not "$(INSTALL_MODULES)"=="" \
581 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_MODULEPDBS) "$(MODULESDIR)"
582
583 uninstall_modules:
584
585 install_runtime: install_programs
586
587 install_runtime_libs: build_libs
588 @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
589 @$(ECHO) "*** Installing runtime libraries"
590 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\bin"
591 @if not "$(SHLIBS)"=="" \
592 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_SHLIBS) "$(INSTALLTOP)\bin"
593 @if not "$(SHLIBS)"=="" \
594 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_SHLIBPDBS) \
595 "$(INSTALLTOP)\bin"
596
597 install_programs: install_runtime_libs build_programs
598 @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
599 @$(ECHO) "*** Installing runtime programs"
600 @if not "$(INSTALL_PROGRAMS)"=="" \
601 "$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\bin"
602 @if not "$(INSTALL_PROGRAMS)"=="" \
603 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMS) \
604 "$(INSTALLTOP)\bin"
605 @if not "$(INSTALL_PROGRAMS)"=="" \
606 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMPDBS) \
607 "$(INSTALLTOP)\bin"
608 @if not "$(INSTALL_PROGRAMS)"=="" \
609 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(BIN_SCRIPTS) \
610 "$(INSTALLTOP)\bin"
611
612 uninstall_runtime:
613
614 install_html_docs: install_image_docs build_html_docs
615 @if "$(INSTALLTOP)"=="" ( echo INSTALLTOP should not be empty & exit 1 )
616 @echo *** Installing HTML docs
617 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\html\man1"
618 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\html\man3"
619 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\html\man5"
620 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\html\man7"
621 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BLDDIR)\doc\html\man1\*.html \
622 "$(INSTALLTOP)\html\man1"
623 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BLDDIR)\doc\html\man3\*.html \
624 "$(INSTALLTOP)\html\man3"
625 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BLDDIR)\doc\html\man5\*.html \
626 "$(INSTALLTOP)\html\man5"
627 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BLDDIR)\doc\html\man7\*.html \
628 "$(INSTALLTOP)\html\man7"
629
630 uninstall_html_docs: uninstall_image_docs
631
632 install_image_docs:
633 @if "$(INSTALLTOP)"=="" ( echo INSTALLTOP should not be empty & exit 1 )
634 @echo *** Installing HTML images
635 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\html\man7\img"
636 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(SRCDIR)\doc\man7\img\*.png \
637 "$(INSTALLTOP)\html\man7\img"
638
639 uninstall_image_docs:
640
641 # Helper targets #####################################################
642
643 copy-utils: $(BLDDIR)\util\wrap.pl $(BLDDIR)\apps\openssl.cnf
644
645 $(BLDDIR)\util\wrap.pl: configdata.pm
646 @if NOT EXIST "$(BLDDIR)\util" mkdir "$(BLDDIR)\util"
647 @if NOT "$(SRCDIR)"=="$(BLDDIR)" copy "$(SRCDIR)\util\$(@F)" "$(BLDDIR)\util"
648
649 $(BLDDIR)\apps\openssl.cnf: configdata.pm
650 @if NOT EXIST "$(BLDDIR)\apps" mkdir "$(BLDDIR)\apps"
651 @if NOT "$(SRCDIR)"=="$(BLDDIR)" copy "$(SRCDIR)\apps\$(@F)" "$(BLDDIR)\apps"
652
653 # Building targets ###################################################
654
655 configdata.pm: "$(SRCDIR)\Configure" {- join(" ", map { '"'.$_.'"' } @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
656 @$(ECHO) "Detected changed: $?"
657 "$(PERL)" configdata.pm -r
658 @$(ECHO) "**************************************************"
659 @$(ECHO) "*** ***"
660 @$(ECHO) "*** Please run the same make command again ***"
661 @$(ECHO) "*** ***"
662 @$(ECHO) "**************************************************"
663 @exit 1
664
665 reconfigure reconf:
666 "$(PERL)" configdata.pm -r
667
668 {-
669 use File::Basename;
670 use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs file_name_is_absolute/;
671
672 # Helper function to convert dependencies in platform agnostic form to
673 # dependencies in platform form.
674 sub compute_platform_depends {
675 map { my $x = $_;
676
677 grep { $x eq $_ } @{$unified_info{programs}} and platform->bin($x)
678 or grep { $x eq $_ } @{$unified_info{modules}} and platform->dso($x)
679 or grep { $x eq $_ } @{$unified_info{libraries}} and platform->lib($x)
680 or platform->convertext($x); } @_;
681 }
682
683 # Helper function to figure out dependencies on libraries
684 # It takes a list of library names and outputs a list of dependencies
685 sub compute_lib_depends {
686 if ($disabled{shared}) {
687 return map { platform->staticlib($_) } @_;
688 }
689 return map { platform->sharedlib_import($_) // platform->staticlib($_) } @_;
690 }
691
692 sub generatetarget {
693 my %args = @_;
694 my $deps = join(" ", compute_platform_depends(@{$args{deps}}));
695 return <<"EOF";
696 $args{target}: $deps
697 EOF
698 }
699
700 # This function (and the next) avoids quoting paths of generated dependencies
701 # (in the build tree), but quotes paths of non-generated dependencies (in the
702 # source tree). This is a workaround for a limitation of C++Builder's make.exe
703 # in handling quoted paths: https://quality.embarcadero.com/browse/RSP-31756
704 sub generatesrc {
705 my %args = @_;
706 my $gen0 = $args{generator}->[0];
707 my $gen_args = join('', map { " $_" }
708 @{$args{generator}}[1..$#{$args{generator}}]);
709 my $gen_incs = join("", map { " -I\"$_\"" } @{$args{generator_incs}});
710 my $incs = join("", map { " -I\"$_\"" } @{$args{incs}});
711 my $defs = join("", map { " -D".$_ } @{$args{defs}});
712 my $deps = join(' ',
713 map { file_name_is_absolute($_) || ($_ =~ m|^../|) ? "\"$_\"" : $_ }
714 compute_platform_depends(@{$args{generator_deps}},
715 @{$args{deps}}));
716
717 if ($args{src} =~ /\.html$/) {
718 #
719 # HTML generator
720 #
721 my $title = basename($args{src}, ".html");
722 my $pod = $gen0;
723 return <<"EOF";
724 $args{src}: "$pod"
725 "\$(PERL)" "\$(SRCDIR)/util/mkpod2html.pl" -i "$pod" -o \$\@ -t "$title" -r "\$(SRCDIR)/doc"
726 EOF
727 } elsif (platform->isdef($args{src})) {
728 #
729 # Linker script-ish generator
730 #
731 my $target = platform->def($args{src});
732 my $mkdef = abs2rel(rel2abs(catfile($config{sourcedir},
733 "util", "mkdef.pl")),
734 rel2abs($config{builddir}));
735 my $ord_ver = $args{intent} eq 'lib' ? ' --version $(VERSION)' : '';
736 my $ord_name =
737 $args{generator}->[1] || platform->dsoname($args{product});
738 return <<"EOF";
739 $target: $gen0 $deps $mkdef
740 "\$(PERL)" $mkdef$ord_ver --ordinals $gen0 --name $ord_name --OS windows > $target
741 EOF
742 } elsif (platform->isasm($args{src})) {
743 #
744 # Assembler generator
745 #
746 my $cppflags = {
747 shlib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
748 lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
749 dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)',
750 bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
751 } -> {$args{intent}};
752 my $target = platform->asm($args{src});
753
754 my $generator;
755 if ($gen0 =~ /\.pl$/) {
756 $generator = '"$(PERL)"'.$gen_incs.' '.$gen0.$gen_args
757 .' "$(PERLASM_SCHEME)"'.$incs.' '.$cppflags.$defs.' $(PROCESSSOR)';
758 } elsif ($gen0 =~ /\.S$/) {
759 $generator = undef;
760 } else {
761 die "Generator type for $src unknown: $gen0\n";
762 }
763
764 if (defined($generator)) {
765 # If the target is named foo.S in build.info, we want to
766 # end up generating foo.s in two steps.
767 if ($args{src} =~ /\.S$/) {
768 return <<"EOF";
769 $target: "$gen0" $deps
770 cmd /C "set "ASM=\$(AS)" & $generator \$@.S"
771 \$(CPP) $incs $cppflags $defs \$@.S > \$@.i
772 move /Y \$@.i \$@
773 del /Q \$@.S
774 EOF
775 }
776 # Otherwise....
777 return <<"EOF";
778 $target: "$gen0" $deps
779 cmd /C "set "ASM=\$(AS)" & $generator \$@"
780 EOF
781 }
782 return <<"EOF";
783 $target: "$gen0" $deps
784 \$(CPP) $incs $cppflags $defs "$gen0" > \$@.i
785 move /Y \$@.i \$@
786 EOF
787 } elsif ($gen0 =~ m|^.*\.in$|) {
788 #
789 # "dofile" generator (file.in -> file)
790 #
791 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
792 "util", "dofile.pl")),
793 rel2abs($config{builddir}));
794 my @perlmodules = ( 'configdata.pm',
795 grep { $_ =~ m|\.pm$| } @{$args{deps}} );
796 my %perlmoduleincs = map { '"-I'.dirname($_).'"' => 1 } @perlmodules;
797 $deps = join(' ', $deps, compute_platform_depends(@perlmodules));
798 @perlmodules = map { "-M".basename($_, '.pm') } @perlmodules;
799 my $perlmodules = join(' ', '', sort keys %perlmoduleincs, @perlmodules);
800 return <<"EOF";
801 $args{src}: "$gen0" $deps
802 "\$(PERL)"$perlmodules "$dofile" "-o$target{build_file}" "$gen0"$gen_args > \$@
803 EOF
804 } elsif (grep { $_ eq $gen0 } @{$unified_info{programs}}) {
805 #
806 # Generic generator using OpenSSL programs
807 #
808
809 # Redo $gen0, to ensure that we have the proper extension.
810 $gen0 = platform->bin($gen0);
811 return <<"EOF";
812 $args{src}: $gen0 $deps "\$(BLDDIR)\\util\\wrap.pl"
813 "\$(PERL)" "\$(BLDDIR)\\util\\wrap.pl" $gen0$gen_args > \$@
814 EOF
815 } else {
816 #
817 # Generic generator using Perl
818 #
819 return <<"EOF";
820 $args{src}: "$gen0" $deps
821 "\$(PERL)"$gen_incs $gen0$gen_args > \$@
822 EOF
823 }
824 }
825
826 sub src2obj {
827 my $asmext = platform->asmext();
828 my %args = @_;
829 my @srcs =
830 map { my $x = $_;
831 (platform->isasm($x) && grep { $x eq $_ } @generated)
832 ? platform->asm($x) : $x }
833 ( @{$args{srcs}} );
834 my $srcs = '"'.join('" "', @srcs).'"';
835 my $deps = join(' ',
836 map { file_name_is_absolute($_) || ($_ =~ m|^../|) ? "\"$_\"" : $_ }
837 (@srcs, @{$args{deps}}));
838 my $incs = join("", map { ' -I"'.$_.'"' } @{$args{incs}});
839 my $defs = join("", map { " -D".$_ } @{$args{defs}});
840 my $cflags = { shlib => ' $(LIB_CFLAGS)',
841 lib => ' $(LIB_CFLAGS)',
842 dso => ' $(DSO_CFLAGS)',
843 bin => ' $(BIN_CFLAGS)' } -> {$args{intent}};
844 $cflags .= $incs;
845 $cflags .= { shlib => ' $(LIB_CPPFLAGS)',
846 lib => ' $(LIB_CPPFLAGS)',
847 dso => ' $(DSO_CPPFLAGS)',
848 bin => ' $(BIN_CPPFLAGS)' } -> {$args{intent}};
849 my $asflags = { shlib => ' $(LIB_ASFLAGS)',
850 lib => ' $(LIB_ASFLAGS)',
851 dso => ' $(DSO_ASFLAGS)',
852 bin => ' $(BIN_ASFLAGS)' } -> {$args{intent}};
853 my $makedepcmd = $config{makedepcmd} unless $disabled{makedepend};
854 if ($srcs[0] =~ /\.rc$/) {
855 my $res = platform->res($args{obj});
856 return <<"EOF";
857 $res: $deps
858 \$(RC) \$(RCFLAGS) \$(RCOUTFLAG)\$\@ $srcs
859 EOF
860 }
861 my $obj = platform->obj($args{obj});
862 my $dep = platform->dep($args{obj});
863 if ($srcs[0] =~ /\Q${asmext}\E$/) {
864 return <<"EOF";
865 $obj: $deps
866 \$(AS) $asflags \$(ASOUTFLAG)\$\@ $srcs
867 EOF
868 } elsif ($srcs[0] =~ /.S$/) {
869 return <<"EOF";
870 $obj: $deps
871 \$(CC) /EP -D__ASSEMBLER__ $cflags $defs $srcs > \$@.asm
872 \$(AS) $asflags \$(ASOUTFLAG)\$\@ \$@.asm
873 EOF
874 }
875 my $recipe = <<"EOF";
876 $obj: $deps
877 \$(CC) $cflags $defs -c \$(COUTFLAG)\$\@ $srcs
878 EOF
879 $recipe .= <<"EOF" unless $disabled{makedepend};
880 cmd /C "$makedepcmd $cflags $defs $srcs > $dep 2>&1"
881 EOF
882 return $recipe;
883 }
884
885 # We *know* this routine is only called when we've configure 'shared'.
886 # Also, note that even though the import library built here looks like
887 # a static library, it really isn't.
888 sub obj2shlib {
889 my %args = @_;
890 my $lib = $args{lib};
891 my @objs = map { platform->convertext($_) }
892 grep { platform->isobj($_) }
893 @{$args{objs}};
894 my @ress = map { platform->convertext($_) }
895 grep { platform->isres($_) }
896 @{$args{objs}};
897 my @defs = map { platform->def($_) }
898 grep { platform->isdef($_) }
899 @{$args{objs}};
900 my @deps = compute_lib_depends(@{$args{deps}});
901 die "More than one exported symbols list" if scalar @defs > 1;
902 my $linklibs = join("", map { "$_$target{ld_resp_delim}" } @deps);
903 my $objs = join($target{ld_resp_delim}, @objs);
904 my $ress = join($target{ld_resp_delim}, @ress);
905 my $deps = join(" ", @objs, @ress, @defs, @deps);
906 my $import = platform->sharedlib_import($lib);
907 my $dll = platform->sharedlib($lib);
908 my $shared_def = $target{lddefflag} . join("", @defs);
909 my $implib_rule = $target{ld_implib_rule} || "";
910 my $implib_flag = $target{ld_implib_flag}
911 ? "$target{ld_implib_flag}$import"
912 : "";
913 return <<"EOF"
914 # The import library may look like a static library, but it is not.
915 # We MUST make the import library depend on the DLL, in case someone
916 # mistakenly removes the latter.
917 $import: $dll
918 $implib_rule
919 $dll: $deps
920 IF EXIST $full.manifest DEL /F /Q $full.manifest
921 IF EXIST \$@ DEL /F /Q \$@
922 cmd /C "\$(LD) \$(LDFLAGS) \$(LIB_LDFLAGS) @<< $implib_flag || (DEL /Q \$(\@B).* $import & EXIT 1)"
923 $objs$target{ld_resp_delim}\$(LDOUTFLAG)$dll$target{ldpostoutflag}$target{ld_resp_delim}$linklibs\$(LIB_EX_LIBS)$target{ld_resp_delim}$shared_def$target{ldresflag}$ress
924 <<
925 IF EXIST $dll.manifest \\
926 \$(MT) \$(MTFLAGS) \$(MTINFLAG)$dll.manifest \$(MTOUTFLAG)$dll
927 IF EXIST apps\\$dll DEL /Q /F apps\\$dll
928 IF EXIST test\\$dll DEL /Q /F test\\$dll
929 IF EXIST fuzz\\$dll DEL /Q /F fuzz\\$dll
930 COPY $dll apps
931 COPY $dll test
932 COPY $dll fuzz
933 EOF
934 }
935 sub obj2dso {
936 my %args = @_;
937 my $dso = platform->dso($args{module});
938 my $dso_n = platform->dsoname($args{module});
939 my @objs = map { platform->convertext($_) }
940 grep { platform->isobj($_) }
941 @{$args{objs}};
942 my @ress = map { platform->convertext($_) }
943 grep { platform->isres($_) }
944 @{$args{objs}};
945 my @defs = map { platform->def($_) }
946 grep { platform->isdef($_) }
947 @{$args{objs}};
948 my @deps = compute_lib_depends(@{$args{deps}});
949 die "More than one exported symbols list" if scalar @defs > 1;
950 my $objs = join($target{ld_resp_delim}, @objs);
951 my $ress = join($target{ld_resp_delim}, @ress);
952 my $linklibs = join("", map { "$_$target{ld_resp_delim}" } @deps);
953 my $deps = join(" ", @objs, @ress, @defs, @deps);
954 my $shared_def = $target{lddefflag} . join("", @defs);
955 return <<"EOF";
956 $dso: $deps
957 IF EXIST $dso.manifest DEL /F /Q $dso.manifest
958 cmd /C "\$(LD) \$(LDFLAGS) \$(DSO_LDFLAGS) @<< || (DEL /Q \$(\@B).* $dso_n.* & EXIT 1)"
959 $objs$target{ld_resp_delim}\$(LDOUTFLAG)$dso$target{ldpostoutflag}$target{ld_resp_delim}$linklibs \$(DSO_EX_LIBS)$target{ld_resp_delim}$shared_def$target{ldresflag}$ress
960 <<
961 IF EXIST $dso.manifest \\
962 \$(MT) \$(MTFLAGS) \$(MTINFLAG)$dso.manifest \$(MTOUTFLAG)$dso
963 EOF
964 }
965 sub obj2lib {
966 my %args = @_;
967 my $lib = platform->staticlib($args{lib});
968 my @objs = map { platform->obj($_) } @{$args{objs}};
969 my $objs = join($target{ar_resp_delim}, @objs);
970 my $deps = join(" ", @objs);
971 return <<"EOF";
972 $lib: $deps
973 \$(AR) \$(ARFLAGS) \$(AROUTFLAG)$lib @<<
974 $objs
975 <<
976 EOF
977 }
978 sub obj2bin {
979 my %args = @_;
980 my $bin = platform->bin($args{bin});
981 my @objs = map { platform->convertext($_) }
982 grep { platform->isobj($_) }
983 @{$args{objs}};
984 my @ress = map { platform->convertext($_) }
985 grep { platform->isres($_) }
986 @{$args{objs}};
987 my @deps = compute_lib_depends(@{$args{deps}});
988 my $objs = join($target{ld_resp_delim}, @objs);
989 my $linklibs = join("", map { "$_$target{ld_resp_delim}" } @deps);
990 my $deps = join(" ", @objs, @ress, @deps);
991 return <<"EOF";
992 $bin: $deps
993 IF EXIST $bin.manifest DEL /F /Q $bin.manifest
994 \$(LD) \$(LDFLAGS) \$(BIN_LDFLAGS) @<<
995 $objs$target{ld_resp_delim}\$(LDOUTFLAG)$bin$target{ldpostoutflag}$target{ld_resp_delim}$linklibs\$(BIN_EX_LIBS)$target{ldresflag}$target{ldresflag}$ress
996 <<
997 IF EXIST $bin.manifest \\
998 \$(MT) \$(MTFLAGS) \$(MTINFLAG)$bin.manifest \$(MTOUTFLAG)$bin
999 EOF
1000 }
1001 sub in2script {
1002 my %args = @_;
1003 my $script = $args{script};
1004 my $sources = '"'.join('" "', @{$args{sources}}).'"';
1005 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
1006 "util", "dofile.pl")),
1007 rel2abs($config{builddir}));
1008 return <<"EOF";
1009 $script: $sources
1010 "\$(PERL)" "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
1011 "-o$target{build_file}" $sources > \$@
1012 EOF
1013 }
1014 sub generatedir {
1015 my %args = @_;
1016 my $dir = $args{dir};
1017 my @deps = map { platform->convertext($_) } @{$args{deps}};
1018 my @actions = ();
1019 my %extinfo = ( dso => platform->dsoext(),
1020 lib => platform->libext(),
1021 bin => platform->binext() );
1022
1023 # We already have a 'test' target, and the top directory is just plain
1024 # silly
1025 return if $dir eq "test" || $dir eq ".";
1026
1027 foreach my $type (("dso", "lib", "bin", "script")) {
1028 next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type});
1029 # For lib object files, we could update the library. However,
1030 # LIB on Windows doesn't work that way, so we won't create any
1031 # actions for it, and the dependencies are already taken care of.
1032 if ($type ne "lib") {
1033 foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) {
1034 if (dirname($prod) eq $dir) {
1035 push @deps, $prod.$extinfo{$type};
1036 }
1037 }
1038 }
1039 }
1040
1041 my $deps = join(" ", @deps);
1042 my $actions = join("\n", "", @actions);
1043 return <<"EOF";
1044 $dir $dir\\ : $deps$actions
1045 EOF
1046 }
1047 "" # Important! This becomes part of the template result.
1048 -}