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 $target{build_scheme}->[2] eq "VC-W32" ?
16 "ProgramFiles(x86)" : "ProgramW6432";
18 $target{build_scheme}->[2] eq "VC-W32"
19 ? "CommonProgramFiles(x86)" : "CommonProgramW6432";
20 our $win_installroot =
21 defined($ENV{$win_installenv})
22 ? '%'.$win_installenv.'%' : '%ProgramFiles%';
24 defined($ENV{$win_commonenv})
25 ? '%'.$win_commonenv.'%' : '%CommonProgramFiles%';
28 return () if $disabled{shared};
30 return $unified_info{sharednames}->{$lib} . $shlibext;
34 return () if $disabled{shared};
36 return $lib . $shlibextimport;
42 return $dso . $dsoext;
47 PLATFORM={- $config{target} -}
48 SRCDIR={- $config{sourcedir} -}
49 BLDDIR={- $config{builddir} -}
51 VERSION={- $config{version} -}
52 MAJOR={- $config{major} -}
53 MINOR={- $config{minor} -}
55 SHLIB_VERSION_NUMBER={- $config{shlib_version_number} -}
57 LIBS={- join(" ", map { $_.$libext } @{$unified_info{libraries}}) -}
58 SHLIBS={- join(" ", map { shlib($_) } @{$unified_info{libraries}}) -}
59 ENGINES={- join(" ", map { dso($_) } @{$unified_info{engines}}) -}
60 PROGRAMS={- join(" ", map { $_.$exeext } grep { !m|^test\\| } @{$unified_info{programs}}) -}
61 TESTPROGS={- join(" ", map { $_.$exeext } grep { m|^test\\| } @{$unified_info{programs}}) -}
62 SCRIPTS={- join(" ", @{$unified_info{scripts}}) -}
64 DEPS={- join(" ", map { (my $x = $_) =~ s|\.o$|$depext|; $x; }
65 grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
66 keys %{$unified_info{sources}}); -}
68 # Do not edit these manually. Use Configure with --prefix or --openssldir
69 # to change this! Short explanation in the top comment in Configure
70 INSTALLTOP={- # $prefix is used in the OPENSSLDIR perl snippet
72 our $prefix = $config{prefix} || "$win_installroot\\OpenSSL";
75 # The logic here is that if no --openssldir was given,
76 # OPENSSLDIR will get the value from $prefix plus "/ssl".
77 # If --openssldir was given and the value is an absolute
78 # path, OPENSSLDIR will get its value without change.
79 # If the value from --openssldir is a relative path,
80 # OPENSSLDIR will get $prefix with the --openssldir
81 # value appended as a subdirectory.
83 use File::Spec::Functions;
86 (file_name_is_absolute($config{openssldir}) ?
88 : catdir($prefix, $config{openssldir}))
89 : "$win_commonroot\\SSL";
91 LIBDIR={- our $libdir = $config{libdir} || "lib";
93 ENGINESDIR={- use File::Spec::Functions;
94 our $enginesdir = catdir($prefix,$libdir,"engines");
98 CFLAGS={- join(" ",(map { "-D".$_} @{$target{defines}}, @{$config{defines}})) -} {- join(" ", quotify_l("-DENGINESDIR=\"$enginesdir\"", "-DOPENSSLDIR=\"$openssldir\"")) -} {- $target{cflags} -} {- $config{cflags} -}
99 COUTFLAG={- $target{coutflag} || "/Fo" -}
100 LD={- $target{ld} || "link" -}
101 LDFLAGS={- $target{lflags} -}
102 LDOUTFLAG={- $target{loutflag} || "/out:" -}
103 EX_LIBS={- $target{ex_libs} -}
104 LIB_CFLAGS={- join(" ", $target{lib_cflags}, $target{shared_cflag}) || "" -}
105 LIB_LDFLAGS={- $target{shared_ldflag} || "" -}
106 DSO_CFLAGS={- join(" ", $target{dso_cflags}, $target{shared_cflag}) || "" -}
107 DSO_LDFLAGS={- join(" ", $target{dso_lflags}, $target{shared_ldflag}) || "" -}
108 BIN_CFLAGS={- $target{bin_cflags} -}
109 BIN_LDFLAGS={- $target{bin_lflags} -}
111 PERL={- $config{perl} -}
114 ARFLAGS= {- $target{arflags} -}
115 AROUTFLAG={- $target{aroutflag} || "/out:" -}
118 ASFLAGS={- $target{asflags} -}
119 ASOUTFLAG={- $target{asoutflag} -}
120 PERLASM_SCHEME= {- $target{perlasm_scheme} -}
122 PROCESSOR= {- $config{processor} -}
124 # The main targets ###################################################
126 all: configdata.pm build_libs_nodep build_engines_nodep build_apps_nodep depend
128 build_libs: configdata.pm build_libs_nodep depend
129 build_libs_nodep: $(LIBS)
130 build_engines: configdata.pm build_engines_nodep depend
131 build_engines_nodep: $(ENGINES)
132 build_apps: configdata.pm build_apps_nodep depend
133 build_apps_nodep: $(PROGRAMS) $(SCRIPTS)
134 build_tests: configdata.pm build_tests_nodep depend
135 build_tests_nodep: $(TESTPROGS)
137 test tests: build_tests_nodep build_apps_nodep build_engines_nodep depend
141 $(PERL) $(SRCDIR)\test\run_tests.pl $(TESTS)
146 @$(PERL) $(SRCDIR)\test\run_tests.pl list
148 install: install_sw install_ssldirs install_docs
150 uninstall: uninstall_docs uninstall_sw
153 del /Q /F $(LIBS) $(SHLIBS)
157 del /Q /F $(PROGRAMS) $(TESTPROGS) $(ENGINES) $(SCRIPTS)
163 del /Q /S /F engines\*.ilk
164 del /Q /S /F engines\*.lib
168 # Install helper targets #############################################
170 install_sw: all install_dev install_engines install_runtime
172 uninstall_sw: uninstall_runtime uninstall_engines uninstall_dev
179 @$(PERL) $(SRCDIR)\util\mkdir-p.pl "$(DESTDIR)$(OPENSSLDIR)\certs"
180 @$(PERL) $(SRCDIR)\util\mkdir-p.pl "$(DESTDIR)$(OPENSSLDIR)\private"
183 @if "$(INSTALLTOP)"=="" ( echo INSTALLTOP should not be empty & exit 1 )
184 @echo *** Installing development files
185 @$(PERL) $(SRCDIR)\util\mkdir-p.pl "$(DESTDIR)$(INSTALLTOP)\include\openssl"
186 @$(PERL) $(SRCDIR)\util\copy.pl $(SRCDIR)\include\openssl\*.h \
187 "$(DESTDIR)$(INSTALLTOP)\include\openssl"
188 @$(PERL) $(SRCDIR)\util\copy.pl $(BLDDIR)\include\openssl\*.h \
189 "$(DESTDIR)$(INSTALLTOP)\include\openssl"
190 @$(PERL) $(SRCDIR)\util\mkdir-p.pl "$(DESTDIR)$(INSTALLTOP)\$(LIBDIR)"
191 @$(PERL) $(SRCDIR)\util\copy.pl $(LIBS) \
192 "$(DESTDIR)$(INSTALLTOP)\$(LIBDIR)"
197 @if "$(INSTALLTOP)"=="" ( echo INSTALLTOP should not be empty & exit 1 )
198 @echo *** Installing engines
199 @$(PERL) $(SRCDIR)\util\mkdir-p.pl "$(DESTDIR)$(ENGINESDIR)"
200 @if not "$(ENGINES)"=="" \
201 $(PERL) $(SRCDIR)\util\copy.pl $(ENGINES) "$(DESTDIR)$(ENGINESDIR)"
206 @if "$(INSTALLTOP)"=="" ( echo INSTALLTOP should not be empty & exit 1 )
207 @echo *** Installing runtime files
208 @$(PERL) $(SRCDIR)\util\mkdir-p.pl "$(DESTDIR)$(INSTALLTOP)\bin"
209 @if not "$(SHLIBS)"=="" \
210 $(PERL) $(SRCDIR)\util\copy.pl $(SHLIBS) "$(DESTDIR)$(INSTALLTOP)\bin"
211 @$(PERL) $(SRCDIR)\util\copy.pl $(PROGRAMS) "$(DESTDIR)$(INSTALLTOP)\bin"
215 # Building targets ###################################################
217 configdata.pm: {- $config{build_file_template} -} $(SRCDIR)\Configure
218 @echo "Detected changed: $?"
219 @echo "Reconfiguring..."
220 $(PERL) $(SRCDIR)\Configure reconf
221 @echo "**************************************************"
223 @echo "*** Please run the same make command again ***"
225 @echo "**************************************************"
230 use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
232 # Helper function to figure out dependencies on libraries
233 # It takes a list of library names and outputs a list of dependencies
234 sub compute_lib_depends {
235 if ($disabled{shared}) {
236 return map { $_.$libext } @_;
238 return map { shlib_import($_) } @_;
243 (my $target = $args{src}) =~ s/\.[sS]$/.asm/;
244 my $generator = join(" ", @{$args{generator}});
245 my $incs = join("", map { " /I ".$_ } @{$args{incs}});
246 my $deps = join(" ", @{$args{deps}});
248 if ($target !~ /\.asm$/) {
250 $target: $args{generator}->[0] $deps
251 \$(PERL) $generator > \$@
254 if ($args{generator}->[0] =~ /\.pl$/) {
255 $generator = '$(PERL) '.$generator;
256 } elsif ($args{generator}->[0] =~ /\.S$/) {
259 die "Generator type for $src unknown: $generator\n";
262 if (defined($generator)) {
263 # If the target is named foo.S in build.info, we want to
264 # end up generating foo.s in two steps.
265 if ($args{src} =~ /\.S$/) {
267 $target: $args{generator}->[0] $deps
271 \$(CC) \$(CFLAGS) $incs /EP /C \$@.S > \$@
277 $target: $args{generator}->[0] $deps
284 $target: $args{generator}->[0] $deps
285 \$(CC) \$(CFLAGS) $incs /EP /C \$< > \$@
292 my $obj = $args{obj};
293 my @srcs = map { if ($unified_info{generate}->{$_}) {
294 (my $x = $_) =~ s/\.[sS]$/.asm/; $x
298 } ( @{$args{srcs}} );
299 my $srcs = join(" ", @srcs);
300 my $deps = join(" ", @srcs, @{$args{deps}});
301 my $incs = join("", map { " /I ".$_ } @{$args{incs}});
302 my $ecflags = { lib => '$(LIB_CFLAGS)',
303 dso => '$(DSO_CFLAGS)',
304 bin => '$(BIN_CFLAGS)' } -> {$args{intent}};
305 my $makedepprog = $config{makedepprog};
306 if ($srcs[0] =~ /\.asm$/) {
309 \$(AS) \$(ASFLAGS) \$(ASOUTFLAG)\$\@ $srcs
314 \$(CC) \$(CFLAGS) $ecflags$inc /Zs /showIncludes $srcs 2>&1 | \\
315 \$(PERL) -n << > $obj$depext
317 s/^Note: including file: *//;
318 \$\$collect{\$\$_} = 1;
319 END { print '$obj$objext: ',join(" ", sort keys \%collect),"\\n" }
321 $obj$objext: $obj$depext
322 \$(CC) \$(CFLAGS) $ecflags$incs -c \$(COUTFLAG)\$\@ @<<
328 # On Unix, we build shlibs from static libs, so we're ignoring the
329 # object file array. We *know* this routine is only called when we've
330 # configure 'shared'.
333 my $lib = $args{lib};
334 my $shlib = $args{shlib};
335 (my $mkdef_key = $lib) =~ s/^lib//i;
336 my $objs = join("\n", map { $_.$objext } @{$args{objs}});
337 my $linklibs = join("",
338 map { "\n$_" } compute_lib_depends(@{$args{deps}}));
340 (map { $_.$objext } @{$args{objs}}),
341 compute_lib_depends(@{$args{deps}}));
342 my $ordinalsfile = defined($args{ordinals}) ? $args{ordinals}->[1] : "";
343 my $mkdef_pl = abs2rel(rel2abs(catfile($config{sourcedir},
344 "util", "mkdef.pl")),
345 rel2abs($config{builddir}));
346 my $target = shlib_import($lib);
348 $target: $deps $ordinalsfile $mkdef_pl
349 \$(PERL) $mkdef_pl "$mkdef_key" 32 > $shlib.def
350 \$(PERL) -i.tmp -pe "s|^LIBRARY\\s+${mkdef_key}32|LIBRARY $shlib|;" $shlib.def
352 \$(LD) \$(LDFLAGS) \$(LIB_LDFLAGS) \\
353 /implib:$target \$(LDOUTFLAG)$shlib$shlibext /def:$shlib.def @<<
354 $objs$linklibs \$(EX_LIBS)
356 DEL /F apps\\$shlib$shlibext
357 DEL /F test\\$shlib$shlibext
358 COPY $shlib$shlibext apps
359 COPY $shlib$shlibext test
364 my $dso = $args{lib};
365 my $dso_n = basename($dso);
366 my $objs = join("\n", map { $_.$objext } @{$args{objs}});
367 my $linklibs = join("",
368 map { "\n$_" } compute_lib_depends(@{$args{deps}}));
370 (map { $_.$objext } @{$args{objs}}),
371 compute_lib_depends(@{$args{deps}}));
374 \$(LD) \$(LDFLAGS) \$(DSO_LDFLAGS) \$(LDOUTFLAG)$dso$dsoext /def:<< @<<
380 $objs$linklibs \$(EX_LIBS)
385 # Because static libs and import libs are both named the same in native
386 # Windows, we can't have both. We skip the static lib in that case,
387 # as the shared libs are what we use anyway.
388 return "" unless $disabled{"shared"};
391 my $lib = $args{lib};
392 my $objs = join("\n", map { $_.$objext } @{$args{objs}});
393 my $deps = join(" ", map { $_.$objext } @{$args{objs}});
396 \$(AR) \$(ARFLAGS) \$(AROUTFLAG)$lib$libext @<<
403 my $bin = $args{bin};
404 my $objs = join("\n", map { $_.$objext } @{$args{objs}});
405 my $linklibs = join("",
406 map { "\n$_" } compute_lib_depends(@{$args{deps}}));
408 (map { $_.$objext } @{$args{objs}}),
409 compute_lib_depends(@{$args{deps}}));
412 \$(LD) \$(LDFLAGS) \$(BIN_LDFLAGS) \$(LDOUTFLAG)$bin$exeext @<<
413 $objs setargv.obj$linklibs \$(EX_LIBS)
419 my $script = $args{script};
420 my $sources = join(" ", @{$args{sources}});
421 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
422 "util", "dofile.pl")),
423 rel2abs($config{builddir}));
426 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
427 "-o$target{build_file}" $sources > "$script"
430 "" # Important! This becomes part of the template result.