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 RC={- $target{rc} || "rc" -}
101 RCOUTFLAG={- $target{rcoutflag} || "/fo" -}
102 LD={- $target{ld} || "link" -}
103 LDFLAGS={- $target{lflags} -}
104 LDOUTFLAG={- $target{loutflag} || "/out:" -}
105 EX_LIBS={- $target{ex_libs} -}
106 LIB_CFLAGS={- join(" ", $target{lib_cflags}, $target{shared_cflag}) || "" -}
107 LIB_LDFLAGS={- $target{shared_ldflag} || "" -}
108 DSO_CFLAGS={- join(" ", $target{dso_cflags}, $target{shared_cflag}) || "" -}
109 DSO_LDFLAGS={- join(" ", $target{dso_lflags}, $target{shared_ldflag}) || "" -}
110 BIN_CFLAGS={- $target{bin_cflags} -}
111 BIN_LDFLAGS={- $target{bin_lflags} -}
113 PERL={- $config{perl} -}
116 ARFLAGS= {- $target{arflags} -}
117 AROUTFLAG={- $target{aroutflag} || "/out:" -}
120 ASFLAGS={- $target{asflags} -}
121 ASOUTFLAG={- $target{asoutflag} -}
122 PERLASM_SCHEME= {- $target{perlasm_scheme} -}
124 PROCESSOR= {- $config{processor} -}
126 # The main targets ###################################################
128 all: configdata.pm build_libs_nodep build_engines_nodep build_apps_nodep depend
130 build_libs: configdata.pm build_libs_nodep depend
131 build_libs_nodep: $(LIBS)
132 build_engines: configdata.pm build_engines_nodep depend
133 build_engines_nodep: $(ENGINES)
134 build_apps: configdata.pm build_apps_nodep depend
135 build_apps_nodep: $(PROGRAMS) $(SCRIPTS)
136 build_tests: configdata.pm build_tests_nodep depend
137 build_tests_nodep: $(TESTPROGS)
139 test tests: build_tests_nodep build_apps_nodep build_engines_nodep depend
143 $(PERL) $(SRCDIR)\test\run_tests.pl $(TESTS)
148 @$(PERL) $(SRCDIR)\test\run_tests.pl list
150 install: install_sw install_ssldirs install_docs
152 uninstall: uninstall_docs uninstall_sw
155 del /Q /F $(LIBS) $(SHLIBS)
159 del /Q /F $(PROGRAMS) $(TESTPROGS) $(ENGINES) $(SCRIPTS)
165 del /Q /S /F engines\*.ilk
166 del /Q /S /F engines\*.lib
170 # Install helper targets #############################################
172 install_sw: all install_dev install_engines install_runtime
174 uninstall_sw: uninstall_runtime uninstall_engines uninstall_dev
181 @$(PERL) $(SRCDIR)\util\mkdir-p.pl "$(DESTDIR)$(OPENSSLDIR)\certs"
182 @$(PERL) $(SRCDIR)\util\mkdir-p.pl "$(DESTDIR)$(OPENSSLDIR)\private"
185 @if "$(INSTALLTOP)"=="" ( echo INSTALLTOP should not be empty & exit 1 )
186 @echo *** Installing development files
187 @$(PERL) $(SRCDIR)\util\mkdir-p.pl "$(DESTDIR)$(INSTALLTOP)\include\openssl"
188 @$(PERL) $(SRCDIR)\util\copy.pl $(SRCDIR)\include\openssl\*.h \
189 "$(DESTDIR)$(INSTALLTOP)\include\openssl"
190 @$(PERL) $(SRCDIR)\util\copy.pl $(BLDDIR)\include\openssl\*.h \
191 "$(DESTDIR)$(INSTALLTOP)\include\openssl"
192 @$(PERL) $(SRCDIR)\util\mkdir-p.pl "$(DESTDIR)$(INSTALLTOP)\$(LIBDIR)"
193 @$(PERL) $(SRCDIR)\util\copy.pl $(LIBS) \
194 "$(DESTDIR)$(INSTALLTOP)\$(LIBDIR)"
199 @if "$(INSTALLTOP)"=="" ( echo INSTALLTOP should not be empty & exit 1 )
200 @echo *** Installing engines
201 @$(PERL) $(SRCDIR)\util\mkdir-p.pl "$(DESTDIR)$(ENGINESDIR)"
202 @if not "$(ENGINES)"=="" \
203 $(PERL) $(SRCDIR)\util\copy.pl $(ENGINES) "$(DESTDIR)$(ENGINESDIR)"
208 @if "$(INSTALLTOP)"=="" ( echo INSTALLTOP should not be empty & exit 1 )
209 @echo *** Installing runtime files
210 @$(PERL) $(SRCDIR)\util\mkdir-p.pl "$(DESTDIR)$(INSTALLTOP)\bin"
211 @if not "$(SHLIBS)"=="" \
212 $(PERL) $(SRCDIR)\util\copy.pl $(SHLIBS) "$(DESTDIR)$(INSTALLTOP)\bin"
213 @$(PERL) $(SRCDIR)\util\copy.pl $(PROGRAMS) "$(DESTDIR)$(INSTALLTOP)\bin"
217 # Building targets ###################################################
219 configdata.pm: {- $config{build_file_template} -} $(SRCDIR)\Configure
220 @echo "Detected changed: $?"
221 @echo "Reconfiguring..."
222 $(PERL) $(SRCDIR)\Configure reconf
223 @echo "**************************************************"
225 @echo "*** Please run the same make command again ***"
227 @echo "**************************************************"
232 use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
234 # Helper function to figure out dependencies on libraries
235 # It takes a list of library names and outputs a list of dependencies
236 sub compute_lib_depends {
237 if ($disabled{shared}) {
238 return map { $_.$libext } @_;
240 return map { shlib_import($_) } @_;
245 (my $target = $args{src}) =~ s/\.[sS]$/.asm/;
246 my $generator = join(" ", @{$args{generator}});
247 my $incs = join("", map { " /I ".$_ } @{$args{incs}});
248 my $deps = join(" ", @{$args{deps}});
250 if ($target !~ /\.asm$/) {
252 $target: $args{generator}->[0] $deps
253 \$(PERL) $generator > \$@
256 if ($args{generator}->[0] =~ /\.pl$/) {
257 $generator = '$(PERL) '.$generator;
258 } elsif ($args{generator}->[0] =~ /\.S$/) {
261 die "Generator type for $src unknown: $generator\n";
264 if (defined($generator)) {
265 # If the target is named foo.S in build.info, we want to
266 # end up generating foo.s in two steps.
267 if ($args{src} =~ /\.S$/) {
269 $target: $args{generator}->[0] $deps
273 \$(CC) \$(CFLAGS) $incs /EP /C \$@.S > \$@
279 $target: $args{generator}->[0] $deps
286 $target: $args{generator}->[0] $deps
287 \$(CC) \$(CFLAGS) $incs /EP /C \$< > \$@
294 my $obj = $args{obj};
295 my @srcs = map { if ($unified_info{generate}->{$_}) {
296 (my $x = $_) =~ s/\.[sS]$/.asm/; $x
300 } ( @{$args{srcs}} );
301 my $srcs = join(" ", @srcs);
302 my $deps = join(" ", @srcs, @{$args{deps}});
303 my $incs = join("", map { " /I ".$_ } @{$args{incs}});
304 my $ecflags = { lib => '$(LIB_CFLAGS)',
305 dso => '$(DSO_CFLAGS)',
306 bin => '$(BIN_CFLAGS)' } -> {$args{intent}};
307 my $makedepprog = $config{makedepprog};
308 if ($srcs[0] =~ /\.asm$/) {
311 \$(AS) \$(ASFLAGS) \$(ASOUTFLAG)\$\@ $srcs
316 \$(CC) \$(CFLAGS) $ecflags$inc /Zs /showIncludes $srcs 2>&1 | \\
317 \$(PERL) -n << > $obj$depext
319 s/^Note: including file: *//;
320 \$\$collect{\$\$_} = 1;
321 END { print '$obj$objext: ',join(" ", sort keys \%collect),"\\n" }
323 $obj$objext: $obj$depext
324 \$(CC) \$(CFLAGS) $ecflags$incs -c \$(COUTFLAG)\$\@ @<<
330 # On Unix, we build shlibs from static libs, so we're ignoring the
331 # object file array. We *know* this routine is only called when we've
332 # configure 'shared'.
335 my $lib = $args{lib};
336 my $shlib = $args{shlib};
337 (my $mkdef_key = $lib) =~ s/^lib//i;
338 my $objs = join("\n", map { $_.$objext } @{$args{objs}});
339 my $linklibs = join("",
340 map { "\n$_" } compute_lib_depends(@{$args{deps}}));
342 (map { $_.$objext } @{$args{objs}}),
343 compute_lib_depends(@{$args{deps}}));
344 my $ordinalsfile = defined($args{ordinals}) ? $args{ordinals}->[1] : "";
345 my $mkdef_pl = abs2rel(rel2abs(catfile($config{sourcedir},
346 "util", "mkdef.pl")),
347 rel2abs($config{builddir}));
348 my $mkrc_pl = abs2rel(rel2abs(catfile($config{sourcedir},
350 rel2abs($config{builddir}));
351 my $target = shlib_import($lib);
353 $target: $deps $ordinalsfile $mkdef_pl
354 \$(PERL) $mkdef_pl "$mkdef_key" 32 > $shlib.def
355 \$(PERL) -i.tmp -pe "s|^LIBRARY\\s+${mkdef_key}32|LIBRARY $shlib|;" $shlib.def
357 \$(PERL) $mkrc_pl $shlib$shlibext > $shlib.rc
358 \$(RC) \$(RCOUTFLAG)$shlib.res $shlib.rc
359 \$(LD) \$(LDFLAGS) \$(LIB_LDFLAGS) \\
360 /implib:$target \$(LDOUTFLAG)$shlib$shlibext /def:$shlib.def @<<
361 $objs $shlib.res$linklibs \$(EX_LIBS)
363 DEL /F apps\\$shlib$shlibext
364 DEL /F test\\$shlib$shlibext
365 COPY $shlib$shlibext apps
366 COPY $shlib$shlibext test
371 my $dso = $args{lib};
372 my $dso_n = basename($dso);
373 my $objs = join("\n", map { $_.$objext } @{$args{objs}});
374 my $linklibs = join("",
375 map { "\n$_" } compute_lib_depends(@{$args{deps}}));
377 (map { $_.$objext } @{$args{objs}}),
378 compute_lib_depends(@{$args{deps}}));
381 \$(LD) \$(LDFLAGS) \$(DSO_LDFLAGS) \$(LDOUTFLAG)$dso$dsoext /def:<< @<<
387 $objs$linklibs \$(EX_LIBS)
392 # Because static libs and import libs are both named the same in native
393 # Windows, we can't have both. We skip the static lib in that case,
394 # as the shared libs are what we use anyway.
395 return "" unless $disabled{"shared"};
398 my $lib = $args{lib};
399 my $objs = join("\n", map { $_.$objext } @{$args{objs}});
400 my $deps = join(" ", map { $_.$objext } @{$args{objs}});
403 \$(AR) \$(ARFLAGS) \$(AROUTFLAG)$lib$libext @<<
410 my $bin = $args{bin};
411 my $objs = join("\n", map { $_.$objext } @{$args{objs}});
412 my $linklibs = join("",
413 map { "\n$_" } compute_lib_depends(@{$args{deps}}));
415 (map { $_.$objext } @{$args{objs}}),
416 compute_lib_depends(@{$args{deps}}));
419 \$(LD) \$(LDFLAGS) \$(BIN_LDFLAGS) \$(LDOUTFLAG)$bin$exeext @<<
420 $objs setargv.obj$linklibs \$(EX_LIBS)
426 my $script = $args{script};
427 my $sources = join(" ", @{$args{sources}});
428 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
429 "util", "dofile.pl")),
430 rel2abs($config{builddir}));
433 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
434 "-o$target{build_file}" $sources > "$script"
437 "" # Important! This becomes part of the template result.