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