Module Name: src
Committed By: christos
Date: Sat Mar 31 00:12:25 UTC 2012
Modified Files:
src/usr.bin/make: config.h parse.c
Log Message:
Add a gmake inspired export command
To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/usr.bin/make/config.h
cvs rdiff -u -r1.181 -r1.182 src/usr.bin/make/parse.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.bin/make/config.h
diff -u src/usr.bin/make/config.h:1.20 src/usr.bin/make/config.h:1.21
--- src/usr.bin/make/config.h:1.20 Sun Oct 14 16:22:53 2007
+++ src/usr.bin/make/config.h Fri Mar 30 20:12:24 2012
@@ -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
Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.181 src/usr.bin/make/parse.c:1.182
--- src/usr.bin/make/parse.c:1.181 Sat Mar 24 16:28:41 2012
+++ src/usr.bin/make/parse.c Fri Mar 30 20:12:24 2012
@@ -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 @@ static void ParseSetParseFile(const char
#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 @@ ParseTraditionalInclude(char *line)
}
#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 @@ Parse_File(const char *name, int fd)
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);