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 a gmake inspired export command



details:   https://anonhg.NetBSD.org/src/rev/a51c18c239fa
branches:  trunk
changeset: 778510:a51c18c239fa
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Mar 31 00:12:24 2012 +0000

description:
Add a gmake inspired export command

diffstat:

 usr.bin/make/config.h |   8 +++++-
 usr.bin/make/parse.c  |  69 ++++++++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 73 insertions(+), 4 deletions(-)

diffs (132 lines):

diff -r b4c8c29cc715 -r a51c18c239fa usr.bin/make/config.h
--- a/usr.bin/make/config.h     Fri Mar 30 20:15:18 2012 +0000
+++ b/usr.bin/make/config.h     Sat Mar 31 00:12:24 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: config.h,v 1.20 2007/10/14 20:22:53 apb Exp $  */
+/*     $NetBSD: config.h,v 1.21 2012/03/31 00:12:24 christos Exp $     */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -133,6 +133,12 @@
 #define SYSVVARSUB
 
 /*
+ * GMAKEEXPORT
+ *     Recognize gmake like variable export directives [export <VAR>=<VALUE>]
+ */
+#define GMAKEEXPORT
+
+/*
  * SUNSHCMD
  *     Recognize SunOS and Solaris:
  *             VAR :sh= CMD    # Assign VAR to the command substitution of CMD
diff -r b4c8c29cc715 -r a51c18c239fa usr.bin/make/parse.c
--- a/usr.bin/make/parse.c      Fri Mar 30 20:15:18 2012 +0000
+++ b/usr.bin/make/parse.c      Sat Mar 31 00:12:24 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: parse.c,v 1.181 2012/03/24 20:28:41 sjg Exp $  */
+/*     $NetBSD: parse.c,v 1.182 2012/03/31 00:12:24 christos Exp $     */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: parse.c,v 1.181 2012/03/24 20:28:41 sjg Exp $";
+static char rcsid[] = "$NetBSD: parse.c,v 1.182 2012/03/31 00:12:24 christos Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)parse.c    8.3 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: parse.c,v 1.181 2012/03/24 20:28:41 sjg Exp $");
+__RCSID("$NetBSD: parse.c,v 1.182 2012/03/31 00:12:24 christos Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -362,6 +362,9 @@
 #ifdef SYSVINCLUDE
 static void ParseTraditionalInclude(char *);
 #endif
+#ifdef GMAKEEXPORT
+static void ParseGmakeExport(char *);
+#endif
 static int ParseEOF(void);
 static char *ParseReadLine(void);
 static void ParseFinishLine(void);
@@ -2402,6 +2405,55 @@
 }
 #endif
 
+#ifdef SYSVINCLUDE
+/*-
+ *---------------------------------------------------------------------
+ * ParseGmakeExport  --
+ *     Parse export <variable>=<value>
+ *
+ *     And set the environment with it.
+ *
+ * Results:
+ *     None
+ *
+ * Side Effects:
+ *     None
+ *---------------------------------------------------------------------
+ */
+static void
+ParseGmakeExport(char *line)
+{
+    char         *variable = &line[6];
+    char         *value;
+
+    if (DEBUG(PARSE)) {
+           fprintf(debug_file, "ParseTraditionalInclude: %s\n", variable);
+    }
+
+    /*
+     * Skip over whitespace
+     */
+    while (isspace((unsigned char)*variable))
+       variable++;
+
+    for (value = variable; *value && *value != '='; value++)
+       continue;
+
+    if (*value != '=') {
+       Parse_Error(PARSE_FATAL,
+                    "Variable/Value missing from \"include\"");
+       return;
+    }
+
+    /*
+     * Substitute for any variables in the file name before trying to
+     * find the thing.
+     */
+    value = Var_Subst(NULL, value, VAR_CMD, FALSE);
+    setenv(variable, value, 1);
+}
+#endif
+
 /*-
  *---------------------------------------------------------------------
  * ParseEOF  --
@@ -2851,6 +2903,17 @@
                continue;
            }
 #endif
+#ifdef GMAKEEXPORT
+           if (strncmp(line, "export", 6) == 0 &&
+               isspace((unsigned char) line[6]) &&
+               strchr(line, ':') == NULL) {
+               /*
+                * It's an Gmake"export".
+                */
+               ParseGmakeExport(line);
+               continue;
+           }
+#endif
            if (Parse_IsVar(line)) {
                ParseFinishLine();
                Parse_DoVar(line, VAR_GLOBAL);



Home | Main Index | Thread Index | Old Index