Unified build: Keep track of generated header files
[openssl.git] / Configure
index 5afa63dd2a6578f51642fc1b4db487b71f68fe17..f617df5fbe30d6828a4712e785be386ec52f37df 100755 (executable)
--- a/Configure
+++ b/Configure
@@ -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;
 
@@ -416,7 +422,6 @@ $config{openssl_other_defines}=[];
 my $libs="";
 my $target="";
 $config{options}="";
-my $make_depend=0;
 my %withargs=();
 my $build_prefix = "release_";
 
@@ -1485,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
@@ -1701,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"));
 }
 
 ###
@@ -1751,42 +1758,12 @@ 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;
@@ -1879,14 +1856,6 @@ 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);
-
-*** Because of configuration changes, you MUST do the following before
-*** building:
-
-       make depend
-EOF
-
 ###### TO BE REMOVED BEFORE FINAL RELEASE
 ######
 ###### If the user hasn't chosen --unified, try to nudge them.