Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make Add -v variable that always expands variables; ...



details:   https://anonhg.NetBSD.org/src/rev/7366ffa15594
branches:  trunk
changeset: 354516:7366ffa15594
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Jun 19 19:58:24 2017 +0000

description:
Add -v variable that always expands variables; restore -V the way it was.

diffstat:

 usr.bin/make/main.c |  26 ++++++++++++++++----------
 usr.bin/make/make.1 |   9 +++++++--
 2 files changed, 23 insertions(+), 12 deletions(-)

diffs (129 lines):

diff -r 5fc64e13b59f -r 7366ffa15594 usr.bin/make/main.c
--- a/usr.bin/make/main.c       Mon Jun 19 19:02:16 2017 +0000
+++ b/usr.bin/make/main.c       Mon Jun 19 19:58:24 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.271 2017/06/19 15:49:21 christos Exp $      */
+/*     $NetBSD: main.c,v 1.272 2017/06/19 19:58:24 christos Exp $      */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: main.c,v 1.271 2017/06/19 15:49:21 christos Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.272 2017/06/19 19:58:24 christos Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
@@ -81,7 +81,7 @@
 #if 0
 static char sccsid[] = "@(#)main.c     8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: main.c,v 1.271 2017/06/19 15:49:21 christos Exp $");
+__RCSID("$NetBSD: main.c,v 1.272 2017/06/19 19:58:24 christos Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -155,7 +155,9 @@
 
 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 int             printVars;      /* -[vV] argument */
+#define COMPAT_VARS 1
+#define EXPAND_VARS 2
 static Lst             variables;      /* list of variables to print */
 int                    maxJobs;        /* -j argument */
 static int             maxJobTokens;   /* -j argument */
@@ -408,7 +410,7 @@
        Boolean inOption, dashDash = FALSE;
        char found_path[MAXPATHLEN + 1];        /* for searching for sys.mk */
 
-#define OPTFLAGS "BC:D:I:J:NST:V:WXd:ef:ij:km:nqrstw"
+#define OPTFLAGS "BC:D:I:J:NST:V:WXd:ef:ij:km:nqrstv:w"
 /* Can't actually use getopt(3) because rescanning is not portable */
 
        getopt_def = OPTFLAGS;
@@ -533,8 +535,9 @@
                        Var_Append(MAKEFLAGS, argvalue, VAR_GLOBAL);
                        break;
                case 'V':
+               case 'v':
                        if (argvalue == NULL) goto noarg;
-                       printVars = TRUE;
+                       printVars = c == 'v' ? EXPAND_VARS : COMPAT_VARS;
                        (void)Lst_AtEnd(variables, argvalue);
                        Var_Append(MAKEFLAGS, "-V", VAR_GLOBAL);
                        Var_Append(MAKEFLAGS, argvalue, VAR_GLOBAL);
@@ -852,10 +855,12 @@
        LstNode ln;
        Boolean expandVars;
 
-       if (debugVflag)
+       if (printVars == EXPAND_VARS)
+               expandVars = TRUE;
+       else if (debugVflag)
                expandVars = FALSE;
        else
-               expandVars = getBoolean(".MAKE.EXPAND_VARIABLES", TRUE);
+               expandVars = getBoolean(".MAKE.EXPAND_VARIABLES", FALSE);
 
        for (ln = Lst_First(variables); ln != NULL;
            ln = Lst_Succ(ln)) {
@@ -1072,7 +1077,7 @@
 
        create = Lst_Init(FALSE);
        makefiles = Lst_Init(FALSE);
-       printVars = FALSE;
+       printVars = 0;
        debugVflag = FALSE;
        variables = Lst_Init(FALSE);
        beSilent = FALSE;               /* Print commands as executed */
@@ -1917,7 +1922,8 @@
 "usage: %s [-BeikNnqrstWwX] \n\
             [-C directory] [-D variable] [-d flags] [-f makefile]\n\
             [-I directory] [-J private] [-j max_jobs] [-m directory] [-T file]\n\
-            [-V variable] [variable=value] [target ...]\n", progname);
+            [-V variable] [-v variable] [variable=value] [target ...]\n",
+           progname);
        exit(2);
 }
 
diff -r 5fc64e13b59f -r 7366ffa15594 usr.bin/make/make.1
--- a/usr.bin/make/make.1       Mon Jun 19 19:02:16 2017 +0000
+++ b/usr.bin/make/make.1       Mon Jun 19 19:58:24 2017 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: make.1,v 1.266 2017/02/01 18:39:27 sjg Exp $
+.\"    $NetBSD: make.1,v 1.267 2017/06/19 19:58:24 christos Exp $
 .\"
 .\" Copyright (c) 1990, 1993
 .\"    The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\"    from: @(#)make.1        8.4 (Berkeley) 3/19/94
 .\"
-.Dd February 1, 2017
+.Dd June 19, 2017
 .Dt MAKE 1
 .Os
 .Sh NAME
@@ -48,6 +48,7 @@
 .Op Fl m Ar directory
 .Op Fl T Ar file
 .Op Fl V Ar variable
+.Op Fl v Ar variable
 .Op Ar variable=value
 .Op Ar target ...
 .Sh DESCRIPTION
@@ -348,6 +349,10 @@
 contains a
 .Ql \&$
 then the value will be expanded before printing.
+.It Fl v Ar variable
+Like 
+.Fl V
+but the variable is always expanded to its final value.
 .It Fl W
 Treat any warnings during makefile parsing as errors.
 .It Fl w



Home | Main Index | Thread Index | Old Index