Module Name:    src
Committed By:   rillig
Date:           Wed Feb 15 06:52:59 UTC 2023

Modified Files:
        src/usr.bin/make: job.c main.c make.h parse.c var.c
        src/usr.bin/make/unit-tests: varname-dot-makeoverrides.mk

Log Message:
make: inline macros for variable names

The variable name '.MAKEOVERRIDES' was already used in the non-macro
form.

No binary change.


To generate a diff of this commit:
cvs rdiff -u -r1.458 -r1.459 src/usr.bin/make/job.c
cvs rdiff -u -r1.590 -r1.591 src/usr.bin/make/main.c
cvs rdiff -u -r1.315 -r1.316 src/usr.bin/make/make.h
cvs rdiff -u -r1.695 -r1.696 src/usr.bin/make/parse.c
cvs rdiff -u -r1.1045 -r1.1046 src/usr.bin/make/var.c
cvs rdiff -u -r1.2 -r1.3 \
    src/usr.bin/make/unit-tests/varname-dot-makeoverrides.mk

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/job.c
diff -u src/usr.bin/make/job.c:1.458 src/usr.bin/make/job.c:1.459
--- src/usr.bin/make/job.c:1.458	Tue Feb 14 21:38:31 2023
+++ src/usr.bin/make/job.c	Wed Feb 15 06:52:58 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: job.c,v 1.458 2023/02/14 21:38:31 rillig Exp $	*/
+/*	$NetBSD: job.c,v 1.459 2023/02/15 06:52:58 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -142,7 +142,7 @@
 #include "trace.h"
 
 /*	"@(#)job.c	8.2 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: job.c,v 1.458 2023/02/14 21:38:31 rillig Exp $");
+MAKE_RCSID("$NetBSD: job.c,v 1.459 2023/02/15 06:52:58 rillig Exp $");
 
 /*
  * A shell defines how the commands are run.  All commands for a target are
@@ -2196,11 +2196,11 @@ Job_SetPrefix(void)
 {
 	if (targPrefix != NULL) {
 		free(targPrefix);
-	} else if (!Var_Exists(SCOPE_GLOBAL, MAKE_JOB_PREFIX)) {
-		Global_Set(MAKE_JOB_PREFIX, "---");
+	} else if (!Var_Exists(SCOPE_GLOBAL, ".MAKE.JOB.PREFIX")) {
+		Global_Set(".MAKE.JOB.PREFIX", "---");
 	}
 
-	targPrefix = Var_Subst("${" MAKE_JOB_PREFIX "}",
+	targPrefix = Var_Subst("${.MAKE.JOB.PREFIX}",
 	    SCOPE_GLOBAL, VARE_WANTRES);
 	/* TODO: handle errors */
 }

Index: src/usr.bin/make/main.c
diff -u src/usr.bin/make/main.c:1.590 src/usr.bin/make/main.c:1.591
--- src/usr.bin/make/main.c:1.590	Tue Feb 14 21:38:31 2023
+++ src/usr.bin/make/main.c	Wed Feb 15 06:52:58 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.590 2023/02/14 21:38:31 rillig Exp $	*/
+/*	$NetBSD: main.c,v 1.591 2023/02/15 06:52:58 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -111,7 +111,7 @@
 #include "trace.h"
 
 /*	"@(#)main.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: main.c,v 1.590 2023/02/14 21:38:31 rillig Exp $");
+MAKE_RCSID("$NetBSD: main.c,v 1.591 2023/02/15 06:52:58 rillig Exp $");
 #if defined(MAKE_NATIVE) && !defined(lint)
 __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 "
 	    "The Regents of the University of California.  "
@@ -440,7 +440,7 @@ MainParseArg(char c, const char *argvalu
 	case 'B':
 		opts.compatMake = true;
 		Global_Append(MAKEFLAGS, "-B");
-		Global_Set(MAKE_MODE, "compat");
+		Global_Set(".MAKE.MODE", "compat");
 		break;
 	case 'C':
 		MainParseArgChdir(argvalue);
@@ -788,7 +788,7 @@ siginfo(int signo MAKE_ATTR_UNUSED)
 static void
 MakeMode(void)
 {
-	char *mode = Var_Subst("${" MAKE_MODE ":tl}",
+	char *mode = Var_Subst("${.MAKE.MODE:tl}",
 	    SCOPE_GLOBAL, VARE_WANTRES);
 	/* TODO: handle errors */
 
@@ -1273,7 +1273,7 @@ ReadFirstDefaultMakefile(void)
 {
 	StringList makefiles = LST_INIT;
 	StringListNode *ln;
-	char *prefs = Var_Subst("${" MAKE_MAKEFILE_PREFERENCE "}",
+	char *prefs = Var_Subst("${.MAKE.MAKEFILE_PREFERENCE}",
 	    SCOPE_CMDLINE, VARE_WANTRES);
 	/* TODO: handle errors */
 
@@ -1352,7 +1352,7 @@ main_Init(int argc, char **argv)
 	/* This is the traditional preference for makefiles. */
 # define MAKEFILE_PREFERENCE_LIST "makefile Makefile"
 #endif
-	Global_Set(MAKE_MAKEFILE_PREFERENCE, MAKEFILE_PREFERENCE_LIST);
+	Global_Set(".MAKE.MAKEFILE_PREFERENCE", MAKEFILE_PREFERENCE_LIST);
 	Global_Set(".MAKE.DEPENDFILE", ".depend");
 
 	CmdOpts_Init();
@@ -1378,7 +1378,7 @@ main_Init(int argc, char **argv)
 	Parse_Init();
 	InitVarMake(argv[0]);
 	Global_Set(MAKEFLAGS, "");
-	Global_Set(MAKEOVERRIDES, "");
+	Global_Set(".MAKEOVERRIDES", "");
 	Global_Set("MFLAGS", "");
 	Global_Set(".ALLTARGETS", "");
 	Var_Set(SCOPE_CMDLINE, ".MAKE.LEVEL.ENV", MAKE_LEVEL_ENV);
@@ -1391,7 +1391,7 @@ main_Init(int argc, char **argv)
 		if (makelevel < 0)
 			makelevel = 0;
 		snprintf(buf, sizeof buf, "%d", makelevel);
-		Global_Set(MAKE_LEVEL, buf);
+		Global_Set(".MAKE.LEVEL", buf);
 		snprintf(buf, sizeof buf, "%u", myPid);
 		Global_Set_ReadOnly(".MAKE.PID", buf);
 		snprintf(buf, sizeof buf, "%u", getppid());

Index: src/usr.bin/make/make.h
diff -u src/usr.bin/make/make.h:1.315 src/usr.bin/make/make.h:1.316
--- src/usr.bin/make/make.h:1.315	Wed Feb 15 06:31:51 2023
+++ src/usr.bin/make/make.h	Wed Feb 15 06:52:58 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: make.h,v 1.315 2023/02/15 06:31:51 rillig Exp $	*/
+/*	$NetBSD: make.h,v 1.316 2023/02/15 06:52:58 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -609,13 +609,6 @@ extern GNode *mainNode;
 extern pid_t myPid;
 
 #define MAKEFLAGS	".MAKEFLAGS"
-#define MAKEOVERRIDES	".MAKEOVERRIDES"
-/* prefix when printing the target of a job */
-#define MAKE_JOB_PREFIX	".MAKE.JOB.PREFIX"
-#define MAKE_MAKEFILES	".MAKE.MAKEFILES"	/* all loaded makefiles */
-#define MAKE_LEVEL	".MAKE.LEVEL"		/* recursion level */
-#define MAKE_MAKEFILE_PREFERENCE ".MAKE.MAKEFILE_PREFERENCE"
-#define MAKE_MODE	".MAKE.MODE"
 #ifndef MAKE_LEVEL_ENV
 # define MAKE_LEVEL_ENV	"MAKELEVEL"
 #endif

Index: src/usr.bin/make/parse.c
diff -u src/usr.bin/make/parse.c:1.695 src/usr.bin/make/parse.c:1.696
--- src/usr.bin/make/parse.c:1.695	Wed Feb 15 06:31:51 2023
+++ src/usr.bin/make/parse.c	Wed Feb 15 06:52:58 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: parse.c,v 1.695 2023/02/15 06:31:51 rillig Exp $	*/
+/*	$NetBSD: parse.c,v 1.696 2023/02/15 06:52:58 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -105,7 +105,7 @@
 #include "pathnames.h"
 
 /*	"@(#)parse.c	8.3 (Berkeley) 3/19/94"	*/
-MAKE_RCSID("$NetBSD: parse.c,v 1.695 2023/02/15 06:31:51 rillig Exp $");
+MAKE_RCSID("$NetBSD: parse.c,v 1.696 2023/02/15 06:52:58 rillig Exp $");
 
 /*
  * A file being read.
@@ -1870,7 +1870,7 @@ VarAssign_Eval(const char *name, VarAssi
 static void
 VarAssignSpecial(const char *name, const char *avalue)
 {
-	if (strcmp(name, MAKEOVERRIDES) == 0)
+	if (strcmp(name, ".MAKEOVERRIDES") == 0)
 		Main_ExportMAKEFLAGS(false);	/* re-export MAKEFLAGS */
 	else if (strcmp(name, ".CURDIR") == 0) {
 		/*
@@ -1880,7 +1880,7 @@ VarAssignSpecial(const char *name, const
 		 */
 		Dir_InitCur(avalue);
 		Dir_SetPATH();
-	} else if (strcmp(name, MAKE_JOB_PREFIX) == 0)
+	} else if (strcmp(name, ".MAKE.JOB.PREFIX") == 0)
 		Job_SetPrefix();
 	else if (strcmp(name, ".MAKE.EXPORTED") == 0)
 		Var_ExportVars(avalue);
@@ -2146,8 +2146,8 @@ VarContainsWord(const char *varname, con
 static void
 TrackInput(const char *name)
 {
-	if (!VarContainsWord(MAKE_MAKEFILES, name))
-		Global_Append(MAKE_MAKEFILES, name);
+	if (!VarContainsWord(".MAKE.MAKEFILES", name))
+		Global_Append(".MAKE.MAKEFILES", name);
 }
 
 

Index: src/usr.bin/make/var.c
diff -u src/usr.bin/make/var.c:1.1045 src/usr.bin/make/var.c:1.1046
--- src/usr.bin/make/var.c:1.1045	Wed Feb 15 06:31:51 2023
+++ src/usr.bin/make/var.c	Wed Feb 15 06:52:58 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: var.c,v 1.1045 2023/02/15 06:31:51 rillig Exp $	*/
+/*	$NetBSD: var.c,v 1.1046 2023/02/15 06:52:58 rillig Exp $	*/
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1993
@@ -139,7 +139,7 @@
 #include "metachar.h"
 
 /*	"@(#)var.c	8.3 (Berkeley) 3/19/94" */
-MAKE_RCSID("$NetBSD: var.c,v 1.1045 2023/02/15 06:31:51 rillig Exp $");
+MAKE_RCSID("$NetBSD: var.c,v 1.1046 2023/02/15 06:52:58 rillig Exp $");
 
 /*
  * Variables are defined using one of the VAR=value assignments.  Their
@@ -1001,7 +1001,7 @@ Var_SetWithFlags(GNode *scope, const cha
 
 		/*
 		 * If requested, don't export these in the environment
-		 * individually.  We still put them in MAKEOVERRIDES so
+		 * individually.  We still put them in .MAKEOVERRIDES so
 		 * that the command-line settings continue to override
 		 * Makefile settings.
 		 */
@@ -1013,7 +1013,7 @@ Var_SetWithFlags(GNode *scope, const cha
 		 * in ExportVarPlain?
 		 */
 
-		Global_Append(MAKEOVERRIDES, name);
+		Global_Append(".MAKEOVERRIDES", name);
 	}
 
 	if (name[0] == '.' && strcmp(name, MAKE_SAVE_DOLLARS) == 0)

Index: src/usr.bin/make/unit-tests/varname-dot-makeoverrides.mk
diff -u src/usr.bin/make/unit-tests/varname-dot-makeoverrides.mk:1.2 src/usr.bin/make/unit-tests/varname-dot-makeoverrides.mk:1.3
--- src/usr.bin/make/unit-tests/varname-dot-makeoverrides.mk:1.2	Sun Aug 16 14:25:16 2020
+++ src/usr.bin/make/unit-tests/varname-dot-makeoverrides.mk	Wed Feb 15 06:52:59 2023
@@ -1,6 +1,6 @@
-# $NetBSD: varname-dot-makeoverrides.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: varname-dot-makeoverrides.mk,v 1.3 2023/02/15 06:52:59 rillig Exp $
 #
-# Tests for the special .MAKE.MAKEOVERRIDES variable.
+# Tests for the special .MAKEOVERRIDES variable.
 
 # TODO: Implementation
 

Reply via email to