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