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