Avoid potential conflicts between #defines in opensslconf.h and
authorBodo Möller <bodo@openssl.org>
Fri, 18 Feb 2000 11:15:32 +0000 (11:15 +0000)
committerBodo Möller <bodo@openssl.org>
Fri, 18 Feb 2000 11:15:32 +0000 (11:15 +0000)
defines when compiling applications, and allow applications to
select what #defines to enable -- OPENSSL_EXLUCDE_DEFINES
enables the "#define NO_whatever" stuff only, which avoids
potential severe confusion caused by "#define _REENTRANT" when
opensslconf.h is not the first header file #included.

Configure

index b8e3b4e78e2713167687e699581bd4e9ef371d03..09997b747b106e35d4dfc4786a18b15be4496d8e 100755 (executable)
--- a/Configure
+++ b/Configure
@@ -410,7 +410,9 @@ $perl=$ENV{'PERL'} or $perl=&which("perl5") or $perl=&which("perl")
 
 my $flags="";
 my $depflags="";
 
 my $flags="";
 my $depflags="";
-my $defines="";
+my $openssl_exclude_defines="";
+my $openssl_thread_defines="";
+my $openssl_other_defines="";
 my $libs="";
 my $target="";
 my $options="";
 my $libs="";
 my $target="";
 my $options="";
@@ -420,7 +422,7 @@ foreach (@ARGV)
                {
                $no_asm=1;
                $flags .= "-DNO_ASM ";
                {
                $no_asm=1;
                $flags .= "-DNO_ASM ";
-               $defines .= "#define NO_ASM\n";
+               $openssl_exclude_defines .= "#define NO_ASM\n";
                }
        elsif (/^no-threads$/)
                { $no_threads=1; }
                }
        elsif (/^no-threads$/)
                { $no_threads=1; }
@@ -433,14 +435,14 @@ foreach (@ARGV)
                $algo =~ tr/[a-z]/[A-Z]/;
                $flags .= "-DNO_$algo ";
                $depflags .= "-DNO_$algo ";
                $algo =~ tr/[a-z]/[A-Z]/;
                $flags .= "-DNO_$algo ";
                $depflags .= "-DNO_$algo ";
-               $defines .= "#define NO_$algo\n";
+               $openssl_exclude_defines .= "#define NO_$algo\n";
                if ($algo eq "DES")
                        {
                        push @skip, "mdc2";
                        $options .= " no-mdc2";
                        $flags .= "-DNO_MDC2 ";
                        $depflags .= "-DNO_MDC2 ";
                if ($algo eq "DES")
                        {
                        push @skip, "mdc2";
                        $options .= " no-mdc2";
                        $flags .= "-DNO_MDC2 ";
                        $depflags .= "-DNO_MDC2 ";
-                       $defines .= "#define NO_MDC2\n";
+                       $openssl_exclude_defines .= "#define NO_MDC2\n";
                        }
                }
        elsif (/^386$/)
                        }
                }
        elsif (/^386$/)
@@ -449,7 +451,7 @@ foreach (@ARGV)
                {
                $libs.= "-lRSAglue -lrsaref ";
                $flags.= "-DRSAref ";
                {
                $libs.= "-lRSAglue -lrsaref ";
                $flags.= "-DRSAref ";
-               $defines .= "#define RSAref\n";
+               $openssl_other_defines .= "#define RSAref\n";
                }
        elsif (/^[-+]/)
                {
                }
        elsif (/^[-+]/)
                {
@@ -537,11 +539,13 @@ if ($thread_cflag eq "(unknown)")
        {
        # If the user asked for "threads", hopefully they also provided
        # any system-dependent compiler options that are necessary.
        {
        # 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";
        }
 else
        {
        $thread_cflags="-DTHREADS $thread_cflag $cflags";
+       $thread_defines .= "#define THREADS\n";
        foreach my $def (split ' ',$thread_cflag)
                {
                if ($def =~ s/^-D//)
        foreach my $def (split ' ',$thread_cflag)
                {
                if ($def =~ s/^-D//)
@@ -562,7 +566,7 @@ if ($no_asm)
 if ($threads)
        {
                $cflags=$thread_cflags;
 if ($threads)
        {
                $cflags=$thread_cflags;
-               $defines .= $thread_defines;
+               $openssl_thread_defines .= $thread_defines;
        }
 
 #my ($bn1)=split(/\s+/,$bn_obj);
        }
 
 #my ($bn1)=split(/\s+/,$bn_obj);
@@ -718,13 +722,17 @@ 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";
 
 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 "/* opensslconf.h */"
+print OUT "/* opensslconf.h */\n";
 print OUT "/* WARNING: Generated automatically from opensslconf.h.in by Configure. */\n\n";
 print OUT "/* WARNING: Generated automatically from opensslconf.h.in by Configure. */\n\n";
-if ($defines ne "")
-       {
-       print OUT "/* OpenSSL was configured with the following options: */\n";
-       print OUT "#ifdef OPENSSL_EXCLUDED\n$defines#endif\n\n";
-       }
+
+print OUT "/* OpenSSL was configured with the following options: */\n";
+$openssl_exclude_defines =~ s/^\s*#\s*define\s+(.*)/# ifndef $1\n#  define $1\n# endif/mg;
+$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_EXCLUDE_DEFINES\n$openssl_exclude_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/)
 while (<IN>)
        {
        if      (/^#define\s+OPENSSLDIR/)