Fix a few Configure errors
[openssl.git] / Configure
index cfd8be0e6401d83daa226fa2c60f11e5d4bb8950..efbe0f8587132c3c0eebfb4bb5c5db1a958881cd 100755 (executable)
--- a/Configure
+++ b/Configure
@@ -1,11 +1,7 @@
 #! /usr/bin/env perl
 # -*- mode: perl; -*-
 
-##
 ##  Configure -- OpenSSL source tree configuration script
-##  If editing this file, run this command before committing
-##     make -f Makefile.in TABLE
-##
 
 require 5.000;
 use strict;
@@ -202,7 +198,6 @@ foreach (sort glob($pattern) ) {
 
 print "Configuring OpenSSL version $config{version} (0x$config{version_num})\n";
 
-$config{perl};
 $config{prefix}="";
 $config{openssldir}="";
 $config{processor}="";
@@ -220,7 +215,7 @@ $config{dirs} = [ "crypto", "ssl", "engines", "apps", "test", "tools" ];
 # crypto/ subdirectories to build
 $config{sdirs} = [
     "objects",
-    "md2", "md4", "md5", "sha", "mdc2", "hmac", "ripemd", "whrlpool", "poly1305",
+    "md2", "md4", "md5", "sha", "mdc2", "hmac", "ripemd", "whrlpool", "poly1305", "blake2",
     "des", "aes", "rc2", "rc4", "rc5", "idea", "bf", "cast", "camellia", "seed", "chacha", "modes",
     "bn", "ec", "rsa", "dsa", "dh", "dso", "engine",
     "buffer", "bio", "stack", "lhash", "rand", "err",
@@ -243,6 +238,7 @@ my @disablables = (
     "autoalginit",
     "autoerrinit",
     "bf",
+    "blake2",
     "camellia",
     "capieng",
     "cast",
@@ -274,7 +270,7 @@ my @disablables = (
     "hmac",
     "hw(-.+)?",
     "idea",
-    "locking",
+    "makedepend",
     "md2",
     "md4",
     "md5",
@@ -396,7 +392,8 @@ my @disable_cascades = (
     "dso"               => [ "dynamic-engine" ],
 
     # Without position independent code, there can be no shared libraries or DSOs
-    "pic"               => [ "shared", "dynamic-engine" ],
+    "pic"               => [ "shared" ],
+    "shared"            => [ "dynamic-engine" ],
     );
 
 # Avoid protocol support holes.  Also disable all versions below N, if version
@@ -744,7 +741,7 @@ while (@tocheckfor) {
        my ($test, $descendents) = (shift @cascade_copy, shift @cascade_copy);
        if (ref($test) eq "CODE" ? $test->() : defined($disabled{$test})) {
            map {
-               $new_tocheckfor{$_} => 1; $disabled{$_} = "forced";
+               $new_tocheckfor{$_} = 1; $disabled{$_} = "forced";
            } grep { !defined($disabled{$_}) } @$descendents;
        }
     }
@@ -796,6 +793,8 @@ foreach (sort (keys %disabled))
                { }
        elsif (/^dynamic-engine$/)
                { }
+       elsif (/^makedepend$/)
+               { }
        elsif (/^zlib-dynamic$/)
                { }
        elsif (/^sse2$/)
@@ -1094,21 +1093,32 @@ 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';
-    open(PIPE, "$ccpcc --version 2>&1 | head -2 |");
+    open(PIPE, "$ccpcc --version 2>&1 |");
+    my $lines = 2;
     while ( <PIPE> ) {
-        $config{makedepprog} = $ccpcc if /clang|gcc/;
+        # Find the version number and save the major.
+        m|(?:.*)\b(\d+)\.\d+\.\d+\b(?:.*)|;
+        my $compiler_major = $1;
+        # We know that GNU C version 3 and up as well as all clang
+        # versions support dependency generation
+        $config{makedepprog} = $ccpcc
+            if (/clang/ || (/gcc/ && $compiler_major > 3));
         $ecc = "clang" if /clang/;
         $ecc = "gcc" if /gcc/;
+        last if ($config{makedepprog} || !$lines--);
     }
     close(PIPE);
+
+    $config{makedepprog} = which('makedepend') unless $config{makedepprog};
+    $disabled{makedepend} = "unavailable" unless $config{makedepprog};
 }
 
 
+
 # Deal with bn_ops ###################################################
 
 $config{bn_ll}                 =0;
@@ -1138,7 +1148,7 @@ die "Exactly one of SIXTY_FOUR_BIT|SIXTY_FOUR_BIT_LONG|THIRTY_TWO_BIT can be set
 
 # "Stringify" the C flags string.  This permits it to be made part of a string
 # and works as well on command lines.
-$config{cflags} =~ s/([\\\"])/\\\1/g;
+$config{cflags} =~ s/([\\\"])/\\$1/g;
 
 if (defined($config{api})) {
     $config{openssl_api_defines} = [ "OPENSSL_MIN_API=".$apitable->{$config{api}} ];
@@ -1183,22 +1193,24 @@ 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;
-        if ($ver < $minver) {
-            $disabled{afalg} = "too-old-kernel";
-        } else {
-            push @{$config{engdirs}}, "afalg";
+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";
     }
-} else {
-    $disabled{afalg}  = "not-linux";
 }
 
 push @{$config{openssl_other_defines}}, "OPENSSL_NO_AFALGENG" if ($disabled{afalg});
@@ -1322,7 +1334,13 @@ if ($builder eq "unified") {
                                                 $l1 =~ s/\\$//; $l1.$l2 }),
             # Info we're looking for
             qr/^\s*IF\[((?:\\.|[^\\\]])*)\]\s*$/
-            => sub { push @skip, !! $1; },
+            => sub {
+                if (! @skip || $skip[$#skip] > 0) {
+                    push @skip, !! $1;
+                } else {
+                    push @skip, -1;
+                }
+            },
             qr/^\s*ELSIF\[((?:\\.|[^\\\]])*)\]\s*$/
             => sub { die "ELSIF out of scope" if ! @skip;
                      die "ELSIF following ELSE" if abs($skip[$#skip]) == 2;
@@ -1741,6 +1759,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";
@@ -1764,6 +1783,7 @@ print "MODES_OBJ     =$target{modes_obj}\n";
 print "PADLOCK_OBJ   =$target{padlock_obj}\n";
 print "CHACHA_ENC    =$target{chacha_obj}\n";
 print "POLY1305_OBJ  =$target{poly1305_obj}\n";
+print "BLAKE2_OBJ    =$target{blake2_obj}\n";
 print "PROCESSOR     =$config{processor}\n";
 print "RANLIB        =$target{ranlib}\n";
 print "ARFLAGS       =$target{arflags}\n";
@@ -1773,7 +1793,7 @@ print "SIXTY_FOUR_BIT_LONG mode\n" if $config{b64l};
 print "SIXTY_FOUR_BIT mode\n" if $config{b64};
 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 "RC4 uses $config{rc4_int}\n" if $config{rc4_int} ne $def_int;
 
 for (@generated_headers) {
     mkpath(catdir($blddir, dirname($_)));
@@ -2040,7 +2060,7 @@ sub resolve_config {
     my $target = shift;
     my @breadcrumbs = @_;
 
-    my $extra_checks = defined($ENV{CONFIGURE_EXTRA_CHECKS});
+#    my $extra_checks = defined($ENV{CONFIGURE_EXTRA_CHECKS});
 
     if (grep { $_ eq $target } @breadcrumbs) {
        die "inherit_from loop!  target backtrace:\n  "
@@ -2140,10 +2160,10 @@ sub resolve_config {
         unless(defined($table{$target}->{$_})) {
             delete $table{$target}->{$_};
         }
-        if ($extra_checks &&
-            $previous && !($add_called ||  $previous ~~ $table{$target}->{$_})) {
-            warn "$_ got replaced in $target\n";
-        }
+#        if ($extra_checks &&
+#            $previous && !($add_called ||  $previous ~~ $table{$target}->{$_})) {
+#            warn "$_ got replaced in $target\n";
+#        }
     }
 
     # Finally done, return the result.
@@ -2185,7 +2205,7 @@ sub usage
        exit(1);
        }
 
-sub run_dofile()
+sub run_dofile
 {
     my $out = shift;
     my @templates = @_;
@@ -2335,10 +2355,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);\''));
                        }
                }
        }