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