From: Joerg Sonnenberger Date: Wed, 1 Dec 2004 01:29:31 +0000 (+0000) Subject: Makefile: 1.32->1.33 X-Git-Tag: v2.0.1~9621 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/c382ef3f90e314df2b723cac3810013f71861c9a Makefile: 1.32->1.33 main.c: 1.90->1.91 nonints.h: 1.22->1.23 var.c: 1.47->1.48 Author: harti Log: 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 make.1:1.78->1.79 Author: ru Log: Document the effects of modifying the .MAKEFLAGS internal variable and using the .MAKEFLAGS special target, and the differences between them. Reviewed by: harti Obtained-from: FreeBSD Submitted-by: Max Okumoto Slightly adjust the change Var_Quote to not cast away a const. --- diff --git a/usr.bin/make/Makefile b/usr.bin/make/Makefile index 3ca38974e9..ccf03d2c60 100644 --- a/usr.bin/make/Makefile +++ b/usr.bin/make/Makefile @@ -1,6 +1,6 @@ # @(#)Makefile 5.2 (Berkeley) 12/28/90 # $FreeBSD: src/usr.bin/make/Makefile,v 1.13.2.1 2001/05/25 08:33:40 sobomax Exp $ -# $DragonFly: src/usr.bin/make/Makefile,v 1.8 2004/12/01 01:10:17 joerg Exp $ +# $DragonFly: src/usr.bin/make/Makefile,v 1.9 2004/12/01 01:29:31 joerg Exp $ PROG= make CFLAGS+=-I${.CURDIR} @@ -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\" # XXX: kernel currently broken # CFLAGS+=-DUSE_KQUEUE diff --git a/usr.bin/make/main.c b/usr.bin/make/main.c index 4c8b9290f6..f8bcae56ed 100644 --- a/usr.bin/make/main.c +++ b/usr.bin/make/main.c @@ -38,7 +38,7 @@ * @(#) Copyright (c) 1988, 1989, 1990, 1993 The Regents of the University of California. All rights reserved. * @(#)main.c 8.3 (Berkeley) 3/19/94 * $FreeBSD: src/usr.bin/make/main.c,v 1.35.2.10 2003/12/16 08:34:11 des Exp $ - * $DragonFly: src/usr.bin/make/main.c,v 1.22 2004/12/01 01:10:17 joerg Exp $ + * $DragonFly: src/usr.bin/make/main.c,v 1.23 2004/12/01 01:29:31 joerg Exp $ */ /*- @@ -350,9 +350,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 == '-') { @@ -629,10 +634,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 diff --git a/usr.bin/make/make.1 b/usr.bin/make/make.1 index 71c7f1e42c..80506cb08a 100644 --- a/usr.bin/make/make.1 +++ b/usr.bin/make/make.1 @@ -31,9 +31,9 @@ .\" .\" from: @(#)make.1 8.4 (Berkeley) 3/19/94 .\" $FreeBSD: src/usr.bin/make/make.1,v 1.29.2.15 2002/12/17 19:01:18 seanc Exp $ -.\" $DragonFly: src/usr.bin/make/make.1,v 1.13 2004/12/01 01:10:17 joerg Exp $ +.\" $DragonFly: src/usr.bin/make/make.1,v 1.14 2004/12/01 01:29:31 joerg Exp $ .\" -.Dd August 4, 2004 +.Dd August 18, 2004 .Dt MAKE 1 .Os .Sh NAME @@ -574,6 +574,15 @@ entered into the environment as for all programs which .Nm executes. +By modifying the contents of the +.Va .MAKEFLAGS +variable, makefile can alter the contents of the +.Va MAKEFLAGS +environment variable made available for all programs which +.Nm +executes; compare with the +.Ic .MAKEFLAGS +special target below. .It Va MFLAGS is provided for backward compatibility and contains all the options from the @@ -1140,6 +1149,20 @@ The flags are as if typed to the shell, though the .Fl f option will have no effect. +Flags (except for +.Fl f ) +and variable assignments specified as the source +for this target are also appended to the +.Va .MAKEFLAGS +internal variable. +Please note the difference between this target and the +.Va .MAKEFLAGS +internal variable: specifying an option or variable +assignment as the source for this target will affect +.Em both +the current makefile and all processes that +.Nm +executes. .It Ic .MFLAGS Same as above, for backward compatibility. .\" XXX: NOT YET!!!! diff --git a/usr.bin/make/nonints.h b/usr.bin/make/nonints.h index a1cee14111..9110c2186e 100644 --- a/usr.bin/make/nonints.h +++ b/usr.bin/make/nonints.h @@ -37,7 +37,7 @@ * * from: @(#)nonints.h 8.3 (Berkeley) 3/19/94 * $FreeBSD: src/usr.bin/make/nonints.h,v 1.8 1999/08/28 01:03:35 peter Exp $ - * $DragonFly: src/usr.bin/make/Attic/nonints.h,v 1.17 2004/12/01 01:10:17 joerg Exp $ + * $DragonFly: src/usr.bin/make/Attic/nonints.h,v 1.18 2004/12/01 01:29:31 joerg Exp $ */ /* arch.c */ @@ -138,7 +138,7 @@ void Var_SetEnv(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 *); diff --git a/usr.bin/make/var.c b/usr.bin/make/var.c index 9b9cf9d0eb..e892506db7 100644 --- a/usr.bin/make/var.c +++ b/usr.bin/make/var.c @@ -37,7 +37,7 @@ * * @(#)var.c 8.3 (Berkeley) 3/19/94 * $FreeBSD: src/usr.bin/make/var.c,v 1.16.2.3 2002/02/27 14:18:57 cjc Exp $ - * $DragonFly: src/usr.bin/make/var.c,v 1.16 2004/12/01 01:10:17 joerg Exp $ + * $DragonFly: src/usr.bin/make/var.c,v 1.17 2004/12/01 01:29:31 joerg Exp $ */ /*- @@ -771,48 +771,9 @@ VarGetPattern(GNode *ctxt, int err, char **tstr, int delim, int *flags, } } - -#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 - /*- *----------------------------------------------------------------------- - * VarQuote -- + * Var_Quote -- * Quote shell meta-characters in the string * * Results: @@ -823,11 +784,11 @@ Var_AddCmdLine(char *name) * *----------------------------------------------------------------------- */ -static char * -VarQuote(char *str) +char * +Var_Quote(const char *str) { - Buffer buf; + char *retstr; /* This should cover most shells :-( */ static char meta[] = "\n \t'`\";&<>()|*?{}[]\\$!#^~"; @@ -838,9 +799,9 @@ VarQuote(char *str) Buf_AddByte(buf, (Byte)*str); } Buf_AddByte(buf, (Byte) '\0'); - str = (char *)Buf_GetAll (buf, (int *)NULL); + retstr = Buf_GetAll (buf, (int *)NULL); Buf_Destroy (buf, FALSE); - return str; + return retstr; } /*- @@ -1507,7 +1468,7 @@ Var_Parse(char *str, GNode *ctxt, Boolean err, int *lengthPtr, Boolean *freePtr) } case 'Q': if (tstr[1] == endc || tstr[1] == ':') { - newStr = VarQuote (str); + newStr = Var_Quote (str); cp = tstr + 1; termc = *cp; break;