Rethink the uplink / applink story
[openssl.git] / Configure
index 2ba33cb0c5ae8cb7b28a2aef0e74cc16553aa5d3..8fb2969a96d8402be8952bce6c5a1869bc165346 100755 (executable)
--- a/Configure
+++ b/Configure
@@ -15,7 +15,7 @@ use File::Path qw/mkpath/;
 
 # see INSTALL for instructions.
 
-my $usage="Usage: Configure [no-<cipher> ...] [enable-<cipher> ...] [experimental-<cipher> ...] [-Dxxx] [-lxxx] [-Lxxx] [-fxxx] [-Kxxx] [no-hw-xxx|no-hw] [[no-]threads] [[no-]shared] [[no-]zlib|zlib-dynamic] [no-asm] [no-dso] [no-egd] [sctp] [386] [--prefix=DIR] [--openssldir=OPENSSLDIR] [--with-xxx[=vvv]] [--config=FILE] os/compiler[:flags]\n";
+my $usage="Usage: Configure [no-<cipher> ...] [enable-<cipher> ...] [-Dxxx] [-lxxx] [-Lxxx] [-fxxx] [-Kxxx] [no-hw-xxx|no-hw] [[no-]threads] [[no-]shared] [[no-]zlib|zlib-dynamic] [no-asm] [no-dso] [no-egd] [sctp] [386] [--prefix=DIR] [--openssldir=OPENSSLDIR] [--with-xxx[=vvv]] [--config=FILE] os/compiler[:flags]\n";
 
 # Options:
 #
@@ -32,10 +32,6 @@ my $usage="Usage: Configure [no-<cipher> ...] [enable-<cipher> ...] [experimenta
 #               This becomes the value of OPENSSLDIR in Makefile and in C.
 #               (Default: PREFIX/ssl)
 #
-# --install_prefix  Additional prefix for package builders (empty by
-#               default).  This needn't be set in advance, you can
-#               just as well use "make INSTALL_PREFIX=/whatever install".
-#
 # --cross-compile-prefix Add specified prefix to binutils components.
 #
 # --api         One of 0.9.8, 1.0.0 or 1.1.0.  Do not compile support for
@@ -80,20 +76,42 @@ my $usage="Usage: Configure [no-<cipher> ...] [enable-<cipher> ...] [experimenta
 # Minimum warning options... any contributions to OpenSSL should at least get
 # past these.
 
-my $gcc_devteam_warn = "-Wall -pedantic -DPEDANTIC -Wno-long-long -Wsign-compare -Wmissing-prototypes -Wshadow -Wformat -Wtype-limits -Werror -DREF_DEBUG -DDEBUG_UNUSED";
+my $gcc_devteam_warn = "-DPEDANTIC -DREF_DEBUG -DDEBUG_UNUSED -DBIO_DEBUG"
+        . " -pedantic"
+        . " -Wall"
+        . " -Wno-long-long"
+        . " -Wsign-compare"
+        . " -Wmissing-prototypes"
+        . " -Wshadow"
+        . " -Wformat"
+        . " -Wtype-limits"
+        . " -Werror"
+        ;
 
 # These are used in addition to $gcc_devteam_warn when the compiler is clang.
 # TODO(openssl-team): fix problems and investigate if (at least) the
 # following warnings can also be enabled:
-# -Wswitch-enum, -Wunused-macros, -Wmissing-field-initializers,
-# -Wcast-align,
-# -Wunreachable-code -Wunused-parameter -Wlanguage-extension-token
-# -Wextended-offsetof
-my $clang_devteam_warn = "-Wno-unused-parameter -Wno-missing-field-initializers -Wno-language-extension-token -Wno-extended-offsetof -Wconditional-uninitialized -Qunused-arguments -Wincompatible-pointer-types-discards-qualifiers -Wmissing-variable-declarations";
-
-# These are used in addition to $gcc_devteam_warn unless this is a mingw build.
-# This adds backtrace information to the memory leak info.
-my $memleak_devteam_backtrace = "-rdynamic -DCRYPTO_MDEBUG_BACKTRACE";
+#       -Wswitch-enum
+#       -Wunused-macros
+#       -Wcast-align
+#       -Wunreachable-code
+#       -Wlanguage-extension-token
+#       -Wextended-offsetof
+my $clang_devteam_warn = ""
+        . " -Qunused-arguments"
+        . " -Wextra"
+        . " -Wno-unused-parameter"
+        . " -Wno-missing-field-initializers"
+        . " -Wno-language-extension-token"
+        . " -Wno-extended-offsetof"
+        . " -Wconditional-uninitialized"
+        . " -Wincompatible-pointer-types-discards-qualifiers"
+        . " -Wmissing-variable-declarations"
+        ;
+
+# This adds backtrace information to the memory leak info.  Is only used
+# when crypto-mdebug-backtrace is enabled.
+my $memleak_devteam_backtrace = "-rdynamic";
 
 my $strict_warnings = 0;
 
@@ -184,7 +202,6 @@ $config{prefix}="";
 $config{openssldir}="";
 $config{processor}="";
 $config{libdir}="";
-$config{install_prefix}= "$ENV{'INSTALL_PREFIX'}";
 $config{cross_compile_prefix}="";
 $config{fipslibdir}="/usr/local/ssl/fips-2.0/lib/";
 my $nofipscanistercheck=0;
@@ -209,7 +226,7 @@ $config{sdirs} = [
     "bn", "ec", "rsa", "dsa", "dh", "dso", "engine",
     "buffer", "bio", "stack", "lhash", "rand", "err",
     "evp", "asn1", "pem", "x509", "x509v3", "conf", "txt_db", "pkcs7", "pkcs12", "comp", "ocsp", "ui",
-    "cms", "ts", "jpake", "srp", "cmac", "ct", "async", "kdf"
+    "cms", "ts", "srp", "cmac", "ct", "async", "kdf"
     ];
 
 # Known TLS and DTLS protocols
@@ -235,6 +252,7 @@ my @disablables = (
     "cms",
     "comp",
     "crypto-mdebug",
+    "crypto-mdebug-backtrace",
     "ct",
     "deprecated",
     "des",
@@ -251,13 +269,13 @@ my @disablables = (
     "ec_nistp_64_gcc_128",
     "egd",
     "engine",
-    "err",                     # Really???
+    "err",
+    "filenames",
     "heartbeats",
     "hmac",
     "hw(-.+)?",
     "idea",
-    "jpake",
-    "locking",                 # Really???
+    "locking",
     "md2",
     "md4",
     "md5",
@@ -275,6 +293,7 @@ my @disablables = (
     "rdrand",
     "rfc3779",
     "rijndael",                        # Old AES name
+    "ripemd",
     "rmd160",
     "rsa",
     "scrypt",
@@ -293,6 +312,8 @@ my @disablables = (
     "stdio",
     "threads",
     "tls",
+    "ts",
+    "ui",
     "unit-test",
     "whirlpool",
     "zlib",
@@ -306,10 +327,9 @@ foreach my $proto ((@tls, @dtls))
 
 # All of the following is disabled by default (RC5 was enabled before 0.9.8):
 
-my %disabled = ( # "what"         => "comment" [or special keyword "experimental"]
+my %disabled = ( # "what"         => "comment"
                 "ec_nistp_64_gcc_128" => "default",
                 "egd"            => "default",
-                "jpake"          => "experimental",
                 "md2"            => "default",
                 "rc5"            => "default",
                 "sctp"           => "default",
@@ -320,7 +340,6 @@ my %disabled = ( # "what"         => "comment" [or special keyword "experimental
                 "crypto-mdebug"  => "default",
                 "heartbeats"     => "default",
               );
-my @experimental = ();
 
 # Note: => pair form used for aesthetics, not to truly make a hash table
 my @disable_cascades = (
@@ -333,7 +352,6 @@ my @disable_cascades = (
     "rijndael"         => [ "aes" ],
     "des"              => [ "mdc2" ],
     "ec"               => [ "ecdsa", "ecdh" ],
-    "psk"              => [ "jpake" ],
 
     "dgram"            => [ "dtls" ],
     "dtls"             => [ @dtls ],
@@ -360,6 +378,8 @@ my @disable_cascades = (
 
     # SRP and HEARTBEATS require TLSEXT
     "tlsext"           => [ "srp", "heartbeats" ],
+
+    "crypto-mdebug"     => [ "crypto-mdebug-backtrace" ],
     );
 
 # Avoid protocol support holes.  Also disable all versions below N, if version
@@ -380,22 +400,10 @@ while ((my $first, my $second) = (shift @list, shift @list)) {
     unshift @list, $second;
 }
 
-# Construct the string of what $config{depdefines} should look like with
-# the defaults from %disabled above.  (we need this to see if we should
-# advise the user to run "make depend"):
-my @default_depdefines =
-    map { my $x = $_; $x =~ tr{[a-z]-}{[A-Z]_}; "OPENSSL_NO_$x"; }
-    grep { $disabled{$_} !~ /\(no-depdefines\)$/ }
-    sort keys %disabled;
-
 # Explicit "no-..." options will be collected in %disabled along with the defaults.
-# To remove something from %disabled, use "enable-foo" (unless it's experimental).
+# To remove something from %disabled, use "enable-foo".
 # For symmetry, "disable-foo" is a synonym for "no-foo".
 
-# For features called "experimental" here, a more explicit "experimental-foo" is needed to enable.
-# We will collect such requests in @experimental.
-# To avoid accidental use of experimental features, applications will have to use -DOPENSSL_EXPERIMENTAL_FOO.
-
 my @generated_headers = (
     "include/openssl/opensslconf.h",
     "crypto/include/internal/bn_conf.h"
@@ -413,8 +421,6 @@ my $no_sse2=0;
 my $user_cflags="";
 my @user_defines=();
 my $unified = 0;
-$config{depdefines}=[];
-$config{openssl_experimental_defines}=[];
 $config{openssl_api_defines}=[];
 $config{openssl_algorithm_defines}=[];
 $config{openssl_thread_defines}=[];
@@ -481,6 +487,13 @@ $config{perlargv} = [ @argvcopy ];
 my %unsupported_options = ();
 foreach (@argvcopy)
        {
+       # VMS is a case insensitive environment, and depending on settings
+       # out of our control, we may receive options uppercased.  Let's
+       # downcase at least the part before any equal sign.
+       if ($^O eq "VMS")
+               {
+               s/^([^=]*)/lc($1)/e;
+               }
        s /^-no-/no-/; # some people just can't read the instructions
 
        # rewrite some options in "enable-..." form
@@ -490,7 +503,7 @@ foreach (@argvcopy)
        s /^zlib$/enable-zlib/;
        s /^zlib-dynamic$/enable-zlib-dynamic/;
 
-        if (/^(no|disable|enable|experimental)-(.+)$/)
+        if (/^(no|disable|enable)-(.+)$/)
                {
                my $word = $2;
                if (!grep { $word =~ /^${_}$/ } @disablables)
@@ -501,52 +514,43 @@ foreach (@argvcopy)
                }
        if (/^no-(.+)$/ || /^disable-(.+)$/)
                {
-               if (!($disabled{$1} eq "experimental"))
-                       {
-                       foreach my $proto ((@tls, @dtls))
-                               {
-                               if ($1 eq "$proto-method")
-                                       {
-                                       $disabled{"$proto"} = "option($proto-method)";
-                                       last;
-                                       }
-                               }
-                       if ($1 eq "dtls")
-                               {
-                                foreach my $proto (@dtls)
-                                       {
-                                       $disabled{$proto} = "option(dtls)";
-                                       }
-                               }
-                       elsif ($1 eq "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";
-                               }
-                       }
+                foreach my $proto ((@tls, @dtls))
+                        {
+                        if ($1 eq "$proto-method")
+                                {
+                                $disabled{"$proto"} = "option($proto-method)";
+                                last;
+                                }
+                        }
+                if ($1 eq "dtls")
+                        {
+                        foreach my $proto (@dtls)
+                                {
+                                $disabled{$proto} = "option(dtls)";
+                                }
+                        }
+                elsif ($1 eq "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";
+                        }
                }
-       elsif (/^enable-(.+)$/ || /^experimental-(.+)$/)
+       elsif (/^enable-(.+)$/)
                {
                my $algo = $1;
-               if ($disabled{$algo} eq "experimental")
-                       {
-                       die "You are requesting an experimental feature; please say 'experimental-$algo' if you are sure\n"
-                               unless (/^experimental-/);
-                       push @experimental, $algo;
-                       }
                delete $disabled{$algo};
 
                $threads = 1 if ($algo eq "threads");
@@ -604,10 +608,6 @@ foreach (@argvcopy)
                        {
                        $config{openssldir}=$1;
                        }
-               elsif (/^--install.prefix=(.*)$/)
-                       {
-                       $config{install_prefix}=$1;
-                       }
                elsif (/^--with-zlib-lib=(.*)$/)
                        {
                        $withargs{zlib_lib}=$1;
@@ -752,13 +752,17 @@ foreach (sort (keys %disabled))
        elsif (/^sse2$/)
                { $no_sse2 = 1; }
        elsif (/^engine$/)
-               { @{$config{dirs}} = grep !/^engine$/, @{$config{dirs}}; }
+               {
+               @{$config{dirs}} = grep !/^engines$/, @{$config{dirs}};
+               @{$config{sdirs}} = grep !/^engine$/, @{$config{sdirs}};
+               push @{$config{openssl_other_defines}}, "OPENSSL_NO_ENGINE";
+               }
        else
                {
                my ($ALGO, $algo);
                ($ALGO = $algo = $_) =~ tr/[\-a-z]/[_A-Z]/;
 
-               if (/^asm$/ || /^err$/ || /^hw$/ || /^hw-/ || /^async$/
+               if (/^asm$/ || /^err$/ || /^hw$/ || /^hw-/
                                || /^autoalginit/ || /^autoerrinit/)
                        {
                        push @{$config{openssl_other_defines}}, "OPENSSL_NO_$ALGO";
@@ -772,7 +776,6 @@ foreach (sort (keys %disabled))
                        ($ALGO,$algo) = ("RMD160","rmd160") if ($algo eq "ripemd");
 
                        push @{$config{openssl_algorithm_defines}}, "OPENSSL_NO_$ALGO";
-                       push @{$config{depdefines}}, "OPENSSL_NO_$ALGO";
                        print " OPENSSL_NO_$ALGO";
 
                        # fix-up crypto/directory name(s)
@@ -787,15 +790,6 @@ foreach (sort (keys %disabled))
        print "\n";
        }
 
-foreach (sort @experimental)
-       {
-       my $ALGO;
-       ($ALGO = $_) =~ tr/[a-z]/[A-Z]/;
-
-       # opensslconf.h will set OPENSSL_NO_... unless OPENSSL_EXPERIMENTAL_... is defined
-       push @{$config{openssl_experimental_defines}}, "OPENSSL_NO_$ALGO";
-       }
-
 print "Configuring for $target\n";
 
 # Support for legacy targets having a name starting with 'debug-'
@@ -858,19 +852,16 @@ $target{build_scheme} = [ $target{build_scheme} ]
 ###### TO BE REMOVED BEFORE FINAL RELEASE
 ######
 ###### 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) {
+    && ($unified || $srcdir ne $blddir)) {
     $target{build_scheme} = [ "unified", "unix" ];
 }
 
 my ($builder, $builder_platform, @builder_opts) =
     @{$target{build_scheme}};
 
-push @{$config{defines}},
-    map { (my $x = $_) =~ s/^OPENSSL_NO_/OPENSSL_EXPERIMENTAL_/; $x }
-        @{$config{openssl_experimental_defines}};
-
 if ($target =~ /^mingw/ && `$target{cc} --target-help 2>&1` =~ m/-mno-cygwin/m)
        {
        $config{cflags} .= " -mno-cygwin";
@@ -887,11 +878,6 @@ my $no_shared_warn=0;
 my $no_user_cflags=0;
 my $no_user_defines=0;
 
-if ($user_cflags ne "") { $config{cflags}="$config{cflags}$user_cflags"; }
-else                    { $no_user_cflags=1;  }
-if (@user_defines) { $config{defines}=[ @{$config{defines}}, @user_defines ]; }
-else               { $no_user_defines=1;    }
-
 # The DSO code currently always implements all functions so that no
 # applications will have to worry about that from a compilation point
 # of view. However, the "method"s may return zero unless that platform
@@ -1027,8 +1013,6 @@ if ($target{ranlib} eq "")
 
 if (!$no_asm) {
     $target{cpuid_asm_src}=$table{BASE}->{cpuid_asm_src} if ($config{processor} eq "386");
-    $target{cpuid_asm_src}.=" uplink.c uplink-x86.s" if (grep { $_ eq "OPENSSL_USE_APPLINK"} @{$config{defines}});
-
     $target{bn_asm_src} =~ s/\w+-gf2m.c// if (defined($disabled{ec2m}));
 
     # bn-586 is the only one implementing bn_*_part_words
@@ -1084,20 +1068,20 @@ if (!$no_asm) {
     }
 }
 
-# Is the compiler gcc or clang?  $ecc is used below to see if error-checking
-# can be turned on.
 my $ecc = $target{cc};
-my $ccpcc = "$config{cross_compile_prefix}$target{cc}";
-$config{makedepprog} = 'makedepend';
-open(PIPE, "$ccpcc --version 2>&1 | head -2 |");
-while ( <PIPE> ) {
-    $config{makedepprog} = $ccpcc if /clang|gcc/;
-    $ecc = "clang" if /clang/;
-    $ecc = "gcc" if /gcc/;
+if ($^O ne "VMS") {
+    # 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 |");
+    while ( <PIPE> ) {
+        $config{makedepprog} = $ccpcc if /clang|gcc/;
+        $ecc = "clang" if /clang/;
+        $ecc = "gcc" if /gcc/;
+    }
+    close(PIPE);
 }
-close(PIPE);
-
-$config{depflags} =~ s/^\s*//;
 
 
 # Deal with bn_ops ###################################################
@@ -1134,41 +1118,46 @@ $config{cflags} =~ s/([\\\"])/\\\1/g;
 if (defined($config{api})) {
     $config{openssl_api_defines} = [ "OPENSSL_MIN_API=".$apitable->{$config{api}} ];
     my $apiflag = sprintf("OPENSSL_API_COMPAT=%s", $apitable->{$config{api}});
-    push @default_depdefines, $apiflag;
     push @{$config{defines}}, $apiflag;
 }
 
 if ($strict_warnings)
        {
        my $wopt;
-       my $addflags = '';
        die "ERROR --strict-warnings requires gcc or clang"
             unless $ecc eq 'gcc' || $ecc eq 'clang';
        foreach $wopt (split /\s+/, $gcc_devteam_warn)
                {
-               $addflags .= " $wopt" unless ($config{cflags} =~ /(^|\s)$wopt(\s|$)/)
+               $config{cflags} .= " $wopt" unless ($config{cflags} =~ /(?:^|\s)$wopt(?:\s|$)/)
                }
        if ($ecc eq "clang")
                {
                foreach $wopt (split /\s+/, $clang_devteam_warn)
                        {
-                       $addflags .= " $wopt" unless ($config{cflags} =~ /(^|\s)$wopt(\s|$)/)
+                       $config{cflags} .= " $wopt" unless ($config{cflags} =~ /(?:^|\s)$wopt(?:\s|$)/)
                        }
                }
-       if ($target !~ /^mingw/)
+       }
+
+unless ($disabled{"crypto-mdebug-backtrace"})
+       {
+       foreach my $wopt (split /\s+/, $memleak_devteam_backtrace)
                {
-               foreach $wopt (split /\s+/, $memleak_devteam_backtrace)
-                       {
-                       $addflags .= " $wopt" unless ($config{cflags} =~ /(^|\s)$wopt(\s|$)/)
-                       }
-               if ($target =~ /^BSD-/)
-                       {
-                       $config{ex_libs} .= " -lexecinfo";
-                       }
+               $config{cflags} .= " $wopt" unless ($config{cflags} =~ /(?:^|\s)$wopt(?:\s|$)/)
+               }
+       if ($target =~ /^BSD-/)
+               {
+               $config{ex_libs} .= " -lexecinfo";
                }
-       $config{cflags} = "$addflags $config{cflags}" if $addflags ne '';
        }
 
+if ($user_cflags ne "") { $config{cflags}="$config{cflags}$user_cflags"; }
+else                    { $no_user_cflags=1;  }
+if (@user_defines) { $config{defines}=[ @{$config{defines}}, @user_defines ]; }
+else               { $no_user_defines=1;    }
+
+# ALL MODIFICATIONS TO %config and %target MUST BE DONE FROM HERE ON
+
 # If we use the unified build, collect information from build.info files
 my %unified_info = ();
 
@@ -1549,9 +1538,9 @@ EOF
 
 # For the schemes that need it, we provide the old *_obj configs
 # from the *_asm_obj ones
-foreach (grep /_asm_src$/, keys %target) {
+foreach (grep /_(asm|aux)_src$/, keys %target) {
     my $src = $_;
-    (my $obj = $_) =~ s/_asm_src$/_obj/;
+    (my $obj = $_) =~ s/_(asm|aux)_src$/_obj/;
     ($target{$obj} = $target{$src}) =~ s/\.[csS]\b/.o/g;
 }
 
@@ -1672,13 +1661,6 @@ EOF
 print OUT "1;\n";
 close(OUT);
 
-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
-***** to use the "unified" build scheme.
-
-EOF
 
 print "IsMK1MF       =", ($builder eq "mk1mf" ? "yes" : "no"), "\n";
 print "CC            =$target{cc}\n";