Keep variable names consistent with corresponding pre-processor
[openssl.git] / Configure
index c2c0798aa90cd42f671f097278b68be12512e95c..86097049c72739c5fe74f2196a106a16df6162cb 100755 (executable)
--- a/Configure
+++ b/Configure
@@ -107,12 +107,17 @@ my %table=(
 "debug-levitte-linux-elf","gcc:-DRL_DEBUG -DREF_CHECK -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DNO_ASM -DL_ENDIAN -DTERMIO -D_POSIX_SOURCE -ggdb -g3 -m486 -pedantic -ansi -Wall -Wshadow -Wid-clash-31 -pipe::-D_REENTRANT:::",
 "dist",                "cc:-O::(unknown):::::",
 
-# Basic configs that should work on any box
+# Basic configs that should work on any (32 and less bit) box
 "gcc",         "gcc:-O3::(unknown)::BN_LLONG:::",
 "cc",          "cc:-O::(unknown):::::",
 
 #### Solaris x86 setups
-"solaris-x86-gcc","gcc:-O3 -fomit-frame-pointer -m486 -Wall -DL_ENDIAN::-D_REENTRANT:-lsocket -lnsl:BN_LLONG $x86_gcc_des $x86_gcc_opts:$x86_sol_asm",
+# -DNO_INLINE_ASM switches off inline assembler. We have to do it
+# here because whenever GNU C instantiates an assembler template it
+# surrounds it with #APP #NO_APP comment pair which (at least Solaris
+# 7_x86) /usr/ccs/bin/as fails to assemble with "Illegal mnemonic"
+# error message.
+"solaris-x86-gcc","gcc:-O3 -fomit-frame-pointer -m486 -Wall -DL_ENDIAN -DNO_INLINE_ASM::-D_REENTRANT:-lsocket -lnsl:BN_LLONG $x86_gcc_des $x86_gcc_opts:$x86_sol_asm",
 
 #### SPARC Solaris with GNU C setups
 "solaris-sparcv7-gcc","gcc:-O3 -fomit-frame-pointer -Wall -DB_ENDIAN -DBN_DIV2W::-D_REENTRANT:-lsocket -lnsl:BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:::",
@@ -176,16 +181,16 @@ my %table=(
 #   procedural analysis. As it has to be performed during the link
 #   stage the compiler leaves behind certain pseudo-code in lib*.a
 #   which might be release or even patch level specific. Generating
-#   the machine code and analyzing the *whole* program appears to be
-#   *extremely* memory demanding while the performance gain is
+#   the machine code for and analyzing the *whole* program appears
+#   to be *extremely* memory demanding while the performance gain is
 #   actually questionable. The situation is intensified by the default
 #   HP-UX data set size limit (infamous 'maxdsiz' tunable) of 64MB
 #   which is way too low for +O4. In other words, doesn't +O3 make
 #   more sense?
-# - Keep in mind that the compiler by default generates code suitable
-#   for execution on the host you're currently compiling at. If you
-#   intend to use it across various PA-RISC processors consider adding
-#   +Dportable.
+# - Keep in mind that the HP compiler by default generates code
+#   suitable for execution on the host you're currently compiling at.
+#   If the toolkit is ment to be used on various PA-RISC processors
+#   consider './config +Dportable'.
 # - +DD64 is chosen in favour of +DA2.0W because it's ment to be
 #   compatible with *future* releases.
 # - If you run ./Configure hpux-parisc-[g]cc manually don't forget to
@@ -239,6 +244,18 @@ my %table=(
 "FreeBSD-alpha","gcc:-DTERMIOS -O3 -fomit-frame-pointer::(unknown)::SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_PTR DES_RISC2:::",
 
 #### Alpha Linux with GNU C and Compaq C setups
+# Special notes:
+# - linux-alpha+bwx-gcc is ment to be used from ./config only. If you
+#   ought to run './Configure linux-alpha+bwx-gcc' manually, do
+#   complement the command line with -mcpu=ev56, -mcpu=ev6 or whatever
+#   which is appropriate.
+# - If you use ccc keep in mind that -fast implies -arch host and the
+#   compiler is free to issue instructions which gonna make elder CPU
+#   choke. If you wish to build "blended" toolkit, add -arch generic
+#   *after* -fast and invoke './Configure linux-alpha-ccc' manually.
+#
+#                                      <appro@fy.chalmers.se>
+#
 "linux-alpha-gcc","gcc:-O3 -DL_ENDIAN -DTERMIO::(unknown)::SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_RISC1 DES_UNROLL:asm/alpha.o::",
 "linux-alpha+bwx-gcc","gcc:-O3 -DL_ENDIAN -DTERMIO::(unknown)::SIXTY_FOUR_BIT_LONG RC4_CHAR RC4_CHUNK DES_RISC1 DES_UNROLL:asm/alpha.o::",
 "linux-alpha-ccc","ccc:-fast -readonly_strings -DL_ENDIAN -DTERMIO::(unknown)::SIXTY_FOUR_BIT_LONG RC4_CHUNK DES_INT DES_PTR DES_RISC1 DES_UNROLL:asm/alpha.o::",
@@ -393,6 +410,9 @@ $perl=$ENV{'PERL'} or $perl=&which("perl5") or $perl=&which("perl")
 
 my $flags="";
 my $depflags="";
+my $openssl_algorithm_defines="";
+my $openssl_thread_defines="";
+my $openssl_other_defines="";
 my $libs="";
 my $target="";
 my $options="";
@@ -402,6 +422,7 @@ foreach (@ARGV)
                {
                $no_asm=1;
                $flags .= "-DNO_ASM ";
+               $openssl_algorithm_defines .= "#define NO_ASM\n";
                }
        elsif (/^no-threads$/)
                { $no_threads=1; }
@@ -414,12 +435,14 @@ foreach (@ARGV)
                $algo =~ tr/[a-z]/[A-Z]/;
                $flags .= "-DNO_$algo ";
                $depflags .= "-DNO_$algo ";
+               $openssl_algorithm_defines .= "#define NO_$algo\n";
                if ($algo eq "DES")
                        {
                        push @skip, "mdc2";
                        $options .= " no-mdc2";
                        $flags .= "-DNO_MDC2 ";
                        $depflags .= "-DNO_MDC2 ";
+                       $openssl_algorithm_defines .= "#define NO_MDC2\n";
                        }
                }
        elsif (/^386$/)
@@ -428,6 +451,7 @@ foreach (@ARGV)
                {
                $libs.= "-lRSAglue -lrsaref ";
                $flags.= "-DRSAref ";
+               $openssl_other_defines .= "#define RSAref\n";
                }
        elsif (/^[-+]/)
                {
@@ -505,6 +529,7 @@ print "IsWindows=$IsWindows\n";
 $cflags="$flags$cflags" if ($flags ne "");
 
 my $thread_cflags;
+my $thread_defines;
 if ($thread_cflag ne "(unknown)" && !$no_threads)
        {
        # If we know how to do it, support threads by default.
@@ -514,11 +539,21 @@ if ($thread_cflag eq "(unknown)")
        {
        # If the user asked for "threads", hopefully they also provided
        # any system-dependent compiler options that are necessary.
-       $thread_cflags="-DTHREADS $cflags" 
+       $thread_cflags="-DTHREADS $cflags" ;
+       $thread_defines .= "#define THREADS\n";
        }
 else
        {
-       $thread_cflags="-DTHREADS $thread_cflag $cflags" 
+       $thread_cflags="-DTHREADS $thread_cflag $cflags";
+       $thread_defines .= "#define THREADS\n";
+       my $def;
+       foreach $def (split ' ',$thread_cflag)
+               {
+               if ($def =~ s/^-D//)
+                       {
+                       $thread_defines .= "#define $def\n";
+                       }
+               }
        }       
 
 $lflags="$libs$lflags"if ($libs ne "");
@@ -532,6 +567,7 @@ if ($no_asm)
 if ($threads)
        {
                $cflags=$thread_cflags;
+               $openssl_thread_defines .= $thread_defines;
        }
 
 #my ($bn1)=split(/\s+/,$bn_obj);
@@ -687,7 +723,18 @@ foreach (sort split(/\s+/,$bn_ops))
 
 open(IN,'<crypto/opensslconf.h.in') || die "unable to read crypto/opensslconf.h.in:$!\n";
 open(OUT,'>crypto/opensslconf.h') || die "unable to create crypto/opensslconf.h:$!\n";
-print OUT "/* Generated automatically from opensslconf.h.in by Configure. */\n\n";
+print OUT "/* opensslconf.h */\n";
+print OUT "/* WARNING: Generated automatically from opensslconf.h.in by Configure. */\n\n";
+
+print OUT "/* OpenSSL was configured with the following options: */\n";
+$openssl_algorithm_defines =~ s/^\s*#\s*define\s+(.*)/# ifndef $1\n#  define $1\n# endif/mg;
+$openssl_algorithm_defines = "   /* no ciphers excluded */\n" if $openssl_algorithm_defines eq "";
+$openssl_thread_defines =~ s/^\s*#\s*define\s+(.*)/# ifndef $1\n#  define $1\n# endif/mg;
+$openssl_other_defines =~ s/^\s*#\s*define\s+(.*)/# ifndef $1\n#  define $1\n# endif/mg;
+print OUT "#ifdef OPENSSL_ALGORITHM_DEFINES\n$openssl_algorithm_defines#endif\n";
+print OUT "#ifdef OPENSSL_THREAD_DEFINES\n$openssl_thread_defines#endif\n";
+print OUT "#ifdef OPENSSL_OTHER_DEFINES\n$openssl_other_defines#endif\n\n";
+
 while (<IN>)
        {
        if      (/^#define\s+OPENSSLDIR/)