Module Name: src Committed By: sjg Date: Tue May 7 18:26:22 UTC 2024
Modified Files: src/usr.bin/make: job.c main.c make.h var.c src/usr.bin/make/unit-tests: opt-debug-graph1.exp opt-debug-graph2.exp opt-debug-graph3.exp suff-main-several.exp suff-transform-debug.exp varname-dot-makeoverrides.exp varname-dot-makeoverrides.mk Log Message: make: all command line overrides go in .MAKEOVERRIDES Not all variables that start with '.' are internals, and unless they are explicitly flagged as internal should go into .MAKEOVERRIDES Update varname-dot-makeoverrides to check this. Also avoid using SCOPE_CMDLINE when ReadOnly will do. To generate a diff of this commit: cvs rdiff -u -r1.470 -r1.471 src/usr.bin/make/job.c cvs rdiff -u -r1.614 -r1.615 src/usr.bin/make/main.c cvs rdiff -u -r1.332 -r1.333 src/usr.bin/make/make.h cvs rdiff -u -r1.1108 -r1.1109 src/usr.bin/make/var.c cvs rdiff -u -r1.12 -r1.13 src/usr.bin/make/unit-tests/opt-debug-graph1.exp cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/opt-debug-graph2.exp \ src/usr.bin/make/unit-tests/opt-debug-graph3.exp \ src/usr.bin/make/unit-tests/suff-transform-debug.exp cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/suff-main-several.exp cvs rdiff -u -r1.3 -r1.4 \ src/usr.bin/make/unit-tests/varname-dot-makeoverrides.exp cvs rdiff -u -r1.5 -r1.6 \ 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.470 src/usr.bin/make/job.c:1.471 --- src/usr.bin/make/job.c:1.470 Sat Apr 27 20:41:32 2024 +++ src/usr.bin/make/job.c Tue May 7 18:26:22 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: job.c,v 1.470 2024/04/27 20:41:32 rillig Exp $ */ +/* $NetBSD: job.c,v 1.471 2024/05/07 18:26:22 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -141,7 +141,7 @@ #include "trace.h" /* "@(#)job.c 8.2 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: job.c,v 1.470 2024/04/27 20:41:32 rillig Exp $"); +MAKE_RCSID("$NetBSD: job.c,v 1.471 2024/05/07 18:26:22 sjg Exp $"); /* * A shell defines how the commands are run. All commands for a target are @@ -2155,7 +2155,8 @@ Shell_Init(void) if (shellPath == NULL) InitShellNameAndPath(); - Var_SetWithFlags(SCOPE_CMDLINE, ".SHELL", shellPath, VAR_SET_READONLY); + Var_SetWithFlags(SCOPE_CMDLINE, ".SHELL", shellPath, + VAR_SET_INTERNAL|VAR_SET_READONLY); if (shell->errFlag == NULL) shell->errFlag = ""; if (shell->echoFlag == NULL) Index: src/usr.bin/make/main.c diff -u src/usr.bin/make/main.c:1.614 src/usr.bin/make/main.c:1.615 --- src/usr.bin/make/main.c:1.614 Tue Apr 30 16:13:33 2024 +++ src/usr.bin/make/main.c Tue May 7 18:26:22 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.614 2024/04/30 16:13:33 sjg Exp $ */ +/* $NetBSD: main.c,v 1.615 2024/05/07 18:26:22 sjg 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.614 2024/04/30 16:13:33 sjg Exp $"); +MAKE_RCSID("$NetBSD: main.c,v 1.615 2024/05/07 18:26:22 sjg Exp $"); #if defined(MAKE_NATIVE) __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 " "The Regents of the University of California. " @@ -1389,7 +1389,7 @@ main_Init(int argc, char **argv) Global_Set(".MAKEOVERRIDES", ""); Global_Set("MFLAGS", ""); Global_Set(".ALLTARGETS", ""); - Var_Set(SCOPE_CMDLINE, ".MAKE.LEVEL.ENV", MAKE_LEVEL_ENV); + Global_Set_ReadOnly(".MAKE.LEVEL.ENV", MAKE_LEVEL_ENV); /* Set some other useful variables. */ { Index: src/usr.bin/make/make.h diff -u src/usr.bin/make/make.h:1.332 src/usr.bin/make/make.h:1.333 --- src/usr.bin/make/make.h:1.332 Sat Apr 27 20:41:32 2024 +++ src/usr.bin/make/make.h Tue May 7 18:26:22 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: make.h,v 1.332 2024/04/27 20:41:32 rillig Exp $ */ +/* $NetBSD: make.h,v 1.333 2024/05/07 18:26:22 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -990,7 +990,8 @@ typedef enum VarSetFlags { * except for another call to Var_Set with the same flag. See the * special targets '.NOREADONLY' and '.READONLY'. */ - VAR_SET_READONLY = 1 << 1 + VAR_SET_READONLY = 1 << 1, + VAR_SET_INTERNAL = 1 << 2 } VarSetFlags; typedef enum VarExportMode { Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.1108 src/usr.bin/make/var.c:1.1109 --- src/usr.bin/make/var.c:1.1108 Sun Apr 28 15:10:19 2024 +++ src/usr.bin/make/var.c Tue May 7 18:26:22 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.1108 2024/04/28 15:10:19 rillig Exp $ */ +/* $NetBSD: var.c,v 1.1109 2024/05/07 18:26:22 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -132,7 +132,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v 1.1108 2024/04/28 15:10:19 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.1109 2024/05/07 18:26:22 sjg Exp $"); /* * Variables are defined using one of the VAR=value assignments. Their @@ -1037,7 +1037,7 @@ Var_SetWithFlags(GNode *scope, const cha * exported to the environment (as per POSIX standard), except * for internals. */ - if (!(flags & VAR_SET_NO_EXPORT) && name[0] != '.') { + if (!(flags & VAR_SET_NO_EXPORT)) { /* * If requested, don't export these in the @@ -1046,14 +1046,11 @@ Var_SetWithFlags(GNode *scope, const cha * command-line settings continue to override * Makefile settings. */ - if (!opts.varNoExportEnv) + if (!opts.varNoExportEnv && name[0] != '.') setenv(name, val, 1); - /* XXX: What about .MAKE.EXPORTED? */ - /* - * XXX: Why not just mark the variable for - * needing export, as in ExportVarPlain? - */ - Global_Append(".MAKEOVERRIDES", name); + + if (!(flags & VAR_SET_INTERNAL)) + Global_Append(".MAKEOVERRIDES", name); } } Index: src/usr.bin/make/unit-tests/opt-debug-graph1.exp diff -u src/usr.bin/make/unit-tests/opt-debug-graph1.exp:1.12 src/usr.bin/make/unit-tests/opt-debug-graph1.exp:1.13 --- src/usr.bin/make/unit-tests/opt-debug-graph1.exp:1.12 Sat Sep 9 16:41:04 2023 +++ src/usr.bin/make/unit-tests/opt-debug-graph1.exp Tue May 7 18:26:22 2024 @@ -23,6 +23,7 @@ .MAKE.GID = <details omitted> .MAKE.JOBS.C = <details omitted> .MAKE.LEVEL = <details omitted> +.MAKE.LEVEL.ENV = MAKELEVEL .MAKE.MAKEFILES = <details omitted> .MAKE.MAKEFILE_PREFERENCE = <details omitted> .MAKE.OS = <details omitted> @@ -42,7 +43,6 @@ MACHINE_ARCH = <details omitted> MAKE = <details omitted> MFLAGS = -r -k -d g1 #*** Command-line Variables: -.MAKE.LEVEL.ENV = MAKELEVEL #*** Directory Cache: # Stats: 0 hits 2 misses 0 near misses 0 losers (0%) Index: src/usr.bin/make/unit-tests/opt-debug-graph2.exp diff -u src/usr.bin/make/unit-tests/opt-debug-graph2.exp:1.7 src/usr.bin/make/unit-tests/opt-debug-graph2.exp:1.8 --- src/usr.bin/make/unit-tests/opt-debug-graph2.exp:1.7 Sat Sep 9 16:41:04 2023 +++ src/usr.bin/make/unit-tests/opt-debug-graph2.exp Tue May 7 18:26:22 2024 @@ -57,6 +57,7 @@ all : made-target error-targ .MAKE.GID = <details omitted> .MAKE.JOBS.C = <details omitted> .MAKE.LEVEL = <details omitted> +.MAKE.LEVEL.ENV = MAKELEVEL .MAKE.MAKEFILES = <details omitted> .MAKE.MAKEFILE_PREFERENCE = <details omitted> .MAKE.OS = <details omitted> @@ -76,7 +77,6 @@ MACHINE_ARCH = <details omitted> MAKE = <details omitted> MFLAGS = -r -k -d g2 #*** Command-line Variables: -.MAKE.LEVEL.ENV = MAKELEVEL .SHELL = <details omitted> #*** Directory Cache: Index: src/usr.bin/make/unit-tests/opt-debug-graph3.exp diff -u src/usr.bin/make/unit-tests/opt-debug-graph3.exp:1.7 src/usr.bin/make/unit-tests/opt-debug-graph3.exp:1.8 --- src/usr.bin/make/unit-tests/opt-debug-graph3.exp:1.7 Sat Sep 9 16:41:04 2023 +++ src/usr.bin/make/unit-tests/opt-debug-graph3.exp Tue May 7 18:26:22 2024 @@ -57,6 +57,7 @@ all : made-target error-targ .MAKE.GID = <details omitted> .MAKE.JOBS.C = <details omitted> .MAKE.LEVEL = <details omitted> +.MAKE.LEVEL.ENV = MAKELEVEL .MAKE.MAKEFILES = <details omitted> .MAKE.MAKEFILE_PREFERENCE = <details omitted> .MAKE.OS = <details omitted> @@ -76,7 +77,6 @@ MACHINE_ARCH = <details omitted> MAKE = <details omitted> MFLAGS = -r -k -d g3 #*** Command-line Variables: -.MAKE.LEVEL.ENV = MAKELEVEL .SHELL = <details omitted> #*** Directory Cache: Index: src/usr.bin/make/unit-tests/suff-transform-debug.exp diff -u src/usr.bin/make/unit-tests/suff-transform-debug.exp:1.7 src/usr.bin/make/unit-tests/suff-transform-debug.exp:1.8 --- src/usr.bin/make/unit-tests/suff-transform-debug.exp:1.7 Sat Sep 9 16:41:04 2023 +++ src/usr.bin/make/unit-tests/suff-transform-debug.exp Tue May 7 18:26:22 2024 @@ -14,6 +14,7 @@ .MAKE.GID = <details omitted> .MAKE.JOBS.C = <details omitted> .MAKE.LEVEL = <details omitted> +.MAKE.LEVEL.ENV = MAKELEVEL .MAKE.MAKEFILES = <details omitted> .MAKE.MAKEFILE_PREFERENCE = <details omitted> .MAKE.OS = <details omitted> @@ -33,7 +34,6 @@ MACHINE_ARCH = <details omitted> MAKE = <details omitted> MFLAGS = -r -k -d g1 #*** Command-line Variables: -.MAKE.LEVEL.ENV = MAKELEVEL #*** Directory Cache: # Stats: 0 hits 2 misses 0 near misses 0 losers (0%) Index: src/usr.bin/make/unit-tests/suff-main-several.exp diff -u src/usr.bin/make/unit-tests/suff-main-several.exp:1.10 src/usr.bin/make/unit-tests/suff-main-several.exp:1.11 --- src/usr.bin/make/unit-tests/suff-main-several.exp:1.10 Sat Sep 9 16:41:04 2023 +++ src/usr.bin/make/unit-tests/suff-main-several.exp Tue May 7 18:26:22 2024 @@ -88,6 +88,7 @@ ParseDependency(.MAKEFLAGS: -d0 -dg1) .MAKE.GID = <details omitted> .MAKE.JOBS.C = <details omitted> .MAKE.LEVEL = <details omitted> +.MAKE.LEVEL.ENV = MAKELEVEL .MAKE.MAKEFILES = <details omitted> .MAKE.MAKEFILE_PREFERENCE = <details omitted> .MAKE.OS = <details omitted> @@ -107,7 +108,6 @@ MACHINE_ARCH = <details omitted> MAKE = <details omitted> MFLAGS = -r -k -d mps -d 0 -d g1 #*** Command-line Variables: -.MAKE.LEVEL.ENV = MAKELEVEL #*** Directory Cache: # Stats: 0 hits 2 misses 0 near misses 0 losers (0%) Index: src/usr.bin/make/unit-tests/varname-dot-makeoverrides.exp diff -u src/usr.bin/make/unit-tests/varname-dot-makeoverrides.exp:1.3 src/usr.bin/make/unit-tests/varname-dot-makeoverrides.exp:1.4 --- src/usr.bin/make/unit-tests/varname-dot-makeoverrides.exp:1.3 Sat Feb 25 06:54:08 2023 +++ src/usr.bin/make/unit-tests/varname-dot-makeoverrides.exp Tue May 7 18:26:22 2024 @@ -1,8 +1,8 @@ all: overrides=<> make -f varname-dot-makeoverrides.mk stage_1 VAR=value stage_1: overrides=< VAR> -make -f varname-dot-makeoverrides.mk stage_2 -stage_2: overrides=< VAR> +make -f varname-dot-makeoverrides.mk stage_2 .VAR=too +stage_2: overrides=< VAR .VAR> make -f varname-dot-makeoverrides.mk stage_3 -stage_3: overrides=< VAR> +stage_3: overrides=< .VAR VAR> exit status 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.5 src/usr.bin/make/unit-tests/varname-dot-makeoverrides.mk:1.6 --- src/usr.bin/make/unit-tests/varname-dot-makeoverrides.mk:1.5 Sat Feb 25 06:54:08 2023 +++ src/usr.bin/make/unit-tests/varname-dot-makeoverrides.mk Tue May 7 18:26:22 2024 @@ -1,4 +1,4 @@ -# $NetBSD: varname-dot-makeoverrides.mk,v 1.5 2023/02/25 06:54:08 rillig Exp $ +# $NetBSD: varname-dot-makeoverrides.mk,v 1.6 2024/05/07 18:26:22 sjg Exp $ # # Tests for the special .MAKEOVERRIDES variable, which lists the names of the # variables that are passed on to child processes via the MAKEFLAGS @@ -13,7 +13,7 @@ all: stage_1: @echo '$@: overrides=<'${.MAKEOVERRIDES:Q}'>' - ${MAKE} -f ${MAKEFILE} stage_2 + ${MAKE} -f ${MAKEFILE} stage_2 .VAR=too stage_2: @echo '$@: overrides=<'${.MAKEOVERRIDES:Q}'>'