Add an OPENSSL_NO_AUTOERRINIT option
[openssl.git] / Configure
index 77bb60c3e6c54b7b741fec153b6e9f60d024135a..c81a66157e0795eb45a0a997d3785952a75faa0e 100755 (executable)
--- a/Configure
+++ b/Configure
@@ -11,8 +11,7 @@ require 5.000;
 use strict;
 use File::Basename;
 use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
 use strict;
 use File::Basename;
 use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
-use File::Path qw/make_path/;
-use Cwd qw/:DEFAULT realpath/;
+use File::Path qw/mkpath/;
 
 # see INSTALL for instructions.
 
 
 # see INSTALL for instructions.
 
@@ -142,8 +141,8 @@ sub resolve_config;
 # Information collection #############################################
 
 # Unified build supports separate build dir
 # Information collection #############################################
 
 # Unified build supports separate build dir
-my $srcdir = catdir(realpath(dirname($0))); # catdir ensures local syntax
-my $blddir = catdir(realpath("."));       # catdir ensures local syntax
+my $srcdir = catdir(absolutedir(dirname($0))); # catdir ensures local syntax
+my $blddir = catdir(absolutedir("."));         # catdir ensures local syntax
 my $dofile = abs2rel(catfile($srcdir, "util/dofile.pl"));
 
 $config{sourcedir} = abs2rel($srcdir);
 my $dofile = abs2rel(catfile($srcdir, "util/dofile.pl"));
 
 $config{sourcedir} = abs2rel($srcdir);
@@ -227,6 +226,9 @@ my @dtls = qw(dtls1 dtls1_2);
 my @disablables = (
     "aes",
     "asm",
 my @disablables = (
     "aes",
     "asm",
+    "async",
+    "autoalginit",
+    "autoerrinit",
     "bf",
     "camellia",
     "capieng",
     "bf",
     "camellia",
     "capieng",
@@ -741,7 +743,8 @@ foreach (sort (keys %disabled))
                my ($ALGO, $algo);
                ($ALGO = $algo = $_) =~ tr/[\-a-z]/[_A-Z]/;
 
                my ($ALGO, $algo);
                ($ALGO = $algo = $_) =~ tr/[\-a-z]/[_A-Z]/;
 
-               if (/^asm$/ || /^err$/ || /^hw$/ || /^hw-/)
+               if (/^asm$/ || /^err$/ || /^hw$/ || /^hw-/ || /^async$/
+                               || /^autoalginit/ || /^autoerrinit/)
                        {
                        push @{$config{openssl_other_defines}}, "OPENSSL_NO_$ALGO";
                        print " OPENSSL_NO_$ALGO";
                        {
                        push @{$config{openssl_other_defines}}, "OPENSSL_NO_$ALGO";
                        print " OPENSSL_NO_$ALGO";
@@ -819,7 +822,8 @@ $config{openssldir} = catdir($config{prefix}, $config{openssldir})
 # Allow environment CC to override compiler...
 $target{cc} = $ENV{CC} || $target{cc};
 
 # Allow environment CC to override compiler...
 $target{cc} = $ENV{CC} || $target{cc};
 
-# For cflags, lflags and ex_libs, add the debug_ or release_ attributes
+# For cflags, lflags, plib_lflags and ex_libs, add the debug_ or release_
+# attributes.
 # Do it in such a way that no spurious space is appended (hence the grep).
 $config{cflags} = join(" ",
                       grep { $_ ne "" } ($target{cflags},
 # Do it in such a way that no spurious space is appended (hence the grep).
 $config{cflags} = join(" ",
                       grep { $_ ne "" } ($target{cflags},
@@ -827,6 +831,9 @@ $config{cflags} = join(" ",
 $config{lflags} = join(" ",
                       grep { $_ ne "" } ($target{lflags},
                                          $target{$build_prefix."lflags"}));
 $config{lflags} = join(" ",
                       grep { $_ ne "" } ($target{lflags},
                                          $target{$build_prefix."lflags"}));
+$config{plib_lflags} = join(" ",
+                           grep { $_  ne "" } ($target{plib_lflags},
+                                               $target{$build_prefix."plib_lflags"}));
 $config{ex_libs} = join(" ",
                        grep { $_  ne "" } ($target{ex_libs},
                                            $target{$build_prefix."ex_libs"}));
 $config{ex_libs} = join(" ",
                        grep { $_  ne "" } ($target{ex_libs},
                                            $target{$build_prefix."ex_libs"}));
@@ -839,6 +846,9 @@ $target{nm} = "nm";
 $target{build_scheme} = [ $target{build_scheme} ]
     if ref($target{build_scheme}) ne "ARRAY";
 
 $target{build_scheme} = [ $target{build_scheme} ]
     if ref($target{build_scheme}) ne "ARRAY";
 
+my ($builder, $builder_platform, @builder_opts) =
+    @{$target{build_scheme}};
+
 # if $config{prefix}/lib$target{multilib} is not an existing directory, then
 # assume that it's not searched by linker automatically, in
 # which case adding $target{multilib} suffix causes more grief than
 # if $config{prefix}/lib$target{multilib} is not an existing directory, then
 # assume that it's not searched by linker automatically, in
 # which case adding $target{multilib} suffix causes more grief than
@@ -971,7 +981,7 @@ if (!$config{no_shared})
                }
        }
 
                }
        }
 
-if ($target{build_scheme}->[0] ne "mk1mf")
+if ($builder ne "mk1mf")
        {
        # add {no-}static-engine to options to allow mkdef.pl to work without extra arguments
        if ($config{no_shared})
        {
        # add {no-}static-engine to options to allow mkdef.pl to work without extra arguments
        if ($config{no_shared})
@@ -1158,26 +1168,28 @@ if ($strict_warnings)
 # If we use the unified build, collect information from build.info files
 my %unified_info = ();
 
 # If we use the unified build, collect information from build.info files
 my %unified_info = ();
 
-if ($target{build_scheme}->[0] eq "unified") {
+if ($builder eq "unified") {
+    # Store the name of the template file we will build the build file from
+    # in %config.  This may be useful for the build file itself.
+    my $build_file_template =
+        catfile($srcdir, "Configurations",
+                $builder_platform."-".$target{build_file}.".tmpl");
+    $build_file_template =
+        catfile($srcdir, "Configurations", $target{build_file}.".tmpl")
+        if (! -f $build_file_template);
+    $config{build_file_template} = $build_file_template;
+
     use lib catdir(dirname(__FILE__),"util");
     use with_fallback qw(Text::Template);
 
     use lib catdir(dirname(__FILE__),"util");
     use with_fallback qw(Text::Template);
 
-    # Helpers to produce clean paths with no /../ in the middle and so on.
-    sub int_absolutedir {
-        my $dir = shift;
-
-        # Required, because realpath only works properly with existing dirs
-        make_path($dir);
-
-        my $res = realpath($dir);
-        return $res;
-    }
-
     sub cleandir {
         my $dir = shift;
         my $base = shift || ".";
 
     sub cleandir {
         my $dir = shift;
         my $base = shift || ".";
 
-        my $res = abs2rel(int_absolutedir($dir), rel2abs($base));
+        # Make sure the directories we're building in exists
+        mkpath($dir);
+
+        my $res = abs2rel(absolutedir($dir), rel2abs($base));
         #print STDERR "DEBUG[cleandir]: $dir , $base => $res\n";
         return $res;
     }
         #print STDERR "DEBUG[cleandir]: $dir , $base => $res\n";
         return $res;
     }
@@ -1188,7 +1200,10 @@ if ($target{build_scheme}->[0] eq "unified") {
         my $d = dirname($file);
         my $f = basename($file);
 
         my $d = dirname($file);
         my $f = basename($file);
 
-        my $res = abs2rel(catfile(int_absolutedir($d), $f), rel2abs($base));
+        # Make sure the directories we're building in exists
+        mkpath($d);
+
+        my $res = abs2rel(catfile(absolutedir($d), $f), rel2abs($base));
         #print STDERR "DEBUG[cleanfile]: $d , $f => $res\n";
         return $res;
     }
         #print STDERR "DEBUG[cleanfile]: $d , $f => $res\n";
         return $res;
     }
@@ -1211,7 +1226,7 @@ if ($target{build_scheme}->[0] eq "unified") {
         my $sourced = catdir($srcdir, $_->[0]);
         my $buildd = catdir($blddir, $_->[0]);
 
         my $sourced = catdir($srcdir, $_->[0]);
         my $buildd = catdir($blddir, $_->[0]);
 
-        make_path($buildd);
+        mkpath($buildd);
 
         my $f = $_->[1];
         # The basic things we're trying to build
 
         my $f = $_->[1];
         # The basic things we're trying to build
@@ -1318,7 +1333,7 @@ if ($target{build_scheme}->[0] eq "unified") {
                     next if @skip && $skip[$#skip] <= 0;
                     push @rawlines,  $_
                         if ($target_kind eq $target{build_file}
                     next if @skip && $skip[$#skip] <= 0;
                     push @rawlines,  $_
                         if ($target_kind eq $target{build_file}
-                            || $target_kind eq $target{build_file}."(".$target{build_scheme}->[1].")");
+                            || $target_kind eq $target{build_file}."(".$builder_platform.")");
                 }
             },
             qr/^(?:#.*|\s*)$/ => sub { },
                 }
             },
             qr/^(?:#.*|\s*)$/ => sub { },
@@ -1596,7 +1611,7 @@ print OUT <<"EOF";
 );
 
 EOF
 );
 
 EOF
-if ($target{build_scheme}->[0] eq "unified") {
+if ($builder eq "unified") {
     my $recurse;
     $recurse = sub {
         my $indent = shift;
     my $recurse;
     $recurse = sub {
         my $indent = shift;
@@ -1641,7 +1656,7 @@ EOF
 print OUT "1;\n";
 close(OUT);
 
 print OUT "1;\n";
 close(OUT);
 
-die <<"EOF" if $target{build_scheme}->[0] ne "unified" && $srcdir ne $blddir;
+die <<"EOF" if $builder ne "unified" && $srcdir ne $blddir;
 
 ***** Trying building anywhere else than in the source tree will not
 ***** work for target $config{target}.  To make it possible, it needs
 
 ***** Trying building anywhere else than in the source tree will not
 ***** work for target $config{target}.  To make it possible, it needs
@@ -1649,10 +1664,11 @@ die <<"EOF" if $target{build_scheme}->[0] ne "unified" && $srcdir ne $blddir;
 
 EOF
 
 
 EOF
 
-print "IsMK1MF       =", ($target{build_scheme}->[0] eq "mk1mf" ? "yes" : "no"), "\n";
+print "IsMK1MF       =", ($builder eq "mk1mf" ? "yes" : "no"), "\n";
 print "CC            =$target{cc}\n";
 print "CFLAG         =$config{cflags}\n";
 print "CC            =$target{cc}\n";
 print "CFLAG         =$config{cflags}\n";
-print "LFLAGS        =$config{lflags}\n";
+print "LFLAG         =$config{lflags}\n";
+print "PLIB_LFLAG    =$config{plib_lflags}\n";
 print "EX_LIBS       =$config{ex_libs}\n";
 print "CPUID_OBJ     =$target{cpuid_obj}\n";
 print "BN_ASM        =$target{bn_obj}\n";
 print "EX_LIBS       =$config{ex_libs}\n";
 print "CPUID_OBJ     =$target{cpuid_obj}\n";
 print "BN_ASM        =$target{bn_obj}\n";
@@ -1682,11 +1698,11 @@ print "THIRTY_TWO_BIT mode\n" if $config{b32};
 print "BN_LLONG mode\n" if $config{bn_ll};
 print "RC4 uses $config{rc4_int}\n" if $config{rc4_int} != $def_int;
 
 print "BN_LLONG mode\n" if $config{bn_ll};
 print "RC4 uses $config{rc4_int}\n" if $config{rc4_int} != $def_int;
 
-make_path(catdir($blddir, "include/openssl"));
+mkpath(catdir($blddir, "include/openssl"));
 run_dofile(catfile($blddir, "include/openssl/opensslconf.h"),
            catfile($srcdir, "include/openssl/opensslconf.h.in"));
 
 run_dofile(catfile($blddir, "include/openssl/opensslconf.h"),
            catfile($srcdir, "include/openssl/opensslconf.h.in"));
 
-make_path(catdir($blddir, "crypto/include/internal"));
+mkpath(catdir($blddir, "crypto/include/internal"));
 foreach my $alg ( 'bn' ) {
     run_dofile(catfile($blddir, "crypto/include/internal/${alg}_conf.h"),
                catfile($srcdir, "crypto/include/internal/${alg}_conf.h.in"));
 foreach my $alg ( 'bn' ) {
     run_dofile(catfile($blddir, "crypto/include/internal/${alg}_conf.h"),
                catfile($srcdir, "crypto/include/internal/${alg}_conf.h.in"));
@@ -1729,7 +1745,20 @@ sub build_Makefile {
 
 my %builders = (
     unified => sub {
 
 my %builders = (
     unified => sub {
-        die "unified build currently does nothing";
+        run_dofile(catfile($blddir, $target{build_file}),
+                   $config{build_file_template},
+                   catfile($srcdir, "Configurations", "common.tmpl"));
+
+        my $make_command = "$make PERL=\'$config{perl}\'";
+        my $make_targets = "";
+        $make_targets .= " depend"
+            if $config{depflags} ne $default_depflags && $make_depend;
+        (system $make_command.$make_targets) == 0
+            or die "make $make_targets failed"
+            if $make_targets ne "";
+        if ($config{depflags} ne $default_depflags && !$make_depend) {
+            $warn_make_depend++;
+        }
     },
     unixmake => sub {
         build_Makefile();
     },
     unixmake => sub {
         build_Makefile();
@@ -1739,14 +1768,18 @@ my %builders = (
 
        my $make_command = "$make PERL=\'$config{perl}\'";
        my $make_targets = "";
 
        my $make_command = "$make PERL=\'$config{perl}\'";
        my $make_targets = "";
-       $make_targets .= " depend" if $config{depflags} ne $default_depflags && $make_depend;
-       (system $make_command.$make_targets) == 0 or die "make $make_targets failed"
+       $make_targets .= " depend"
+           if $config{depflags} ne $default_depflags && $make_depend;
+       (system $make_command.$make_targets) == 0
+           or die "make $make_targets failed"
            if $make_targets ne "";
            if $make_targets ne "";
+
        if ($config{depflags} ne $default_depflags && !$make_depend) {
             $warn_make_depend++;
         }
     },
     mk1mf => sub {
        if ($config{depflags} ne $default_depflags && !$make_depend) {
             $warn_make_depend++;
         }
     },
     mk1mf => sub {
+        my $platform = shift;
         # The only reason we do this is to have something to build MINFO from
         build_Makefile();
 
         # The only reason we do this is to have something to build MINFO from
         build_Makefile();
 
@@ -1763,7 +1796,7 @@ EOF
        close(OUT);
 
        # create the ms/version32.rc file if needed
        close(OUT);
 
        # create the ms/version32.rc file if needed
-       if (! grep /^netware/, @{$target{build_scheme}}) {
+       if ($platform eq "netware") {
            my ($v1, $v2, $v3, $v4);
            if ($config{version_num} =~ /^0x([0-9a-f]{1})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{1})L$/i) {
                $v1=hex $1;
            my ($v1, $v2, $v3, $v4);
            if ($config{version_num} =~ /^0x([0-9a-f]{1})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{1})L$/i) {
                $v1=hex $1;
@@ -1826,8 +1859,7 @@ EOF
     },
     );
 
     },
     );
 
-my ($builder, @builder_opts) = @{$target{build_scheme}};
-$builders{$builder}->(@builder_opts);
+$builders{$builder}->($builder_platform, @builder_opts);
 
 print <<"EOF";
 
 
 print <<"EOF";
 
@@ -2115,10 +2147,13 @@ sub print_table_entry
        "unistd",
        "ld",
        "lflags",
        "unistd",
        "ld",
        "lflags",
+       "plib_lflags",
        "ex_libs",
        "debug_lflags",
        "ex_libs",
        "debug_lflags",
+       "debug_plib_lflags",
        "debug_ex_libs",
        "release_lflags",
        "debug_ex_libs",
        "release_lflags",
+       "release_plib_lflags",
        "release_ex_libs",
        "bn_ops",
        "cpuid_obj",
        "release_ex_libs",
        "bn_ops",
        "cpuid_obj",
@@ -2171,6 +2206,29 @@ sub print_table_entry
 
 # Utility routines ###################################################
 
 
 # Utility routines ###################################################
 
+# Makes a directory absolute and cleans out /../ in paths like foo/../bar
+# On some platforms, this uses rel2abs(), while on others, realpath() is used.
+# realpath() requires that at least all path components except the last is an
+# existing directory.  On VMS, the last component of the directory spec must
+# exist.
+sub absolutedir {
+    my $dir = shift;
+
+    # realpath() is quite buggy on VMS.  It uses LIB$FID_TO_NAME, which
+    # will return the volume name for the device, no matter what.  Also,
+    # it will return an incorrect directory spec if the argument is a
+    # directory that doesn't exist.
+    if ($^O eq "VMS") {
+        return rel2abs($dir);
+    }
+
+    # We use realpath() on Unix, since no other will properly clean out
+    # a directory spec.
+    use Cwd qw/realpath/;
+
+    return realpath($dir);
+}
+
 sub which
        {
        my($name)=@_;
 sub which
        {
        my($name)=@_;