Link library for backtrace() on BSD...
[openssl.git] / Configure
index cfd1980d809678de1c0da9904ee7d13861c263fa..9473452bf8ca80b390e916ad74d25f12dd9add4a 100755 (executable)
--- a/Configure
+++ b/Configure
@@ -1,6 +1,6 @@
-:
-eval 'exec perl -S $0 ${1+"$@"}'
-    if $running_under_some_shell;
+#! /usr/bin/env perl
+# -*- mode: perl; -*-
+
 ##
 ##  Configure -- OpenSSL source tree configuration script
 ##  If editing this file, run this command before committing
@@ -101,13 +101,17 @@ my $gcc_devteam_warn = "-Wall -pedantic -DPEDANTIC -Wno-long-long -Wsign-compare
 
 # 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: -Wconditional-uninitialized,
+# following warnings can also be enabled:
 # -Wswitch-enum, -Wunused-macros, -Wmissing-field-initializers,
-# -Wmissing-variable-declarations,
-# -Wincompatible-pointer-types-discards-qualifiers, -Wcast-align,
+# -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 -Qunused-arguments";
+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";
+
 
 my $strict_warnings = 0;
 
@@ -769,7 +773,7 @@ my $no_threads=0;
 my $threads=0;
 my $no_shared=0; # but "no-shared" is default
 my $zlib=1;      # but "no-zlib" is default
-my $no_rfc3779=1; # but "no-rfc3779" is default
+my $no_rfc3779=0;
 my $no_asm=0;
 my $no_dso=0;
 my $no_gmp=0;
@@ -797,6 +801,86 @@ my $default_ranlib;
 my $perl;
 my $fips=0;
 
+# 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
+
+my @disablables = (
+    "aes",
+    "asm",
+    "bf",
+    "camellia",
+    "capieng",
+    "cast",
+    "cmac",
+    "cms",
+    "comp",
+    "ct",
+    "deprecated",
+    "des",
+    "dgram",
+    "dh",
+    "dsa",
+    "dso",
+    "dtls1?",
+    "dynamic[-_]engine",
+    "ec",
+    "ec2m",
+    "ec_nistp_64_gcc_128",
+    "engine",
+    "err",                     # Really???
+    "gmp",
+    "gost",
+    "heartbeats",
+    "hmac",
+    "hw(-.+)?",
+    "idea",
+    "jpake",
+    "locking",                 # Really???
+    "md2",
+    "md4",
+    "md5",
+    "mdc2",
+    "md[-_]ghost94",
+    "nextprotoneg",
+    "ocb",
+    "ocsp",
+    "posix-io",
+    "psk",
+    "rc2",
+    "rc4",
+    "rc5",
+    "rdrand",
+    "rfc3779",
+    "rijndael",                        # Old AES name
+    "rmd160",
+    "rsa",
+    "scrypt",
+    "sct",
+    "sctp",
+    "seed",
+    "sha",
+    "shared",
+    "sock",
+    "srp",
+    "srtp",
+    "sse2",
+    "ssl",
+    "ssl3",
+    "ssl3-method",
+    "ssl-trace",
+    "static-engine",
+    "stdio",
+    "store",
+    "threads",
+    "tls",
+    "tls1",
+    "unit-test",
+    "whirlpool",
+    "zlib",
+    "zlib-dynamic",
+    );
+
 # All of the following is disabled by default (RC5 was enabled before 0.9.8):
 
 my %disabled = ( # "what"         => "comment" [or special keyword "experimental"]
@@ -806,7 +890,6 @@ my %disabled = ( # "what"         => "comment" [or special keyword "experimental
                 "jpake"          => "experimental",
                 "md2"            => "default",
                 "rc5"            => "default",
-                "rfc3779"        => "default",
                 "sctp"       => "default",
                 "shared"         => "default",
                 "ssl-trace"      => "default",
@@ -819,7 +902,7 @@ my @experimental = ();
 
 # This is what $depflags will look like with the above defaults
 # (we need this to see if we should advise the user to run "make depend"):
-my $default_depflags = " -DOPENSSL_NO_DEPRECATED -DOPENSSL_NO_EC_NISTP_64_GCC_128 -DOPENSSL_NO_GMP -DOPENSSL_NO_JPAKE -DOPENSSL_NO_MD2 -DOPENSSL_NO_RC5 -DOPENSSL_NO_RFC3779 -DOPENSSL_NO_SCTP -DOPENSSL_NO_SSL_TRACE -DOPENSSL_NO_STORE -DOPENSSL_NO_UNIT_TEST";
+my $default_depflags = " -DOPENSSL_NO_DEPRECATED -DOPENSSL_NO_EC_NISTP_64_GCC_128 -DOPENSSL_NO_GMP -DOPENSSL_NO_JPAKE -DOPENSSL_NO_MD2 -DOPENSSL_NO_RC5 -DOPENSSL_NO_SCTP -DOPENSSL_NO_SSL_TRACE -DOPENSSL_NO_STORE -DOPENSSL_NO_UNIT_TEST";
 
 # Explicit "no-..." options will be collected in %disabled along with the defaults.
 # To remove something from %disabled, use "enable-foo" (unless it's experimental).
@@ -869,6 +952,8 @@ while($argv_unprocessed)
        $argvstring=join(' ',@argvcopy);
 
 PROCESS_ARGS:
+       {
+       my %unsupported_options = ();
        foreach (@argvcopy)
                {
                s /^-no-/no-/; # some people just can't read the instructions
@@ -880,6 +965,15 @@ PROCESS_ARGS:
                s /^zlib$/enable-zlib/;
                s /^zlib-dynamic$/enable-zlib-dynamic/;
 
+               if (/^(no|disable|enable|experimental)-(.+)$/)
+                       {
+                       my $word = $2;
+                       if (!grep { $word =~ /^${_}$/ } @disablables)
+                               {
+                               $unsupported_options{$_} = 1;
+                               next;
+                               }
+                       }
                if (/^no-(.+)$/ || /^disable-(.+)$/)
                        {
                        if (!($disabled{$1} eq "experimental"))
@@ -1048,8 +1142,14 @@ PROCESS_ARGS:
                                { $options .= " ".$_; }
                        }
                }
-       }
 
+       if (keys %unsupported_options)
+               {
+               die "***** Unsupported options: ",
+                       join(", ", keys %unsupported_options), "\n";
+               }
+       }
+       }
 
 
 if ($processor eq "386")
@@ -1088,7 +1188,7 @@ if (defined($disabled{"md5"}) || defined($disabled{"sha"})
 
 
 if (defined($disabled{"ec"}) || defined($disabled{"dsa"})
-    || defined($disabled{"dh"}))
+    || defined($disabled{"dh"}) || defined($disabled{"stdio"}))
        {
        $disabled{"gost"} = "forced";
        }
@@ -1637,23 +1737,35 @@ if ($shlib_version_number =~ /(^[0-9]*)\.([0-9\.]*)/)
        $shlib_minor=$2;
        }
 
+my $ecc = $cc;
+$ecc = "clang" if `$cc --version 2>&1` =~ /clang/;
+
 if ($strict_warnings)
        {
-       my $ecc = $cc;
-       $ecc = "clang" if `$cc --version 2>&1` =~ /clang/;
        my $wopt;
-       die "ERROR --strict-warnings requires gcc or clang" unless ($ecc =~ /gcc$/ or $ecc =~ /clang$/);
+       die "ERROR --strict-warnings requires gcc or clang" unless ($ecc =~ /gcc(-\d(\.\d)*)?$/ or $ecc =~ /clang$/);
        foreach $wopt (split /\s+/, $gcc_devteam_warn)
                {
-               $cflags .= " $wopt" unless ($cflags =~ /$wopt/)
+               $cflags .= " $wopt" unless ($cflags =~ /(^|\s)$wopt(\s|$)/)
                }
        if ($ecc eq "clang")
                {
                foreach $wopt (split /\s+/, $clang_devteam_warn)
                        {
-                       $cflags .= " $wopt" unless ($cflags =~ /$wopt/)
+                       $cflags .= " $wopt" unless ($cflags =~ /(^|\s)$wopt(\s|$)/)
                        }
                }
+       if ($target !~ /^mingw/)
+               {
+               foreach $wopt (split /\s+/, $memleak_devteam_backtrace)
+                       {
+                       $cflags .= " $wopt" unless ($cflags =~ /(^|\s)$wopt(\s|$)/)
+                       }
+                if ($target =~ /^BSD-/)
+                       {
+                        $lflags .= " -lexecinfo";
+                        }
+                }
        }
 
 open(IN,"<Makefile.org") || die "unable to read Makefile.org:$!\n";
@@ -1705,7 +1817,7 @@ while (<IN>)
                s/^CC=.*$/CC= $cc/;
                s/^AR=\s*ar/AR= $ar/;
                s/^RANLIB=.*/RANLIB= $ranlib/;
-               s/^MAKEDEPPROG=.*$/MAKEDEPPROG= $cc/ if $cc eq "gcc" || ($cc eq 'cc' && $target =~ /darwin/);
+               s/^MAKEDEPPROG=.*$/MAKEDEPPROG= $cc/ if $ecc eq "gcc" || $ecc eq "clang";
                }
        s/^CFLAG=.*$/CFLAG= $cflags/;
        s/^DEPFLAG=.*$/DEPFLAG=$depflags/;
@@ -1984,6 +2096,16 @@ print "RC2 uses u$type[$rc2_int]\n" if $rc2_int != $def_int;
 print "BF_PTR used\n" if $bf_ptr == 1;
 print "BF_PTR2 used\n" if $bf_ptr == 2;
 
+{
+    my $perlguess = $perl =~ m@^/@ ? $perl : '/usr/local/bin/perl';
+
+    &dofile("tools/c_rehash",$perlguess,
+           '^#!/'              => '#!%s',
+           '^my \$dir;$'       => 'my $dir = "' . $openssldir . '";',
+           '^my \$prefix;$'    => 'my $prefix = "' . $prefix . '";');
+    &dofile("apps/CA.pl",$perl,
+           '^#!/'              => '#!%s');
+}
 if($IsMK1MF) {
        open (OUT,">crypto/buildinf.h") || die "Can't open buildinf.h";
        printf OUT <<EOF;
@@ -2002,14 +2124,6 @@ EOF
        $make_targets .= " depend" if $depflags ne $default_depflags && $make_depend;
        (system $make_command.$make_targets) == 0 or die "make $make_targets failed"
                if $make_targets ne "";
-       if ( $perl =~ m@^/@) {
-           &dofile("tools/c_rehash",$perl,'^#!/', '#!%s','^my \$dir;$', 'my $dir = "' . $openssldir . '";', '^my \$prefix;$', 'my $prefix = "' . $prefix . '";');
-           &dofile("apps/CA.pl",$perl,'^#!/', '#!%s');
-       } else {
-           # No path for Perl known ...
-           &dofile("tools/c_rehash",'/usr/local/bin/perl','^#!/', '#!%s','^my \$dir;$', 'my $dir = "' . $openssldir . '";',  '^my \$prefix;$', 'my $prefix = "' . $prefix . '";');
-           &dofile("apps/CA.pl",'/usr/local/bin/perl','^#!/', '#!%s');
-       }
        if ($depflags ne $default_depflags && !$make_depend) {
                print <<EOF;
 
@@ -2068,7 +2182,7 @@ BEGIN
            VALUE "ProductVersion", "$version\\0"
            // Optional:
            //VALUE "Comments", "\\0"
-           VALUE "LegalCopyright", "Copyright © 1998-2005 The OpenSSL Project. Copyright © 1995-1998 Eric A. Young, Tim J. Hudson. All rights reserved.\\0"
+           VALUE "LegalCopyright", "Copyright © 1998-2015 The OpenSSL Project. Copyright © 1995-1998 Eric A. Young, Tim J. Hudson. All rights reserved.\\0"
            //VALUE "LegalTrademarks", "\\0"
            //VALUE "PrivateBuild", "\\0"
            //VALUE "SpecialBuild", "\\0"