summaryrefslogtreecommitdiff
path: root/tests/run_make_tests.pl
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2021-09-05 17:11:44 -0400
committerPaul Smith <psmith@gnu.org>2021-09-05 21:08:59 -0400
commitf4b8ddf260f1ab1f1b75b9a9d602c409c6c01b0e (patch)
tree98ee9e000a1965d07c357ff548159caea2304a44 /tests/run_make_tests.pl
parente13fd5c83d9a6df3c303cec7c8791d76f25e1616 (diff)
downloadmake-git-f4b8ddf260f1ab1f1b75b9a9d602c409c6c01b0e.tar.gz
[SV 45211] Parse MAKEFLAGS immediately when it's reset
When MAKEFLAGS is set in a makefile, reparse it immediately rather than waiting until after all makefiles have been read and parsed. This change doesn't actually fix the SV bug referenced because, even though we do reparse MAKEFLAGS, we don't handle the -r or -R options immediately. Doing this will require more effort. * NEWS: Announce the change. * src/makeint.h: Publish reset_switches() and decode_env_switches() from main.c * src/main.c (main): Don't call construct_include_path(); it will be invoked decode_switches(). Preserve the old values of builtin_rules, builtin_variables, and job_slots before we read makefiles since they can be changed now. (reset_switches): Publish (remove static). Set the initial value of the stringlist list to NULL. (decode_switches): Call construct_include_path() after decoding. (decode_env_switches): Publish (remove static). (define_makeflags): Set the MAKEFLAGS variable for special handling. * src/read.c (eval_makefile): Check for empty include_directories. (construct_include_path): Clear any old value of .INCLUDE_DIRS before appending new values. Free the previous include_directories. * src/variable.c (lookup_special_var): When MAKEFLAGS is set, first reset the switches then re-parse the variable. * tests/run_make_tests.pl: Memo-ize some default variable values. * tests/scripts/options/dash-r: Create tests for setting -r and -R. * tests/scripts/variables/MAKEFLAGS: Test that resetting -I from within the makefile takes effect immediately.
Diffstat (limited to 'tests/run_make_tests.pl')
-rw-r--r--tests/run_make_tests.pl16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/run_make_tests.pl b/tests/run_make_tests.pl
index d76e4f3b..d248ec97 100644
--- a/tests/run_make_tests.pl
+++ b/tests/run_make_tests.pl
@@ -45,6 +45,10 @@ $cwdpath = cwd();
$has_POSIX = eval { require "POSIX.pm" };
%FEATURES = ();
+%DEFVARS = (
+ AR => undef,
+ CC => undef
+);
$valgrind = 0; # invoke make with valgrind
$valgrind_args = '';
@@ -649,6 +653,18 @@ sub set_more_defaults
%FEATURES = map { $_ => 1 } split /\s+/, `$make_path -sf features.mk`;
unlink('features.mk');
+ # Find the default values for different built-in variables
+ my $s = "all:;\n";
+ foreach (keys %DEFVARS) {
+ $s .= "\$(info $_=\$($_))\n";
+ }
+ create_file('defvars.mk', $s);
+ foreach (split "\n", `$make_path -sf defvars.mk`) {
+ my @e = split /=/, $_, 2;
+ $DEFVARS{$e[0]} = $e[1];
+ }
+ unlink('defvars.mk');
+
# Set up for valgrind, if requested.
@make_command = ($make_path);