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