Configure: correct the check of env vars vs command line flags
[openssl.git] / Configure
index f0a88f8468344f6bc96b9a6f1d80be835db816a8..9cf3d750a9b5a0e41b6bf696789a894277f7b9b6 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,33 @@ while (@argvcopy)
                }
        }
 
+# If any %useradd entry has been set, we must check that the environment
+# variables haven't been set.  We start by checking of any %useradd entry
+# is set.
+if (grep { scalar @$_ > 0 } values %useradd) {
+    # Hash of env / make variables names.  The possible values are:
+    # 1 - environment set
+    # 2 - %useradd entry set
+    # 3 - both set
+    my %detected_env =
+        map { my $v = 0;
+              $v += 1 if env($_);
+              $v += 2 if @{$useradd{$_}};
+              $_ => $v }
+        keys %useradd;
+
+    # If any of the corresponding environment variables is set, we error
+    if (grep { $_ & 1 } values %detected_env) {
+        my $names = join(', ', grep { $detected_env{$_} > 0 }
+                               sort keys %detected_env);
+        die <<"_____";
+***** Mixing env / make variables and additional compiler/linker flags as
+***** configure command line option is not permitted.
+***** Affected env / make variables: $names
+_____
+    }
+}
+
 foreach (keys %user) {
     my $value = env($_);
     $value //= defined $user_synonyms{$_} ? env($user_synonyms{$_}) : undef;
@@ -1101,7 +1128,6 @@ foreach (keys %user) {
         || $mkvalue->($ref_type, $target{$_});
     delete $config{$_} unless defined $config{$_};
 }
-$config{plib_lflags} = [ $target{plib_lflags} ];
 
 # Allow overriding the build file name
 $config{build_file} = env('BUILDFILE') || $target{build_file} || "Makefile";
@@ -3104,7 +3130,6 @@ sub print_table_entry
        "ld",
        "lflags",
        "loutflag",
-       "plib_lflags",
        "ex_libs",
        "bn_ops",
        "apps_aux_src",