]> git.ipfire.org Git - thirdparty/make.git/commitdiff
[SV 59230] Preserve export settings for target-specific vars
authorDmitry Goncharov <dgoncharov@users.sf.net>
Fri, 27 Nov 2020 22:18:05 +0000 (17:18 -0500)
committerPaul Smith <psmith@gnu.org>
Sun, 29 Nov 2020 22:55:32 +0000 (17:55 -0500)
* src/read.c (record_target_var): Don't overwrite pre-existing export
flag unless we're changing it.
* tests/scripts/features/targetvars: Add a test.

src/read.c
tests/scripts/features/targetvars

index 3553fd79b1e4d17e12cc5c427d059ca42c20c26c..9e2c169568b72b398820512aef2676683cafdda8 100644 (file)
@@ -1832,7 +1832,8 @@ record_target_var (struct nameseq *filenames, char *defn,
       /* Set up the variable to be *-specific.  */
       v->per_target = 1;
       v->private_var = vmod->private_v;
-      v->export = vmod->export_v ? v_export : v_default;
+      if (vmod->export_v)
+        v->export = v_export;
 
       /* If it's not an override, check to see if there was a command-line
          setting.  If so, reset the value.  */
index 08263bf34c57d91c14d7d4732bab895a2a256dd2..14b9f1da731382e30f29fff4ebad2382eb478f2c 100644 (file)
@@ -86,7 +86,6 @@ run_make_test(undef, "foo.q bar.q", "qvar = rvar\nqvar =\n");
 
 run_make_test(undef, "foo.t bar.s", "qvar = qvar\nqvar =\n");
 
-
 # TEST #8
 # For PR/1378: Target-specific vars don't inherit correctly
 
@@ -291,6 +290,17 @@ dummy: hello?=world
 !,
               '', 'hello=moon');
 
+# SV 59230: Assignment of a global variable should not affect export of a
+# target specific variable.
+
+$ENV{hello} = "moon";
+run_make_test(q!
+all:; @echo hello=$$hello
+hello=sun
+dummy: hello?=world
+!,
+              '', 'hello=sun');
+
 # TEST #19: Test define/endef variables as target-specific vars
 
 # run_make_test('