2 ## Makefile for OpenSSL
4 ## {- join("\n## ", @autowarntext) -}
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";
15 return () if $disabled{shared};
17 return $unified_info{sharednames}->{$lib} . $shlibext;
21 return () if $disabled{shared};
23 return $lib . $shlibextimport;
29 return $dso . $dsoext;
34 PLATFORM={- $config{target} -}
35 SRCDIR={- $config{sourcedir} -}
36 BLDDIR={- $config{builddir} -}
38 VERSION={- $config{version} -}
39 MAJOR={- $config{major} -}
40 MINOR={- $config{minor} -}
42 SHLIB_VERSION_NUMBER={- $config{shlib_version_number} -}
44 LIBS={- join(" ", map { $_.$libext } @{$unified_info{libraries}}) -}
45 SHLIBS={- join(" ", map { shlib($_) } @{$unified_info{libraries}}) -}
46 ENGINES={- join(" ", map { dso($_) } @{$unified_info{engines}}) -}
47 PROGRAMS={- join(" ", map { $_.$exeext } grep { !m|^test\\| } @{$unified_info{programs}}) -}
48 TESTPROGS={- join(" ", map { $_.$exeext } grep { m|^test\\| } @{$unified_info{programs}}) -}
49 SCRIPTS={- join(" ", @{$unified_info{scripts}}) -}
51 DEPS={- join(" ", map { (my $x = $_) =~ s|\.o$|$depext|; $x; }
52 grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
53 keys %{$unified_info{sources}}); -}
55 # Do not edit these manually. Use Configure with --prefix or --openssldir
56 # to change this! Short explanation in the top comment in Configure
57 INSTALLTOP={- # $prefix is used in the OPENSSLDIR perl snippet
59 our $prefix = $config{prefix} || "/usr/local";
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.
70 use File::Spec::Functions;
73 (file_name_is_absolute($config{openssldir}) ?
75 : catdir($prefix, $config{openssldir}))
76 : catdir($prefix, "ssl");
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...
84 -d "$prefix/lib$target{multilib}" ? $target{multilib} : "";
85 our $libdir = $config{libdir} || "lib$multilib";
87 ENGINESDIR={- use File::Spec::Functions;
88 our $enginesdir = catdir($prefix,$libdir,"engines");
92 CFLAGS={- join(" ",(map { "-D".$_} @{$target{defines}}, @{$config{defines}})) -} {- join(" ", quotify_l("-DENGINESDIR=\"$enginesdir\"", "-DOPENSSLDIR=\"$openssldir\"")) -} {- $target{cflags} -} {- $config{cflags} -}
93 COUTFLAG={- $target{coutflag} || "/Fo" -}
94 LD={- $target{ld} || "link" -}
95 LDFLAGS={- $target{lflags} -}
96 LDOUTFLAG={- $target{loutflag} || "/out:" -}
97 EX_LIBS={- $target{ex_libs} -}
98 LIB_CFLAGS={- join(" ", $target{lib_cflags}, $target{shared_cflag}) || "" -}
99 LIB_LDFLAGS={- $target{shared_ldflag} || "" -}
100 DSO_CFLAGS={- join(" ", $target{dso_cflags}, $target{shared_cflag}) || "" -}
101 DSO_LDFLAGS={- join(" ", $target{dso_lflags}, $target{shared_ldflag}) || "" -}
102 BIN_CFLAGS={- $target{bin_cflags} -}
103 BIN_LDFLAGS={- $target{bin_lflags} -}
105 PERL={- $config{perl} -}
108 ARFLAGS= {- $target{arflags} -}
109 AROUTFLAG={- $target{aroutflag} || "/out:" -}
112 ASFLAGS={- $target{asflags} -}
113 ASOUTFLAG={- $target{asoutflag} -}
114 PERLASM_SCHEME= {- $target{perlasm_scheme} -}
116 PROCESSOR= {- $config{processor} -}
118 # The main targets ###################################################
120 all: configdata.pm build_libs_nodep build_engines_nodep build_apps_nodep depend
122 build_libs: configdata.pm build_libs_nodep depend
123 build_libs_nodep: $(LIBS)
124 build_engines: configdata.pm build_engines_nodep depend
125 build_engines_nodep: $(ENGINES)
126 build_apps: configdata.pm build_apps_nodep depend
127 build_apps_nodep: $(PROGRAMS) $(SCRIPTS)
128 build_tests: configdata.pm build_tests_nodep depend
129 build_tests_nodep: $(TESTPROGS)
131 test tests: build_tests_nodep build_apps_nodep build_engines_nodep depend
135 $(PERL) $(SRCDIR)\test\run_tests.pl $(TESTS)
140 @$(PERL) $(SRCDIR)\test\run_tests.pl list
143 del /Q /F $(LIBS) $(SHLIBS)
147 del /Q /F $(PROGRAMS) $(TESTPROGS) $(ENGINES) $(SCRIPTS)
153 del /Q /S /F engines\*.ilk
154 del /Q /S /F engines\*.lib
158 # Building targets ###################################################
160 configdata.pm: {- $config{build_file_template} -} $(SRCDIR)\Configure
161 @echo "Detected changed: $?"
162 @echo "Reconfiguring..."
163 $(PERL) $(SRCDIR)\Configure reconf
164 @echo "**************************************************"
166 @echo "*** Please run the same make command again ***"
168 @echo "**************************************************"
173 use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
175 # Helper function to figure out dependencies on libraries
176 # It takes a list of library names and outputs a list of dependencies
177 sub compute_lib_depends {
178 if ($disabled{shared}) {
179 return map { $_.$libext } @_;
181 return map { shlib_import($_) } @_;
186 (my $target = $args{src}) =~ s/\.[sS]$/.asm/;
187 my $generator = join(" ", @{$args{generator}});
188 my $incs = join("", map { " /I ".$_ } @{$args{incs}});
190 if ($target !~ /\.asm$/) {
192 $target: $args{generator}->[0]
193 \$(PERL) $generator > \$@
196 if ($args{generator}->[0] =~ /\.pl$/) {
197 $generator = '$(PERL) '.$generator;
198 } elsif ($args{generator}->[0] =~ /\.S$/) {
201 die "Generator type for $src unknown: $generator\n";
204 if (defined($generator)) {
205 # If the target is named foo.S in build.info, we want to
206 # end up generating foo.s in two steps.
207 if ($args{src} =~ /\.S$/) {
209 $target: $args{generator}->[0]
213 \$(CC) \$(CFLAGS) $incs /EP /C \$@.S > \$@
219 $target: $args{generator}->[0]
226 $target: $args{generator}->[0]
227 \$(CC) \$(CFLAGS) $incs /EP /C \$< > \$@
234 my $obj = $args{obj};
235 my @srcs = map { (my $x = $_) =~ s/\.[sS]$/.asm/; $x } ( @{$args{srcs}} );
236 my $srcs = join(" ", @srcs);
237 my $deps = join(" ", @srcs, @{$args{deps}});
238 my $incs = join("", map { " /I ".$_ } @{$args{incs}});
239 my $ecflags = { lib => '$(LIB_CFLAGS)',
240 dso => '$(DSO_CFLAGS)',
241 bin => '$(BIN_CFLAGS)' } -> {$args{intent}};
242 my $makedepprog = $config{makedepprog};
243 if ($srcs[0] =~ /\.asm$/) {
246 \$(AS) \$(ASFLAGS) \$(ASOUTFLAG)\$\@ $srcs
251 \$(CC) \$(CFLAGS) $ecflags$inc /Zs /showIncludes $srcs 2>&1 | \\
252 \$(PERL) -n << > $obj$depext
254 s/^Note: including file: *//;
255 \$\$collect{\$\$_} = 1;
256 END { print '$obj$objext: ',join(" ", sort keys \%collect),"\\n" }
258 $obj$objext: $obj$depext
259 \$(CC) \$(CFLAGS) $ecflags$incs -c \$(COUTFLAG)\$\@ @<<
265 # On Unix, we build shlibs from static libs, so we're ignoring the
266 # object file array. We *know* this routine is only called when we've
267 # configure 'shared'.
270 my $lib = $args{lib};
271 my $shlib = $args{shlib};
272 (my $mkdef_key = $lib) =~ s/^lib//i;
273 my $objs = join("\n", map { $_.$objext } @{$args{objs}});
274 my $linklibs = join("",
275 map { "\n$_" } compute_lib_depends(@{$args{deps}}));
277 (map { $_.$objext } @{$args{objs}}),
278 compute_lib_depends(@{$args{deps}}));
279 my $ordinalsfile = defined($args{ordinals}) ? $args{ordinals}->[1] : "";
280 my $mkdef_pl = abs2rel(rel2abs(catfile($config{sourcedir},
281 "util", "mkdef.pl")),
282 rel2abs($config{builddir}));
283 my $target = shlib_import($lib);
285 $target: $deps $ordinalsfile
286 \$(PERL) $mkdef_pl "$mkdef_key" 32 > $shlib.def
287 \$(LD) \$(LDFLAGS) \$(LIB_LDFLAGS) \\
288 /implib:$target \$(LDOUTFLAG)$shlib$shlibext /def:$shlib.def @<<
289 $objs$linklibs \$(EX_LIBS)
295 my $dso = $args{lib};
296 my $dso_n = basename($dso);
297 my $objs = join("\n", map { $_.$objext } @{$args{objs}});
298 my $linklibs = join("",
299 map { "\n$_" } compute_lib_depends(@{$args{deps}}));
301 (map { $_.$objext } @{$args{objs}}),
302 compute_lib_depends(@{$args{deps}}));
305 \$(LD) \$(LDFLAGS) \$(DSO_LDFLAGS) \$(LDOUTFLAG)$dso$dsoext /def:<< @<<
311 $objs$linklibs \$(EX_LIBS)
316 # Because static libs and import libs are both named the same in native
317 # Windows, we can't have both. We skip the static lib in that case,
318 # as the shared libs are what we use anyway.
319 return "" unless $disabled{"shared"};
322 my $lib = $args{lib};
323 my $objs = join("\n", map { $_.$objext } @{$args{objs}});
324 my $deps = join(" ", map { $_.$objext } @{$args{objs}});
327 \$(AR) \$(ARFLAGS) \$(AROUTFLAG)$lib$libext @<<
334 my $bin = $args{bin};
335 my $objs = join("\n", map { $_.$objext } @{$args{objs}});
336 my $linklibs = join("",
337 map { "\n$_" } compute_lib_depends(@{$args{deps}}));
339 (map { $_.$objext } @{$args{objs}}),
340 compute_lib_depends(@{$args{deps}}));
343 \$(LD) \$(LDFLAGS) \$(BIN_LDFLAGS) \$(LDOUTFLAG)$bin$exeext @<<
344 $objs setargv.obj$linklibs \$(EX_LIBS)
350 my $script = $args{script};
351 my $sources = join(" ", @{$args{sources}});
352 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
353 "util", "dofile.pl")),
354 rel2abs($config{builddir}));
357 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
358 "-o$target{build_file}" $sources > "$script"
361 "" # Important! This becomes part of the template result.