Configure: disallow the mixture of compiling flags and env / make variables
authorRichard Levitte <levitte@openssl.org>
Thu, 8 Mar 2018 13:16:18 +0000 (14:16 +0100)
committerRichard Levitte <levitte@openssl.org>
Thu, 8 Mar 2018 16:24:02 +0000 (17:24 +0100)
Note that this might give surprising results if someone forgets an environment
variable that has been set previously.

Reviewed-by: Andy Polyakov <appro@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/5534)

Configure
INSTALL

index bb951bdfcdb859c1b2fc1e03eaab0625c8ecd7ea..1b6a7b63c86191a1b75115cc6a1d474870383f02 100755 (executable)
--- a/Configure
+++ b/Configure
@@ -621,10 +621,10 @@ while (@argvcopy)
                        {
                        $user{$1} = ref $user{$1} eq "ARRAY" ? [] : undef;
                        }
-               if (exists $useradd{$1})
-                       {
-                       $useradd{$1} = [];
-                       }
+               #if (exists $useradd{$1})
+               #       {
+               #       $useradd{$1} = [];
+               #       }
                next;
                }
 
@@ -891,6 +891,18 @@ while (@argvcopy)
                }
        }
 
+if (grep { scalar @$_ > 0 } values %useradd) {
+    my $detected_env = join(', ', grep { @{$useradd{$_}} || env($_) }
+                                  sort keys %useradd);
+    if ($detected_env) {
+        die <<"_____";
+***** Mixing env / make variables and additional compiler/linker flags as
+***** configure command line option is not permitted.
+***** Affected env / make variables: $detected_env
+_____
+    }
+}
+
 foreach (keys %user) {
     my $value = env($_);
     $value //= defined $user_synonyms{$_} ? env($user_synonyms{$_}) : undef;
diff --git a/INSTALL b/INSTALL
index 3c8548dd3b89104015d654f307d3fad11efead97..08758339a2b5c987ba26b2f7bb8151b7e8cc135d 100644 (file)
--- a/INSTALL
+++ b/INSTALL
                    RCFLAGS         Flags for the Windows reources manipulator.
                    RM              The command to remove files and directories.
 
-                   These can be mixed with flags given on the command line.
-                   Any variable assignment resets any corresponding flags
-                   given before it, so for example:
+                   These cannot be mixed with compiling / linking flags given
+                   on the command line.  In other words, something like this
+                   isn't permitted.
 
                        ./config -DFOO CPPFLAGS=-DBAR -DCOOKIE
 
-                   Will end up having 'CPPFLAGS=-DBAR -DCOOKIE'.
-
-                   Here is how the flags documented above are collected as
-                   augmentation of these variables:
-
-                   -Dxxx           xxx is collected in CPPDEFINES
-                   -Ixxx           xxx is collected in CPPINCLUDES
-                   -Wp,xxx         collected in CPPFLAGS
-                   -Lxxx           collected in LDFLAGS
-                   -lxxx           collected in LDLIBS
-                   -Wp,xxx         collected in LDLIBS
-                   -rpath xxx      collected in LDLIBS
-                   -R xxx          collected in LDLIBS
-                   -framework xxx  collected in LDLIBS
-                   -static         collected in LDLIBS
-                   -xxx            collected in CFLAGS
-                   +xxx            collected in CFLAGS
-
   reconf
   reconfigure
                    Reconfigure from earlier data.  This fetches the previous