Move to REF_DEBUG, for consistency.
[openssl.git] / Configure
index a6310366ce971a6af825dda56f098d07925b1115..4198ff74ceae031c472ccf4a81527b2b8458ca3d 100755 (executable)
--- a/Configure
+++ b/Configure
@@ -80,7 +80,7 @@ my $usage="Usage: Configure [no-<cipher> ...] [enable-<cipher> ...] [experimenta
 # Minimum warning options... any contributions to OpenSSL should at least get
 # past these.
 
-my $gcc_devteam_warn = "-Wall -pedantic -DPEDANTIC -Wno-long-long -Wsign-compare -Wmissing-prototypes -Wshadow -Wformat -Wtype-limits -Werror -DREF_CHECK -DDEBUG_UNUSED";
+my $gcc_devteam_warn = "-Wall -pedantic -DPEDANTIC -Wno-long-long -Wsign-compare -Wmissing-prototypes -Wshadow -Wformat -Wtype-limits -Werror -DREF_DEBUG -DDEBUG_UNUSED";
 
 # These are used in addition to $gcc_devteam_warn when the compiler is clang.
 # TODO(openssl-team): fix problems and investigate if (at least) the
@@ -91,9 +91,6 @@ my $gcc_devteam_warn = "-Wall -pedantic -DPEDANTIC -Wno-long-long -Wsign-compare
 # -Wextended-offsetof
 my $clang_devteam_warn = "-Wno-unused-parameter -Wno-missing-field-initializers -Wno-language-extension-token -Wno-extended-offsetof -Wconditional-uninitialized -Qunused-arguments -Wincompatible-pointer-types-discards-qualifiers -Wmissing-variable-declarations";
 
-# Warn that "make depend" should be run?
-my $warn_make_depend = 0;
-
 # These are used in addition to $gcc_devteam_warn unless this is a mingw build.
 # This adds backtrace information to the memory leak info.
 my $memleak_devteam_backtrace = "-rdynamic -DCRYPTO_MDEBUG_BACKTRACE";
@@ -398,6 +395,15 @@ my @default_depdefines =
 # We will collect such requests in @experimental.
 # To avoid accidental use of experimental features, applications will have to use -DOPENSSL_EXPERIMENTAL_FOO.
 
+my @generated_headers = (
+    "include/openssl/opensslconf.h",
+    "crypto/include/internal/bn_conf.h"
+    );
+
+my @generated_by_make_headers = (
+    "crypto/buildinf.h"
+    );
+
 
 my $no_sse2=0;
 
@@ -405,6 +411,7 @@ my $no_sse2=0;
 
 my $user_cflags="";
 my @user_defines=();
+my $unified = 0;
 $config{depdefines}=[];
 $config{openssl_experimental_defines}=[];
 $config{openssl_api_defines}=[];
@@ -415,7 +422,6 @@ $config{openssl_other_defines}=[];
 my $libs="";
 my $target="";
 $config{options}="";
-my $make_depend=0;
 my %withargs=();
 my $build_prefix = "release_";
 
@@ -575,9 +581,15 @@ foreach (@argvcopy)
                }
        elsif (/^[-+]/)
                {
-               if (/^--prefix=(.*)$/)
+               if (/^--unified$/)
+                       {
+                       $unified=1;
+                       }
+               elsif (/^--prefix=(.*)$/)
                        {
                        $config{prefix}=$1;
+                       die "Directory given with --prefix MUST be absolute\n"
+                               unless file_name_is_absolute($config{prefix});
                        }
                elsif (/^--api=(.*)$/)
                        {
@@ -813,11 +825,6 @@ my $make   = $ENV{'MAKE'} || "make";
 $config{cross_compile_prefix} = $ENV{'CROSS_COMPILE'}
     if $config{cross_compile_prefix} eq "";
 
-$config{prefix} = "/usr/local" if !$config{prefix};
-$config{openssldir} = "ssl" if !$config{openssldir};
-$config{openssldir} = catdir($config{prefix}, $config{openssldir})
-    unless file_name_is_absolute($config{openssldir});
-
 # Allow environment CC to override compiler...
 $target{cc} = $ENV{CC} || $target{cc};
 
@@ -847,26 +854,26 @@ $target{nm} = "nm";
 $target{build_scheme} = [ $target{build_scheme} ]
     if ref($target{build_scheme}) ne "ARRAY";
 
+###### TO BE REMOVED BEFORE FINAL RELEASE
+######
+###### If the user has chosen --unified, we give it to them.
+if ($target{build_file} eq "Makefile"
+    && $target{build_scheme}->[0] eq "unixmake"
+    && $unified) {
+    $target{build_scheme} = [ "unified", "unix" ];
+}
+
 my ($builder, $builder_platform, @builder_opts) =
     @{$target{build_scheme}};
 
-# if $config{prefix}/lib$target{multilib} is not an existing directory, then
-# assume that it's not searched by linker automatically, in
-# which case adding $target{multilib} suffix causes more grief than
-# we're ready to tolerate, so don't...
-$target{multilib}="" if !-d "$config{prefix}/lib$target{multilib}";
-
-$config{libdir}="lib$target{multilib}" if $config{libdir} eq "";
-$config{enginesdir}=$config{prefix} . "/" . $config{libdir}  . "/engines";
-
 push @{$config{defines}},
     map { (my $x = $_) =~ s/^OPENSSL_NO_/OPENSSL_EXPERIMENTAL_/; $x }
         @{$config{openssl_experimental_defines}};
 
-if ($target =~ /^mingw/ && `$target{cc} --target-help 2>&1` !~ m/-mno-cygwin/m)
+if ($target =~ /^mingw/ && `$target{cc} --target-help 2>&1` =~ m/-mno-cygwin/m)
        {
-       $config{cflags} =~ s/-mno-cygwin\s*//;
-       $target{shared_ldflag} =~ s/-mno-cygwin\s*//;
+       $config{cflags} .= " -mno-cygwin";
+       $target{shared_ldflag} .= " -mno-cygwin";
        }
 
 if ($target =~ /linux.*-mips/ && !$no_asm && $user_cflags !~ /-m(ips|arch=)/) {
@@ -1007,19 +1014,6 @@ if ($builder ne "mk1mf")
 #
 # Platform fix-ups
 #
-# Unlike other OSes (like Solaris, Linux, Tru64, IRIX) BSD run-time
-# linkers (tested OpenBSD, NetBSD and FreeBSD) "demand" RPATH set on
-# .so objects. Apparently application RPATH is not global and does
-# not apply to .so linked with other .so. Problem manifests itself
-# when libssl.so fails to load libcrypto.so. One can argue that we
-# should engrave this into Makefile.shared rules or into BSD-* config
-# lines above. Meanwhile let's try to be cautious and pass -rpath to
-# linker only when --prefix is not /usr.
-if ($target =~ /^BSD-/)
-       {
-       $target{shared_ldflag}.=" -Wl,-rpath,\$\$(LIBRPATH)" if ($config{prefix} !~ m|^/usr[/]*$|);
-       }
-
 if ($target{sys_id} ne "")
        {
        push @{$config{openssl_sys_defines}}, "OPENSSL_SYS_$target{sys_id}";
@@ -1496,9 +1490,15 @@ EOF
             foreach (@{$depends{$dest}}) {
                 my $d = cleanfile($sourced, $_, $blddir);
 
-                # If it isn't found in the source, let's assume it's generated
-                # and that the Makefile template has the lines
-                if (! -f $d) {
+                # If we know it's generated, or assume it is because we can't
+                # find it in the source tree, we set file we depend on to be
+                # in the build tree rather than the source tree, and assume
+                # and that there are lines to build it in a BEGINRAW..ENDRAW
+                # section or in the Makefile template.
+                if (! -f $d
+                    || !(grep { $d eq $_ }
+                         map { cleanfile($srcdir, $_, $blddir) }
+                         (@generated_headers, @generated_by_make_headers))) {
                     $d = cleanfile($buildd, $_, $blddir);
                 }
                 # Take note if the file to depend on is being renamed
@@ -1712,14 +1712,10 @@ 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;
 
-mkpath(catdir($blddir, "include/openssl"));
-run_dofile(catfile($blddir, "include/openssl/opensslconf.h"),
-           catfile($srcdir, "include/openssl/opensslconf.h.in"));
-
-mkpath(catdir($blddir, "crypto/include/internal"));
-foreach my $alg ( 'bn' ) {
-    run_dofile(catfile($blddir, "crypto/include/internal/${alg}_conf.h"),
-               catfile($srcdir, "crypto/include/internal/${alg}_conf.h.in"));
+for (@generated_headers) {
+    mkpath(catdir($blddir, dirname($_)));
+    run_dofile(catfile($blddir, $_),
+               catfile($srcdir, $_.".in"));
 }
 
 ###
@@ -1762,60 +1758,18 @@ my %builders = (
         run_dofile(catfile($blddir, $target{build_file}),
                    $config{build_file_template},
                    catfile($srcdir, "Configurations", "common.tmpl"));
-
-        my $make_command = "$make PERL=\'$config{perl}\'";
-        my $make_targets = "";
-        my $need_make_depend =
-            join(" ", @{$config{depdefines}}) ne join(" ", @default_depdefines);
-        $make_targets .= " depend"
-            if $need_make_depend && $make_depend;
-
-        (system $make_command.$make_targets) == 0
-            or die "make $make_targets failed"
-            if $make_targets ne "";
-
-        if ($need_make_depend && !$make_depend) {
-            $warn_make_depend++;
-        }
     },
     unixmake => sub {
         build_Makefile();
 
         run_dofile("util/domd", "util/domd.in");
         chmod 0755, "util/domd";
-
-        my $make_command = "$make PERL=\'$config{perl}\'";
-        my $make_targets = "";
-        my $need_make_depend =
-            join(" ", @{$config{depdefines}}) ne join(" ", @default_depdefines);
-        $make_targets .= " depend"
-            if $need_make_depend && $make_depend;
-
-        (system $make_command.$make_targets) == 0
-            or die "make $make_targets failed"
-            if $make_targets ne "";
-
-        if ($need_make_depend && !$make_depend) {
-            $warn_make_depend++;
-        }
     },
     mk1mf => sub {
         my $platform = shift;
         # The only reason we do this is to have something to build MINFO from
         build_Makefile();
 
-       open (OUT,">crypto/buildinf.h") || die "Can't open buildinf.h";
-       printf OUT <<"EOF";
-#ifndef MK1MF_BUILD
-  /* auto-generated by Configure for crypto/cversion.c:
-   * for Unix builds, crypto/Makefile.ssl generates functional definitions;
-   * Windows builds (and other mk1mf builds) compile cversion.c with
-   * -DMK1MF_BUILD and use definitions added to this file by util/mk1mf.pl. */
-  #error "Windows builds (PLATFORM=$target) use mk1mf.pl-created Makefiles"
-#endif
-EOF
-       close(OUT);
-
        # create the ms/version32.rc file if needed
        if ($platform ne "netware") {
            my ($v1, $v2, $v3, $v4);
@@ -1902,13 +1856,38 @@ shared libraries, please let us know (but please first make sure you have
 tried with a current version of OpenSSL).
 EOF
 
-print <<"EOF" if ($warn_make_depend);
+###### TO BE REMOVED BEFORE FINAL RELEASE
+######
+###### If the user hasn't chosen --unified, try to nudge them.
+if ($target{build_file} eq "Makefile"
+    && $target{build_scheme}->[0] eq "unixmake"
+    && !$unified) {
+
+    my $plausible_builddir =
+        abs2rel(rel2abs("../_openssl-build_$target"),rel2abs("."));
+    my $plausible_to_sourcedir =
+        abs2rel(rel2abs("."),rel2abs("../_openssl-build_$target"));
+    print <<"EOF";
 
-*** Because of configuration changes, you MUST do the following before
-*** building:
+----------------------------------------------------------------------
+Please consider configuring with the flag --unified .
+It's to test out a new "unified" building system.
+
+One cool feature is that you can have your build directory elsewhere,
+for example:
+
+    make clean          # Clean the current configuration away
+    mkdir $plausible_builddir
+    cd $plausible_builddir
+    $plausible_to_sourcedir/config --unified
+    make
+    make test
+
+Please report any problem you have.
+----------------------------------------------------------------------
 
-       make depend
 EOF
+}
 
 exit(0);
 
@@ -2201,6 +2180,7 @@ sub print_table_entry
        "shared_target",
        "shared_cflag",
        "shared_ldflag",
+       "shared_rcflag",
        "shared_extension",
        "obj_extension",
        "exe_extension",