mirror of
https://github.com/opnsense/src.git
synced 2026-06-13 18:50:31 -04:00
Put variable assignments on .MAKEFLAGS and .MFLAGS targets into
the .MAKEFLAGS variable so that these are also passed to sub-makes. This makes the handling of variables in the command environment more consistent. PR: bin/68853 Submitted by: Martin Kamerhofer <data@sbox.tugraz.at>
This commit is contained in:
parent
51fce6f692
commit
313745d2ad
4 changed files with 13 additions and 52 deletions
|
|
@ -15,7 +15,7 @@ SRCS+= lstAppend.c lstAtEnd.c lstAtFront.c lstClose.c lstConcat.c \
|
|||
|
||||
NOSHARED?= YES
|
||||
|
||||
CFLAGS+=-DMAKE_VERSION=\"5200408030\"
|
||||
CFLAGS+=-DMAKE_VERSION=\"5200408120\"
|
||||
.if defined(_UPGRADING)
|
||||
CFLAGS+=-D__FBSDID=__RCSID
|
||||
.endif
|
||||
|
|
|
|||
|
|
@ -355,9 +355,14 @@ rearg: while((c = getopt(argc, argv, OPTFLAGS)) != -1) {
|
|||
* on the end of the "create" list.
|
||||
*/
|
||||
for (argv += optind, argc -= optind; *argv; ++argv, --argc)
|
||||
if (Parse_IsVar(*argv))
|
||||
if (Parse_IsVar(*argv)) {
|
||||
char *ptr = Var_Quote(*argv);
|
||||
|
||||
Var_Append(MAKEFLAGS, ptr, VAR_GLOBAL);
|
||||
free(ptr);
|
||||
|
||||
Parse_DoVar(*argv, VAR_CMD);
|
||||
else {
|
||||
} else {
|
||||
if (!**argv)
|
||||
Punt("illegal (null) argument.");
|
||||
if (**argv == '-') {
|
||||
|
|
@ -645,10 +650,6 @@ main(int argc, char **argv)
|
|||
|
||||
MainParseArgs(argc, argv);
|
||||
|
||||
#ifdef POSIX
|
||||
Var_AddCmdLine(MAKEFLAGS);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Find where we are...
|
||||
* All this code is so that we know where we are when we start up
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ void Var_Set(char *, char *, GNode *);
|
|||
void Var_Append(char *, char *, GNode *);
|
||||
Boolean Var_Exists(char *, GNode *);
|
||||
char *Var_Value(char *, GNode *, char **);
|
||||
void Var_AddCmdLine(char *);
|
||||
char *Var_Quote(const char *);
|
||||
char *Var_Parse(char *, GNode *, Boolean, int *, Boolean *);
|
||||
char *Var_Subst(char *, char *, GNode *, Boolean);
|
||||
char *Var_GetTail(char *);
|
||||
|
|
|
|||
|
|
@ -137,7 +137,6 @@ static void VarAdd(char *, char *, GNode *);
|
|||
static void VarDelete(void *);
|
||||
static char *VarGetPattern(GNode *, int, char **, int, int *, int *,
|
||||
VarPattern *);
|
||||
static char *VarQuote(const char *);
|
||||
static char *VarModify(char *,
|
||||
Boolean (*)(const char *, Boolean, Buffer, void *),
|
||||
void *);
|
||||
|
|
@ -773,7 +772,7 @@ VarGetPattern(GNode *ctxt, int err, char **tstr, int delim, int *flags,
|
|||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* VarQuote --
|
||||
* Var_Quote --
|
||||
* Quote shell meta-characters in the string
|
||||
*
|
||||
* Results:
|
||||
|
|
@ -784,8 +783,8 @@ VarGetPattern(GNode *ctxt, int err, char **tstr, int delim, int *flags,
|
|||
*
|
||||
*-----------------------------------------------------------------------
|
||||
*/
|
||||
static char *
|
||||
VarQuote(const char *str)
|
||||
char *
|
||||
Var_Quote(const char *str)
|
||||
{
|
||||
|
||||
Buffer buf;
|
||||
|
|
@ -831,45 +830,6 @@ VarREError(int err, regex_t *pat, const char *str)
|
|||
free(errbuf);
|
||||
}
|
||||
|
||||
|
||||
#ifdef POSIX
|
||||
|
||||
|
||||
/* In POSIX mode, variable assignments passed on the command line are
|
||||
* propagated to sub makes through MAKEFLAGS.
|
||||
*/
|
||||
void
|
||||
Var_AddCmdLine(char *name)
|
||||
{
|
||||
const Var *v;
|
||||
LstNode ln;
|
||||
Buffer buf;
|
||||
static const char quotable[] = " \t\n\\'\"";
|
||||
char *s;
|
||||
int first = 1;
|
||||
|
||||
buf = Buf_Init (MAKE_BSIZE);
|
||||
|
||||
for (ln = Lst_First(VAR_CMD->context); ln != NULL;
|
||||
ln = Lst_Succ(ln)) {
|
||||
if (!first)
|
||||
Buf_AddByte(buf, ' ');
|
||||
first = 0;
|
||||
/* We assume variable names don't need quoting */
|
||||
v = (Var *)Lst_Datum(ln);
|
||||
Buf_AddBytes(buf, strlen(v->name), v->name);
|
||||
Buf_AddByte(buf, '=');
|
||||
for (s = Buf_GetAll(v->val, (int *)NULL); *s != '\0'; s++) {
|
||||
if (strchr(quotable, *s))
|
||||
Buf_AddByte(buf, '\\');
|
||||
Buf_AddByte(buf, *s);
|
||||
}
|
||||
}
|
||||
Var_Append(name, Buf_GetAll(buf, (int *)NULL), VAR_GLOBAL);
|
||||
Buf_Destroy(buf, 1);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*-
|
||||
*-----------------------------------------------------------------------
|
||||
* Var_Parse --
|
||||
|
|
@ -1526,7 +1486,7 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr)
|
|||
/* FALLTHROUGH */
|
||||
case 'Q':
|
||||
if (tstr[1] == endc || tstr[1] == ':') {
|
||||
newStr = VarQuote (str);
|
||||
newStr = Var_Quote (str);
|
||||
cp = tstr + 1;
|
||||
termc = *cp;
|
||||
break;
|
||||
|
|
|
|||
Loading…
Reference in a new issue