summaryrefslogtreecommitdiff
path: root/usr.bin/make/parse.c
diff options
context:
space:
mode:
authorchristos <christos@NetBSD.org>2012-03-31 00:12:24 +0000
committerchristos <christos@NetBSD.org>2012-03-31 00:12:24 +0000
commitd516675e4a805c4ffbebaf0071d9510b658d3f2d (patch)
treeee5f97816a0e8433aaa6158c4736134d0e08b758 /usr.bin/make/parse.c
parent6a55859f93b527d5de166b125d4150df1e849180 (diff)
Add a gmake inspired export command
Diffstat (limited to 'usr.bin/make/parse.c')
-rw-r--r--usr.bin/make/parse.c69
1 files changed, 66 insertions, 3 deletions
diff --git a/usr.bin/make/parse.c b/usr.bin/make/parse.c
index 022984c98a5..b4af8d848f0 100644
--- a/usr.bin/make/parse.c
+++ b/usr.bin/make/parse.c
@@ -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);