Debian Codegraph @

debian/rust-vendor/openssl-src/openssl/Configurations/windows-makefile.tmpl

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