X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=blobdiff_plain;f=Configure;h=3c720c3a87425378b3634f5f2ecc87e9553cfe30;hp=bd4506d4081840dff2b751cc40ecf18a1b7de26b;hb=bcaa88342b72a0283ba1b97593f8bd4c3013311b;hpb=9d07a3c9a5833fab2064df4e1b6e484749443b47 diff --git a/Configure b/Configure index bd4506d408..3c720c3a87 100755 --- a/Configure +++ b/Configure @@ -9,24 +9,20 @@ require 5.000; use strict; # see INSTALL for instructions. -# -# Usage: Configure [-Dxxx] [-Lxxx] [-fxxx] [-Kxxx] [no-asm] [rsaref] -# [386] platform[:flags] -# + +my $usage="Usage: Configure [-Dxxx] [-lxxx] [-Lxxx] [-fxxx] [-Kxxx] [rsaref] [no-asm] [386] [--prefix=DIR] [--openssldir=OPENSSLDIR] os/compiler[:flags]\n"; + # Options: +# --openssldir install OpenSSL in OPENSSLDIR (Default: DIR/ssl if the +# --prefix option is given; /usr/local/ssl otherwise) +# --prefix prefix for the OpenSSL include, lib and bin directories +# (Default: the OPENSSLDIR directory) # rsaref use RSAref # no-asm do not use assembler # 386 generate 80386 code +# no- build without specified algorithm (rsa, idea, rc5, ...) # -D, -L, -l, -f, -K: compiler options are passed through # -# -DRSAref build to use RSAref -# -DNO_IDEA build with no IDEA algorithm -# -DNO_RC4 build with no RC4 algorithm -# -DNO_RC2 build with no RC2 algorithm -# -DNO_BF build with no Blowfish algorithm -# -DNO_DES build with no DES/3DES algorithm -# -DNO_MD2 build with no MD2 algorithm -# # DES_PTR use pointer lookup vs arrays in the DES in crypto/des/des_locl.h # DES_RISC1 use different DES_ENCRYPT macro that helps reduce register # dependancies but needs to more registers, good for RISC CPU's @@ -47,7 +43,7 @@ use strict; # RC4_INDEX define RC4_INDEX in crypto/rc4/rc4_locl.h. This turns on # array lookups instead of pointer use. # BF_PTR use 'pointer arithmatic' for Blowfish (unsafe on Alpha). -# BF_PTR2 use a pentium/intel specific version. +# BF_PTR2 intel specific version (generic version is more efficient). # MD5_ASM use some extra md5 assember, # SHA1_ASM use some extra sha1 assember, must define L_ENDIAN for x86 # RMD160_ASM use some extra ripemd160 assember, @@ -55,7 +51,7 @@ use strict; my $x86_gcc_des="DES_PTR DES_RISC1 DES_UNROLL"; # MD2_CHAR slags pentium pros -my $x86_gcc_opts="RC4_INDEX MD2_INT BF_PTR2"; +my $x86_gcc_opts="RC4_INDEX MD2_INT"; # MODIFY THESE PARAMETERS IF YOU ARE GOING TO USE THE 'util/speed.sh SCRIPT # Don't worry about these normally @@ -88,7 +84,7 @@ my %table=( # Our 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-ben", "gcc:-DBN_DEBUG -DREF_CHECK -DCRYPTO_MDEBUG -O2 -Wall -Wshadow -Werror -pipe:::::", +"debug-ben", "gcc:-DBN_DEBUG -DREF_CHECK -DCRYPTO_MDEBUG -O2 -pedantic -Wall -Wshadow -Werror -pipe:::::", "debug-ben-strict", "gcc:-DBN_DEBUG -DREF_CHECK -DCRYPTO_MDEBUG -DCONST_STRICT -O2 -Wall -Wshadow -Werror -Wpointer-arith -Wcast-qual -Wwrite-strings -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:::::", @@ -113,8 +109,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/sparcv8.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:::", +#"solaris-sparc-sc4-pic","cc:-xO5 -Xa -DB_ENDIAN -KPIC:-lsocket -lnsl:\ +# BN_LLONG RC4_CHAR DES_PTR DES_RISC1 DES_UNROLL BF_PTR:::", # Sunos configs, assuming sparc for the gcc one. ##"sunos-cc", "cc:-O4 -DNOPROTO -DNOCONST::DES_UNROLL:::", @@ -233,8 +229,8 @@ my %table=( "CygWin32", "gcc:-DTERMIOS -DL_ENDIAN -fomit-frame-pointer -O3 -m486 -Wall::BN_LLONG $x86_gcc_des $x86_gcc_opts:", # Ultrix from Bernhard Simon -"ultrix","cc:-std1 -O -Olimit 1000 -DL_ENDIAN::::::", -"ultrix-gcc","cc:-O3 -DL_ENDIAN::::::", +"ultrix-cc","cc:-std1 -O -Olimit 1000 -DL_ENDIAN::::::", +"ultrix-gcc","gcc:-O3 -DL_ENDIAN::::::", # K&R C is no longer supported; you need gcc on old Ultrix installations ##"ultrix","cc:-O2 -DNOPROTO -DNOCONST -DL_ENDIAN::::::", @@ -249,7 +245,10 @@ my %table=( my @WinTargets=qw(VC-NT VC-WIN32 VC-WIN16 VC-W31-16 VC-W31-32 VC-MSDOS BC-32 BC-16 CygWin32); +my $installprefix=""; +my $openssldir=""; my $no_asm=0; +my @skip=(); my $Makefile="Makefile.ssl"; my $des_locl="crypto/des/des_locl.h"; my $des ="crypto/des/des.h"; @@ -276,43 +275,53 @@ my $perl; $ranlib=&which("ranlib") or $ranlib="true"; $perl=&which("perl5") or $perl=&which("perl"); -if ($#ARGV < 0) - { - &bad_target; - exit(1); - } +&usage if ($#ARGV < 0); my $flags=""; +my $depflags=""; my $libs=""; my $target=""; foreach (@ARGV) { - if ($_ =~ /^no-asm$/) + if (/^no-asm$/) { $no_asm=1; } - elsif ($_ =~ /^386$/) + elsif (/^no-(.+)$/) + { + my $algo=$1; + push @skip,$algo; + $algo =~ tr/[a-z]/[A-Z]/; + $flags .= "-DNO_$algo "; + $depflags .= "-DNO_$algo "; + } + elsif (/^386$/) { $processor=386; } - elsif ($_ =~ /^rsaref$/) + elsif (/^rsaref$/) { $libs.= "-lRSAglue -lrsaref "; $flags.= "-DRSAref "; } - elsif ($_ =~ /^-/) + elsif (/^-/) { - if ($_ =~ /^-[lL](.*)$/) + if (/^-[lL](.*)$/) { $libs.=$_." "; } - elsif ($_ =~ /^-D(.*)$/) + elsif (/^-[DfK](.*)$/) { $flags.=$_." "; } - elsif ($_ =~ /^-[fK](.*)$/) + elsif (/^--prefix=(.*)$/) { - $flags.=$_." "; + $installprefix=$1; + } + elsif (/^--openssldir=(.*)$/) + { + $openssldir=$1; } else { - die "unknown options, only -Dxxx, -Lxxx, -lxxx, -fxxx and -Kxxx are supported\n"; + print STDERR $usage; + exit(1); } } elsif ($_ =~ /^([^:]+):(.+)$/) { @@ -323,22 +332,23 @@ foreach (@ARGV) { die "target already defined - $target\n" if ($target ne ""); $target=$_; - if (!defined($table{$target})) - { - &bad_target; - exit(1); - } } - } +} -if (!defined($table{$target})) - { - &bad_target; - exit(1); - } +&usage if (!defined($table{$target})); my $IsWindows=scalar grep /^$target$/,@WinTargets; +$openssldir="/usr/local/ssl" if ($openssldir eq "" and $installprefix eq ""); +$installprefix=$openssldir if $installprefix eq ""; + +chop $openssldir if $openssldir =~ /\/$/; +chop $installprefix if $installprefix =~ /\/$/; + +$openssldir=$installprefix . "/ssl" if $openssldir eq ""; +$openssldir=$installprefix . "/" . $openssldir if $openssldir !~ /^\//; + + print "IsWindows=$IsWindows\n"; (my $cc,my $cflags,my $lflags,my $bn_ops,my $bn_obj,my $des_obj,my $bf_obj, @@ -381,14 +391,46 @@ if ($rmd160_obj =~ /\.o$/) $cflags.=" -DRMD160_ASM"; } +my $version = "unknown"; +my $major = "unknown"; +my $minor = "unknown"; + +open(IN,') + { + $version=$1 if /OPENSSL.VERSION.TEXT.*OpenSSL (\S+) /; + } +close(IN); + +if ($version =~ /(^[0-9]*)\.([\0-9\.]*)/) + { + $major=$1; + $minor=$2; + } + open(IN,'$Makefile") || die "unable to create $Makefile:$!\n"; +my $sdirs=0; while () { chop; + $sdirs = 1 if /^SDIRS=/; + $sdirs = 0 unless /\\$/; + if ($sdirs) { + my $dir; + foreach $dir (@skip) { + s/$dir//; + } + } + s/^VERSION=.*/VERSION=$version/; + s/^MAJOR=.*/MAJOR=$major/; + s/^MINOR=.*/MINOR=$minor/; + s/^INSTALLTOP=.*$/INSTALLTOP=$installprefix/; + s/^OPENSSLDIR=.*$/OPENSSLDIR=$openssldir/; s/^PLATFORM=.*$/PLATFORM=$target/; s/^CC=.*$/CC= $cc/; s/^CFLAG=.*$/CFLAG= $cflags/; + s/^DEPFLAG=.*$/DEPFLAG= $depflags/; s/^EX_LIBS=.*$/EX_LIBS= $lflags/; s/^BN_ASM=.*$/BN_ASM= $bn_obj/; s/^DES_ENC=.*$/DES_ENC= $des_obj/; @@ -470,7 +512,9 @@ open(IN,'crypto/opensslconf.h') || die "unable to create crypto/opensslconf.h:$!\n"; while () { - if (/^#((define)|(undef))\s+SIXTY_FOUR_BIT_LONG/) + if (/^#define\s+OPENSSLDIR/) + { print OUT "#define OPENSSLDIR \"$openssldir\"\n"; } + elsif (/^#((define)|(undef))\s+SIXTY_FOUR_BIT_LONG/) { printf OUT "#%s SIXTY_FOUR_BIT_LONG\n",($b64l)?"define":"undef"; } elsif (/^#((define)|(undef))\s+SIXTY_FOUR_BIT/) { printf OUT "#%s SIXTY_FOUR_BIT\n",($b64)?"define":"undef"; } @@ -538,24 +582,69 @@ if($IsWindows) { open (OUT,">crypto/date.h") || die "Can't open date.h"; printf OUT "#define DATE \"%s\"\n", scalar gmtime(); close(OUT); +} else { + (system 'make -f Makefile.ssl links') == 0 or exit $?; + (system 'make depend') == 0 or exit $? if $depflags ne ""; + &dofile("tools/c_rehash",$openssldir,'^DIR=', 'DIR=%s',); + &dofile("util/mk1mf.pl",$openssldir, + ('^\$INSTALLTOP=','$INSTALLTOP="%s";',)); } -system 'make -f Makefile.ssl links' if !$IsWindows; + +my $pwd; + +if($IsWindows) { + $pwd="(include directory)"; +} else { + $pwd =`pwd`; + chop($pwd); +} +print < +should be used instead of #include . +These new file locations allow installing the OpenSSL header +files in /usr/local/include/openssl/ and should help avoid +conflicts with other libraries. + +To compile programs that use the old form , +usually an additional compiler option will suffice: E.g., add + -I$installprefix/include/openssl +or + -I$pwd/include/openssl +to the CFLAGS in the Makefile of the program that you want to compile +(and leave all the original -I...'s in place!). + +Please make sure that no old OpenSSL header files are around: +The include directory should now be empty except for the openssl +subdirectory. +EOF exit(0); -sub bad_target +sub usage { - print STDERR "Usage: Configure [-Dxxx] [-Lxxx] [-lxxx] [no-asm] [rsaref] os/compiler\n"; + print STDERR $usage; print STDERR "pick os/compiler from:"; my $j=0; my $i; foreach $i (sort keys %table) { + next if $i =~ /^debug/; + print STDERR "\n" if ($j++ % 4) == 0; + printf(STDERR "%-18s ",$i); + } + foreach $i (sort keys %table) + { + next if $i !~ /^debug/; print STDERR "\n" if ($j++ % 4) == 0; printf(STDERR "%-18s ",$i); } print STDERR "\n"; + exit(1); } sub which @@ -572,3 +661,22 @@ sub which } } +sub dofile + { + my $f; my $p; my %m; my @a; my $k; my $ff; + ($f,$p,%m)=@_; + + open(IN,"<$f") || die "unable to open $f:$!\n"; + @a=; + close(IN); + foreach $k (keys %m) + { + grep(/$k/ && ($_=sprintf($m{$k}."\n",$p)),@a); + } + ($ff=$f) =~ s/\..*$//; + open(OUT,">$ff.new") || die "unable to open $f:$!\n"; + print OUT @a; + close(OUT); + rename($f,"$ff.bak") || die "unable to rename $f\n"; + rename("$ff.new",$f) || die "unable to rename $ff.new\n"; + }