]> git.ipfire.org Git - thirdparty/openssl.git/blame - Configurations/windows-makefile.tmpl
Make util/mk1mf.pl recognise no-weak-ssl-ciphers
[thirdparty/openssl.git] / Configurations / windows-makefile.tmpl
CommitLineData
7c0e1aa6
RL
1##
2## Makefile for OpenSSL
3##
4## {- join("\n## ", @autowarntext) -}
5{-
6 our $objext = $target{obj_extension} || ".obj";
7 our $depext = $target{dep_extension} || ".d";
8 our $exeext = $target{exe_extension} || ".exe";
9 our $libext = $target{lib_extension} || ".lib";
10 our $shlibext = $target{shared_extension} || ".dll";
11 our $shlibextimport = $target{shared_import_extension} || ".lib";
12 our $dsoext = $target{dso_extension} || ".dll";
13
14 sub shlib {
15 return () if $disabled{shared};
16 my $lib = shift;
17 return $unified_info{sharednames}->{$lib} . $shlibext;
18 }
19
20 sub shlib_import {
21 return () if $disabled{shared};
22 my $lib = shift;
23 return $lib . $shlibextimport;
24 }
25
26 sub dso {
27 my $dso = shift;
28
29 return $dso . $dsoext;
30 }
31 '';
32-}
33
34PLATFORM={- $config{target} -}
35SRCDIR={- $config{sourcedir} -}
36BLDDIR={- $config{builddir} -}
37
38VERSION={- $config{version} -}
39MAJOR={- $config{major} -}
40MINOR={- $config{minor} -}
41
42SHLIB_VERSION_NUMBER={- $config{shlib_version_number} -}
43
44LIBS={- join(" ", map { $_.$libext } @{$unified_info{libraries}}) -}
45SHLIBS={- join(" ", map { shlib($_) } @{$unified_info{libraries}}) -}
46ENGINES={- join(" ", map { dso($_) } @{$unified_info{engines}}) -}
47PROGRAMS={- join(" ", map { $_.$exeext } grep { !m|^test\\| } @{$unified_info{programs}}) -}
48TESTPROGS={- join(" ", map { $_.$exeext } grep { m|^test\\| } @{$unified_info{programs}}) -}
49SCRIPTS={- join(" ", @{$unified_info{scripts}}) -}
50
51DEPS={- join(" ", map { (my $x = $_) =~ s|\.o$|$depext|; $x; }
52 grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
53 keys %{$unified_info{sources}}); -}
54
55# Do not edit these manually. Use Configure with --prefix or --openssldir
56# to change this! Short explanation in the top comment in Configure
57INSTALLTOP={- # $prefix is used in the OPENSSLDIR perl snippet
58 #
59 our $prefix = $config{prefix} || "/usr/local";
60 $prefix -}
61OPENSSLDIR={- #
62 # The logic here is that if no --openssldir was given,
63 # OPENSSLDIR will get the value from $prefix plus "/ssl".
64 # If --openssldir was given and the value is an absolute
65 # path, OPENSSLDIR will get its value without change.
66 # If the value from --openssldir is a relative path,
67 # OPENSSLDIR will get $prefix with the --openssldir
68 # value appended as a subdirectory.
69 #
70 use File::Spec::Functions;
71 our $openssldir =
72 $config{openssldir} ?
73 (file_name_is_absolute($config{openssldir}) ?
74 $config{openssldir}
75 : catdir($prefix, $config{openssldir}))
76 : catdir($prefix, "ssl");
77 $openssldir -}
78LIBDIR={- #
79 # if $prefix/lib$target{multilib} is not an existing
80 # directory, then assume that it's not searched by linker
81 # automatically, in which case adding $target{multilib} suffix
82 # causes more grief than we're ready to tolerate, so don't...
83 our $multilib =
84 -d "$prefix/lib$target{multilib}" ? $target{multilib} : "";
85 our $libdir = $config{libdir} || "lib$multilib";
86 $libdir -}
87ENGINESDIR={- use File::Spec::Functions;
88 our $enginesdir = catdir($prefix,$libdir,"engines");
89 $enginesdir -}
90
91CC={- $target{cc} -}
92CFLAGS={- join(" ",(map { "-D".$_} @{$target{defines}}, @{$config{defines}})) -} {- join(" ", quotify_l("-DENGINESDIR=\"$enginesdir\"", "-DOPENSSLDIR=\"$openssldir\"")) -} {- $target{cflags} -} {- $config{cflags} -}
93COUTFLAG={- $target{coutflag} || "/Fo" -}
94LD={- $target{ld} || "link" -}
95LDFLAGS={- $target{lflags} -}
96LDOUTFLAG={- $target{loutflag} || "/out:" -}
2fe73036
RL
97EX_LIBS={- $target{ex_libs} -}
98LIB_CFLAGS={- join(" ", $target{lib_cflags}, $target{shared_cflag}) || "" -}
7c0e1aa6 99SHARED_LDFLAGS={- $target{shared_ldflag} || "" -}
2fe73036
RL
100DSO_CFLAGS={- join(" ", $target{dso_cflags}, $target{shared_cflag}) || "" -}
101DSO_LDFLAGS={- join(" ", $target{dso_lflags}, $target{shared_ldflag}) || "" -}
7c0e1aa6 102BIN_CFLAGS={- $target{bin_cflags} -}
2fe73036 103BIN_LDFLAGS={- $target{bin_lflags} -}
7c0e1aa6
RL
104
105PERL={- $config{perl} -}
106
107AR={- $target{ar} -}
108ARFLAGS= {- $target{arflags} -}
109AROUTFLAG={- $target{aroutflag} || "/out:" -}
110
111AS={- $target{as} -}
112ASFLAGS={- $target{asflags} -}
113ASOUTFLAG={- $target{asoutflag} -}
114PERLASM_SCHEME= {- $target{perlasm_scheme} -}
115
116PROCESSOR= {- $config{processor} -}
117
118# The main targets ###################################################
119
2fe73036 120all: configdata.pm build_libs_nodep build_engines_nodep build_apps_nodep depend
7c0e1aa6
RL
121
122build_libs: configdata.pm build_libs_nodep depend
123build_libs_nodep: $(LIBS)
124build_engines: configdata.pm build_engines_nodep depend
125build_engines_nodep: $(ENGINES)
126build_apps: configdata.pm build_apps_nodep depend
127build_apps_nodep: $(PROGRAMS) $(SCRIPTS)
128build_tests: configdata.pm build_tests_nodep depend
129build_tests_nodep: $(TESTPROGS)
130
2fe73036 131test tests: build_tests_nodep build_apps_nodep build_engines_nodep depend
7c0e1aa6
RL
132 set SRCTOP=$(SRCDIR)
133 set BLDTOP=$(BLDDIR)
134 set PERL=$(PERL)
135 $(PERL) $(SRCDIR)\test\run_tests.pl $(TESTS)
136
137list-tests:
138 @set TOP=$(SRCDIR)
139 @set PERL=$(PERL)
140 @$(PERL) $(SRCDIR)\test\run_tests.pl list
141
142depend:
143
144# Building targets ###################################################
145
146configdata.pm: {- $config{build_file_template} -} $(SRCDIR)\Configure
147 @echo "Detected changed: $?"
148 @echo "Reconfiguring..."
149 $(PERL) $(SRCDIR)\Configure reconf
150 @echo "**************************************************"
151 @echo "*** ***"
152 @echo "*** Please run the same make command again ***"
153 @echo "*** ***"
154 @echo "**************************************************"
155 @( exit 1 )
156
157{-
158 use File::Basename;
159 use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
160
161 # Helper function to figure out dependencies on libraries
162 # It takes a list of library names and outputs a list of dependencies
163 sub compute_lib_depends {
164 if ($disabled{shared}) {
165 return map { $_.$libext } @_;
166 }
167 return map { shlib_import($_) } @_;
168 }
169
9a1394c5
RL
170 sub generatesrc {
171 my %args = @_;
172 (my $target = $args{src}) =~ s/\.[sS]$/.asm/;
173 my $generator = join(" ", @{$args{generator}});
174
175 if ($target !~ /\.asm$/) {
176 return <<"EOF";
177$target: $args{generator}->[0]
178 \$(PERL) $generator > \$@
179EOF
180 } else {
181 if ($args{generator}->[0] =~ /\.pl$/) {
182 $generator = '$(PERL) '.$generator;
183 } elsif ($args{generator}->[0] =~ /\.S$/) {
184 $generator = undef;
185 } else {
186 die "Generator type for $src unknown: $generator\n";
187 }
188
189 if (defined($generator)) {
190 # If the target is named foo.S in build.info, we want to
191 # end up generating foo.s in two steps.
192 if ($args{src} =~ /\.S$/) {
193 return <<"EOF";
194$target: $args{generator}->[0]
195 set ASM=\$(AS)
196 set CC=\$(CC)
197 $generator \$@.S
198 \$(CC) \$(CFLAGS) /EP /C \$@.S > \$@
199 del /Q \$@.S
200EOF
201 }
202 # Otherwise....
203 return <<"EOF";
204$target: $args{generator}->[0]
205 set ASM=\$(AS)
206 set CC=\$(CC)
207 $generator \$@
208EOF
209 }
210 return <<"EOF";
211$target: $args{generator}->[0]
212 \$(CC) \$(CFLAGS) /EP /C \$< > \$@
213EOF
214 }
215 }
216
7c0e1aa6
RL
217 sub src2obj {
218 my %args = @_;
219 my $obj = $args{obj};
220 my @srcs = map { (my $x = $_) =~ s/\.[sS]$/.asm/; $x } ( @{$args{srcs}} );
221 my $srcs = join(" ", @srcs);
222 my $deps = join(" ", @srcs, @{$args{deps}});
223 my $incs = join("", map { " /I ".$_ } @{$args{incs}});
2fe73036 224 my $ecflags = { lib => '$(LIB_CFLAGS)',
7c0e1aa6
RL
225 dso => '$(DSO_CFLAGS)',
226 bin => '$(BIN_CFLAGS)' } -> {$args{intent}};
227 my $makedepprog = $config{makedepprog};
228 if ($srcs[0] =~ /\.asm$/) {
229 return <<"EOF";
230$obj$objext: $deps
231 \$(AS) \$(ASFLAGS) \$(ASOUTFLAG)\$\@ $srcs
232EOF
233 }
234 return <<"EOF";
235$obj$depext: $deps
236 \$(CC) \$(CFLAGS) $ecflags$inc /Zs /showIncludes $srcs 2>&1 | \\
237 \$(PERL) -n << > $obj$depext
238chomp;
239s/^Note: including file: *//;
240\$\$collect{\$\$_} = 1;
241END { print '$obj$objext: ',join(" ", sort keys \%collect),"\\n" }
242<<KEEP
243$obj$objext: $obj$depext
244 \$(CC) \$(CFLAGS) $ecflags$incs -c \$(COUTFLAG)\$\@ @<<
245$srcs
246<<KEEP
247EOF
248 }
249
250 # On Unix, we build shlibs from static libs, so we're ignoring the
251 # object file array. We *know* this routine is only called when we've
252 # configure 'shared'.
253 sub libobj2shlib {
254 my %args = @_;
255 my $lib = $args{lib};
256 my $shlib = $args{shlib};
257 (my $mkdef_key = $lib) =~ s/^lib//i;
258 my $objs = join("\n", map { $_.$objext } @{$args{objs}});
259 my $linklibs = join("",
260 map { "\n$_" } compute_lib_depends(@{$args{deps}}));
261 my $deps = join(" ",
262 (map { $_.$objext } @{$args{objs}}),
263 compute_lib_depends(@{$args{deps}}));
264 my $ordinalsfile = defined($args{ordinals}) ? $args{ordinals}->[1] : "";
265 my $mkdef_pl = abs2rel(rel2abs(catfile($config{sourcedir},
266 "util", "mkdef.pl")),
267 rel2abs($config{builddir}));
268 my $target = shlib_import($lib);
269 return <<"EOF"
270$target: $deps $ordinalsfile
271 \$(PERL) $mkdef_pl "$mkdef_key" 32 > $shlib.def
2fe73036
RL
272 \$(LD) \$(LDFLAGS) \$(SHARED_LDFLAGS) \\
273 /implib:$target \$(LDOUTFLAG)$shlib$shlibext /def:$shlib.def @<<
7c0e1aa6
RL
274$objs$linklibs \$(EX_LIBS)
275<<
276EOF
277 }
278 sub obj2dso {
279 my %args = @_;
280 my $dso = $args{lib};
2fe73036 281 my $dso_n = basename($dso);
7c0e1aa6
RL
282 my $objs = join("\n", map { $_.$objext } @{$args{objs}});
283 my $linklibs = join("",
284 map { "\n$_" } compute_lib_depends(@{$args{deps}}));
285 my $deps = join(" ",
286 (map { $_.$objext } @{$args{objs}}),
287 compute_lib_depends(@{$args{deps}}));
288 return <<"EOF";
289$dso$dsoext: $deps
2fe73036
RL
290 \$(LD) \$(LDFLAGS) \$(DSO_LDFLAGS) \$(LDOUTFLAG)$dso$dsoext /def:<< @<<
291LIBRARY $dso_n
7c0e1aa6
RL
292EXPORTS
293 bind_engine @1
294 v_check @2
295<<
296$objs$linklibs \$(EX_LIBS)
297<<
298EOF
299 }
300 sub obj2lib {
301 my %args = @_;
302 my $lib = $args{lib};
303 my $objs = join("\n", map { $_.$objext } @{$args{objs}});
304 my $deps = join(" ", map { $_.$objext } @{$args{objs}});
305 return <<"EOF";
306$lib$libext: $deps
307 \$(AR) \$(ARFLAGS) \$(AROUTFLAG)$lib$libext @<<
308$objs
309<<
310EOF
311 }
312 sub obj2bin {
313 my %args = @_;
314 my $bin = $args{bin};
315 my $objs = join("\n", map { $_.$objext } @{$args{objs}});
316 my $linklibs = join("",
317 map { "\n$_" } compute_lib_depends(@{$args{deps}}));
318 my $deps = join(" ",
319 (map { $_.$objext } @{$args{objs}}),
320 compute_lib_depends(@{$args{deps}}));
321 return <<"EOF";
322$bin$exeext: $deps
2fe73036 323 \$(LD) \$(LDFLAGS) \$(BIN_LDFLAGS) \$(LDOUTFLAG)$bin$exeext @<<
7c0e1aa6
RL
324$objs setargv.obj$linklibs \$(EX_LIBS)
325<<
326EOF
327 }
328 sub in2script {
329 my %args = @_;
330 my $script = $args{script};
331 my $sources = join(" ", @{$args{sources}});
332 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
333 "util", "dofile.pl")),
334 rel2abs($config{builddir}));
335 return <<"EOF";
336$script: $sources
337 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
338 "-o$target{build_file}" $sources > "$script"
339EOF
340 }
341 "" # Important! This becomes part of the template result.
342-}