Module Name: src
Committed By: sjg
Date: Sat Feb 20 01:19:03 UTC 2016
Modified Files:
src/usr.bin/make: make.1 var.c
Log Message:
Add a knob .MAKE.SAVE_DOLLARS to control the behavior of $$ during :=
If TRUE '$$' are not consumed (saved).
If FALSE '$$' becomes '$' just like normal expansion rules.
default is TRUE.
Reviewed by: christos
To generate a diff of this commit:
cvs rdiff -u -r1.252 -r1.253 src/usr.bin/make/make.1
cvs rdiff -u -r1.204 -r1.205 src/usr.bin/make/var.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/make.1
diff -u src/usr.bin/make/make.1:1.252 src/usr.bin/make/make.1:1.253
--- src/usr.bin/make/make.1:1.252 Thu Feb 18 20:25:08 2016
+++ src/usr.bin/make/make.1 Sat Feb 20 01:19:03 2016
@@ -1,4 +1,4 @@
-.\" $NetBSD: make.1,v 1.252 2016/02/18 20:25:08 sjg Exp $
+.\" $NetBSD: make.1,v 1.253 2016/02/20 01:19:03 sjg 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 18, 2016
+.Dd February 19, 2016
.Dt MAKE 1
.Os
.Sh NAME
@@ -941,6 +941,18 @@ The process-id of
.It Va .MAKE.PPID
The parent process-id of
.Nm .
+.It Va .MAKE.SAVE_DOLLARS
+value should be a boolen that controls wether
+.Ql $$
+are preserved when doing
+.Ql :=
+assignments.
+The default is true, for compatability with other makes.
+If set to false,
+.Ql $$
+becomes
+.Ql $
+per normal evaluation rules.
.It Va MAKE_PRINT_VAR_ON_ERROR
When
.Nm
Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.204 src/usr.bin/make/var.c:1.205
--- src/usr.bin/make/var.c:1.204 Thu Feb 18 23:33:25 2016
+++ src/usr.bin/make/var.c Sat Feb 20 01:19:03 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: var.c,v 1.204 2016/02/18 23:33:25 sjg Exp $ */
+/* $NetBSD: var.c,v 1.205 2016/02/20 01:19:03 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,14 +69,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: var.c,v 1.204 2016/02/18 23:33:25 sjg Exp $";
+static char rcsid[] = "$NetBSD: var.c,v 1.205 2016/02/20 01:19:03 sjg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: var.c,v 1.204 2016/02/18 23:33:25 sjg Exp $");
+__RCSID("$NetBSD: var.c,v 1.205 2016/02/20 01:19:03 sjg Exp $");
#endif
#endif /* not lint */
#endif
@@ -162,6 +162,16 @@ char var_Error[] = "";
static char varNoError[] = "";
/*
+ * Traditionally we consume $$ during := like any other expansion.
+ * Other make's do not.
+ * This knob allows controlling the behavior.
+ * FALSE for old behavior.
+ * TRUE for new compatible.
+ */
+#define SAVE_DOLLARS ".MAKE.SAVE_DOLLARS"
+static Boolean save_dollars = TRUE;
+
+/*
* Internally, variables are contained in four different contexts.
* 1) the environment. They may not be changed. If an environment
* variable is appended-to, the result is placed in the global
@@ -992,7 +1002,11 @@ Var_Set(const char *name, const char *va
Var_Append(MAKEOVERRIDES, name, VAR_GLOBAL);
}
-
+ if (*name == '.') {
+ if (strcmp(name, SAVE_DOLLARS) == 0)
+ save_dollars = s2Boolean(val, save_dollars);
+ }
+
out:
free(expanded_name);
if (v != NULL)
@@ -3989,7 +4003,7 @@ Var_Subst(const char *var, const char *s
* In such a case, we skip over the escape character and store the
* dollar sign into the buffer directly.
*/
- if (flags & VARF_ASSIGN)
+ if (save_dollars && (flags & VARF_ASSIGN))
Buf_AddByte(&buf, *str);
str++;
Buf_AddByte(&buf, *str);