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