summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@redhat.com>1994-10-01 08:07:35 +0000
committerRoland McGrath <roland@redhat.com>1994-10-01 08:07:35 +0000
commit1766b7fa591d204708a36b7ca52a4c9cb62ded0b (patch)
treea8977085cf12246ffd785f640e79b3eed34b18e7 /main.c
parentfa999783d7c66ee106c2fd95c1832457082f517e (diff)
downloadmake-1766b7fa591d204708a36b7ca52a4c9cb62ded0b.tar.gz
(main): Define hidden automatic variable with command vars, and
MAKEOVERRIDES to a reference to that. (define_makeflags): If posix_pedantic, write a reference to that instead.
Diffstat (limited to 'main.c')
-rw-r--r--main.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/main.c b/main.c
index 2a61455..205fa63 100644
--- a/main.c
+++ b/main.c
@@ -602,8 +602,19 @@ main (argc, argv, envp)
}
p[-1] = '\0'; /* Kill the final space and terminate. */
- /* Define the variable; this will not override any user definition. */
- (void) define_variable ("MAKEOVERRIDES", 13, value, o_env, 0);
+ /* Define an unchangeable variable with a name that no POSIX.2
+ makefile could validly use for its own variable. */
+ (void) define_variable ("-*-command-variables-*-", 23,
+ value, o_automatic, 0);
+
+ /* Define the variable; this will not override any user definition.
+ Normally a reference to this variable is written into the value of
+ MAKEFLAGS, allowing the user to override this value to affect the
+ exported value of MAKEFLAGS. In POSIX-pedantic mode, we cannot
+ allow the user's setting of MAKEOVERRIDES to affect MAKEFLAGS, so
+ a reference to this hidden variable is written instead. */
+ (void) define_variable ("MAKEOVERRIDES", 13,
+ "${-*-command-variables-*-}", o_env, 1);
}
/* If there were -C flags, move ourselves about. */
@@ -1582,6 +1593,7 @@ define_makeflags (all, makefile)
int all, makefile;
{
static const char ref[] = "$(MAKEOVERRIDES)";
+ static const char posixref[] = "$(-*-command-variables-*-)";
register const struct command_switch *cs;
char *flagstring;
register char *p;
@@ -1695,7 +1707,7 @@ define_makeflags (all, makefile)
break;
}
- flagslen += 4 + sizeof ref; /* Four more for the possible " -- ". */
+ flagslen += 4 + sizeof posixref; /* Four more for the possible " -- ". */
#undef ADD_FLAG
@@ -1767,8 +1779,16 @@ define_makeflags (all, makefile)
}
/* Copy in the string. */
- bcopy (ref, p, sizeof ref - 1);
- p += sizeof ref - 1;
+ if (posix_pedantic)
+ {
+ bcopy (posixref, p, sizeof posixref - 1);
+ p += sizeof posixref - 1;
+ }
+ else
+ {
+ bcopy (ref, p, sizeof ref - 1);
+ p += sizeof ref - 1;
+ }
}
else if (p[-1] == '-')
/* Kill the final space and dash. */