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 {- output_off() if $disabled{makedepend}; "" -}
65 DEPS={- join(" ", map { (my $x = $_) =~ s|\.o$|$depext|; $x; }
66 grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
67 keys %{$unified_info{sources}}); -}
68 {- output_on() if $disabled{makedepend}; "" -}
70 # Do not edit these manually. Use Configure with --prefix or --openssldir
71 # to change this! Short explanation in the top comment in Configure
72 INSTALLTOP={- # $prefix is used in the OPENSSLDIR perl snippet
74 our $prefix = $config{prefix} || "$win_installroot\\OpenSSL";
77 # The logic here is that if no --openssldir was given,
78 # OPENSSLDIR will get the value from $prefix plus "/ssl".
79 # If --openssldir was given and the value is an absolute
80 # path, OPENSSLDIR will get its value without change.
81 # If the value from --openssldir is a relative path,
82 # OPENSSLDIR will get $prefix with the --openssldir
83 # value appended as a subdirectory.
85 use File::Spec::Functions;
88 (file_name_is_absolute($config{openssldir}) ?
90 : catdir($prefix, $config{openssldir}))
91 : "$win_commonroot\\SSL";
93 LIBDIR={- our $libdir = $config{libdir} || "lib";
95 ENGINESDIR={- use File::Spec::Functions;
96 our $enginesdir = catdir($prefix,$libdir,"engines");
100 CFLAGS={- join(" ",(map { "-D".$_} @{$target{defines}}, @{$config{defines}})) -} {- join(" ", quotify_l("-DENGINESDIR=\"$enginesdir\"", "-DOPENSSLDIR=\"$openssldir\"")) -} {- $target{cflags} -} {- $config{cflags} -}
101 COUTFLAG={- $target{coutflag} || "/Fo" -}
102 RC={- $target{rc} || "rc" -}
103 RCOUTFLAG={- $target{rcoutflag} || "/fo" -}
104 LD={- $target{ld} || "link" -}
105 LDFLAGS={- $target{lflags} -}
106 LDOUTFLAG={- $target{loutflag} || "/out:" -}
107 EX_LIBS={- $target{ex_libs} -}
108 LIB_CFLAGS={- join(" ", $target{lib_cflags}, $target{shared_cflag}) || "" -}
109 LIB_LDFLAGS={- $target{shared_ldflag} || "" -}
110 DSO_CFLAGS={- join(" ", $target{dso_cflags}, $target{shared_cflag}) || "" -}
111 DSO_LDFLAGS={- join(" ", $target{dso_lflags}, $target{shared_ldflag}) || "" -}
112 BIN_CFLAGS={- $target{bin_cflags} -}
113 BIN_LDFLAGS={- $target{bin_lflags} -}
115 PERL={- $config{perl} -}
118 ARFLAGS= {- $target{arflags} -}
119 AROUTFLAG={- $target{aroutflag} || "/out:" -}
122 ASFLAGS={- $target{asflags} -}
123 ASOUTFLAG={- $target{asoutflag} -}
124 PERLASM_SCHEME= {- $target{perlasm_scheme} -}
126 PROCESSOR= {- $config{processor} -}
128 # The main targets ###################################################
130 all: configdata.pm build_libs_nodep build_engines_nodep build_apps_nodep depend
132 build_libs: configdata.pm build_libs_nodep depend
133 build_libs_nodep: $(LIBS)
134 build_engines: configdata.pm build_engines_nodep depend
135 build_engines_nodep: $(ENGINES)
136 build_apps: configdata.pm build_apps_nodep depend
137 build_apps_nodep: $(PROGRAMS) $(SCRIPTS)
138 build_tests: configdata.pm build_tests_nodep depend
139 build_tests_nodep: $(TESTPROGS)
141 test tests: build_tests_nodep build_apps_nodep build_engines_nodep depend
145 $(PERL) $(SRCDIR)\test\run_tests.pl $(TESTS)
150 @$(PERL) $(SRCDIR)\test\run_tests.pl list
152 install: install_sw install_ssldirs install_docs
154 uninstall: uninstall_docs uninstall_sw
157 del /Q /F $(LIBS) $(SHLIBS)
161 del /Q /F $(PROGRAMS) $(TESTPROGS) $(ENGINES) $(SCRIPTS)
167 del /Q /S /F engines\*.ilk
168 del /Q /S /F engines\*.lib
172 # Install helper targets #############################################
174 install_sw: all install_dev install_engines install_runtime
176 uninstall_sw: uninstall_runtime uninstall_engines uninstall_dev
183 @$(PERL) $(SRCDIR)\util\mkdir-p.pl "$(DESTDIR)$(OPENSSLDIR)\certs"
184 @$(PERL) $(SRCDIR)\util\mkdir-p.pl "$(DESTDIR)$(OPENSSLDIR)\private"
187 @if "$(INSTALLTOP)"=="" ( echo INSTALLTOP should not be empty & exit 1 )
188 @echo *** Installing development files
189 @$(PERL) $(SRCDIR)\util\mkdir-p.pl "$(DESTDIR)$(INSTALLTOP)\include\openssl"
190 @$(PERL) $(SRCDIR)\util\copy.pl $(SRCDIR)\include\openssl\*.h \
191 "$(DESTDIR)$(INSTALLTOP)\include\openssl"
192 @$(PERL) $(SRCDIR)\util\copy.pl $(BLDDIR)\include\openssl\*.h \
193 "$(DESTDIR)$(INSTALLTOP)\include\openssl"
194 @$(PERL) $(SRCDIR)\util\mkdir-p.pl "$(DESTDIR)$(INSTALLTOP)\$(LIBDIR)"
195 @$(PERL) $(SRCDIR)\util\copy.pl $(LIBS) \
196 "$(DESTDIR)$(INSTALLTOP)\$(LIBDIR)"
201 @if "$(INSTALLTOP)"=="" ( echo INSTALLTOP should not be empty & exit 1 )
202 @echo *** Installing engines
203 @$(PERL) $(SRCDIR)\util\mkdir-p.pl "$(DESTDIR)$(ENGINESDIR)"
204 @if not "$(ENGINES)"=="" \
205 $(PERL) $(SRCDIR)\util\copy.pl $(ENGINES) "$(DESTDIR)$(ENGINESDIR)"
210 @if "$(INSTALLTOP)"=="" ( echo INSTALLTOP should not be empty & exit 1 )
211 @echo *** Installing runtime files
212 @$(PERL) $(SRCDIR)\util\mkdir-p.pl "$(DESTDIR)$(INSTALLTOP)\bin"
213 @if not "$(SHLIBS)"=="" \
214 $(PERL) $(SRCDIR)\util\copy.pl $(SHLIBS) "$(DESTDIR)$(INSTALLTOP)\bin"
215 @$(PERL) $(SRCDIR)\util\copy.pl $(PROGRAMS) "$(DESTDIR)$(INSTALLTOP)\bin"
219 # Building targets ###################################################
221 configdata.pm: {- $config{build_file_template} -} $(SRCDIR)\Configure
222 @echo "Detected changed: $?"
223 @echo "Reconfiguring..."
224 $(PERL) $(SRCDIR)\Configure reconf
225 @echo "**************************************************"
227 @echo "*** Please run the same make command again ***"
229 @echo "**************************************************"
234 use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
236 # Helper function to figure out dependencies on libraries
237 # It takes a list of library names and outputs a list of dependencies
238 sub compute_lib_depends {
239 if ($disabled{shared}) {
240 return map { $_.$libext } @_;
242 return map { shlib_import($_) } @_;
247 (my $target = $args{src}) =~ s/\.[sS]$/.asm/;
248 my $generator = join(" ", @{$args{generator}});
249 my $incs = join("", map { " /I ".$_ } @{$args{incs}});
250 my $deps = join(" ", @{$args{deps}});
252 if ($target !~ /\.asm$/) {
254 $target: $args{generator}->[0] $deps
255 \$(PERL) $generator > \$@
258 if ($args{generator}->[0] =~ /\.pl$/) {
259 $generator = '$(PERL) '.$generator;
260 } elsif ($args{generator}->[0] =~ /\.S$/) {
263 die "Generator type for $src unknown: $generator\n";
266 if (defined($generator)) {
267 # If the target is named foo.S in build.info, we want to
268 # end up generating foo.s in two steps.
269 if ($args{src} =~ /\.S$/) {
271 $target: $args{generator}->[0] $deps
275 \$(CC) \$(CFLAGS) $incs /EP /C \$@.S > \$@.i && move /Y \$@.i \$@
281 $target: $args{generator}->[0] $deps
288 $target: $args{generator}->[0] $deps
289 \$(CC) \$(CFLAGS) $incs /EP /C $args{generator}->[0] > \$@.i && move /Y \$@.i \$@
296 my $obj = $args{obj};
297 my @srcs = map { if ($unified_info{generate}->{$_}) {
298 (my $x = $_) =~ s/\.[sS]$/.asm/; $x
302 } ( @{$args{srcs}} );
303 my $srcs = join(" ", @srcs);
304 my $deps = join(" ", @srcs, @{$args{deps}});
305 my $incs = join("", map { " /I ".$_ } @{$args{incs}});
306 my $ecflags = { lib => '$(LIB_CFLAGS)',
307 dso => '$(DSO_CFLAGS)',
308 bin => '$(BIN_CFLAGS)' } -> {$args{intent}};
309 my $makedepprog = $config{makedepprog};
310 if ($srcs[0] =~ /\.asm$/) {
313 \$(AS) \$(ASFLAGS) \$(ASOUTFLAG)\$\@ $srcs
316 return <<"EOF" if (!$disabled{makedepend});
318 \$(CC) \$(CFLAGS) $ecflags$inc /Zs /showIncludes $srcs 2>&1 | \\
319 \$(PERL) -n << > $obj$depext
321 s/^Note: including file: *//;
322 \$\$collect{\$\$_} = 1;
323 END { print '$obj$objext: ',join(" ", sort keys \%collect),"\\n" }
325 $obj$objext: $obj$depext
326 \$(CC) \$(CFLAGS) $ecflags$incs -c \$(COUTFLAG)\$\@ @<<
330 return <<"EOF" if ($disabled{makedepend});
332 \$(CC) \$(CFLAGS) $ecflags$incs -c \$(COUTFLAG)\$\@ $srcs
336 # On Unix, we build shlibs from static libs, so we're ignoring the
337 # object file array. We *know* this routine is only called when we've
338 # configure 'shared'.
341 my $lib = $args{lib};
342 my $shlib = $args{shlib};
343 (my $mkdef_key = $lib) =~ s/^lib//i;
344 my $objs = join("\n", map { $_.$objext } @{$args{objs}});
345 my $linklibs = join("",
346 map { "\n$_" } compute_lib_depends(@{$args{deps}}));
348 (map { $_.$objext } @{$args{objs}}),
349 compute_lib_depends(@{$args{deps}}));
350 my $ordinalsfile = defined($args{ordinals}) ? $args{ordinals}->[1] : "";
351 my $mkdef_pl = abs2rel(rel2abs(catfile($config{sourcedir},
352 "util", "mkdef.pl")),
353 rel2abs($config{builddir}));
354 my $mkrc_pl = abs2rel(rel2abs(catfile($config{sourcedir},
356 rel2abs($config{builddir}));
357 my $target = shlib_import($lib);
359 $target: $deps $ordinalsfile $mkdef_pl
360 \$(PERL) $mkdef_pl "$mkdef_key" 32 > $shlib.def
361 \$(PERL) -i.tmp -pe "s|^LIBRARY\\s+${mkdef_key}32|LIBRARY $shlib|;" $shlib.def
363 \$(PERL) $mkrc_pl $shlib$shlibext > $shlib.rc
364 \$(RC) \$(RCOUTFLAG)$shlib.res $shlib.rc
365 \$(LD) \$(LDFLAGS) \$(LIB_LDFLAGS) \\
366 /implib:$target \$(LDOUTFLAG)$shlib$shlibext /def:$shlib.def @<<
367 $objs $shlib.res$linklibs \$(EX_LIBS)
369 DEL /F apps\\$shlib$shlibext
370 DEL /F test\\$shlib$shlibext
371 COPY $shlib$shlibext apps
372 COPY $shlib$shlibext test
377 my $dso = $args{lib};
378 my $dso_n = basename($dso);
379 my $objs = join("\n", map { $_.$objext } @{$args{objs}});
380 my $linklibs = join("",
381 map { "\n$_" } compute_lib_depends(@{$args{deps}}));
383 (map { $_.$objext } @{$args{objs}}),
384 compute_lib_depends(@{$args{deps}}));
387 \$(LD) \$(LDFLAGS) \$(DSO_LDFLAGS) \$(LDOUTFLAG)$dso$dsoext /def:<< @<<
393 $objs$linklibs \$(EX_LIBS)
398 # Because static libs and import libs are both named the same in native
399 # Windows, we can't have both. We skip the static lib in that case,
400 # as the shared libs are what we use anyway.
401 return "" unless $disabled{"shared"};
404 my $lib = $args{lib};
405 my $objs = join("\n", map { $_.$objext } @{$args{objs}});
406 my $deps = join(" ", map { $_.$objext } @{$args{objs}});
409 \$(AR) \$(ARFLAGS) \$(AROUTFLAG)$lib$libext @<<
416 my $bin = $args{bin};
417 my $objs = join("\n", map { $_.$objext } @{$args{objs}});
418 my $linklibs = join("",
419 map { "\n$_" } compute_lib_depends(@{$args{deps}}));
421 (map { $_.$objext } @{$args{objs}}),
422 compute_lib_depends(@{$args{deps}}));
425 \$(LD) \$(LDFLAGS) \$(BIN_LDFLAGS) \$(LDOUTFLAG)$bin$exeext @<<
426 $objs setargv.obj$linklibs \$(EX_LIBS)
432 my $script = $args{script};
433 my $sources = join(" ", @{$args{sources}});
434 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
435 "util", "dofile.pl")),
436 rel2abs($config{builddir}));
439 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
440 "-o$target{build_file}" $sources > "$script"
443 "" # Important! This becomes part of the template result.