diff options
author | peter <peter@FreeBSD.org> | 2000-09-25 18:44:30 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 2000-09-25 18:44:30 +0000 |
commit | d9de6c575335a618c2c4db4e1d2934cf9f3b29fc (patch) | |
tree | f77f043b018563da24bb0bc6fad5c760555d7416 /usr.bin/make | |
parent | a9a721b7061259dbb530bf837770ac49cc3eb608 (diff) | |
download | FreeBSD-src-d9de6c575335a618c2c4db4e1d2934cf9f3b29fc.zip FreeBSD-src-d9de6c575335a618c2c4db4e1d2934cf9f3b29fc.tar.gz |
*** empty log message ***
Diffstat (limited to 'usr.bin/make')
-rw-r--r-- | usr.bin/make/main.c | 33 | ||||
-rw-r--r-- | usr.bin/make/make.1 | 7 |
2 files changed, 28 insertions, 12 deletions
diff --git a/usr.bin/make/main.c b/usr.bin/make/main.c index 2694eed..33719e8 100644 --- a/usr.bin/make/main.c +++ b/usr.bin/make/main.c @@ -116,6 +116,7 @@ Boolean allPrecious; /* .PRECIOUS given on line by itself */ static Boolean noBuiltins; /* -r flag */ static Lst makefiles; /* ordered list of makefiles to read */ static Boolean printVars; /* print value of one or more vars */ +static Boolean expandVars; /* fully expand printed variables */ static Lst variables; /* list of variables to print */ int maxJobs; /* -j argument */ static Boolean forceJobs; /* -j argument given */ @@ -167,9 +168,9 @@ MainParseArgs(argc, argv) optind = 1; /* since we're called more than once */ #ifdef REMOTE -# define OPTFLAGS "BD:E:I:L:PSV:d:ef:ij:km:nqrstv" +# define OPTFLAGS "BD:E:I:L:PSV:Xd:ef:ij:km:nqrstv" #else -# define OPTFLAGS "BD:E:I:PSV:d:ef:ij:km:nqrstv" +# define OPTFLAGS "BD:E:I:PSV:Xd:ef:ij:km:nqrstv" #endif rearg: while((c = getopt(argc, argv, OPTFLAGS)) != -1) { switch(c) { @@ -185,15 +186,13 @@ rearg: while((c = getopt(argc, argv, OPTFLAGS)) != -1) { break; case 'V': printVars = TRUE; - p = malloc(strlen(optarg) + 1 + 3); - if (!p) - Punt("make: cannot allocate memory."); - /* This sprintf is safe, because of the malloc above */ - (void)sprintf(p, "${%s}", optarg); - (void)Lst_AtEnd(variables, (ClientData)p); + (void)Lst_AtEnd(variables, (ClientData)optarg); Var_Append(MAKEFLAGS, "-V", VAR_GLOBAL); Var_Append(MAKEFLAGS, optarg, VAR_GLOBAL); break; + case 'X': + expandVars = FALSE; + break; case 'B': compatMake = TRUE; Var_Append(MAKEFLAGS, "-B", VAR_GLOBAL); @@ -621,6 +620,7 @@ main(argc, argv) makefiles = Lst_Init(FALSE); envFirstVars = Lst_Init(FALSE); printVars = FALSE; + expandVars = TRUE; variables = Lst_Init(FALSE); beSilent = FALSE; /* Print commands as executed */ ignoreErrors = FALSE; /* Pay attention to non-zero returns */ @@ -828,10 +828,21 @@ main(argc, argv) for (ln = Lst_First(variables); ln != NILLNODE; ln = Lst_Succ(ln)) { - char *value = Var_Subst(NULL, (char *)Lst_Datum(ln), - VAR_GLOBAL, FALSE); - + char *value; + if (expandVars) { + p1 = malloc(strlen((char *)Lst_Datum(ln)) + 1 + 3); + if (!p1) + Punt("make: cannot allocate memory."); + /* This sprintf is safe, because of the malloc above */ + (void)sprintf(p1, "${%s}", (char *)Lst_Datum(ln)); + value = Var_Subst(NULL, p1, VAR_GLOBAL, FALSE); + } else { + value = Var_Value((char *)Lst_Datum(ln), + VAR_GLOBAL, &p1); + } printf("%s\n", value ? value : ""); + if (p1) + free(p1); } } diff --git a/usr.bin/make/make.1 b/usr.bin/make/make.1 index 48f5f93..d8f1950 100644 --- a/usr.bin/make/make.1 +++ b/usr.bin/make/make.1 @@ -40,7 +40,7 @@ .Nd maintain program dependencies .Sh SYNOPSIS .Nm make -.Op Fl BPSeiknqrstv +.Op Fl BPSXeiknqrstv .Op Fl D Ar variable .Op Fl d Ar flags .Op Fl E Ar variable @@ -217,6 +217,11 @@ with a blank line for each null or undefined variable. .It Fl v Be extra verbose. For multi-job makes, this will cause file banners to be generated. +.It Fl X +When using the +.Fl V +option to print the values of variables, +do not recursively expand the values. .It Ar variable Ns No = Ns Ar value Set the value of the variable .Ar variable |