Refactor config - a small cosmetic touchup of Configure
[openssl.git] / Configure
index 7126659aee7b6741972c63ad78c555da8acebcf8..934e934dbb15c382d71b2f699e68945b7409a411 100755 (executable)
--- a/Configure
+++ b/Configure
@@ -127,11 +127,6 @@ my $x86_gcc_des="DES_PTR DES_RISC1 DES_UNROLL";
 # MD2_CHAR slags pentium pros
 my $x86_gcc_opts="RC4_INDEX MD2_INT";
 
-#$bits1="SIXTEEN_BIT ";
-#$bits2="THIRTY_TWO_BIT ";
-my $bits1="THIRTY_TWO_BIT ";
-my $bits2="SIXTY_FOUR_BIT ";
-
 # As for $BSDthreads. Idea is to maintain "collective" set of flags,
 # which would cover all BSD flavors. -pthread applies to them all,
 # but is treated differently. OpenBSD expands is as -D_POSIX_THREAD
@@ -820,6 +815,10 @@ my $default_ranlib;
 my $perl;
 my $fips=0;
 
+# Known TLS and DTLS protocols
+my @tls = qw(ssl3 tls1 tls1_1 tls1_2);
+my @dtls = qw(dtls1 dtls1_2);
+
 # Explicitelly known options that are possible to disable.  They can
 # be regexps, and will be used like this: /^no-${option}$/
 # For developers: keep it sorted alphabetically
@@ -847,6 +846,8 @@ my @disablables = (
     "dynamic[-_]engine",
     "ec",
     "ec2m",
+    "ecdh",
+    "ecdsa",
     "ec_nistp_64_gcc_128",
     "engine",
     "err",                     # Really???
@@ -887,20 +888,22 @@ my @disablables = (
     "srtp",
     "sse2",
     "ssl",
-    "ssl3",
-    "ssl3-method",
     "ssl-trace",
     "static-engine",
     "stdio",
     "store",
     "threads",
     "tls",
-    "tls1",
     "unit-test",
     "whirlpool",
     "zlib",
     "zlib-dynamic",
     );
+foreach my $proto ((@tls, @dtls))
+       {
+       push(@disablables, $proto);
+       push(@disablables, "$proto-method");
+       }
 
 # All of the following is disabled by default (RC5 was enabled before 0.9.8):
 
@@ -1000,19 +1003,35 @@ PROCESS_ARGS:
                        {
                        if (!($disabled{$1} eq "experimental"))
                                {
-                               if ($1 eq "ssl")
+                               foreach my $proto ((@tls, @dtls))
                                        {
-                                       $disabled{"ssl3"} = "option(ssl)";
+                                       if ($1 eq "$proto-method")
+                                               {
+                                               $disabled{"$proto"} = "option($proto-method)";
+                                               last;
+                                               }
                                        }
-                               elsif ($1 eq "tls")
+                               if ($1 eq "dtls")
                                        {
-                                       $disabled{"tls1"} = "option(tls)"
+                                        foreach my $proto (@dtls)
+                                               {
+                                               $disabled{$proto} = "option(dtls)";
+                                               }
                                        }
-                               elsif ($1 eq "ssl3-method")
+                               elsif ($1 eq "ssl")
                                        {
-                                       $disabled{"ssl3-method"} = "option(ssl)";
+                                       # Last one of its kind
                                        $disabled{"ssl3"} = "option(ssl)";
                                        }
+                               elsif ($1 eq "tls")
+                                       {
+                                        # XXX: Tests will fail if all SSL/TLS
+                                        # protocols are disabled.
+                                        foreach my $proto (@tls)
+                                               {
+                                               $disabled{$proto} = "option(tls)";
+                                               }
+                                       }
                                else
                                        {
                                        $disabled{$1} = "option";
@@ -1216,19 +1235,89 @@ if (defined($disabled{"ec"}))
        $disabled{"ecdh"} = "forced";
        }
 
-# SSL 3.0 and TLS requires MD5 and SHA and either RSA or DSA+DH
+# SSL 3.0 requires MD5 and SHA and either RSA or DSA+DH
 if (defined($disabled{"md5"}) || defined($disabled{"sha"})
     || (defined($disabled{"rsa"})
-        && (defined($disabled{"dsa"}) || defined($disabled{"dh"}))))
+       && (defined($disabled{"dsa"}) || defined($disabled{"dh"}))))
        {
        $disabled{"ssl3"} = "forced";
+       $disabled{"ssl"} = "forced";
+       }
+
+# (D)TLS 1.0 and TLS 1.1 require MD5 and SHA and either RSA or DSA+DH
+# or ECDSA + ECDH.  (XXX: We don't support PSK-only builds).
+#
+if (defined($disabled{"md5"}) || defined($disabled{"sha"})
+    || (defined($disabled{"rsa"})
+       && (defined($disabled{"dsa"}) || defined($disabled{"dh"}))
+       && (defined($disabled{"ecdsa"}) || defined($disabled{"ecdh"}))))
+       {
        $disabled{"tls1"} = "forced";
+       $disabled{"dtls1"} = "forced";
+       $disabled{"tls1_1"} = "forced";
+       }
+
+# (D)TLS 1.2 requires either RSA or DSA+DH or ECDSA + ECDH
+# So if all are missing, we can't do either TLS or DTLS.
+# (XXX: We don't support PSK-only builds).
+#
+if (defined($disabled{"rsa"})
+    && (defined($disabled{"dsa"}) || defined($disabled{"dh"}))
+    && (defined($disabled{"ecdsa"}) || defined($disabled{"ecdh"})))
+       {
+       $disabled{"tls"} = "forced";
+       $disabled{"dtls"} = "forced";
+       foreach my $proto ((@tls, @dtls))
+               {
+               $disabled{"$proto"} = "forced";
+               }
+       }
+
+
+# Avoid protocol support holes.  Also disable all versions below N, if version
+# N is disabled while N+1 is enabled.
+#
+my $prev_disabled = 1;
+my $force_disable = 0;
+foreach my $proto (reverse(@tls))
+       {
+       if ($force_disable)
+               {
+               $disabled{$proto} = 1;
+               }
+       elsif (! defined($disabled{$proto}))
+               {
+               $prev_disabled = 0;
+               }
+       elsif (! $prev_disabled)
+               {
+               $force_disable = 1;
+               }
+       }
+my $prev_disabled = 1;
+my $force_disable = 0;
+foreach my $proto (reverse(@dtls))
+       {
+       if ($force_disable)
+               {
+               $disabled{$proto} = 1;
+               }
+       elsif (! defined($disabled{$proto}))
+               {
+               $prev_disabled = 0;
+               }
+       elsif (! $prev_disabled)
+               {
+               $force_disable = 1;
+               }
        }
 
 if (defined($disabled{"dgram"}))
        {
-        $disabled{"dtls"} = "forced";
-        }
+       $disabled{"dtls"} = "forced";
+       $disabled{"dtls1"} = "forced";
+       $disabled{"dtls1_2"} = "forced";
+       }
 
 if (defined($disabled{"ec"}) || defined($disabled{"dsa"})
     || defined($disabled{"dh"}) || defined($disabled{"stdio"}))
@@ -1270,7 +1359,6 @@ print "Configuring for $target\n";
 my ($d, $t) = $target =~ m/^(debug-)?(.*)$/;
 if ($d) {
     $build_prefix = "debug_";
-    $target = $t;
 
     # If we do not find debug-foo in the table, the target is set to foo,
     # but only if the foo target has a noon-empty debug_cflags or debug_lflags
@@ -1644,7 +1732,7 @@ if ($target =~ /\-icc$/)  # Intel C compiler
 # linker only when --prefix is not /usr.
 if ($target =~ /^BSD\-/)
        {
-       $shared_ldflag.=" -Wl,-rpath,\$(LIBRPATH)" if ($prefix !~ m|^/usr[/]*$|);
+       $shared_ldflag.=" -Wl,-rpath,\$\$(LIBRPATH)" if ($prefix !~ m|^/usr[/]*$|);
        }
 
 if ($sys_id ne "")
@@ -1839,7 +1927,6 @@ while (<IN>)
        $sdirs = 0 unless /\\$/;
         s/fips // if (/^DIRS=/ && !$fips);
         s/engines // if (/^DIRS=/ && $disabled{"engine"});
-       s/ccgost// if (/^ENGDIRS=/ && $disabled{"gost"});
        s/^VERSION=.*/VERSION=$version/;
        s/^MAJOR=.*/MAJOR=$major/;
        s/^MINOR=.*/MINOR=$minor/;
@@ -2191,7 +2278,7 @@ find(sub {
 }
 if($IsMK1MF) {
        open (OUT,">crypto/buildinf.h") || die "Can't open buildinf.h";
-       printf OUT <<EOF;
+       printf OUT <<"EOF";
 #ifndef MK1MF_BUILD
   /* auto-generated by Configure for crypto/cversion.c:
    * for Unix builds, crypto/Makefile.ssl generates functional definitions;
@@ -2222,7 +2309,7 @@ if ($IsMK1MF && ($target !~ /^netware/)) {
                $v4=hex $4;
        }
        open (OUT,">ms/version32.rc") || die "Can't open ms/version32.rc";
-       print OUT <<EOF;
+       print OUT <<"EOF";
 #include <winver.h>
 
 LANGUAGE 0x09,0x01
@@ -2274,19 +2361,19 @@ EOF
        close(OUT);
   }
 
-print <<EOF;
+print <<"EOF";
 
 Configured for $target.
 EOF
 
-print <<\EOF if (!$no_threads && !$threads);
+print <<"EOF" if (!$no_threads && !$threads);
 
 The library could not be configured for supporting multi-threaded
 applications as the compiler options required on this system are not known.
 See file INSTALL for details if you need multi-threading.
 EOF
 
-print <<\EOF if ($no_shared_warn);
+print <<"EOF" if ($no_shared_warn);
 
 You gave the option 'shared', which is not supported on this platform, so
 we will pretend you gave the option 'no-shared'.  If you know how to implement
@@ -2294,7 +2381,7 @@ shared libraries, please let us know (but please first make sure you have
 tried with a current version of OpenSSL).
 EOF
 
-print <<EOF if ($warn_make_depend);
+print <<"EOF" if ($warn_make_depend);
 
 *** Because of configuration changes, you MUST do the following before
 *** building:
@@ -2379,7 +2466,7 @@ sub print_table_entry
        return if $table{$target}->{template};
 
        if ($type eq "TABLE") {
-           print <<EOF
+           print <<"EOF"
 
 *** $target
 \$cc           = $table{$target}->{cc}