summaryrefslogtreecommitdiff
path: root/src/variable.c
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2022-12-24 09:26:24 -0500
committerPaul Smith <psmith@gnu.org>2022-12-24 10:52:43 -0500
commit76d2e5d98dbbf655f74f6ef2f6dd3cdd45052ea0 (patch)
tree3a9ed561d856a8031812f472cae408f9bc74fe8d /src/variable.c
parenta581146562009407649b85fac48f4e7cafe5eaa0 (diff)
downloadmake-git-76d2e5d98dbbf655f74f6ef2f6dd3cdd45052ea0.tar.gz
[SV 63552] Change directories before constructing include paths
* src/makeint.h (reset_makeflags): New function to handle changing MAKEFLAGS from within makefiles. Remove decode_env_switches(). * src/variable.c (set_special_var): Call reset_makeflags() instead of various internal methods. * src/main.c (decode_env_switches): Only internal now so make static. (decode_switches): Don't invoke construct_include_path() yet. (reset_makeflags): Decode env switches and construct include paths. (main): Construct include paths after we process -C options. * tests/scripts/options/dash-C: Rewrite to use new test constructs. Add a test using both -C and -I together. Add a test for multiple -C options.
Diffstat (limited to 'src/variable.c')
-rw-r--r--src/variable.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/variable.c b/src/variable.c
index d8bf4288..1b1cb743 100644
--- a/src/variable.c
+++ b/src/variable.c
@@ -1217,18 +1217,16 @@ target_environment (struct file *file, int recursive)
static struct variable *
set_special_var (struct variable *var, enum variable_origin origin)
{
- if (streq (var->name, RECIPEPREFIX_NAME))
+ if (streq (var->name, MAKEFLAGS_NAME))
+ reset_makeflags (origin);
+
+ else if (streq (var->name, RECIPEPREFIX_NAME))
{
/* The user is resetting the command introduction prefix. This has to
happen immediately, so that subsequent rules are interpreted
properly. */
cmd_prefix = var->value[0]=='\0' ? RECIPEPREFIX_DEFAULT : var->value[0];
}
- else if (streq (var->name, MAKEFLAGS_NAME))
- {
- decode_env_switches (STRING_SIZE_TUPLE(MAKEFLAGS_NAME), origin);
- define_makeflags (rebuilding_makefiles);
- }
return var;
}