Fix a typo in the X.509v3 docs: cRLSign instead of cRLCertSign is correct
[openssl.git] / Configure
index 79edba214ccbd820a65a4a68f4c6e45574f8e73a..c5867401e3daf775be667f5e1f7d1a5330917d2a 100755 (executable)
--- a/Configure
+++ b/Configure
@@ -1,8 +1,12 @@
-#!/usr/local/bin/perl -w
+:
+eval 'exec perl -S $0 ${1+"$@"}'
+    if $running_under_some_shell;
+##
+##  Configure -- OpenSSL source tree configuration script
+##
 
 require 5.000;
 use strict;
-use POSIX qw(:errno_h);
 
 #
 # see PROBLEMS for instructions on what sort of things to do when 
@@ -78,7 +82,8 @@ my %table=(
 # A few of my development configs
 "purify",      "purify gcc:-g -DPURIFY -Wall:-lsocket -lnsl::::",
 "debug",       "gcc:-DBN_DEBUG -DREF_CHECK -DCRYPTO_MDEBUG -ggdb -g2 -Wformat -Wshadow -Wmissing-prototypes -Wmissing-declarations -Werror:-lefence::::",
-"debug-rse","gcc:-DTERMIOS -DL_ENDIAN -O -g -ggdb3 -m486 -Wall::BN_LLONG $x86_gcc_des $x86_gcc_opts:$x86_out_asm",
+"debug-ben",   "gcc:-DBN_DEBUG -DREF_CHECK -DCRYPTO_MDEBUG -O2 -Wall -Wshadow -Werror -pipe:::::",
+"debug-rse","cc:-DTERMIOS -DL_ENDIAN -pipe -O -g -ggdb3 -Wall::BN_LLONG $x86_gcc_des $x86_gcc_opts:$x86_elf_asm",
 "dist",                "cc:-O -DNOPROTO::::",
 
 # Basic configs that should work on any box
@@ -100,6 +105,8 @@ my %table=(
 "solaris-usparc-sc4","cc:-xtarget=ultra -xarch=v8plus -Xa -xO5 -DB_ENDIAN:\
        -lsocket -lnsl:\
        BN_LLONG RC4_CHAR DES_PTR DES_RISC1 DES_UNROLL BF_PTR:asm/sparc.o::",
+"solaris-sparc-sc4-pic","cc:-xO5 -Xa -DB_ENDIAN -KPIC:-lsocket -lnsl:\
+       BN_LLONG RC4_CHAR DES_PTR DES_RISC1 DES_UNROLL BF_PTR:asm/sparc.o::",
 
 # Sunos configs, assuming sparc for the gcc one.
 "sunos-cc", "cc:-O4 -DNOPROTO -DNOCONST::DES_UNROLL:::",
@@ -144,13 +151,15 @@ my %table=(
 "linux-elf",   "gcc:-DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -m486 -Wall -Wuninitialized::BN_LLONG $x86_gcc_des $x86_gcc_opts:$x86_elf_asm",
 "debug-linux-elf","gcc:-DREF_CHECK -DCRYPTO_MDEBUG -DL_ENDIAN -DTERMIO -g -m486 -Wall:-lefence:BN_LLONG $x86_gcc_des $x86_gcc_opts:$x86_elf_asm",
 "linux-aout",  "gcc:-DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -m486 -Wall::BN_LLONG $x86_gcc_des $x86_gcc_opts:$x86_out_asm",
+"linux-mips",   "gcc:-DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall -Wuninitialized::BN_LLONG:::",
+"linux-ppc",    "gcc:-DB_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall::::",
 "NetBSD-sparc",        "gcc:-DTERMIOS -O3 -fomit-frame-pointer -mv8 -Wall -DB_ENDIAN::BN_LLONG MD2_CHAR RC4_INDEX DES_UNROLL:::",
 "NetBSD-m68",  "gcc:-DTERMIOS -O3 -fomit-frame-pointer -Wall -DB_ENDIAN::BN_LLONG MD2_CHAR RC4_INDEX DES_UNROLL:::",
 "NetBSD-x86",  "gcc:-DTERMIOS -D_ANSI_SOURCE -O3 -fomit-frame-pointer -m486 -Wall::BN_LLONG $x86_gcc_des $x86_gcc_opts:",
 #"FreeBSD",   "gcc:-DTERMIOS -DL_ENDIAN -D_ANSI_SOURCE -fomit-frame-pointer -O3 -m486 -Wall::BN_LLONG $x86_gcc_des $x86_gcc_opts:$x86_out_asm",
 "FreeBSD",      "gcc:-DTERMIOS -DL_ENDIAN -fomit-frame-pointer -O3 -m486 -Wall::BN_LLONG $x86_gcc_des $x86_gcc_opts:$x86_out_asm",
 "FreeBSD-elf",  "gcc:-DTERMIOS -DL_ENDIAN -fomit-frame-pointer -O3 -m486 -Wall::BN_LLONG $x86_gcc_des $x86_gcc_opts:$x86_elf_asm",
-#"bsdi-gcc",     "gcc:-O3 -ffast-math -DL_ENDIAN -DPERL5 -m486::RSA_LLONG $x86_gc_des $x86_gcc_opts:$x86_bsdi_asm",
+"bsdi-gcc",     "gcc:-O3 -ffast-math -DL_ENDIAN -DPERL5 -m486::RSA_LLONG $x86_gcc_des $x86_gcc_opts:$x86_bsdi_asm",
 "nextstep",    "cc:-O3 -Wall::BN_LLONG $x86_gcc_des ${x86_gcc_opts}:::",
 # NCR MP-RAS UNIX ver 02.03.01
 "ncr-scde","cc:-O6 -Xa -Hoff=BEHAVED -686 -Hwide -Hiw:-lsocket -lnsl:$x86_gcc_des ${x86_gcc_opts}:::",
@@ -225,6 +234,23 @@ my %table=(
 "OpenBSD-mips","gcc:-O2 -DL_ENDIAN:BN_LLONG MD2_CHAR RC4_INDEX RC4_CHAR DES_UNROLL DES_RISC2 DES_PTR BF_PTR::::",
 );
 
+# Miscellaneous hacks: this is designed to allow environments where the "one
+# makefile" option does not auto build all files.
+# The first six fields are the hard coded versions of the stuff generated by
+# ctx_size for pem.h: that is EVP_ENCODE_CTX_SIZE, EVP_MD_SIZE EVP_MD_CTX_SIZE,
+# EVP_CIPHER_SIZE, EVP_CIPHER_CTX_SIZE and EVP_MAX_MD_SIZE respectively.
+# If the seventh field is 1 then auto generate
+# crypto/date.h
+# Need to add Win16 and others here.
+
+my %misc_table = (
+"VC-WIN32",    "96:60:152:40:4212:20:1",
+"VC-NT",       "96:60:152:40:4212:20:1"
+);
+
+my @WinTargets=qw(VC-NT VC-WIN32 VC-WIN16 VC-W31-16 VC-W31-32 VC-MSDOS BC-32
+       BC-16 CygWin32);
+
 my $no_asm=0;
 my $postfix="org";
 my $Makefile="Makefile.ssl";
@@ -246,6 +272,12 @@ my $rc5_enc="rc5_enc.o";
 my $md5_obj="";
 my $sha1_obj="";
 my $rmd160_obj="";
+my $processor="";
+my $ranlib;
+my $perl;
+
+$ranlib=&which("ranlib") or $ranlib="true";
+$perl=&which("perl5") or $perl=&which("perl");
 
 if ($#ARGV < 0)
        {
@@ -260,6 +292,8 @@ foreach (@ARGV)
        {
        if ($_ =~ /^no-asm$/)
                { $no_asm=1; }
+       elsif ($_ =~ /^386$/)
+               { $processor=386; }
        elsif ($_ =~ /^-/)
                {
                if ($_ =~ /^-[lL](.*)$/)
@@ -270,11 +304,19 @@ foreach (@ARGV)
                        {
                        $flags.=$_." ";
                        }
+               elsif ($_ =~ /^-[fK](.*)$/)
+                       {
+                       $flags.=$_." ";
+                       }
                else
                        {
-                       die "unknown options, only -Dxxx, -Lxxx and -lxxx supported\n";
+                       die "unknown options, only -Dxxx, -Lxxx, -lxxx, -fxxx and -Kxxx are supported\n";
                        }
                }
+       elsif ($_ =~ /^([^:]+):(.+)$/) {
+               eval "\$table{\$1} = \"$2\""; # allow $xxx constructs in the string
+               $target=$1;
+       }
        else
                {
                die "target already defined - $target\n" if ($target ne "");
@@ -293,9 +335,13 @@ if (!defined($table{$target}))
        exit(1);
        }
 
+my $IsWindows=scalar grep /^$target$/,@WinTargets;
+
+print "IsWindows=$IsWindows\n";
+
 (my $cc,my $cflags,my $lflags,my $bn_ops,my $bn_obj,my $des_obj,my $bf_obj,
  $md5_obj,$sha1_obj,my $cast_obj,my $rc4_obj,$rmd160_obj,my $rc5_obj)=
-       split(/\s*:\s*/,$table{$target});
+       split(/\s*:\s*/,$table{$target} . ":" x 20 , -1);
 $cflags="$flags$cflags" if ($flags ne "");
 $lflags="$libs$lflags"if ($libs ne "");
 
@@ -305,9 +351,12 @@ if ($no_asm)
        $sha1_obj=$md5_obj=$rmd160_obj="";
        }
 
-my ($bn1)=split(/\s+/,$bn_obj);
-$bn1=$bn_asm unless ($bn1 =~ /\.o$/);
-$bn_obj="$bn1";
+#my ($bn1)=split(/\s+/,$bn_obj);
+#$bn1 = "" unless defined $bn1;
+#$bn1=$bn_asm unless ($bn1 =~ /\.o$/);
+#$bn_obj="$bn1";
+
+$bn_obj = $bn_asm unless $bn_obj ne "";
 
 $des_obj=$des_enc      unless ($des_obj =~ /\.o$/);
 $bf_obj=$bf_enc                unless ($bf_obj =~ /\.o$/);
@@ -339,7 +388,7 @@ while (<IN>)
        s/^CC=.*$/CC= $cc/;
        s/^CFLAG=.*$/CFLAG= $cflags/;
        s/^EX_LIBS=.*$/EX_LIBS= $lflags/;
-       s/^BN_MULW=.*$/BN_MULW= $bn_obj/;
+       s/^BN_ASM=.*$/BN_ASM= $bn_obj/;
        s/^DES_ENC=.*$/DES_ENC= $des_obj/;
        s/^BF_ENC=.*$/BF_ENC= $bf_obj/;
        s/^CAST_ENC=.*$/CAST_ENC= $cast_obj/;
@@ -348,6 +397,9 @@ while (<IN>)
        s/^MD5_ASM_OBJ=.*$/MD5_ASM_OBJ= $md5_obj/;
        s/^SHA1_ASM_OBJ=.*$/SHA1_ASM_OBJ= $sha1_obj/;
        s/^RMD160_ASM_OBJ=.*$/RMD160_ASM_OBJ= $rmd160_obj/;
+       s/^PROCESSOR=.*/PROCESSOR= $processor/;
+       s/^RANLIB=.*/RANLIB= $ranlib/;
+       s/^PERL=.*/PERL= $perl/;
        print OUT $_."\n";
        }
 close(IN);
@@ -356,7 +408,7 @@ close(OUT);
 print "CC            =$cc\n";
 print "CFLAG         =$cflags\n";
 print "EX_LIBS       =$lflags\n";
-print "BN_MULW       =$bn_obj\n";
+print "BN_ASM        =$bn_obj\n";
 print "DES_ENC       =$des_obj\n";
 print "BF_ENC        =$bf_obj\n";
 print "CAST_ENC      =$cast_obj\n";
@@ -365,6 +417,9 @@ print "RC5_ENC       =$rc5_obj\n";
 print "MD5_OBJ_ASM   =$md5_obj\n";
 print "SHA1_OBJ_ASM  =$sha1_obj\n";
 print "RMD160_OBJ_ASM=$rmd160_obj\n";
+print "PROCESSOR     =$processor\n";
+print "RANLIB        =$ranlib\n";
+print "PERL          =$perl\n";
 
 my $des_ptr=0;
 my $des_risc1=0;
@@ -574,6 +629,50 @@ close(OUT);
 &Rename($bf,&file_old($bf));
 &Rename($n,$bf);
 
+# Now the miscellaneous fixups
+
+if(defined $misc_table{$target}) {
+       my ($enc_ctx, $md_size, $md_ctx_size, $cipher_size, $cipher_ctx_size,
+               $max_md_size, $date_fix) = 
+               split(/\s*:\s*/,$misc_table{$target} . ":", -1);
+
+#print "EVP_ENCODE_CTX_SIZE $enc_ctx\n";
+#print "EVP_MD_SIZE $md_size\n";
+#print "EVP_MD_CTX_SIZE $md_ctx_size\n";
+#print "EVP_CIPHER_SIZE $cipher_size\n";
+#print "EVP_CIPHER_CTX_SIZE $cipher_ctx_size\n";
+#print "EVP_MAX_MD_SIZE $max_md_size\n";
+#printf "Date fix: %s\n", $date_fix ? "Yes" : "No";
+
+# Fix the date
+
+if($date_fix) {
+       open (OUT,">crypto/date.h") || die "Can't open date.h";
+       printf OUT "#define DATE \"%s\"\n", scalar gmtime();
+       close(OUT);
+}
+
+open (IN, "crypto/pem/pem.org") || die "Can't open crypto/pem/pem.org";
+open (OUT, ">crypto/pem/pem.h") || die "Can't create crypto/pem/pem.h";
+
+# Now fix up pem.h
+while(<IN>) {
+       chop;
+       s/^(#define EVP_ENCODE_CTX_SIZE).*$/$1 $enc_ctx/;
+       s/^(#define EVP_MD_SIZE).*$/$1 $md_size/;
+       s/^(#define EVP_MD_CTX_SIZE).*$/$1 $md_ctx_size/;
+       s/^(#define EVP_CIPHER_SIZE).*$/$1 $cipher_size/;
+       s/^(#define EVP_CIPHER_CTX_SIZE).*$/$1 $cipher_ctx_size/;
+       s/^(#define EVP_MAX_MD_SIZE).*$/$1 $max_md_size/;
+       print OUT "$_\n";
+}
+
+close (IN);
+close (OUT);
+
+
+}
+
 print "SIXTY_FOUR_BIT_LONG mode\n" if $b64l;
 print "SIXTY_FOUR_BIT mode\n" if $b64;
 print "THIRTY_TWO_BIT mode\n" if $b32;
@@ -592,6 +691,9 @@ print "IDEA uses u$type[$idea_int]\n" if $idea_int != $def_int;
 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; 
+
+system 'make -f Makefile.ssl links' if !$IsWindows;
+
 exit(0);
 
 sub bad_target
@@ -599,7 +701,8 @@ sub bad_target
        print STDERR "Usage: Configure [-Dxxx] [-Lxxx] [-lxxx] os/compiler\n";
        print STDERR "pick os/compiler from:";
        my $j=0;
-       foreach my $i (sort keys %table)
+       my $i;
+       foreach $i (sort keys %table)
                {
                print STDERR "\n" if ($j++ % 4) == 0;
                printf(STDERR "%-18s ",$i);
@@ -610,13 +713,27 @@ sub bad_target
 sub Rename
        {
        my($from,$to)=@_;
-
        unlink($to);
        if(!rename($from,$to))
            {
-           POSIX::errno() == POSIX::ENOENT || die "unable to rename $from to $to:$!\n";
+            -e $from && die "unable to rename $from to $to:$!\n";
            }
        }
 
-sub file_new { local($a)=@_; $a =~ s/(\.[^.]+$|$)/.new/; $a; }
-sub file_old { local($a)=@_; $a =~ s/(\.[^.]+$|$)/.old/; $a; }
+sub file_new { my($a)=@_; $a =~ s/(\.[^.]+$|$)/.new/; $a; }
+sub file_old { my($a)=@_; $a =~ s/(\.[^.]+$|$)/.old/; $a; }
+
+sub which
+       {
+       my($name)=@_;
+       my $path;
+       foreach $path (split /:/, $ENV{PATH})
+               {
+               if (-x "$path/$name")
+                       {
+                       return "$path/$name" unless ($name eq "perl" and
+                        system("$path/$name -e " . '\'exit($]<5.0);\''));
+                       }
+               }
+       }
+