Don't check the conditions to build e_afalg if configured "no-engine"
[openssl.git] / Configure
index 1a578be09150d73b8e55e051b2cb8004d5b6f92b..9a2ac4e5316463599bf11071e24509ea667cb0f5 100755 (executable)
--- a/Configure
+++ b/Configure
@@ -275,11 +275,13 @@ my @disablables = (
     "hw(-.+)?",
     "idea",
     "locking",
+    "makedepend",
     "md2",
     "md4",
     "md5",
     "mdc2",
     "md[-_]ghost94",
+    "multiblock",
     "nextprotoneg",
     "ocb",
     "ocsp",
@@ -437,7 +439,6 @@ my $no_sse2=0;
 
 my $user_cflags="";
 my @user_defines=();
-my $unified = 0;
 $config{openssl_api_defines}=[];
 $config{openssl_algorithm_defines}=[];
 $config{openssl_thread_defines}=[];
@@ -448,6 +449,8 @@ my $target="";
 $config{options}="";
 $config{build_type} = "release";
 
+my $classic = 0;
+
 my @argvcopy=@ARGV;
 
 if (grep /^reconf(igure)?$/, @argvcopy) {
@@ -631,9 +634,9 @@ foreach (@argvcopy)
                }
        elsif (/^[-+]/)
                {
-               if (/^--unified$/)
+               if (/^--classic$/)
                        {
-                       $unified=1;
+                       $classic=1;
                        }
                elsif (/^--prefix=(.*)$/)
                        {
@@ -794,6 +797,8 @@ foreach (sort (keys %disabled))
                { }
        elsif (/^dynamic-engine$/)
                { }
+       elsif (/^makedepend$/)
+               { }
        elsif (/^zlib-dynamic$/)
                { }
        elsif (/^sse2$/)
@@ -890,14 +895,20 @@ $config{shared_ldflag} = "";
 $target{build_scheme} = [ $target{build_scheme} ]
     if ref($target{build_scheme}) ne "ARRAY";
 
-###### TO BE REMOVED BEFORE FINAL RELEASE
+###### TO BE REMOVED WHEN CLASSIC BUILD IS REMOVED
 ######
-###### If the user has chosen --unified, we give it to them.
-###### The same happens if we detect that they try to build out-of-source.
-if ($target{build_file} eq "Makefile"
-    && $target{build_scheme}->[0] eq "unixmake"
-    && ($unified || $srcdir ne $blddir)) {
-    $target{build_scheme} = [ "unified", "unix" ];
+###### If the user has chosen --classic, we give it to them.
+###### If they try that with an out-of-source config, we complain.
+if ($target{build_scheme}->[0] eq "unified" && $classic) {
+    die "Can't perform a classic build out of source tree\n"
+        if $srcdir ne $blddir;
+
+    $target{build_scheme} = { unix    => [ "unixmake" ],
+                              windows => [ "mk1mf", $target{build_scheme}->[2] ],
+                              VMS     => undef } -> {$target{build_scheme}->[1]};
+
+    die "Classic mode unavailable on this platform\n"
+        unless defined($target{build_scheme});
 }
 
 my ($builder, $builder_platform, @builder_opts) =
@@ -1086,21 +1097,28 @@ unless ($disabled{asm}) {
 }
 
 my $ecc = $target{cc};
-if ($^O ne "VMS") {
+if ($^O ne "VMS" && !$disabled{makedepend}) {
     # Is the compiler gcc or clang?  $ecc is used below to see if
     # error-checking can be turned on.
     my $ccpcc = "$config{cross_compile_prefix}$target{cc}";
-    $config{makedepprog} = 'makedepend';
+    $config{makedepprog} = which('makedepend');
     open(PIPE, "$ccpcc --version 2>&1 | head -2 |");
     while ( <PIPE> ) {
-        $config{makedepprog} = $ccpcc if /clang|gcc/;
+        # Find the version number and save the major.
+        m|(?:.*)\b(\d+)\.\d+\.\d+\b(?:.*)|;
+        # We know that GNU C version 3 and up as well as all clang
+        # versions support dependency generation
+        $config{makedepprog} = $ccpcc if /clang/ || (/gcc/ && $1 > 3);
         $ecc = "clang" if /clang/;
         $ecc = "gcc" if /gcc/;
     }
     close(PIPE);
+
+    $disabled{makedepend} = "unavailable" unless $config{makedepprog};
 }
 
 
+
 # Deal with bn_ops ###################################################
 
 $config{bn_ll}                 =0;
@@ -1175,18 +1193,27 @@ else               { $no_user_defines=1;    }
 
 # ALL MODIFICATIONS TO %config and %target MUST BE DONE FROM HERE ON
 
-$config{afalg}="";
-if ($target =~ m/^linux/) {
-    my $minver = 4*10000 + 1*100 + 0;
-    if ($config{cross_compile_prefix} eq "") {
-        my $verstr = `uname -r`;
-        my ($ma, $mi1, $mi2) = split("\\.", $verstr);
-        ($mi2) = $mi2 =~ /(\d+)/;
-        my $ver = $ma*10000 + $mi1*100 + $mi2;
-        $config{afalg}="afalg" if ($ver >= $minver);
+unless ($disabled{engine}) {
+    $config{afalg}="";
+    if ($target =~ m/^linux/) {
+        my $minver = 4*10000 + 1*100 + 0;
+        if ($config{cross_compile_prefix} eq "") {
+            my $verstr = `uname -r`;
+            my ($ma, $mi1, $mi2) = split("\\.", $verstr);
+            ($mi2) = $mi2 =~ /(\d+)/;
+            my $ver = $ma*10000 + $mi1*100 + $mi2;
+            if ($ver < $minver) {
+                $disabled{afalg} = "too-old-kernel";
+            } else {
+                push @{$config{engdirs}}, "afalg";
+            }
+        }
+    } else {
+        $disabled{afalg}  = "not-linux";
     }
 }
-push @{$config{engdirs}}, $config{afalg};
+
+push @{$config{openssl_other_defines}}, "OPENSSL_NO_AFALGENG" if ($disabled{afalg});
 
 # If we use the unified build, collect information from build.info files
 my %unified_info = ();
@@ -1267,6 +1294,7 @@ if ($builder eq "unified") {
         my @engines = ();
         my @scripts = ();
         my @extra = ();
+        my @overrides = ();
         my @intermediates = ();
         my @rawlines = ();
 
@@ -1276,6 +1304,7 @@ if ($builder eq "unified") {
         my %depends = ();
         my %renames = ();
         my %sharednames = ();
+        my %generate = ();
 
         push @{$config{build_infos}}, catfile(abs2rel($sourced, $blddir), $f);
         my $template = Text::Template->new(TYPE => 'FILE',
@@ -1334,6 +1363,9 @@ if ($builder eq "unified") {
             qr/^\s*EXTRA\s*=\s*(.*)\s*$/
             => sub { push @extra, split(/\s+/, $1)
                          if !@skip || $skip[$#skip] > 0 },
+            qr/^\s*OVERRIDES\s*=\s*(.*)\s*$/
+            => sub { push @overrides, split(/\s+/, $1)
+                         if !@skip || $skip[$#skip] > 0 },
 
             qr/^\s*ORDINALS\[((?:\\.|[^\\\]])+)\]\s*=\s*(.*)\s*$/,
             => sub { push @{$ordinals{$1}}, split(/\s+/, $2)
@@ -1347,6 +1379,9 @@ if ($builder eq "unified") {
             qr/^\s*DEPEND\[((?:\\.|[^\\\]])+)\]\s*=\s*(.*)\s*$/
             => sub { push @{$depends{$1}}, split(/\s+/, $2)
                          if !@skip || $skip[$#skip] > 0 },
+            qr/^\s*GENERATE\[((?:\\.|[^\\\]])+)\]\s*=\s*(.*)\s*$/
+            => sub { push @{$generate{$1}}, $2
+                         if !@skip || $skip[$#skip] > 0 },
             qr/^\s*RENAME\[((?:\\.|[^\\\]])+)\]\s*=\s*(.*)\s*$/
             => sub { push @{$renames{$1}}, split(/\s+/, $2)
                          if !@skip || $skip[$#skip] > 0 },
@@ -1429,6 +1464,11 @@ EOF
             $unified_info{extra}->{$extra} = 1;
         }
 
+        foreach (@overrides) {
+            my $override = cleanfile($buildd, $_, $blddir);
+            $unified_info{overrides}->{$override} = 1;
+        }
+
         push @{$unified_info{rawlines}}, @rawlines;
 
         unless ($disabled{shared}) {
@@ -1507,6 +1547,20 @@ EOF
             }
         }
 
+        foreach (keys %generate) {
+            my $dest = $_;
+            my $ddest = cleanfile($buildd, $_, $blddir);
+            if ($unified_info{rename}->{$ddest}) {
+                $ddest = $unified_info{rename}->{$ddest};
+            }
+            die "more than one generator for $dest: "
+                    ,join(" ", @{$generate{$_}}),"\n"
+                    if scalar @{$generate{$_}} > 1;
+            my @generator = split /\s+/, $generate{$dest}->[0];
+            $generator[0] = cleanfile($sourced, $generator[0], $blddir),
+            $unified_info{generate}->{$ddest} = [ @generator ];
+        }
+
         foreach (keys %depends) {
             my $dest = $_;
             my $ddest = cleanfile($buildd, $_, $blddir);
@@ -1558,7 +1612,7 @@ EOF
 
     ### Make unified_info a bit more efficient
     # One level structures
-    foreach (("programs", "libraries", "engines", "scripts", "extra")) {
+    foreach (("programs", "libraries", "engines", "scripts", "extra", "overrides")) {
         $unified_info{$_} = [ sort keys %{$unified_info{$_}} ];
     }
     # Two level structures
@@ -1699,6 +1753,7 @@ close(OUT);
 print "IsMK1MF       =", ($builder eq "mk1mf" ? "yes" : "no"), "\n";
 print "CC            =$target{cc}\n";
 print "CFLAG         =$target{cflags} $config{cflags}\n";
+print "SHARED_CFLAG  =$target{shared_cflag}\n";
 print "DEFINES       =",join(" ", @{$target{defines}}, @{$config{defines}}),"\n";
 print "LFLAG         =$target{lflags}\n";
 print "PLIB_LFLAG    =$target{plib_lflags}\n";
@@ -1878,39 +1933,6 @@ or position independent code, please let us know (but please first make sure
 you have tried with a current version of OpenSSL).
 EOF
 
-###### TO BE REMOVED BEFORE FINAL RELEASE
-######
-###### If the user hasn't chosen --unified, try to nudge them.
-if ($target{build_file} eq "Makefile"
-    && $target{build_scheme}->[0] eq "unixmake"
-    && !$unified) {
-
-    my $plausible_builddir =
-        abs2rel(rel2abs("../_openssl-build_$target"),rel2abs("."));
-    my $plausible_to_sourcedir =
-        abs2rel(rel2abs("."),rel2abs("../_openssl-build_$target"));
-    print <<"EOF";
-
-----------------------------------------------------------------------
-Please consider configuring with the flag --unified .
-It's to test out a new "unified" building system.
-
-One cool feature is that you can have your build directory elsewhere,
-for example:
-
-    make clean          # Clean the current configuration away
-    mkdir $plausible_builddir
-    cd $plausible_builddir
-    $plausible_to_sourcedir/config --unified
-    make
-    make test
-
-Please report any problem you have.
-----------------------------------------------------------------------
-
-EOF
-}
-
 exit(0);
 
 ######################################################################
@@ -2326,10 +2348,12 @@ sub which
        my $path;
        foreach $path (split /:/, $ENV{PATH})
                {
-               if (-f "$path/$name$target{exe_extension}" and -x _)
+               my $fullpath = "$path/$name$target{exe_extension}";
+               if (-f $fullpath and -x $fullpath)
                        {
-                       return "$path/$name$target{exe_extension}" unless ($name eq "perl" and
-                        system("$path/$name$target{exe_extension} -e " . '\'exit($]<5.0);\''));
+                       return $fullpath
+                           unless ($name eq "perl" and
+                                   system("$fullpath -e " . '\'exit($]<5.0);\''));
                        }
                }
        }