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