update ordinals
[openssl.git] / Configure
index e374a69dcadd39a72acbfe5a392132eea5baf701..fd7988e2b3d93aad622f530327944fecca98ae88 100755 (executable)
--- a/Configure
+++ b/Configure
@@ -7,6 +7,7 @@ eval 'exec perl -S $0 ${1+"$@"}'
 
 require 5.000;
 use strict;
+use File::Compare;
 
 # see INSTALL for instructions.
 
@@ -57,8 +58,13 @@ my $usage="Usage: Configure [no-<cipher> ...] [enable-<cipher> ...] [experimenta
 # zlib-dynamic Like "zlib", but the zlib library is expected to be a shared
 #              library and will be loaded in run-time by the OpenSSL library.
 # sctp          include SCTP support
-# 386           generate 80386 code
-# no-sse2      disables IA-32 SSE2 code, above option implies no-sse2
+# enable-weak-ssl-ciphers
+#              Enable EXPORT and LOW SSLv3 ciphers that are disabled by
+#              default.  Note, weak SSLv2 ciphers are unconditionally
+#              disabled.
+# 386          generate 80386 code in assembly modules
+# no-sse2      disables IA-32 SSE2 code in assembly modules, the above
+#              mentioned '386' option implies this one
 # no-<cipher>   build without specified algorithm (rsa, idea, rc5, ...)
 # -<xxx> +<xxx> compiler options are passed through 
 #
@@ -103,7 +109,7 @@ 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 -Werror -DCRYPTO_MDEBUG_ALL -DCRYPTO_MDEBUG_ABORT -DREF_CHECK -DOPENSSL_NO_DEPRECATED";
+my $gcc_devteam_warn = "-Wall -pedantic -DPEDANTIC -Wno-long-long -Wsign-compare -Wmissing-prototypes -Wshadow -Wformat -Wundef -Werror -DCRYPTO_MDEBUG_ALL -DCRYPTO_MDEBUG_ABORT -DREF_CHECK -DOPENSSL_NO_DEPRECATED";
 
 # TODO(openssl-team): fix problems and investigate if (at least) the following
 # warnings can also be enabled:
@@ -124,6 +130,9 @@ my $clang_disabled_warnings = "-Wno-unused-parameter -Wno-missing-field-initiali
 # -Wextended-offsetof
 my $clang_devteam_warn = "-Wno-unused-parameter -Wno-missing-field-initializers -Wno-language-extension-token -Wno-extended-offsetof -Qunused-arguments";
 
+# Warn that "make depend" should be run?
+my $warn_make_depend = 0;
+
 my $strict_warnings = 0;
 
 my $x86_gcc_des="DES_PTR DES_RISC1 DES_UNROLL";
@@ -778,11 +787,13 @@ my %disabled = ( # "what"         => "comment" [or special keyword "experimental
                 "md2"            => "default",
                 "rc5"            => "default",
                 "rfc3779"        => "default",
-                "sctp"       => "default",
+                "sctp"           => "default",
                 "shared"         => "default",
                 "ssl-trace"      => "default",
+                "ssl2"           => "default",
                 "store"          => "experimental",
                 "unit-test"      => "default",
+                "weak-ssl-ciphers" => "default",
                 "zlib"           => "default",
                 "zlib-dynamic"   => "default"
               );
@@ -790,7 +801,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_EC_NISTP_64_GCC_128 -DOPENSSL_NO_GMP -DOPENSSL_NO_JPAKE -DOPENSSL_NO_LIBUNBOUND -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_EC_NISTP_64_GCC_128 -DOPENSSL_NO_GMP -DOPENSSL_NO_JPAKE -DOPENSSL_NO_LIBUNBOUND -DOPENSSL_NO_MD2 -DOPENSSL_NO_RC5 -DOPENSSL_NO_RFC3779 -DOPENSSL_NO_SCTP -DOPENSSL_NO_SSL_TRACE -DOPENSSL_NO_SSL2 -DOPENSSL_NO_STORE -DOPENSSL_NO_UNIT_TEST -DOPENSSL_NO_WEAK_SSL_CIPHERS";
 
 # Explicit "no-..." options will be collected in %disabled along with the defaults.
 # To remove something from %disabled, use "enable-foo" (unless it's experimental).
@@ -1073,11 +1084,6 @@ if (defined($disabled{"md5"}) || defined($disabled{"sha"})
        $disabled{"tls1"} = "forced";
        }
 
-if (defined($disabled{"tls1"}))
-       {
-       $disabled{"tlsext"} = "forced";
-       }
-
 if (defined($disabled{"ec"}) || defined($disabled{"dsa"})
     || defined($disabled{"dh"}))
        {
@@ -1245,6 +1251,7 @@ my $shared_extension = $fields[$idx_shared_extension];
 my $ranlib = $ENV{'RANLIB'} || $fields[$idx_ranlib];
 my $ar = $ENV{'AR'} || "ar";
 my $arflags = $fields[$idx_arflags];
+my $windres = $ENV{'RC'} || $ENV{'WINDRES'} || "windres";
 my $multilib = $fields[$idx_multilib];
 
 # if $prefix/lib$multilib is not an existing directory, then
@@ -1513,7 +1520,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 "")
@@ -1553,8 +1560,15 @@ $cpuid_obj="mem_clr.o"   unless ($cpuid_obj =~ /\.o$/);
 $des_obj=$des_enc      unless ($des_obj =~ /\.o$/);
 $bf_obj=$bf_enc                unless ($bf_obj =~ /\.o$/);
 $cast_obj=$cast_enc    unless ($cast_obj =~ /\.o$/);
-$rc4_obj=$rc4_enc      unless ($rc4_obj =~ /\.o$/);
 $rc5_obj=$rc5_enc      unless ($rc5_obj =~ /\.o$/);
+if ($rc4_obj =~ /\.o$/)
+       {
+       $cflags.=" -DRC4_ASM";
+       }
+else
+       {
+       $rc4_obj=$rc4_enc;
+       }
 if ($sha1_obj =~ /\.o$/)
        {
 #      $sha1_obj=$sha1_enc;
@@ -1656,13 +1670,13 @@ if ($strict_warnings)
        die "ERROR --strict-warnings requires gcc or clang" unless ($ecc =~ /gcc$/ 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|$)/)
                        }
                }
        }
@@ -1708,12 +1722,14 @@ while (<IN>)
                s/^AR=\s*/AR= \$\(CROSS_COMPILE\)/;
                s/^NM=\s*/NM= \$\(CROSS_COMPILE\)/;
                s/^RANLIB=\s*/RANLIB= \$\(CROSS_COMPILE\)/;
+               s/^RC=\s*/RC= \$\(CROSS_COMPILE\)/;
                s/^MAKEDEPPROG=.*$/MAKEDEPPROG= \$\(CROSS_COMPILE\)$cc/ if $cc eq "gcc";
                }
        else    {
                s/^CC=.*$/CC= $cc/;
                s/^AR=\s*ar/AR= $ar/;
                s/^RANLIB=.*/RANLIB= $ranlib/;
+               s/^RC=.*/RC= $windres/;
                s/^MAKEDEPPROG=.*$/MAKEDEPPROG= $cc/ if $cc eq "gcc";
                s/^MAKEDEPPROG=.*$/MAKEDEPPROG= $cc/ if $ecc eq "gcc" || $ecc eq "clang";
                }
@@ -1778,8 +1794,16 @@ while (<IN>)
        }
 close(IN);
 close(OUT);
-rename($Makefile,"$Makefile.bak") || die "unable to rename $Makefile\n" if -e $Makefile;
-rename("$Makefile.new",$Makefile) || die "unable to rename $Makefile.new\n";
+if ((compare($Makefile, "$Makefile.new"))
+       or file_newer('Configure', $Makefile)
+       or file_newer('config', $Makefile)
+       or file_newer('Makefile.org', $Makefile))
+       {
+       rename($Makefile,"$Makefile.bak") || die "unable to rename $Makefile\n" if -e $Makefile;
+       rename("$Makefile.new",$Makefile) || die "unable to rename $Makefile.new\n";
+       }
+else
+       { unlink("$Makefile.new"); }
 
 print "CC            =$cc\n";
 print "CFLAG         =$cflags\n";
@@ -1971,9 +1995,13 @@ print OUT "#ifdef  __cplusplus\n";
 print OUT "}\n";
 print OUT "#endif\n";
 close(OUT);
-rename("crypto/opensslconf.h","crypto/opensslconf.h.bak") || die "unable to rename crypto/opensslconf.h\n" if -e "crypto/opensslconf.h";
-rename("crypto/opensslconf.h.new","crypto/opensslconf.h") || die "unable to rename crypto/opensslconf.h.new\n";
-
+if (compare("crypto/opensslconf.h.new","crypto/opensslconf.h"))
+       {
+       rename("crypto/opensslconf.h","crypto/opensslconf.h.bak") || die "unable to rename crypto/opensslconf.h\n" if -e "crypto/opensslconf.h";
+       rename("crypto/opensslconf.h.new","crypto/opensslconf.h") || die "unable to rename crypto/opensslconf.h.new\n";
+       }
+else
+       { unlink("crypto/opensslconf.h.new"); }
 
 # Fix the date
 
@@ -2013,12 +2041,13 @@ EOF
        close(OUT);
 } else {
        my $make_command = "$make PERL=\'$perl\'";
-       my $make_targets = "";
-       $make_targets .= " links" if $symlink;
-       $make_targets .= " depend" if $depflags ne $default_depflags && $make_depend;
-       $make_targets .= " gentests" if $symlink;
-       (system $make_command.$make_targets) == 0 or exit $?
-               if $make_targets ne "";
+       my @make_targets = ();
+       push @make_targets, "links" if $symlink;
+       push @make_targets, "depend" if $depflags ne $default_depflags && $make_depend;
+       push @make_targets, "gentests" if $symlink;
+       foreach my $make_target (@make_targets) {
+           (system "$make_command $make_target") == 0 or exit $?;
+       }
        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');
@@ -2028,13 +2057,7 @@ EOF
            &dofile("apps/CA.pl",'/usr/local/bin/perl','^#!/', '#!%s');
        }
        if ($depflags ne $default_depflags && !$make_depend) {
-               print <<EOF;
-
-Since you've disabled or enabled at least one algorithm, you need to do
-the following before building:
-
-       make depend
-EOF
+           $warn_make_depend++;
        }
 }
 
@@ -2114,12 +2137,18 @@ EOF
 
 print <<\EOF if ($no_shared_warn);
 
-You gave the option 'shared'.  Normally, that would give you shared libraries.
-Unfortunately, the OpenSSL configuration doesn't include shared library support
-for this platform yet, so it will pretend you gave the option 'no-shared'.  If
-you can inform the developpers (openssl-dev\@openssl.org) how to support shared
-libraries on this platform, they will at least look at it and try their best
-(but please first make sure you have tried with a current version of OpenSSL).
+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
+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);
+
+*** Because of configuration changes, you MUST do the following before
+*** building:
+
+       make depend
 EOF
 
 exit(0);
@@ -2275,3 +2304,9 @@ sub test_sanity
        print STDERR "No sanity errors detected!\n" if $errorcnt == 0;
        return $errorcnt;
        }
+
+sub file_newer
+       {
+       my ($file1, $file2) = @_;
+       return (stat($file1))[9] > (stat($file2))[9]
+       }