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