Fix no-psk compile failure
[openssl.git] / Configure
index d8ea689d704f2029d6e0adfd265f2cd6c725ea0f..dfbc667aec290f655b6373d8361ebcbda671570f 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
@@ -108,6 +108,11 @@ my $gcc_devteam_warn = "-Wall -pedantic -DPEDANTIC -Wno-long-long -Wsign-compare
 # -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";
+
+
 my $strict_warnings = 0;
 
 my $x86_gcc_des="DES_PTR DES_RISC1 DES_UNROLL";
@@ -210,6 +215,8 @@ my $BSDthreads="-pthread -D_THREAD_SAFE -D_REENTRANT";
 #        cmll_obj => $cmll_obj,
 #        modes_obj => $modes_obj,
 #        engines_obj => $engines_obj,
+#        chacha_obj => $wp_obj,
+#        poly1305_obj => $cmll_obj,
 #        dso_scheme => $dso_scheme,
 #        shared_target => $shared_target,
 #        shared_cflag => $shared_cflag,
@@ -791,6 +798,7 @@ my $cast_enc="c_enc.o";
 my $rc4_enc="rc4_enc.o rc4_skey.o";
 my $rc5_enc="rc5_enc.o";
 my $cmll_enc="camellia.o cmll_misc.o cmll_cbc.o";
+my $chacha_enc="chacha_enc.o";
 my $processor="";
 my $default_ranlib;
 my $perl;
@@ -807,6 +815,7 @@ my @disablables = (
     "camellia",
     "capieng",
     "cast",
+    "chacha",
     "cmac",
     "cms",
     "comp",
@@ -817,7 +826,7 @@ my @disablables = (
     "dh",
     "dsa",
     "dso",
-    "dtls1?",
+    "dtls",
     "dynamic[-_]engine",
     "ec",
     "ec2m",
@@ -840,6 +849,7 @@ my @disablables = (
     "nextprotoneg",
     "ocb",
     "ocsp",
+    "poly1305",
     "posix-io",
     "psk",
     "rc2",
@@ -947,6 +957,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
@@ -963,7 +975,7 @@ PROCESS_ARGS:
                        my $word = $2;
                        if (!grep { $word =~ /^${_}$/ } @disablables)
                                {
-                               warn "Unsupported option ${word}, ignored...\n";
+                               $unsupported_options{$_} = 1;
                                next;
                                }
                        }
@@ -1023,6 +1035,7 @@ PROCESS_ARGS:
                        {
                        if (open(IN,"<$Makefile"))
                                {
+                               my $config_args_found=0;
                                while (<IN>)
                                        {
                                        chomp;
@@ -1034,11 +1047,19 @@ PROCESS_ARGS:
                                                        if (grep(/^reconf/,@argvcopy));
                                                print "Reconfiguring with: $argvstring\n";
                                                $argv_unprocessed=1;
-                                               close(IN);
-                                               last PROCESS_ARGS;
+                                               $config_args_found=1;
+                                               }
+                                       elsif (/^CROSS_COMPILE=\s*(.*)/)
+                                               {
+                                               $ENV{CROSS_COMPILE}=$1;
+                                               }
+                                       elsif (/^CC=\s*(?:\$\(CROSS_COMPILE\))?(.*?)/)
+                                               {
+                                               $ENV{CC}=$1;
                                                }
                                        }
                                close(IN);
+                               last PROCESS_ARGS if ($config_args_found);
                                }
                        die "Insufficient data to reconfigure, please do a normal configuration\n";
                        }
@@ -1135,8 +1156,14 @@ PROCESS_ARGS:
                                { $options .= " ".$_; }
                        }
                }
-       }
 
+       if (keys %unsupported_options)
+               {
+               die "***** Unsupported options: ",
+                       join(", ", keys %unsupported_options), "\n";
+               }
+       }
+       }
 
 
 if ($processor eq "386")
@@ -1358,6 +1385,8 @@ my $wp_obj = $table{$target}->{wp_obj};
 my $cmll_obj = $table{$target}->{cmll_obj};
 my $modes_obj = $table{$target}->{modes_obj};
 my $engines_obj = $table{$target}->{engines_obj};
+my $chacha_obj = $table{$target}->{chacha_obj};
+my $poly1305_obj = $table{$target}->{poly1305_obj};
 my $perlasm_scheme = $table{$target}->{perlasm_scheme};
 my $dso_scheme = $table{$target}->{dso_scheme};
 my $shared_target = $table{$target}->{shared_target};
@@ -1468,7 +1497,8 @@ if ($no_asm)
        {
        $cpuid_obj=$bn_obj=$ec_obj=
        $des_obj=$aes_obj=$bf_obj=$cast_obj=$rc4_obj=$rc5_obj=$cmll_obj=
-       $modes_obj=$sha1_obj=$md5_obj=$rmd160_obj=$wp_obj=$engines_obj="";
+       $modes_obj=$sha1_obj=$md5_obj=$rmd160_obj=$wp_obj=$engines_obj=
+       $chacha_obj=$poly1305_obj="";
        $cflags=~s/\-D[BL]_ENDIAN//             if ($fips);
        $thread_cflags=~s/\-D[BL]_ENDIAN//      if ($fips);
        }
@@ -1687,6 +1717,11 @@ if ($ec_obj =~ /ecp_nistz256/)
        {
        $cflags.=" -DECP_NISTZ256_ASM";
        }
+$chacha_obj=$chacha_enc        unless ($chacha_obj =~ /\.o$/);
+if ($poly1305_obj =~ /\.o$/)
+       {
+       $cflags.=" -DPOLY1305_ASM";
+       }
 
 # "Stringify" the C flags string.  This permits it to be made part of a string
 # and works as well on command lines.
@@ -1733,15 +1768,26 @@ if ($strict_warnings)
        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";
@@ -1815,6 +1861,8 @@ while (<IN>)
        s/^WP_ASM_OBJ=.*$/WP_ASM_OBJ= $wp_obj/;
        s/^CMLL_ENC=.*$/CMLL_ENC= $cmll_obj/;
        s/^MODES_ASM_OBJ.=*$/MODES_ASM_OBJ= $modes_obj/;
+       s/^CHACHA_ENC=.*$/CHACHA_ENC= $chacha_obj/;
+       s/^POLY1305_ASM_OBJ=.*$/POLY1305_ASM_OBJ= $poly1305_obj/;
        s/^ENGINES_ASM_OBJ.=*$/ENGINES_ASM_OBJ= $engines_obj/;
        s/^PERLASM_SCHEME=.*$/PERLASM_SCHEME= $perlasm_scheme/;
        s/^PROCESSOR=.*/PROCESSOR= $processor/;
@@ -1874,6 +1922,8 @@ print "RMD160_OBJ_ASM=$rmd160_obj\n";
 print "CMLL_ENC      =$cmll_obj\n";
 print "MODES_OBJ     =$modes_obj\n";
 print "ENGINES_OBJ   =$engines_obj\n";
+print "CHACHA_ENC    =$chacha_obj\n";
+print "POLY1305_OBJ  =$poly1305_obj\n";
 print "PROCESSOR     =$processor\n";
 print "RANLIB        =$ranlib\n";
 print "ARFLAGS       =$arflags\n";
@@ -2302,6 +2352,8 @@ sub print_table_entry
 \$cmll_obj     = $table{$target}->{cmll_obj}
 \$modes_obj    = $table{$target}->{modes_obj}
 \$engines_obj  = $table{$target}->{engines_obj}
+\$chacha_obj   = $table{$target}->{chacha_obj}
+\$poly1305_obj = $table{$target}->{poly1305_obj}
 \$perlasm_scheme = $table{$target}->{perlasm_scheme}
 \$dso_scheme   = $table{$target}->{dso_scheme}
 \$shared_target= $table{$target}->{shared_target}
@@ -2341,6 +2393,8 @@ EOF
                "cmll_obj",
                "modes_obj",
                "engines_obj",
+               "chacha_obj",
+               "poly1305_obj",
                "perlasm_scheme",
                "dso_scheme",
                "shared_target",