Move more BN internals to bn_lcl.h
[openssl.git] / Configure
index ec94edc5245af641c9184767c84972f07ff2c344..9a9b92a7739fb18ceffac9182b2ffd493290305e 100755 (executable)
--- a/Configure
+++ b/Configure
@@ -97,12 +97,8 @@ my $warn_make_depend = 0;
 # 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="";
-my $x86_gcc_opts="";
-
 # 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
@@ -196,7 +192,6 @@ my $zlib=1;      # but "no-zlib" is default
 my $no_rfc3779=0;
 my $no_asm=0;
 my $no_dso=0;
-my $Makefile="Makefile";
 my $default_ranlib;
 $config{fips}=0;
 
@@ -815,7 +810,7 @@ $config{openssldir} = catdir($config{prefix}, $config{openssldir})
 # Allow environment CC to override compiler...
 $target{cc} = $ENV{CC} || $target{cc};
 
-# For cflags and lflags, add the debug_ or release_ attributes
+# For cflags, lflags and ex_libs, add the debug_ or release_ attributes
 # Do it in such a way that no spurious space is appended (hence the grep).
 $config{cflags} = join(" ",
                       grep { $_ ne "" } ($target{cflags},
@@ -823,6 +818,9 @@ $config{cflags} = join(" ",
 $config{lflags} = join(" ",
                       grep { $_ ne "" } ($target{lflags},
                                          $target{$build_prefix."lflags"}));
+$config{ex_libs} = join(" ",
+                       grep { $_  ne "" } ($target{ex_libs},
+                                           $target{$build_prefix."ex_libs"}));
 
 $target{ranlib} = $ENV{'RANLIB'} || $target{ranlib} || $default_ranlib;
 $target{ar} = $ENV{'AR'} || "ar";
@@ -843,11 +841,6 @@ $config{enginesdir}=$config{prefix} . "/" . $config{libdir}  . "/engines";
 
 $config{cflags} .= "$exp_cflags";
 
-# '%' in $config{lflags} is used to split flags to "pre-" and post-flags
-my ($pre,$post)=split('%',$config{lflags});
-if (defined($post))    { $config{prelflags}=$pre; $config{lflags}=$post;       }
-else                   { $config{prelflags}="";   $config{lflags}=$pre;        }
-
 if ($target =~ /^mingw/ && `$target{cc} --target-help 2>&1` !~ m/-mno-cygwin/m)
        {
        $config{cflags} =~ s/-mno-cygwin\s*//;
@@ -891,7 +884,7 @@ if (!$no_dso && $target{dso_scheme} ne "")
        $config{cflags} = "$dso_cflags $config{cflags}";
        }
 
-my $thread_cflags;
+my $thread_cflags = "";
 my @thread_defines;
 if ($target{thread_cflag} ne "(unknown)" && !$no_threads)
        {
@@ -909,34 +902,25 @@ if ($target{thread_cflag} eq "(unknown)" && $threads)
                print "provide any system-specific compiler options\n";
                exit(1);
                }
-       $thread_cflags="-DOPENSSL_THREADS $config{cflags}" ;
+       $thread_cflags="-DOPENSSL_THREADS" ;
        push @thread_defines, "OPENSSL_THREADS";
        }
 else
        {
-       $thread_cflags="-DOPENSSL_THREADS $target{thread_cflag} $config{cflags}";
+       $thread_cflags="-DOPENSSL_THREADS $target{thread_cflag}";
        push @thread_defines, "OPENSSL_THREADS";
-#      my $def;
-#      foreach $def (split ' ',$target{thread_cflag})
-#              {
-#              if ($def =~ s/^-D// && $def !~ /^_/)
-#                      {
-#                      push @thread_defines, "$def";
-#                      }
-#              }
        }
 
-$config{lflags}="$libs$config{lflags}" if ($libs ne "");
+$config{ex_libs}="$libs$config{ex_libs}" if ($libs ne "");
 
 if ($no_asm)
        {
        $config{cflags}=~s/-D[BL]_ENDIAN//              if ($config{fips});
-       $thread_cflags=~s/-D[BL]_ENDIAN//       if ($config{fips});
        }
 
 if ($threads)
        {
-       $config{cflags}=$thread_cflags;
+       $config{cflags} = "$thread_cflags $config{cflags}" if $thread_cflags;
        push @{$config{openssl_thread_defines}}, @thread_defines;
        }
 
@@ -947,11 +931,11 @@ if ($zlib)
                {
                if (defined($withargs{"zlib-lib"}))
                        {
-                       $config{lflags} .= " -L" . $withargs{"zlib-lib"} . " -lz";
+                       $config{ex_libs} .= " -L" . $withargs{"zlib-lib"} . " -lz";
                        }
                else
                        {
-                       $config{lflags} .= " -lz";
+                       $config{ex_libs} .= " -lz";
                        }
                }
        else
@@ -1014,17 +998,17 @@ if ($target =~ /-icc$/)  # Intel C compiler
                }
        if ($iccver>=9)
                {
-               $config{lflags}.=" -i-static";
-               $config{lflags}=~s/-no_cpprt/-no-cpprt/;
+               $config{ex_libs}.=" -i-static";
+               $config{ex_libs}=~s/-no_cpprt/-no-cpprt/;
                }
        if ($iccver>=10)
                {
-               $config{lflags}=~s/-i-static/-static-intel/;
+               $config{ex_libs}=~s/-i-static/-static-intel/;
                }
        if ($iccver>=11)
                {
                $config{cflags}.=" -no-intel-extensions";       # disable Cilk
-               $config{lflags}=~s/-no-cpprt/-no-cxxlib/;
+               $config{ex_libs}=~s/-no-cpprt/-no-cxxlib/;
                }
        }
 
@@ -1130,20 +1114,23 @@ $config{bn_ll}                  =0;
 $config{export_var_as_fn}      =0;
 my $def_int="unsigned int";
 $config{rc4_int}               =$def_int;
-$config{rc2_int}               =$def_int;
 ($config{b64l},$config{b64},$config{b32})=(0,0,1);
 
+my $count = 0;
 foreach (sort split(/\s+/,$target{bn_ops})) {
-    $config{bn_ll}=1                           if /BN_LLONG/;
-    $config{rc4_int}="unsigned char"           if /RC4_CHAR/;
-    ($config{b64l},$config{b64},$config{b32},$config{b16},$config{b8})
-       =(0,1,0,0,0)                            if /SIXTY_FOUR_BIT/;
-    ($config{b64l},$config{b64},$config{b32},$config{b16},$config{b8})
-       =(1,0,0,0,0)                            if /SIXTY_FOUR_BIT_LONG/;
-    ($config{b64l},$config{b64},$config{b32},$config{b16},$config{b8})
-       =(0,0,1,0,0)                            if /THIRTY_TWO_BIT/;
-    $config{export_var_as_fn}=1                        if /EXPORT_VAR_AS_FN/;
+    $count++ if /SIXTY_FOUR_BIT|SIXTY_FOUR_BIT_LONG|THIRTY_TWO_BIT/;
+    $config{export_var_as_fn}=1                 if $_ eq 'EXPORT_VAR_AS_FN';
+    $config{bn_ll}=1                           if $_ eq 'BN_LLONG';
+    $config{rc4_int}="unsigned char"           if $_ eq 'RC4_CHAR';
+    ($config{b64l},$config{b64},$config{b32})
+       =(0,1,0)                                if $_ eq 'SIXTY_FOUR_BIT';
+    ($config{b64l},$config{b64},$config{b32})
+       =(1,0,0)                                if $_ eq 'SIXTY_FOUR_BIT_LONG';
+    ($config{b64l},$config{b64},$config{b32})
+       =(0,0,1)                                if $_ eq 'THIRTY_TWO_BIT';
 }
+die "Exactly one of SIXTY_FOUR_BIT|SIXTY_FOUR_BIT_LONG|THIRTY_TWO_BIT can be set in bn_ops\n"
+    if $count > 1;
 
 
 # Hack cflags for better warnings (dev option) #######################
@@ -1182,7 +1169,7 @@ if ($strict_warnings)
                        }
                if ($target =~ /^BSD-/)
                        {
-                       $config{lflags} .= " -lexecinfo";
+                       $config{ex_libs} .= " -lexecinfo";
                        }
                }
        }
@@ -1265,7 +1252,8 @@ close(OUT);
 print "IsMK1MF       =", ($target{build_scheme}->[0] eq "mk1mf" ? "yes" : "no"), "\n";
 print "CC            =$target{cc}\n";
 print "CFLAG         =$config{cflags}\n";
-print "EX_LIBS       =$config{lflags}\n";
+print "LFLAGS        =$config{lflags}\n";
+print "EX_LIBS       =$config{ex_libs}\n";
 print "CPUID_OBJ     =$target{cpuid_obj}\n";
 print "BN_ASM        =$target{bn_obj}\n";
 print "EC_ASM        =$target{ec_obj}\n";
@@ -1293,9 +1281,11 @@ print "SIXTY_FOUR_BIT mode\n" if $config{b64};
 print "THIRTY_TWO_BIT mode\n" if $config{b32};
 print "BN_LLONG mode\n" if $config{bn_ll};
 print "RC4 uses $config{rc4_int}\n" if $config{rc4_int} != $def_int;
-print "RC2 uses $config{rc2_int}\n" if $config{rc2_int} != $def_int;
 
-run_dofile("$Makefile.in","$Makefile");
+run_dofile("Makefile.in","Makefile");
+
+run_dofile("util/domd.in", "util/domd");
+chmod 0755, "util/domd";
 
 run_dofile("include/openssl/opensslconf.h.in", "include/openssl/opensslconf.h");
 
@@ -1669,7 +1659,9 @@ sub run_dofile()
     my $in = shift;
     my $out = shift;
 
-    # should we remove $out ?
+    unlink $out || warn "Can't remove $out, $!"
+        if -f $out;
+    die "Can't open $in, $!" unless -f $in;
     system("$config{perl} -I. -Mconfigdata util/dofile.pl -o\"Configure\" $in > $out.new");
     exit 1 if $? != 0;
     rename("$out.new", $out) || die "Can't rename $out.new, $!";
@@ -1696,8 +1688,11 @@ sub print_table_entry
        "unistd",
        "ld",
        "lflags",
+       "ex_libs",
        "debug_lflags",
+       "debug_ex_libs",
        "release_lflags",
+       "release_ex_libs",
        "bn_ops",
        "cpuid_obj",
        "bn_obj",