CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: sjg Date: Tue Apr 30 16:41:33 UTC 2024 Modified Files: src/usr.bin/make/unit-tests: Makefile deptgt-phony.exp Log Message: Subst DEFSYSPATH in deptgt-phony To generate a diff of this commit: cvs rdiff -u -r1.343 -r1.344 src/usr.bin/make/unit-tests/Makefile cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/deptgt-phony.exp 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/unit-tests/Makefile diff -u src/usr.bin/make/unit-tests/Makefile:1.343 src/usr.bin/make/unit-tests/Makefile:1.344 --- src/usr.bin/make/unit-tests/Makefile:1.343 Sat Apr 20 10:18:55 2024 +++ src/usr.bin/make/unit-tests/Makefile Tue Apr 30 16:41:32 2024 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.343 2024/04/20 10:18:55 rillig Exp $ +# $NetBSD: Makefile,v 1.344 2024/04/30 16:41:32 sjg Exp $ # # Unit tests for make(1) # @@ -589,8 +589,9 @@ unexport-env.rawout: export.mk # In tests that use the debugging option -dd, ignore debugging output that is # only logged in -DCLEANUP mode. -STD_SED_CMDS.dd= -e '/^OpenDirs_Done:/d' -STD_SED_CMDS.dd+= -e '/^CachedDir /d' +STD_SED_CMDS.dd= -e '/^OpenDirs_Done:/d' +STD_SED_CMDS.dd+= -e '/^CachedDir /d' +STD_SED_CMDS.dd+= -e 's, ${DEFSYSPATH:U/usr/share/mk} , ,' # Omit details such as process IDs from the output of the -dg1 option. STD_SED_CMDS.dg1= -e 's,${.CURDIR}$$,,' Index: src/usr.bin/make/unit-tests/deptgt-phony.exp diff -u src/usr.bin/make/unit-tests/deptgt-phony.exp:1.3 src/usr.bin/make/unit-tests/deptgt-phony.exp:1.4 --- src/usr.bin/make/unit-tests/deptgt-phony.exp:1.3 Tue Apr 30 16:13:34 2024 +++ src/usr.bin/make/unit-tests/deptgt-phony.exp Tue Apr 30 16:41:32 2024 @@ -3,7 +3,7 @@ Expanding "deptgt-phony-pr-15164-*-wildc Searching for .depend ... failed. Searching for .depend ...[dot last]... - /usr/share/mk ... +... failed. Wildcard expanding "all"... Searching for all ...
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: sjg Date: Tue Apr 30 16:41:33 UTC 2024 Modified Files: src/usr.bin/make/unit-tests: Makefile deptgt-phony.exp Log Message: Subst DEFSYSPATH in deptgt-phony To generate a diff of this commit: cvs rdiff -u -r1.343 -r1.344 src/usr.bin/make/unit-tests/Makefile cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/deptgt-phony.exp Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Tue Apr 30 16:13:34 UTC 2024 Modified Files: src/usr.bin/make: main.c src/usr.bin/make/unit-tests: deptgt-phony.exp opt-m-include-dir.mk Log Message: make: ensure '.include ' respects MAKESYSPATH Since Dir_FindFile is used by '.include' and its variants, and will first search .CURDIR unless the give path starts with ".DOTLAST". Update unit-tests/opt-m-include-dir to test this. To generate a diff of this commit: cvs rdiff -u -r1.613 -r1.614 src/usr.bin/make/main.c cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/deptgt-phony.exp cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/opt-m-include-dir.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/main.c diff -u src/usr.bin/make/main.c:1.613 src/usr.bin/make/main.c:1.614 --- src/usr.bin/make/main.c:1.613 Sat Apr 27 17:33:46 2024 +++ src/usr.bin/make/main.c Tue Apr 30 16:13:33 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.613 2024/04/27 17:33:46 rillig Exp $ */ +/* $NetBSD: main.c,v 1.614 2024/04/30 16:13:33 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.613 2024/04/27 17:33:46 rillig Exp $"); +MAKE_RCSID("$NetBSD: main.c,v 1.614 2024/04/30 16:13:33 sjg Exp $"); #if defined(MAKE_NATIVE) __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 " "The Regents of the University of California. " @@ -1156,6 +1156,8 @@ InitDefSysIncPath(char *syspath) else syspath = bmake_strdup(syspath); + /* do NOT search .CURDIR first for .include */ + SearchPath_Add(defSysIncPath, ".DOTLAST"); for (start = syspath; *start != '\0'; start = p) { for (p = start; *p != '\0' && *p != ':'; p++) continue; Index: src/usr.bin/make/unit-tests/deptgt-phony.exp diff -u src/usr.bin/make/unit-tests/deptgt-phony.exp:1.2 src/usr.bin/make/unit-tests/deptgt-phony.exp:1.3 --- src/usr.bin/make/unit-tests/deptgt-phony.exp:1.2 Fri Feb 11 23:44:18 2022 +++ src/usr.bin/make/unit-tests/deptgt-phony.exp Tue Apr 30 16:13:34 2024 @@ -2,7 +2,7 @@ Expanding "depsrc-phony-pr-15164-*-wildc Expanding "deptgt-phony-pr-15164-*-wildcard"... Searching for .depend ... failed. -Searching for .depend ... +Searching for .depend ...[dot last]... /usr/share/mk ... failed. Wildcard expanding "all"... Index: src/usr.bin/make/unit-tests/opt-m-include-dir.mk diff -u src/usr.bin/make/unit-tests/opt-m-include-dir.mk:1.4 src/usr.bin/make/unit-tests/opt-m-include-dir.mk:1.5 --- src/usr.bin/make/unit-tests/opt-m-include-dir.mk:1.4 Tue Sep 1 20:14:34 2020 +++ src/usr.bin/make/unit-tests/opt-m-include-dir.mk Tue Apr 30 16:13:34 2024 @@ -1,4 +1,4 @@ -# $NetBSD: opt-m-include-dir.mk,v 1.4 2020/09/01 20:14:34 rillig Exp $ +# $NetBSD: opt-m-include-dir.mk,v 1.5 2024/04/30 16:13:34 sjg Exp $ # # Tests for the -m command line option, which adds a directory to the # search path for the .include <...> directive. @@ -22,11 +22,14 @@ TEST_DIR:= ${.PARSEFILE:R}.tmp/sub/sub/sub/workdir CANARY_FILE:= ${.PARSEFILE:R}.tmp/sub/opt-m-canary.mk ACTUAL_FILE:= ${.PARSEFILE:R}.tmp/sub/opt-m-step3.mk +WANTED_FILE:= ${.PARSEFILE:R}.tmp/sub/opt-m-check.mk _!= mkdir -p ${TEST_DIR} _!= > ${CANARY_FILE} _!= cp ${MAKEFILE} ${TEST_DIR}/step2.mk _!= cp ${MAKEFILE} ${ACTUAL_FILE} +_!= echo CHECK=ok > ${WANTED_FILE} +_!= echo CHECK=${WANTED_FILE:T} found in .CURDIR > ${TEST_DIR}/${WANTED_FILE:T} step1: @${.MAKE} -C ${TEST_DIR} -f step2.mk step2 @@ -52,9 +55,10 @@ step1: .elif ${.PARSEFILE:T} == "opt-m-step3.mk" # This file is included by step2.mk. +.include step2: - @echo ok + @echo ${CHECK} .else . error
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Tue Apr 30 16:13:34 UTC 2024 Modified Files: src/usr.bin/make: main.c src/usr.bin/make/unit-tests: deptgt-phony.exp opt-m-include-dir.mk Log Message: make: ensure '.include ' respects MAKESYSPATH Since Dir_FindFile is used by '.include' and its variants, and will first search .CURDIR unless the give path starts with ".DOTLAST". Update unit-tests/opt-m-include-dir to test this. To generate a diff of this commit: cvs rdiff -u -r1.613 -r1.614 src/usr.bin/make/main.c cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/deptgt-phony.exp cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/opt-m-include-dir.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Sun Mar 10 02:53:38 UTC 2024 Modified Files: src/usr.bin/make: compat.c job.c main.c make.1 make.h targ.c Log Message: make: record exit status in GNode SetErrorVars can now set .ERROR_EXIT which allows a .ERROR target to ignore the case of .ERROR_EXIT == 6 which means failure happened elsewhere. Reviewed by: To generate a diff of this commit: cvs rdiff -u -r1.253 -r1.254 src/usr.bin/make/compat.c cvs rdiff -u -r1.466 -r1.467 src/usr.bin/make/job.c cvs rdiff -u -r1.611 -r1.612 src/usr.bin/make/main.c cvs rdiff -u -r1.374 -r1.375 src/usr.bin/make/make.1 cvs rdiff -u -r1.328 -r1.329 src/usr.bin/make/make.h cvs rdiff -u -r1.179 -r1.180 src/usr.bin/make/targ.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/compat.c diff -u src/usr.bin/make/compat.c:1.253 src/usr.bin/make/compat.c:1.254 --- src/usr.bin/make/compat.c:1.253 Fri Mar 1 16:41:42 2024 +++ src/usr.bin/make/compat.c Sun Mar 10 02:53:37 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: compat.c,v 1.253 2024/03/01 16:41:42 sjg Exp $ */ +/* $NetBSD: compat.c,v 1.254 2024/03/10 02:53:37 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -91,7 +91,7 @@ #include "pathnames.h" /* "@(#)compat.c 8.2 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: compat.c,v 1.253 2024/03/01 16:41:42 sjg Exp $"); +MAKE_RCSID("$NetBSD: compat.c,v 1.254 2024/03/10 02:53:37 sjg Exp $"); static GNode *curTarg = NULL; static pid_t compatChild; @@ -390,6 +390,8 @@ Compat_RunCommand(const char *cmdp, GNod meta_job_error(NULL, gn, false, status); #endif gn->made = ERROR; + if (WIFEXITED(reason)) +gn->exit_status = status; if (opts.keepgoing) { /* * Abort the current target, Index: src/usr.bin/make/job.c diff -u src/usr.bin/make/job.c:1.466 src/usr.bin/make/job.c:1.467 --- src/usr.bin/make/job.c:1.466 Fri Mar 1 16:41:42 2024 +++ src/usr.bin/make/job.c Sun Mar 10 02:53:37 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: job.c,v 1.466 2024/03/01 16:41:42 sjg Exp $ */ +/* $NetBSD: job.c,v 1.467 2024/03/10 02:53:37 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.466 2024/03/01 16:41:42 sjg Exp $"); +MAKE_RCSID("$NetBSD: job.c,v 1.467 2024/03/10 02:53:37 sjg Exp $"); /* * A shell defines how the commands are run. All commands for a target are @@ -2044,6 +2044,8 @@ JobReapChild(pid_t pid, int status, bool job->status = JOB_ST_FINISHED; job->exit_status = status; + if (WIFEXITED(status)) + job->node->exit_status = WEXITSTATUS(status); JobFinish(job, status); } Index: src/usr.bin/make/main.c diff -u src/usr.bin/make/main.c:1.611 src/usr.bin/make/main.c:1.612 --- src/usr.bin/make/main.c:1.611 Fri Mar 1 16:41:42 2024 +++ src/usr.bin/make/main.c Sun Mar 10 02:53:37 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.611 2024/03/01 16:41:42 sjg Exp $ */ +/* $NetBSD: main.c,v 1.612 2024/03/10 02:53:37 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.611 2024/03/01 16:41:42 sjg Exp $"); +MAKE_RCSID("$NetBSD: main.c,v 1.612 2024/03/10 02:53:37 sjg Exp $"); #if defined(MAKE_NATIVE) __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 " "The Regents of the University of California. " @@ -2037,10 +2037,13 @@ static void SetErrorVars(GNode *gn) { StringListNode *ln; + char sts[16]; /* * We can print this even if there is no .ERROR target. */ + snprintf(sts, sizeof(sts), "%d", gn->exit_status); + Global_Set(".ERROR_EXIT", sts); Global_Set(".ERROR_TARGET", gn->name); Global_Delete(".ERROR_CMD"); Index: src/usr.bin/make/make.1 diff -u src/usr.bin/make/make.1:1.374 src/usr.bin/make/make.1:1.375 --- src/usr.bin/make/make.1:1.374 Thu Jan 25 21:00:59 2024 +++ src/usr.bin/make/make.1 Sun Mar 10 02:53:37 2024 @@ -1,4 +1,4 @@ -.\" $NetBSD: make.1,v 1.374 2024/01/25 21:00:59 sjg Exp $ +.\" $NetBSD: make.1,v 1.375 2024/03/10 02:53:37 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 January 24, 2024 +.Dd March 9, 2024 .Dt MAKE 1 .Os .Sh NAME @@ -879,6 +879,9 @@ Is used in error handling, see .It Va .ERROR_CWD Is used in error handling, see .Va MAKE_PRINT_VAR_ON_ERROR . +.It Va .ERROR_EXIT +Is used in error handling, see +.Va MAKE_PRINT_VAR_ON_ERROR . .It Va .ERROR_META_FILE Is used in error handling in .Dq meta @@ -1185,6 +1188,8 @@ When stops due to an error, it sets .Sq Va .ERROR_TARGET to the name of the target that failed, +.Sq Va .ERROR_EXIT +to the exit status of the failed target, .Sq Va
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Sun Mar 10 02:53:38 UTC 2024 Modified Files: src/usr.bin/make: compat.c job.c main.c make.1 make.h targ.c Log Message: make: record exit status in GNode SetErrorVars can now set .ERROR_EXIT which allows a .ERROR target to ignore the case of .ERROR_EXIT == 6 which means failure happened elsewhere. Reviewed by: To generate a diff of this commit: cvs rdiff -u -r1.253 -r1.254 src/usr.bin/make/compat.c cvs rdiff -u -r1.466 -r1.467 src/usr.bin/make/job.c cvs rdiff -u -r1.611 -r1.612 src/usr.bin/make/main.c cvs rdiff -u -r1.374 -r1.375 src/usr.bin/make/make.1 cvs rdiff -u -r1.328 -r1.329 src/usr.bin/make/make.h cvs rdiff -u -r1.179 -r1.180 src/usr.bin/make/targ.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: sjg Date: Fri Mar 1 20:15:59 UTC 2024 Modified Files: src/usr.bin/make/unit-tests: var-scope-local.exp var-scope-local.mk Log Message: make: update var-scope-local test Show what VAR value is in environment of target script. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/var-scope-local.exp cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/var-scope-local.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/unit-tests/var-scope-local.exp diff -u src/usr.bin/make/unit-tests/var-scope-local.exp:1.7 src/usr.bin/make/unit-tests/var-scope-local.exp:1.8 --- src/usr.bin/make/unit-tests/var-scope-local.exp:1.7 Wed Dec 20 09:03:09 2023 +++ src/usr.bin/make/unit-tests/var-scope-local.exp Fri Mar 1 20:15:59 2024 @@ -61,11 +61,18 @@ dir/subdir/inference-rule-chain.ir-to: * : Making var-scope-local.o from var-scope-local.c. : Making basename "var-scope-local.o" in "." from "var-scope-local.c" in ".". : Making var-scope-local-assign.o with VAR="local". +var-scope-local-assign.o env has VAR='local' : Making var-scope-local-append.o with VAR="local to var-scope-local-append.o". +var-scope-local-append.o env has VAR='local to var-scope-local-append.o' : Making var-scope-local-append-global.o with VAR="global+local". +var-scope-local-append-global.o env has VAR='global+local' : Making var-scope-local-default.o with VAR="global". +var-scope-local-default.o env has VAR='global' : Making var-scope-local-subst.o with VAR="global+local". +var-scope-local-subst.o env has VAR='global+local' : Making var-scope-local-shell.o with VAR="output". +var-scope-local-shell.o env has VAR='output' : var-scope-local-use.o uses .USE VAR="global" +var-scope-local-use.o env has VAR='global' : all overwritten exit status 0 Index: src/usr.bin/make/unit-tests/var-scope-local.mk diff -u src/usr.bin/make/unit-tests/var-scope-local.mk:1.9 src/usr.bin/make/unit-tests/var-scope-local.mk:1.10 --- src/usr.bin/make/unit-tests/var-scope-local.mk:1.9 Wed Dec 20 09:03:09 2023 +++ src/usr.bin/make/unit-tests/var-scope-local.mk Fri Mar 1 20:15:59 2024 @@ -1,4 +1,4 @@ -# $NetBSD: var-scope-local.mk,v 1.9 2023/12/20 09:03:09 rillig Exp $ +# $NetBSD: var-scope-local.mk,v 1.10 2024/03/01 20:15:59 sjg Exp $ # # Tests for target-local variables, such as ${.TARGET} or $@. These variables # are relatively short-lived as they are created just before making the @@ -200,12 +200,14 @@ var-scope-local-default.o \ var-scope-local-subst.o \ var-scope-local-shell.o: : Making ${.TARGET} with VAR="${VAR}". + @echo "${.TARGET} env has VAR='$$VAR'" # Target-local variables are enabled by default. Force them to be enabled # just in case a test above has disabled them. .MAKE.TARGET_LOCAL_VARIABLES= yes VAR= global +.export VAR # If the sources of a dependency line look like a variable assignment, make # treats them as such. There is only a single variable assignment per @@ -264,6 +266,7 @@ var-scope-local-shell.o: VAR != echo out # expect: : var-scope-local-use.o uses .USE VAR="global" a_use: .USE VAR=use : ${.TARGET} uses .USE VAR="${VAR}" + @echo "${.TARGET} env has VAR='$$VAR'" all: var-scope-local-use.o var-scope-local-use.o: a_use
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: sjg Date: Fri Mar 1 20:15:59 UTC 2024 Modified Files: src/usr.bin/make/unit-tests: var-scope-local.exp var-scope-local.mk Log Message: make: update var-scope-local test Show what VAR value is in environment of target script. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/var-scope-local.exp cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/var-scope-local.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Fri Mar 1 16:41:42 UTC 2024 Modified Files: src/usr.bin/make: compat.c job.c main.c make.h var.c Log Message: make: export target scope values Pass target scope to Var_ReexportVars so that a target process will see the correct values in its env. We must then mark any Global scope variable as unexported so targets without local value get the Global one. To generate a diff of this commit: cvs rdiff -u -r1.252 -r1.253 src/usr.bin/make/compat.c cvs rdiff -u -r1.465 -r1.466 src/usr.bin/make/job.c cvs rdiff -u -r1.610 -r1.611 src/usr.bin/make/main.c cvs rdiff -u -r1.327 -r1.328 src/usr.bin/make/make.h cvs rdiff -u -r1.1099 -r1.1100 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/compat.c diff -u src/usr.bin/make/compat.c:1.252 src/usr.bin/make/compat.c:1.253 --- src/usr.bin/make/compat.c:1.252 Fri Jan 5 23:22:06 2024 +++ src/usr.bin/make/compat.c Fri Mar 1 16:41:42 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: compat.c,v 1.252 2024/01/05 23:22:06 rillig Exp $ */ +/* $NetBSD: compat.c,v 1.253 2024/03/01 16:41:42 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -91,7 +91,7 @@ #include "pathnames.h" /* "@(#)compat.c 8.2 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: compat.c,v 1.252 2024/01/05 23:22:06 rillig Exp $"); +MAKE_RCSID("$NetBSD: compat.c,v 1.253 2024/03/01 16:41:42 sjg Exp $"); static GNode *curTarg = NULL; static pid_t compatChild; @@ -326,7 +326,7 @@ Compat_RunCommand(const char *cmdp, GNod meta_compat_start(); #endif - Var_ReexportVars(); + Var_ReexportVars(gn); compatChild = cpid = vfork(); if (cpid < 0) Index: src/usr.bin/make/job.c diff -u src/usr.bin/make/job.c:1.465 src/usr.bin/make/job.c:1.466 --- src/usr.bin/make/job.c:1.465 Sun Jan 7 11:39:04 2024 +++ src/usr.bin/make/job.c Fri Mar 1 16:41:42 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: job.c,v 1.465 2024/01/07 11:39:04 rillig Exp $ */ +/* $NetBSD: job.c,v 1.466 2024/03/01 16:41:42 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.465 2024/01/07 11:39:04 rillig Exp $"); +MAKE_RCSID("$NetBSD: job.c,v 1.466 2024/03/01 16:41:42 sjg Exp $"); /* * A shell defines how the commands are run. All commands for a target are @@ -1420,7 +1420,7 @@ JobExec(Job *job, char **argv) /* Pre-emptively mark job running, pid still zero though */ job->status = JOB_ST_RUNNING; - Var_ReexportVars(); + Var_ReexportVars(job->node); cpid = vfork(); if (cpid == -1) Index: src/usr.bin/make/main.c diff -u src/usr.bin/make/main.c:1.610 src/usr.bin/make/main.c:1.611 --- src/usr.bin/make/main.c:1.610 Wed Feb 7 06:43:02 2024 +++ src/usr.bin/make/main.c Fri Mar 1 16:41:42 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.610 2024/02/07 06:43:02 rillig Exp $ */ +/* $NetBSD: main.c,v 1.611 2024/03/01 16:41:42 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.610 2024/02/07 06:43:02 rillig Exp $"); +MAKE_RCSID("$NetBSD: main.c,v 1.611 2024/03/01 16:41:42 sjg Exp $"); #if defined(MAKE_NATIVE) __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 " "The Regents of the University of California. " @@ -1735,7 +1735,7 @@ Cmd_Exec(const char *cmd, char **error) return bmake_strdup(""); } - Var_ReexportVars(); + Var_ReexportVars(SCOPE_GLOBAL); switch (cpid = vfork()) { case 0: Index: src/usr.bin/make/make.h diff -u src/usr.bin/make/make.h:1.327 src/usr.bin/make/make.h:1.328 --- src/usr.bin/make/make.h:1.327 Sun Dec 17 09:02:26 2023 +++ src/usr.bin/make/make.h Fri Mar 1 16:41:42 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: make.h,v 1.327 2023/12/17 09:02:26 rillig Exp $ */ +/* $NetBSD: make.h,v 1.328 2024/03/01 16:41:42 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -1011,7 +1011,7 @@ char *Var_Subst(const char *, GNode *, V void Var_Expand(FStr *, GNode *, VarEvalMode); void Var_Stats(void); void Var_Dump(GNode *); -void Var_ReexportVars(void); +void Var_ReexportVars(GNode *); void Var_Export(VarExportMode, const char *); void Var_ExportVars(const char *); void Var_UnExport(bool, const char *); Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.1099 src/usr.bin/make/var.c:1.1100 --- src/usr.bin/make/var.c:1.1099 Wed Feb 7 06:43:02 2024 +++ src/usr.bin/make/var.c Fri Mar 1 16:41:42 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.1099 2024/02/07 06:43:02 rillig Exp $ */ +/* $NetBSD: var.c,v 1.1100 2024/03/01 16:41:42 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -137,7 +137,7 @@ #include "metachar.h" /* "@(#)var.c 8.3 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: var.c,v
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Fri Mar 1 16:41:42 UTC 2024 Modified Files: src/usr.bin/make: compat.c job.c main.c make.h var.c Log Message: make: export target scope values Pass target scope to Var_ReexportVars so that a target process will see the correct values in its env. We must then mark any Global scope variable as unexported so targets without local value get the Global one. To generate a diff of this commit: cvs rdiff -u -r1.252 -r1.253 src/usr.bin/make/compat.c cvs rdiff -u -r1.465 -r1.466 src/usr.bin/make/job.c cvs rdiff -u -r1.610 -r1.611 src/usr.bin/make/main.c cvs rdiff -u -r1.327 -r1.328 src/usr.bin/make/make.h cvs rdiff -u -r1.1099 -r1.1100 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.
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Sat Feb 3 00:20:23 UTC 2024 Modified Files: src/usr.bin/make: var.c src/usr.bin/make/unit-tests: varmod.exp varmod.mk Log Message: make: state of save_dollars affects what is a parse error When save_dollars is false it is not a parse error to encounter $$ rather than \$. To generate a diff of this commit: cvs rdiff -u -r1.1095 -r1.1096 src/usr.bin/make/var.c cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/varmod.exp cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/varmod.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/var.c diff -u src/usr.bin/make/var.c:1.1095 src/usr.bin/make/var.c:1.1096 --- src/usr.bin/make/var.c:1.1095 Sun Jan 21 15:02:17 2024 +++ src/usr.bin/make/var.c Sat Feb 3 00:20:23 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.1095 2024/01/21 15:02:17 rillig Exp $ */ +/* $NetBSD: var.c,v 1.1096 2024/02/03 00:20:23 sjg 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.1095 2024/01/21 15:02:17 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.1096 2024/02/03 00:20:23 sjg Exp $"); /* * Variables are defined using one of the VAR=value assignments. Their @@ -4147,12 +4147,12 @@ IsShortVarnameValid(char varname, const if (!opts.strict) return false; /* XXX: Missing error message */ - if (varname == '$') + if (varname == '$' && save_dollars) Parse_Error(PARSE_FATAL, "To escape a dollar, use \\$, not $$, at \"%s\"", start); else if (varname == '\0') Parse_Error(PARSE_FATAL, "Dollar followed by nothing"); - else + else if (save_dollars) Parse_Error(PARSE_FATAL, "Invalid variable name '%c', at \"%s\"", varname, start); Index: src/usr.bin/make/unit-tests/varmod.exp diff -u src/usr.bin/make/unit-tests/varmod.exp:1.7 src/usr.bin/make/unit-tests/varmod.exp:1.8 --- src/usr.bin/make/unit-tests/varmod.exp:1.7 Thu Jun 1 20:56:35 2023 +++ src/usr.bin/make/unit-tests/varmod.exp Sat Feb 3 00:20:23 2024 @@ -1,8 +1,8 @@ -make: "varmod.mk" line 98: To escape a dollar, use \$, not $$, at "$$:L} != """ -make: "varmod.mk" line 98: Invalid variable name ':', at "$:L} != """ -make: "varmod.mk" line 104: Dollar followed by nothing -make: "varmod.mk" line 114: Missing delimiter ':' after modifier "P" -make: "varmod.mk" line 116: Missing argument for ".error" +make: "varmod.mk" line 101: To escape a dollar, use \$, not $$, at "$$:L} != """ +make: "varmod.mk" line 101: Invalid variable name ':', at "$:L} != """ +make: "varmod.mk" line 107: Dollar followed by nothing +make: "varmod.mk" line 117: Missing delimiter ':' after modifier "P" +make: "varmod.mk" line 119: Missing argument for ".error" make: Fatal errors encountered -- cannot continue make: stopped in unit-tests exit status 1 Index: src/usr.bin/make/unit-tests/varmod.mk diff -u src/usr.bin/make/unit-tests/varmod.mk:1.9 src/usr.bin/make/unit-tests/varmod.mk:1.10 --- src/usr.bin/make/unit-tests/varmod.mk:1.9 Sun Nov 19 21:47:52 2023 +++ src/usr.bin/make/unit-tests/varmod.mk Sat Feb 3 00:20:23 2024 @@ -1,4 +1,4 @@ -# $NetBSD: varmod.mk,v 1.9 2023/11/19 21:47:52 rillig Exp $ +# $NetBSD: varmod.mk,v 1.10 2024/02/03 00:20:23 sjg Exp $ # # Tests for variable modifiers, such as :Q, :S,from,to or :Ufallback. # @@ -56,6 +56,9 @@ # | `u` | strict || yes | # | `from=to`| greedy | SysV, fallback | N/A | +# These tests assume +.MAKE.SAVE_DOLLARS = yes + DOLLAR1= $$ DOLLAR2= ${:U\$}
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Sat Feb 3 00:20:23 UTC 2024 Modified Files: src/usr.bin/make: var.c src/usr.bin/make/unit-tests: varmod.exp varmod.mk Log Message: make: state of save_dollars affects what is a parse error When save_dollars is false it is not a parse error to encounter $$ rather than \$. To generate a diff of this commit: cvs rdiff -u -r1.1095 -r1.1096 src/usr.bin/make/var.c cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/varmod.exp cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/varmod.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Thu Jan 25 21:00:59 UTC 2024 Modified Files: src/usr.bin/make: make.1 Log Message: Note that in both :U and :D newval may be empty To generate a diff of this commit: cvs rdiff -u -r1.373 -r1.374 src/usr.bin/make/make.1 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.373 src/usr.bin/make/make.1:1.374 --- src/usr.bin/make/make.1:1.373 Thu Jan 25 07:35:46 2024 +++ src/usr.bin/make/make.1 Thu Jan 25 21:00:59 2024 @@ -1,4 +1,4 @@ -.\" $NetBSD: make.1,v 1.373 2024/01/25 07:35:46 sjg Exp $ +.\" $NetBSD: make.1,v 1.374 2024/01/25 21:00:59 sjg Exp $ .\" .\" Copyright (c) 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -1772,11 +1772,11 @@ is used to save the result of the .Ql :S modifier which is later referenced using the index values from .Ql :range . -.It Cm \&:U\| Ns Oo Ar newval Oc +.It Cm \&:U\| Ns Ar newval If the variable is undefined, the optional .Ar newval -is the value. +(which may be empty) is the value. If the variable is defined, the existing value is returned. This is another ODE make feature. It is handy for setting per-target CFLAGS for instance: @@ -1786,7 +1786,7 @@ If a value is only required if the varia .It Cm \&:D\| Ns Ar newval If the variable is defined, .Ar newval -is the value. +(which may be empty) is the value. .It Cm \&:L The name of the variable is the value. .It Cm \&:P
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Thu Jan 25 21:00:59 UTC 2024 Modified Files: src/usr.bin/make: make.1 Log Message: Note that in both :U and :D newval may be empty To generate a diff of this commit: cvs rdiff -u -r1.373 -r1.374 src/usr.bin/make/make.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Thu Jan 25 07:35:46 UTC 2024 Modified Files: src/usr.bin/make: make.1 Log Message: Indicate that for :U newval is optional To generate a diff of this commit: cvs rdiff -u -r1.372 -r1.373 src/usr.bin/make/make.1 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.372 src/usr.bin/make/make.1:1.373 --- src/usr.bin/make/make.1:1.372 Sun Dec 24 16:48:30 2023 +++ src/usr.bin/make/make.1 Thu Jan 25 07:35:46 2024 @@ -1,4 +1,4 @@ -.\" $NetBSD: make.1,v 1.372 2023/12/24 16:48:30 sjg Exp $ +.\" $NetBSD: make.1,v 1.373 2024/01/25 07:35:46 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 December 24, 2023 +.Dd January 24, 2024 .Dt MAKE 1 .Os .Sh NAME @@ -1772,8 +1772,9 @@ is used to save the result of the .Ql :S modifier which is later referenced using the index values from .Ql :range . -.It Cm \&:U\| Ns Ar newval +.It Cm \&:U\| Ns Oo Ar newval Oc If the variable is undefined, +the optional .Ar newval is the value. If the variable is defined, the existing value is returned.
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Thu Jan 25 07:35:46 UTC 2024 Modified Files: src/usr.bin/make: make.1 Log Message: Indicate that for :U newval is optional To generate a diff of this commit: cvs rdiff -u -r1.372 -r1.373 src/usr.bin/make/make.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: sjg Date: Sun Jan 7 02:07:44 UTC 2024 Modified Files: src/usr.bin/make/unit-tests: Makefile Log Message: make: unit-tests handle TEST_MAKE:T != make We need to allow for ${TEST_MAKE:T}[1-9]: etc when TEST_MAKE is not 'make' To generate a diff of this commit: cvs rdiff -u -r1.341 -r1.342 src/usr.bin/make/unit-tests/Makefile 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/unit-tests/Makefile diff -u src/usr.bin/make/unit-tests/Makefile:1.341 src/usr.bin/make/unit-tests/Makefile:1.342 --- src/usr.bin/make/unit-tests/Makefile:1.341 Sat Sep 9 16:41:04 2023 +++ src/usr.bin/make/unit-tests/Makefile Sun Jan 7 02:07:44 2024 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.341 2023/09/09 16:41:04 sjg Exp $ +# $NetBSD: Makefile,v 1.342 2024/01/07 02:07:44 sjg Exp $ # # Unit tests for make(1) # @@ -747,6 +747,7 @@ _SED_CMDS+= -e 's,${.OBJDIR},,g' _SED_CMDS+= -e 's,^${TEST_MAKE:T:S,.,\\.,g}[][0-9]*:,make:,' _SED_CMDS+= -e 's,${TEST_MAKE:S,.,\\.,g},make,' _SED_CMDS+= -e 's,^usage: ${TEST_MAKE:T:S,.,\\.,g} ,usage: make ,' +_SED_CMDS+= -e 's,${TEST_MAKE:T:S,.,\\.,g}\(\[[1-9][0-9]*\]:\),make\1,' _SED_CMDS+= -e 's,/,,g' _SED_CMDS+= -e 's,${UNIT_TESTS:S,.,\\.,g}/,,g' _SED_CMDS+= -e '/MAKE_VERSION/d'
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: sjg Date: Sun Jan 7 02:07:44 UTC 2024 Modified Files: src/usr.bin/make/unit-tests: Makefile Log Message: make: unit-tests handle TEST_MAKE:T != make We need to allow for ${TEST_MAKE:T}[1-9]: etc when TEST_MAKE is not 'make' To generate a diff of this commit: cvs rdiff -u -r1.341 -r1.342 src/usr.bin/make/unit-tests/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Sun Jan 7 01:33:58 UTC 2024 Modified Files: src/usr.bin/make: job.c main.c src/usr.bin/make/unit-tests: jobs-error-indirect.exp jobs-error-nested-make.exp jobs-error-nested.exp var-recursive.exp Log Message: make: more consistent error messages Move %s: progname from Job_CheckCommands to Fatal to avoid is being repeated when Job_CheckCommands is passed Error. This means some errors from var also report progname (and level) which is useful. Reviewed by: rillig To generate a diff of this commit: cvs rdiff -u -r1.463 -r1.464 src/usr.bin/make/job.c cvs rdiff -u -r1.608 -r1.609 src/usr.bin/make/main.c cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/jobs-error-indirect.exp \ src/usr.bin/make/unit-tests/jobs-error-nested.exp cvs rdiff -u -r1.3 -r1.4 \ src/usr.bin/make/unit-tests/jobs-error-nested-make.exp cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/var-recursive.exp 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.463 src/usr.bin/make/job.c:1.464 --- src/usr.bin/make/job.c:1.463 Fri Jan 5 23:22:06 2024 +++ src/usr.bin/make/job.c Sun Jan 7 01:33:57 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: job.c,v 1.463 2024/01/05 23:22:06 rillig Exp $ */ +/* $NetBSD: job.c,v 1.464 2024/01/07 01:33:57 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.463 2024/01/05 23:22:06 rillig Exp $"); +MAKE_RCSID("$NetBSD: job.c,v 1.464 2024/01/07 01:33:57 sjg Exp $"); /* * A shell defines how the commands are run. All commands for a target are @@ -1379,7 +1379,7 @@ Job_CheckCommands(GNode *gn, void (*abor return false; } - abortProc("%s: don't know how to make %s. Stop", progname, gn->name); + abortProc("don't know how to make %s. Stop", gn->name); return false; } Index: src/usr.bin/make/main.c diff -u src/usr.bin/make/main.c:1.608 src/usr.bin/make/main.c:1.609 --- src/usr.bin/make/main.c:1.608 Fri Jan 5 23:22:06 2024 +++ src/usr.bin/make/main.c Sun Jan 7 01:33:57 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.608 2024/01/05 23:22:06 rillig Exp $ */ +/* $NetBSD: main.c,v 1.609 2024/01/07 01:33:57 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.608 2024/01/05 23:22:06 rillig Exp $"); +MAKE_RCSID("$NetBSD: main.c,v 1.609 2024/01/07 01:33:57 sjg Exp $"); #if defined(MAKE_NATIVE) __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 " "The Regents of the University of California. " @@ -1851,6 +1851,7 @@ Fatal(const char *fmt, ...) Job_Wait(); (void)fflush(stdout); + fprintf(stderr, "%s: ", progname); va_start(ap, fmt); (void)vfprintf(stderr, fmt, ap); va_end(ap); Index: src/usr.bin/make/unit-tests/jobs-error-indirect.exp diff -u src/usr.bin/make/unit-tests/jobs-error-indirect.exp:1.1 src/usr.bin/make/unit-tests/jobs-error-indirect.exp:1.2 --- src/usr.bin/make/unit-tests/jobs-error-indirect.exp:1.1 Tue Dec 1 17:50:04 2020 +++ src/usr.bin/make/unit-tests/jobs-error-indirect.exp Sun Jan 7 01:33:57 2024 @@ -2,7 +2,7 @@ false *** [indirect] Error code 1 make: stopped in unit-tests -1 error +make: 1 error make: stopped in unit-tests exit status 2 Index: src/usr.bin/make/unit-tests/jobs-error-nested.exp diff -u src/usr.bin/make/unit-tests/jobs-error-nested.exp:1.1 src/usr.bin/make/unit-tests/jobs-error-nested.exp:1.2 --- src/usr.bin/make/unit-tests/jobs-error-nested.exp:1.1 Tue Dec 1 17:50:04 2020 +++ src/usr.bin/make/unit-tests/jobs-error-nested.exp Sun Jan 7 01:33:57 2024 @@ -3,13 +3,13 @@ false *** [nested] Error code 1 make: stopped in unit-tests -1 error +make: 1 error make: stopped in unit-tests *** [all] Error code 2 make: stopped in unit-tests -1 error +make: 1 error make: stopped in unit-tests exit status 2 Index: src/usr.bin/make/unit-tests/jobs-error-nested-make.exp diff -u src/usr.bin/make/unit-tests/jobs-error-nested-make.exp:1.3 src/usr.bin/make/unit-tests/jobs-error-nested-make.exp:1.4 --- src/usr.bin/make/unit-tests/jobs-error-nested-make.exp:1.3 Fri Jan 8 21:46:50 2021 +++ src/usr.bin/make/unit-tests/jobs-error-nested-make.exp Sun Jan 7 01:33:57 2024 @@ -3,7 +3,7 @@ false *** [nested] Error code 1 make: stopped in unit-tests -1 error +make: 1 error make: stopped in unit-tests Index: src/usr.bin/make/unit-tests/var-recursive.exp diff -u src/usr.bin/make/unit-tests/var-recursive.exp:1.6 src/usr.bin/make/unit-tests/var-recursive.exp:1.7 --- src/usr.bin/make/unit-tests/var-recursive.exp:1.6 Thu Jun 1 20:56:35 2023 +++ src/usr.bin/make/unit-tests/var-recursive.exp Sun Jan 7 01:33:57 2024 @@ -1,19 +1,19 @@ make:
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Sun Jan 7 01:33:58 UTC 2024 Modified Files: src/usr.bin/make: job.c main.c src/usr.bin/make/unit-tests: jobs-error-indirect.exp jobs-error-nested-make.exp jobs-error-nested.exp var-recursive.exp Log Message: make: more consistent error messages Move %s: progname from Job_CheckCommands to Fatal to avoid is being repeated when Job_CheckCommands is passed Error. This means some errors from var also report progname (and level) which is useful. Reviewed by: rillig To generate a diff of this commit: cvs rdiff -u -r1.463 -r1.464 src/usr.bin/make/job.c cvs rdiff -u -r1.608 -r1.609 src/usr.bin/make/main.c cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/jobs-error-indirect.exp \ src/usr.bin/make/unit-tests/jobs-error-nested.exp cvs rdiff -u -r1.3 -r1.4 \ src/usr.bin/make/unit-tests/jobs-error-nested-make.exp cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/var-recursive.exp Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Fri Jan 5 22:20:07 UTC 2024 Modified Files: src/usr.bin/make: main.c Log Message: Cmd_Exec use tempfile if cmd is too big To avoid blowing commandline/env limits, if "cmd" is more than 1000 bytes, write it to a file and pass that to shell. Reviewed by: rillig To generate a diff of this commit: cvs rdiff -u -r1.606 -r1.607 src/usr.bin/make/main.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/main.c diff -u src/usr.bin/make/main.c:1.606 src/usr.bin/make/main.c:1.607 --- src/usr.bin/make/main.c:1.606 Wed Dec 27 00:45:37 2023 +++ src/usr.bin/make/main.c Fri Jan 5 22:20:07 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.606 2023/12/27 00:45:37 sjg Exp $ */ +/* $NetBSD: main.c,v 1.607 2024/01/05 22:20:07 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.606 2023/12/27 00:45:37 sjg Exp $"); +MAKE_RCSID("$NetBSD: main.c,v 1.607 2024/01/05 22:20:07 sjg Exp $"); #if defined(MAKE_NATIVE) __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 " "The Regents of the University of California. " @@ -1705,14 +1705,38 @@ Cmd_Exec(const char *cmd, char **error) char *output; char *p; int saved_errno; + char cmd_file[MAXPATHLEN]; + size_t cmd_len; + int cmd_fd = -1; if (shellPath == NULL) Shell_Init(); + cmd_len = strlen(cmd); + if (cmd_len > 1000) { + cmd_fd = mkTempFile(NULL, cmd_file, sizeof(cmd_file)); + if (cmd_fd >= 0) { + ssize_t n; + + n = write(cmd_fd, cmd, cmd_len); + close(cmd_fd); + if (n < (ssize_t)cmd_len) { +unlink(cmd_file); +cmd_fd = -1; + } + } + } + args[0] = shellName; - args[1] = "-c"; - args[2] = cmd; - args[3] = NULL; + if (cmd_fd >= 0) { + args[1] = cmd_file; + args[2] = NULL; + } else { + cmd_file[0] = '\0'; + args[1] = "-c"; + args[2] = cmd; + args[3] = NULL; + } DEBUG1(VAR, "Capturing the output of command \"%s\"\n", cmd); if (pipe(pipefds) == -1) { @@ -1775,6 +1799,8 @@ Cmd_Exec(const char *cmd, char **error) "Couldn't read shell's output for \"", cmd, "\""); else *error = NULL; + if (cmd_file[0] != '\0') + unlink(cmd_file); return output; } @@ -2129,7 +2155,7 @@ getTmpdir(void) /* * Create and open a temp file using "pattern". - * If out_fname is provided, set it to a copy of the filename created. + * If tfile is provided, set it to a copy of the filename created. * Otherwise unlink the file once open. */ int
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Fri Jan 5 22:20:07 UTC 2024 Modified Files: src/usr.bin/make: main.c Log Message: Cmd_Exec use tempfile if cmd is too big To avoid blowing commandline/env limits, if "cmd" is more than 1000 bytes, write it to a file and pass that to shell. Reviewed by: rillig To generate a diff of this commit: cvs rdiff -u -r1.606 -r1.607 src/usr.bin/make/main.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Wed Jan 3 20:24:16 UTC 2024 Modified Files: src/usr.bin/make: parse.c Log Message: make: do not add newline to an empty buffer When LoadFile reads from /dev/null the buffer will be empty, appending "\n" just results in an unnecessary extra call to ParseRawLine. Reviewed by: rillig To generate a diff of this commit: cvs rdiff -u -r1.713 -r1.714 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/parse.c diff -u src/usr.bin/make/parse.c:1.713 src/usr.bin/make/parse.c:1.714 --- src/usr.bin/make/parse.c:1.713 Fri Dec 29 20:43:58 2023 +++ src/usr.bin/make/parse.c Wed Jan 3 20:24:16 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: parse.c,v 1.713 2023/12/29 20:43:58 rillig Exp $ */ +/* $NetBSD: parse.c,v 1.714 2024/01/03 20:24:16 sjg 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.713 2023/12/29 20:43:58 rillig Exp $"); +MAKE_RCSID("$NetBSD: parse.c,v 1.714 2024/01/03 20:24:16 sjg Exp $"); /* Detects a multiple-inclusion guard in a makefile. */ typedef enum { @@ -383,7 +383,7 @@ LoadFile(const char *path, int fd) } assert(buf.len <= buf.cap); - if (!Buf_EndsWith(, '\n')) + if (buf.len > 0 && !Buf_EndsWith(, '\n')) Buf_AddByte(, '\n'); return buf; /* may not be null-terminated */
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Wed Jan 3 20:24:16 UTC 2024 Modified Files: src/usr.bin/make: parse.c Log Message: make: do not add newline to an empty buffer When LoadFile reads from /dev/null the buffer will be empty, appending "\n" just results in an unnecessary extra call to ParseRawLine. Reviewed by: rillig To generate a diff of this commit: cvs rdiff -u -r1.713 -r1.714 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.
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Wed Dec 27 00:45:37 UTC 2023 Modified Files: src/usr.bin/make: main.c Log Message: make: ensure shellPath is set before using it. To generate a diff of this commit: cvs rdiff -u -r1.605 -r1.606 src/usr.bin/make/main.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/main.c diff -u src/usr.bin/make/main.c:1.605 src/usr.bin/make/main.c:1.606 --- src/usr.bin/make/main.c:1.605 Sun Dec 17 09:02:26 2023 +++ src/usr.bin/make/main.c Wed Dec 27 00:45:37 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.605 2023/12/17 09:02:26 rillig Exp $ */ +/* $NetBSD: main.c,v 1.606 2023/12/27 00:45:37 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.605 2023/12/17 09:02:26 rillig Exp $"); +MAKE_RCSID("$NetBSD: main.c,v 1.606 2023/12/27 00:45:37 sjg Exp $"); #if defined(MAKE_NATIVE) __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 " "The Regents of the University of California. " @@ -1706,7 +1706,7 @@ Cmd_Exec(const char *cmd, char **error) char *p; int saved_errno; - if (shellName == NULL) + if (shellPath == NULL) Shell_Init(); args[0] = shellName;
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Wed Dec 27 00:45:37 UTC 2023 Modified Files: src/usr.bin/make: main.c Log Message: make: ensure shellPath is set before using it. To generate a diff of this commit: cvs rdiff -u -r1.605 -r1.606 src/usr.bin/make/main.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Tue Dec 26 20:09:42 UTC 2023 Modified Files: src/usr.bin/make: compat.c Log Message: Move fflush to a point to catch all cases. To generate a diff of this commit: cvs rdiff -u -r1.250 -r1.251 src/usr.bin/make/compat.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Tue Dec 26 20:09:42 UTC 2023 Modified Files: src/usr.bin/make: compat.c Log Message: Move fflush to a point to catch all cases. To generate a diff of this commit: cvs rdiff -u -r1.250 -r1.251 src/usr.bin/make/compat.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/compat.c diff -u src/usr.bin/make/compat.c:1.250 src/usr.bin/make/compat.c:1.251 --- src/usr.bin/make/compat.c:1.250 Tue Dec 26 17:12:33 2023 +++ src/usr.bin/make/compat.c Tue Dec 26 20:09:42 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: compat.c,v 1.250 2023/12/26 17:12:33 sjg Exp $ */ +/* $NetBSD: compat.c,v 1.251 2023/12/26 20:09:42 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -91,7 +91,7 @@ #include "pathnames.h" /* "@(#)compat.c 8.2 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: compat.c,v 1.250 2023/12/26 17:12:33 sjg Exp $"); +MAKE_RCSID("$NetBSD: compat.c,v 1.251 2023/12/26 20:09:42 sjg Exp $"); static GNode *curTarg = NULL; static pid_t compatChild; @@ -400,7 +400,6 @@ Compat_RunCommand(const char *cmdp, GNod * but let others continue. */ printf(" (continuing)\n"); -fflush(stdout); } else { printf("\n"); } @@ -412,9 +411,9 @@ Compat_RunCommand(const char *cmdp, GNod * If we return 0, this will happen... */ printf(" (ignored)\n"); - fflush(stdout); status = 0; } + fflush(stdout); } free(cmdStart);
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Tue Dec 26 17:12:33 UTC 2023 Modified Files: src/usr.bin/make: compat.c src/usr.bin/make/unit-tests: depsrc-ignore.exp deptgt-delete_on_error.exp sh-leading-hyphen.exp Log Message: make: fix order of output in compat mode Ensure that make's output is correctly ordered with the output of the target's commands, even when the output does not go to a terminal. Reviewed by: rillig To generate a diff of this commit: cvs rdiff -u -r1.249 -r1.250 src/usr.bin/make/compat.c cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/depsrc-ignore.exp \ src/usr.bin/make/unit-tests/sh-leading-hyphen.exp cvs rdiff -u -r1.3 -r1.4 \ src/usr.bin/make/unit-tests/deptgt-delete_on_error.exp Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Tue Dec 26 17:12:33 UTC 2023 Modified Files: src/usr.bin/make: compat.c src/usr.bin/make/unit-tests: depsrc-ignore.exp deptgt-delete_on_error.exp sh-leading-hyphen.exp Log Message: make: fix order of output in compat mode Ensure that make's output is correctly ordered with the output of the target's commands, even when the output does not go to a terminal. Reviewed by: rillig To generate a diff of this commit: cvs rdiff -u -r1.249 -r1.250 src/usr.bin/make/compat.c cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/depsrc-ignore.exp \ src/usr.bin/make/unit-tests/sh-leading-hyphen.exp cvs rdiff -u -r1.3 -r1.4 \ src/usr.bin/make/unit-tests/deptgt-delete_on_error.exp 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/compat.c diff -u src/usr.bin/make/compat.c:1.249 src/usr.bin/make/compat.c:1.250 --- src/usr.bin/make/compat.c:1.249 Sun Dec 24 16:48:30 2023 +++ src/usr.bin/make/compat.c Tue Dec 26 17:12:33 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: compat.c,v 1.249 2023/12/24 16:48:30 sjg Exp $ */ +/* $NetBSD: compat.c,v 1.250 2023/12/26 17:12:33 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -91,7 +91,7 @@ #include "pathnames.h" /* "@(#)compat.c 8.2 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: compat.c,v 1.249 2023/12/24 16:48:30 sjg Exp $"); +MAKE_RCSID("$NetBSD: compat.c,v 1.250 2023/12/26 17:12:33 sjg Exp $"); static GNode *curTarg = NULL; static pid_t compatChild; @@ -400,6 +400,7 @@ Compat_RunCommand(const char *cmdp, GNod * but let others continue. */ printf(" (continuing)\n"); +fflush(stdout); } else { printf("\n"); } @@ -411,6 +412,7 @@ Compat_RunCommand(const char *cmdp, GNod * If we return 0, this will happen... */ printf(" (ignored)\n"); + fflush(stdout); status = 0; } } Index: src/usr.bin/make/unit-tests/depsrc-ignore.exp diff -u src/usr.bin/make/unit-tests/depsrc-ignore.exp:1.2 src/usr.bin/make/unit-tests/depsrc-ignore.exp:1.3 --- src/usr.bin/make/unit-tests/depsrc-ignore.exp:1.2 Sat Aug 29 15:06:33 2020 +++ src/usr.bin/make/unit-tests/depsrc-ignore.exp Tue Dec 26 17:12:33 2023 @@ -1,8 +1,8 @@ ignore-errors begin false ignore-errors +*** Error code 1 (ignored) ignore-errors end all begin -*** Error code 1 (ignored) false all *** Error code 1 (continuing) Index: src/usr.bin/make/unit-tests/sh-leading-hyphen.exp diff -u src/usr.bin/make/unit-tests/sh-leading-hyphen.exp:1.2 src/usr.bin/make/unit-tests/sh-leading-hyphen.exp:1.3 --- src/usr.bin/make/unit-tests/sh-leading-hyphen.exp:1.2 Thu Jan 19 19:55:27 2023 +++ src/usr.bin/make/unit-tests/sh-leading-hyphen.exp Tue Dec 26 17:12:33 2023 @@ -6,6 +6,6 @@ unknown-command: not found *** Error code 127 (ignored) unknown-long-option 'needed for needshell in compat.c' unknown-long-option: not found -whitespace in leading part *** Error code 127 (ignored) +whitespace in leading part exit status 0 Index: src/usr.bin/make/unit-tests/deptgt-delete_on_error.exp diff -u src/usr.bin/make/unit-tests/deptgt-delete_on_error.exp:1.3 src/usr.bin/make/unit-tests/deptgt-delete_on_error.exp:1.4 --- src/usr.bin/make/unit-tests/deptgt-delete_on_error.exp:1.3 Sat Mar 18 22:20:12 2023 +++ src/usr.bin/make/unit-tests/deptgt-delete_on_error.exp Tue Dec 26 17:12:33 2023 @@ -16,6 +16,7 @@ make: *** deptgt-delete_on_error-regular Stop. make: stopped in unit-tests +*** Error code 1 (ignored) Parallel mode > deptgt-delete_on_error-regular; false @@ -45,5 +46,4 @@ make: stopped in unit-tests make: stopped in unit-tests *** Error code 1 (ignored) -*** Error code 1 (ignored) exit status 0
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Sun Dec 24 16:48:30 UTC 2023 Modified Files: src/usr.bin/make: compat.c make.1 src/usr.bin/make/unit-tests: shell-sh.mk Log Message: Compat_RunCommand call Shell_Init is shellPath is NULL Since .SHELL is potentially used in compat mode as well, the man page description should not imply it is only used in jobs mode. Remove path="sh" from shell-sh unit-test - and it would have detected this bug. Reviewed by: rillig To generate a diff of this commit: cvs rdiff -u -r1.248 -r1.249 src/usr.bin/make/compat.c cvs rdiff -u -r1.371 -r1.372 src/usr.bin/make/make.1 cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/shell-sh.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/compat.c diff -u src/usr.bin/make/compat.c:1.248 src/usr.bin/make/compat.c:1.249 --- src/usr.bin/make/compat.c:1.248 Tue Dec 19 19:33:39 2023 +++ src/usr.bin/make/compat.c Sun Dec 24 16:48:30 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: compat.c,v 1.248 2023/12/19 19:33:39 rillig Exp $ */ +/* $NetBSD: compat.c,v 1.249 2023/12/24 16:48:30 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -91,7 +91,7 @@ #include "pathnames.h" /* "@(#)compat.c 8.2 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: compat.c,v 1.248 2023/12/19 19:33:39 rillig Exp $"); +MAKE_RCSID("$NetBSD: compat.c,v 1.249 2023/12/24 16:48:30 sjg Exp $"); static GNode *curTarg = NULL; static pid_t compatChild; @@ -275,11 +275,9 @@ Compat_RunCommand(const char *cmdp, GNod silent = !DEBUG(LOUD); else if (*cmd == '-') errCheck = false; - else if (*cmd == '+') { + else if (*cmd == '+') doIt = true; - if (shellName == NULL) /* we came here from jobs */ -Shell_Init(); - } else if (!ch_isspace(*cmd)) + else if (!ch_isspace(*cmd)) /* Ignore whitespace for compatibility with gnu make */ break; cmd++; @@ -302,6 +300,9 @@ Compat_RunCommand(const char *cmdp, GNod DEBUG1(JOB, "Execute: '%s'\n", cmd); + if (useShell && shellPath == NULL) + Shell_Init(); /* we need shellPath */ + if (useShell) { static const char *shargv[5]; Index: src/usr.bin/make/make.1 diff -u src/usr.bin/make/make.1:1.371 src/usr.bin/make/make.1:1.372 --- src/usr.bin/make/make.1:1.371 Sun Sep 10 21:52:36 2023 +++ src/usr.bin/make/make.1 Sun Dec 24 16:48:30 2023 @@ -1,4 +1,4 @@ -.\" $NetBSD: make.1,v 1.371 2023/09/10 21:52:36 rillig Exp $ +.\" $NetBSD: make.1,v 1.372 2023/12/24 16:48:30 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 September 9, 2023 +.Dd December 24, 2023 .Dt MAKE 1 .Os .Sh NAME @@ -2522,7 +2522,7 @@ set the read-only attribute on the globa .It Ic .SHELL Sets the shell that .Nm -uses to execute commands in jobs mode. +uses to execute commands. The sources are a set of .Ar field\| Ns Cm \&= Ns Ar value pairs. Index: src/usr.bin/make/unit-tests/shell-sh.mk diff -u src/usr.bin/make/unit-tests/shell-sh.mk:1.1 src/usr.bin/make/unit-tests/shell-sh.mk:1.2 --- src/usr.bin/make/unit-tests/shell-sh.mk:1.1 Sat Oct 3 14:39:36 2020 +++ src/usr.bin/make/unit-tests/shell-sh.mk Sun Dec 24 16:48:30 2023 @@ -1,9 +1,9 @@ -# $NetBSD: shell-sh.mk,v 1.1 2020/10/03 14:39:36 rillig Exp $ +# $NetBSD: shell-sh.mk,v 1.2 2023/12/24 16:48:30 sjg Exp $ # # Tests for using a bourne shell for running the commands. # This is the default shell, so there's nothing surprising. -.SHELL: name="sh" path="sh" +.SHELL: name="sh" all: : normal
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Sun Dec 24 16:48:30 UTC 2023 Modified Files: src/usr.bin/make: compat.c make.1 src/usr.bin/make/unit-tests: shell-sh.mk Log Message: Compat_RunCommand call Shell_Init is shellPath is NULL Since .SHELL is potentially used in compat mode as well, the man page description should not imply it is only used in jobs mode. Remove path="sh" from shell-sh unit-test - and it would have detected this bug. Reviewed by: rillig To generate a diff of this commit: cvs rdiff -u -r1.248 -r1.249 src/usr.bin/make/compat.c cvs rdiff -u -r1.371 -r1.372 src/usr.bin/make/make.1 cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/shell-sh.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Sat Dec 9 00:13:38 UTC 2023 Modified Files: src/usr.bin/make: var.c src/usr.bin/make/unit-tests: varname-dot-shell.exp Log Message: make: Var_SetWithFlags set fromCmd for SCOPE_CMDLINE Set fromCmd true for SCOPE_CMDLINE regardless of the variable name. Reviewed by: rillig To generate a diff of this commit: cvs rdiff -u -r1.1075 -r1.1076 src/usr.bin/make/var.c cvs rdiff -u -r1.16 -r1.17 src/usr.bin/make/unit-tests/varname-dot-shell.exp Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Sat Dec 9 00:13:38 UTC 2023 Modified Files: src/usr.bin/make: var.c src/usr.bin/make/unit-tests: varname-dot-shell.exp Log Message: make: Var_SetWithFlags set fromCmd for SCOPE_CMDLINE Set fromCmd true for SCOPE_CMDLINE regardless of the variable name. Reviewed by: rillig To generate a diff of this commit: cvs rdiff -u -r1.1075 -r1.1076 src/usr.bin/make/var.c cvs rdiff -u -r1.16 -r1.17 src/usr.bin/make/unit-tests/varname-dot-shell.exp 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/var.c diff -u src/usr.bin/make/var.c:1.1075 src/usr.bin/make/var.c:1.1076 --- src/usr.bin/make/var.c:1.1075 Sun Nov 19 22:50:11 2023 +++ src/usr.bin/make/var.c Sat Dec 9 00:13:38 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.1075 2023/11/19 22:50:11 rillig Exp $ */ +/* $NetBSD: var.c,v 1.1076 2023/12/09 00:13:38 sjg 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.1075 2023/11/19 22:50:11 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.1076 2023/12/09 00:13:38 sjg Exp $"); /* * Variables are defined using one of the VAR=value assignments. Their @@ -994,25 +994,26 @@ Var_SetWithFlags(GNode *scope, const cha * Any variables given on the command line are automatically exported * to the environment (as per POSIX standard), except for internals. */ - if (scope == SCOPE_CMDLINE && !(flags & VAR_SET_NO_EXPORT) && - name[0] != '.') { + if (scope == SCOPE_CMDLINE) { v->fromCmd = true; + if (!(flags & VAR_SET_NO_EXPORT) && name[0] != '.') { - /* - * If requested, don't export these in the environment - * individually. We still put them in .MAKEOVERRIDES so - * that the command-line settings continue to override - * Makefile settings. - */ - if (!opts.varNoExportEnv) - 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 requested, don't export these in the + * environment individually. We still put + * them in .MAKEOVERRIDES so that the + * command-line settings continue to override + * Makefile settings. + */ + if (!opts.varNoExportEnv) +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 (name[0] == '.' && strcmp(name, MAKE_SAVE_DOLLARS) == 0) Index: src/usr.bin/make/unit-tests/varname-dot-shell.exp diff -u src/usr.bin/make/unit-tests/varname-dot-shell.exp:1.16 src/usr.bin/make/unit-tests/varname-dot-shell.exp:1.17 --- src/usr.bin/make/unit-tests/varname-dot-shell.exp:1.16 Sat Mar 26 14:34:07 2022 +++ src/usr.bin/make/unit-tests/varname-dot-shell.exp Sat Dec 9 00:13:38 2023 @@ -5,7 +5,7 @@ Global: delete .SHELL (not found) Command: .SHELL = (details omitted) Global: ORIG_SHELL = (details omitted) Parsing line 12: .SHELL= overwritten -Global: .SHELL = overwritten +Global: .SHELL = overwritten ignored! CondParser_Eval: ${.SHELL} != ${ORIG_SHELL} Var_Parse: ${.SHELL} != ${ORIG_SHELL} (eval-defined) Var_Parse: ${ORIG_SHELL} (eval-defined) @@ -18,9 +18,9 @@ Var_Parse: ${.SHELL} != ${ORIG_SHELL} (e Var_Parse: ${ORIG_SHELL} (eval-defined) Comparing "(details omitted)" != "(details omitted)" Parsing line 27: .undef .SHELL -Global: delete .SHELL +Global: delete .SHELL (not found) Parsing line 28: .SHELL= newly overwritten -Global: .SHELL = newly overwritten +Global: .SHELL = newly overwritten ignored! CondParser_Eval: ${.SHELL} != ${ORIG_SHELL} Var_Parse: ${.SHELL} != ${ORIG_SHELL} (eval-defined) Var_Parse: ${ORIG_SHELL} (eval-defined)
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: sjg Date: Sun Sep 10 16:25:32 UTC 2023 Modified Files: src/usr.bin/make/unit-tests: opt-jobs.mk varname-dot-make-jobs.mk Log Message: make: skip -jC tests unless .MAKE.JOBS.C is yes To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/opt-jobs.mk \ src/usr.bin/make/unit-tests/varname-dot-make-jobs.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/unit-tests/opt-jobs.mk diff -u src/usr.bin/make/unit-tests/opt-jobs.mk:1.4 src/usr.bin/make/unit-tests/opt-jobs.mk:1.5 --- src/usr.bin/make/unit-tests/opt-jobs.mk:1.4 Sun Sep 10 11:41:33 2023 +++ src/usr.bin/make/unit-tests/opt-jobs.mk Sun Sep 10 16:25:32 2023 @@ -1,4 +1,4 @@ -# $NetBSD: opt-jobs.mk,v 1.4 2023/09/10 11:41:33 rillig Exp $ +# $NetBSD: opt-jobs.mk,v 1.5 2023/09/10 16:25:32 sjg Exp $ # # Tests for the -j command line option, which creates the targets in parallel. @@ -39,7 +39,7 @@ EXPECT..5e1C= # unlikely to o EXPECT.07.5C= EXPECT.08.5C= argument '08.5C' to option '-j' must be a positive number (exit 2) -.if ${.MAKE.JOBS.C} +.if ${.MAKE.JOBS.C} == "yes" . for arg in ${ARGS} OUTPUT!= ${MAKE} -r -f /dev/null -j ${arg} -v .MAKE.JOBS 2>&1 || echo "(exit $$?)" .if ${OUTPUT:C,^[0-9]+$,numeric,W} == numeric Index: src/usr.bin/make/unit-tests/varname-dot-make-jobs.mk diff -u src/usr.bin/make/unit-tests/varname-dot-make-jobs.mk:1.4 src/usr.bin/make/unit-tests/varname-dot-make-jobs.mk:1.5 --- src/usr.bin/make/unit-tests/varname-dot-make-jobs.mk:1.4 Sat Sep 9 01:30:59 2023 +++ src/usr.bin/make/unit-tests/varname-dot-make-jobs.mk Sun Sep 10 16:25:32 2023 @@ -1,4 +1,4 @@ -# $NetBSD: varname-dot-make-jobs.mk,v 1.4 2023/09/09 01:30:59 sjg Exp $ +# $NetBSD: varname-dot-make-jobs.mk,v 1.5 2023/09/10 16:25:32 sjg Exp $ # # Tests for the special .MAKE.JOBS variable, which is defined in jobs mode # only. There it contains the number of jobs that may run in parallel. @@ -15,16 +15,13 @@ all: @${MAKE} -r -f ${MAKEFILE} echo -j20 @${MAKE} -r -f ${MAKEFILE} echo -j0001 -.if !make(echo) +.if !make(echo) && ${.MAKE.JOBS.C} == "yes" # These results will not be static, we need NCPU # to compute expected results. -# We only support -jC if _SC_NPROCESSORS_ONLN is defined, -# otherwise we will get NCPU=0 -NCPU!= ${MAKE} -r -f /dev/null -jC -V .MAKE.JOBS 2> /dev/null || echo 0 - -.if ${NCPU} > 0 all: jC +NCPU!= ${MAKE} -r -f /dev/null -jC -V .MAKE.JOBS + # If -j arg is floating point or ends in C; # .MAKE.JOBS is a multiple of _SC_NPROCESSORS_ONLN # No news is good news here. @@ -38,7 +35,6 @@ jC: done .endif -.endif # expect: undefined # expect: 1
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: sjg Date: Sun Sep 10 16:25:32 UTC 2023 Modified Files: src/usr.bin/make/unit-tests: opt-jobs.mk varname-dot-make-jobs.mk Log Message: make: skip -jC tests unless .MAKE.JOBS.C is yes To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/opt-jobs.mk \ src/usr.bin/make/unit-tests/varname-dot-make-jobs.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Sat Sep 9 16:41:04 UTC 2023 Modified Files: src/usr.bin/make: main.c make.1 src/usr.bin/make/unit-tests: Makefile opt-debug-graph1.exp opt-debug-graph2.exp opt-debug-graph3.exp suff-main-several.exp suff-transform-debug.exp Log Message: Add .MAKE.JOBS.C to indicate wether -jC is supported To generate a diff of this commit: cvs rdiff -u -r1.595 -r1.596 src/usr.bin/make/main.c cvs rdiff -u -r1.369 -r1.370 src/usr.bin/make/make.1 cvs rdiff -u -r1.340 -r1.341 src/usr.bin/make/unit-tests/Makefile cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/opt-debug-graph1.exp cvs rdiff -u -r1.6 -r1.7 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.9 -r1.10 src/usr.bin/make/unit-tests/suff-main-several.exp 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/main.c diff -u src/usr.bin/make/main.c:1.595 src/usr.bin/make/main.c:1.596 --- src/usr.bin/make/main.c:1.595 Sat Sep 9 04:38:48 2023 +++ src/usr.bin/make/main.c Sat Sep 9 16:41:04 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.595 2023/09/09 04:38:48 mrg Exp $ */ +/* $NetBSD: main.c,v 1.596 2023/09/09 16:41:04 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.595 2023/09/09 04:38:48 mrg Exp $"); +MAKE_RCSID("$NetBSD: main.c,v 1.596 2023/09/09 16:41:04 sjg Exp $"); #if defined(MAKE_NATIVE) && !defined(lint) __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 " "The Regents of the University of California. " @@ -1373,6 +1373,12 @@ main_Init(int argc, char **argv) #endif Global_Set(".MAKE.MAKEFILE_PREFERENCE", MAKEFILE_PREFERENCE_LIST); Global_Set(".MAKE.DEPENDFILE", ".depend"); + /* Tell makefiles like jobs.mk wether we support -jC */ +#ifdef _SC_NPROCESSORS_ONLN + Global_Set_ReadOnly(".MAKE.JOBS.C", "yes"); +#else + Global_Set_ReadOnly(".MAKE.JOBS.C", "no"); +#endif CmdOpts_Init(); allPrecious = false; /* Remove targets when interrupted */ Index: src/usr.bin/make/make.1 diff -u src/usr.bin/make/make.1:1.369 src/usr.bin/make/make.1:1.370 --- src/usr.bin/make/make.1:1.369 Sat Sep 9 01:30:59 2023 +++ src/usr.bin/make/make.1 Sat Sep 9 16:41:04 2023 @@ -1,4 +1,4 @@ -.\" $NetBSD: make.1,v 1.369 2023/09/09 01:30:59 sjg Exp $ +.\" $NetBSD: make.1,v 1.370 2023/09/09 16:41:04 sjg Exp $ .\" .\" Copyright (c) 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -977,6 +977,11 @@ making it easier to track the degree of The argument to the .Fl j option. +.It Va .MAKE.JOBS.C +A read-only boolean that indicates wether the +.Fl j +option supports use of +.Ql C . .It Va .MAKE.LEVEL The recursion depth of .Nm . Index: src/usr.bin/make/unit-tests/Makefile diff -u src/usr.bin/make/unit-tests/Makefile:1.340 src/usr.bin/make/unit-tests/Makefile:1.341 --- src/usr.bin/make/unit-tests/Makefile:1.340 Thu Aug 17 18:48:32 2023 +++ src/usr.bin/make/unit-tests/Makefile Sat Sep 9 16:41:04 2023 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.340 2023/08/17 18:48:32 rillig Exp $ +# $NetBSD: Makefile,v 1.341 2023/09/09 16:41:04 sjg Exp $ # # Unit tests for make(1) # @@ -597,6 +597,7 @@ STD_SED_CMDS.dg1= -e 's,${.CURDIR}$$,,' STD_SED_CMDS.dg1+= -e 's,^\(\.MAKE *=\) .*,\1 ,' STD_SED_CMDS.dg1+= -e 's,^\(\.MAKE\.[A-Z_]* *=\) .*,\1 ,' +STD_SED_CMDS.dg1+= -e 's,^\(\.MAKE\.JOBS\.C *=\) .*,\1 ,' STD_SED_CMDS.dg1+= -e 's,^\(MACHINE[_ARCH]* *=\) .*,\1 ,' STD_SED_CMDS.dg1+= -e 's,^\(MAKE *=\) .*,\1 ,' STD_SED_CMDS.dg1+= -e 's,^\(\.SHELL *=\) .*,\1 ,' Index: src/usr.bin/make/unit-tests/opt-debug-graph1.exp diff -u src/usr.bin/make/unit-tests/opt-debug-graph1.exp:1.11 src/usr.bin/make/unit-tests/opt-debug-graph1.exp:1.12 --- src/usr.bin/make/unit-tests/opt-debug-graph1.exp:1.11 Tue Jan 24 00:24:02 2023 +++ src/usr.bin/make/unit-tests/opt-debug-graph1.exp Sat Sep 9 16:41:04 2023 @@ -21,6 +21,7 @@ .MAKE= .MAKE.DEPENDFILE = .MAKE.GID= +.MAKE.JOBS.C = .MAKE.LEVEL = .MAKE.MAKEFILES = .MAKE.MAKEFILE_PREFERENCE = Index: src/usr.bin/make/unit-tests/opt-debug-graph2.exp diff -u src/usr.bin/make/unit-tests/opt-debug-graph2.exp:1.6 src/usr.bin/make/unit-tests/opt-debug-graph2.exp:1.7 --- src/usr.bin/make/unit-tests/opt-debug-graph2.exp:1.6 Tue Jan 24 00:24:02 2023 +++ src/usr.bin/make/unit-tests/opt-debug-graph2.exp Sat Sep 9 16:41:04 2023 @@ -55,6 +55,7 @@ all : made-target error-targ .MAKE= .MAKE.DEPENDFILE = .MAKE.GID= +.MAKE.JOBS.C = .MAKE.LEVEL = .MAKE.MAKEFILES = .MAKE.MAKEFILE_PREFERENCE = Index: src/usr.bin/make/unit-tests/opt-debug-graph3.exp diff -u
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Sat Sep 9 16:41:04 UTC 2023 Modified Files: src/usr.bin/make: main.c make.1 src/usr.bin/make/unit-tests: Makefile opt-debug-graph1.exp opt-debug-graph2.exp opt-debug-graph3.exp suff-main-several.exp suff-transform-debug.exp Log Message: Add .MAKE.JOBS.C to indicate wether -jC is supported To generate a diff of this commit: cvs rdiff -u -r1.595 -r1.596 src/usr.bin/make/main.c cvs rdiff -u -r1.369 -r1.370 src/usr.bin/make/make.1 cvs rdiff -u -r1.340 -r1.341 src/usr.bin/make/unit-tests/Makefile cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/opt-debug-graph1.exp cvs rdiff -u -r1.6 -r1.7 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.9 -r1.10 src/usr.bin/make/unit-tests/suff-main-several.exp Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Sat Sep 9 01:30:59 UTC 2023 Modified Files: src/usr.bin/make: main.c make.1 src/usr.bin/make/unit-tests: varname-dot-make-jobs.exp varname-dot-make-jobs.mk Log Message: make: allow -j to compute a multiple of ncpu If _SC_NPROCESSORS_ONLN is supported; and -j arg is a floating point number or ends in 'C' compute .MAKE.JOBS as a multiple of _SC_NPROCESSORS_ONLN Based on a suggestion from des at freebsd.org Discussed with: rillig, christos To generate a diff of this commit: cvs rdiff -u -r1.593 -r1.594 src/usr.bin/make/main.c cvs rdiff -u -r1.368 -r1.369 src/usr.bin/make/make.1 cvs rdiff -u -r1.2 -r1.3 \ src/usr.bin/make/unit-tests/varname-dot-make-jobs.exp cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/varname-dot-make-jobs.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/main.c diff -u src/usr.bin/make/main.c:1.593 src/usr.bin/make/main.c:1.594 --- src/usr.bin/make/main.c:1.593 Tue Mar 28 14:39:31 2023 +++ src/usr.bin/make/main.c Sat Sep 9 01:30:59 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.593 2023/03/28 14:39:31 rillig Exp $ */ +/* $NetBSD: main.c,v 1.594 2023/09/09 01:30:59 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.593 2023/03/28 14:39:31 rillig Exp $"); +MAKE_RCSID("$NetBSD: main.c,v 1.594 2023/09/09 01:30:59 sjg Exp $"); #if defined(MAKE_NATIVE) && !defined(lint) __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 " "The Regents of the University of California. " @@ -398,18 +398,37 @@ static void MainParseArgJobs(const char *argvalue) { char *p; + char v[12]; forceJobs = true; opts.maxJobs = (int)strtol(argvalue, , 0); +#ifdef _SC_NPROCESSORS_ONLN + if (*p != '\0') { + double d; + + if (*p == 'C') { + d = (opts.maxJobs > 0) ? opts.maxJobs : 1; + } else if (*p == '.') { + d = strtod(argvalue, ); + } else + d = 0; + if (d > 0) { + p = strchr(argvalue, 0); + opts.maxJobs = sysconf(_SC_NPROCESSORS_ONLN); + opts.maxJobs = (int)(d * (double)opts.maxJobs); + } + } +#endif if (*p != '\0' || opts.maxJobs < 1) { (void)fprintf(stderr, "%s: illegal argument to -j -- must be positive integer!\n", progname); exit(2); /* Not 1 so -q can distinguish error */ } + snprintf(v, sizeof(v), "%d", opts.maxJobs); Global_Append(MAKEFLAGS, "-j"); - Global_Append(MAKEFLAGS, argvalue); - Global_Set(".MAKE.JOBS", argvalue); + Global_Append(MAKEFLAGS, v); + Global_Set(".MAKE.JOBS", v); maxJobTokens = opts.maxJobs; } Index: src/usr.bin/make/make.1 diff -u src/usr.bin/make/make.1:1.368 src/usr.bin/make/make.1:1.369 --- src/usr.bin/make/make.1:1.368 Sun Aug 20 19:58:15 2023 +++ src/usr.bin/make/make.1 Sat Sep 9 01:30:59 2023 @@ -1,4 +1,4 @@ -.\" $NetBSD: make.1,v 1.368 2023/08/20 19:58:15 sjg Exp $ +.\" $NetBSD: make.1,v 1.369 2023/09/09 01:30:59 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 August 20, 2023 +.Dd September 9, 2023 .Dt MAKE 1 .Os .Sh NAME @@ -267,6 +267,12 @@ cooperate to avoid overloading the syste Specify the maximum number of jobs that .Nm may have running at any one time. +If +.Ar max_jobs +is a floating point number, or ends with +.Ql C , +then the value is multiplied by the number of CPUs reported online by +.Xr sysconf 3 . The value of .Ar max_jobs is saved in Index: src/usr.bin/make/unit-tests/varname-dot-make-jobs.exp diff -u src/usr.bin/make/unit-tests/varname-dot-make-jobs.exp:1.2 src/usr.bin/make/unit-tests/varname-dot-make-jobs.exp:1.3 --- src/usr.bin/make/unit-tests/varname-dot-make-jobs.exp:1.2 Wed Jan 26 22:47:03 2022 +++ src/usr.bin/make/unit-tests/varname-dot-make-jobs.exp Sat Sep 9 01:30:59 2023 @@ -4,5 +4,5 @@ undefined 5 --- echo --- 20 -0001 +1 exit status 0 Index: src/usr.bin/make/unit-tests/varname-dot-make-jobs.mk diff -u src/usr.bin/make/unit-tests/varname-dot-make-jobs.mk:1.3 src/usr.bin/make/unit-tests/varname-dot-make-jobs.mk:1.4 --- src/usr.bin/make/unit-tests/varname-dot-make-jobs.mk:1.3 Wed Jan 26 22:47:03 2022 +++ src/usr.bin/make/unit-tests/varname-dot-make-jobs.mk Sat Sep 9 01:30:59 2023 @@ -1,4 +1,4 @@ -# $NetBSD: varname-dot-make-jobs.mk,v 1.3 2022/01/26 22:47:03 rillig Exp $ +# $NetBSD: varname-dot-make-jobs.mk,v 1.4 2023/09/09 01:30:59 sjg Exp $ # # Tests for the special .MAKE.JOBS variable, which is defined in jobs mode # only. There it contains the number of jobs that may run in parallel. @@ -15,10 +15,33 @@ all: @${MAKE} -r -f ${MAKEFILE} echo -j20 @${MAKE} -r -f ${MAKEFILE} echo -j0001 +.if !make(echo) +# These results will not be
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Sat Sep 9 01:30:59 UTC 2023 Modified Files: src/usr.bin/make: main.c make.1 src/usr.bin/make/unit-tests: varname-dot-make-jobs.exp varname-dot-make-jobs.mk Log Message: make: allow -j to compute a multiple of ncpu If _SC_NPROCESSORS_ONLN is supported; and -j arg is a floating point number or ends in 'C' compute .MAKE.JOBS as a multiple of _SC_NPROCESSORS_ONLN Based on a suggestion from des at freebsd.org Discussed with: rillig, christos To generate a diff of this commit: cvs rdiff -u -r1.593 -r1.594 src/usr.bin/make/main.c cvs rdiff -u -r1.368 -r1.369 src/usr.bin/make/make.1 cvs rdiff -u -r1.2 -r1.3 \ src/usr.bin/make/unit-tests/varname-dot-make-jobs.exp cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/varname-dot-make-jobs.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Sun Aug 20 19:58:15 UTC 2023 Modified Files: src/usr.bin/make: make.1 Log Message: make.1: note that %s should only be used with :localtime To generate a diff of this commit: cvs rdiff -u -r1.367 -r1.368 src/usr.bin/make/make.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Sun Aug 20 19:58:15 UTC 2023 Modified Files: src/usr.bin/make: make.1 Log Message: make.1: note that %s should only be used with :localtime To generate a diff of this commit: cvs rdiff -u -r1.367 -r1.368 src/usr.bin/make/make.1 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.367 src/usr.bin/make/make.1:1.368 --- src/usr.bin/make/make.1:1.367 Wed Jun 28 06:15:07 2023 +++ src/usr.bin/make/make.1 Sun Aug 20 19:58:15 2023 @@ -1,4 +1,4 @@ -.\" $NetBSD: make.1,v 1.367 2023/06/28 06:15:07 rillig Exp $ +.\" $NetBSD: make.1,v 1.368 2023/08/20 19:58:15 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 June 28, 2023 +.Dd August 20, 2023 .Dt MAKE 1 .Os .Sh NAME @@ -1496,6 +1496,10 @@ The value is interpreted as a format str using .Xr gmtime 3 , producing the formatted timestamp. +Note: the +.Ql %s +format should only be used with +.Sq Cm \&:localtime . If a .Ar timestamp value is not provided or is 0, the current time is used.
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: sjg Date: Sat Aug 19 01:34:21 UTC 2023 Modified Files: src/usr.bin/make/unit-tests: varmod-mtime.exp varmod-mtime.mk Log Message: varmod-mtime.mk: use :localtime for %s Add a comment to explain why ${%s:L:localtime} should be used to get a value that matches time(3). To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/varmod-mtime.exp \ src/usr.bin/make/unit-tests/varmod-mtime.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: sjg Date: Sat Aug 19 01:34:21 UTC 2023 Modified Files: src/usr.bin/make/unit-tests: varmod-mtime.exp varmod-mtime.mk Log Message: varmod-mtime.mk: use :localtime for %s Add a comment to explain why ${%s:L:localtime} should be used to get a value that matches time(3). To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/varmod-mtime.exp \ src/usr.bin/make/unit-tests/varmod-mtime.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/unit-tests/varmod-mtime.exp diff -u src/usr.bin/make/unit-tests/varmod-mtime.exp:1.3 src/usr.bin/make/unit-tests/varmod-mtime.exp:1.4 --- src/usr.bin/make/unit-tests/varmod-mtime.exp:1.3 Thu Aug 17 19:06:51 2023 +++ src/usr.bin/make/unit-tests/varmod-mtime.exp Sat Aug 19 01:34:21 2023 @@ -1,8 +1,8 @@ -make: "varmod-mtime.mk" line 58: Cannot determine mtime for 'no/such/file1': -make: "varmod-mtime.mk" line 58: Cannot determine mtime for 'no/such/file2': -make: "varmod-mtime.mk" line 58: Malformed conditional (${no/such/file1 no/such/file2:L:mtime=error}) -make: "varmod-mtime.mk" line 69: Invalid argument 'errorhandler-no' for modifier ':mtime' -make: "varmod-mtime.mk" line 69: Malformed conditional (${MAKEFILE:mtime=errorhandler-no} > 0) +make: "varmod-mtime.mk" line 60: Cannot determine mtime for 'no/such/file1': +make: "varmod-mtime.mk" line 60: Cannot determine mtime for 'no/such/file2': +make: "varmod-mtime.mk" line 60: Malformed conditional (${no/such/file1 no/such/file2:L:mtime=error}) +make: "varmod-mtime.mk" line 71: Invalid argument 'errorhandler-no' for modifier ':mtime' +make: "varmod-mtime.mk" line 71: Malformed conditional (${MAKEFILE:mtime=errorhandler-no} > 0) make: Fatal errors encountered -- cannot continue make: stopped in unit-tests exit status 1 Index: src/usr.bin/make/unit-tests/varmod-mtime.mk diff -u src/usr.bin/make/unit-tests/varmod-mtime.mk:1.3 src/usr.bin/make/unit-tests/varmod-mtime.mk:1.4 --- src/usr.bin/make/unit-tests/varmod-mtime.mk:1.3 Thu Aug 17 19:06:51 2023 +++ src/usr.bin/make/unit-tests/varmod-mtime.mk Sat Aug 19 01:34:21 2023 @@ -1,9 +1,11 @@ -# $NetBSD: varmod-mtime.mk,v 1.3 2023/08/17 19:06:51 rillig Exp $ +# $NetBSD: varmod-mtime.mk,v 1.4 2023/08/19 01:34:21 sjg Exp $ # # Tests for the ':mtime' variable modifier, which maps each word of the # expression to that file's modification time. -start:= ${%s:L:gmtime} +# Note: strftime() uses mktime() for %s and mktime() assumes localtime +# so this should match time() +start:= ${%s:L:localtime} # Ensure that this makefile exists and has a modification time. If the file
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Sat Aug 19 00:09:17 UTC 2023 Modified Files: src/usr.bin/make: meta.c Log Message: meta_ignore: check metaIgnorePaths on raw path Some path prefixes can trigger automount, if we want to ignore them it might be best to check metaIgnorePaths before we call realpath. If the raw path does not match, check again after realpath. To generate a diff of this commit: cvs rdiff -u -r1.205 -r1.206 src/usr.bin/make/meta.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/meta.c diff -u src/usr.bin/make/meta.c:1.205 src/usr.bin/make/meta.c:1.206 --- src/usr.bin/make/meta.c:1.205 Tue Mar 28 14:39:31 2023 +++ src/usr.bin/make/meta.c Sat Aug 19 00:09:17 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: meta.c,v 1.205 2023/03/28 14:39:31 rillig Exp $ */ +/* $NetBSD: meta.c,v 1.206 2023/08/19 00:09:17 sjg Exp $ */ /* * Implement 'meta' mode. @@ -932,6 +932,13 @@ meta_ignore(GNode *gn, const char *p) return true; if (*p == '/') { + /* first try the raw path "as is" */ + if (has_any_prefix(p, )) { +#ifdef DEBUG_META_MODE + DEBUG1(META, "meta_oodate: ignoring path: %s\n", p); +#endif + return true; + } cached_realpath(p, fname); /* clean it up */ if (has_any_prefix(fname, )) { #ifdef DEBUG_META_MODE
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Sat Aug 19 00:09:17 UTC 2023 Modified Files: src/usr.bin/make: meta.c Log Message: meta_ignore: check metaIgnorePaths on raw path Some path prefixes can trigger automount, if we want to ignore them it might be best to check metaIgnorePaths before we call realpath. If the raw path does not match, check again after realpath. To generate a diff of this commit: cvs rdiff -u -r1.205 -r1.206 src/usr.bin/make/meta.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: sjg Date: Wed Jun 21 21:21:52 UTC 2023 Modified Files: src/usr.bin/make/unit-tests: directive-include-guard.exp directive-include-guard.mk Log Message: Cleanup guard tests The .PARSEFILE:tA tests add no value, the correct form is ${.PARSEDIR:tA}/${.PARSEFILE} but even there :tA rarely matters. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 \ src/usr.bin/make/unit-tests/directive-include-guard.exp cvs rdiff -u -r1.10 -r1.11 \ src/usr.bin/make/unit-tests/directive-include-guard.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/unit-tests/directive-include-guard.exp diff -u src/usr.bin/make/unit-tests/directive-include-guard.exp:1.9 src/usr.bin/make/unit-tests/directive-include-guard.exp:1.10 --- src/usr.bin/make/unit-tests/directive-include-guard.exp:1.9 Wed Jun 21 14:33:36 2023 +++ src/usr.bin/make/unit-tests/directive-include-guard.exp Wed Jun 21 21:21:52 2023 @@ -73,12 +73,6 @@ Parse_PushInput: file target-indirect-PA Skipping 'target-indirect-PARSEFILE2.tmp' because '__target-indirect-PARSEFILE2.tmp__' is defined Parse_PushInput: file subdir/target-indirect-PARSEFILE.tmp, line 1 Skipping 'subdir/target-indirect-PARSEFILE.tmp' because '__target-indirect-PARSEFILE.tmp__' is defined -Parse_PushInput: file target-indirect-PARSEFILE-tA.tmp, line 1 -Skipping 'target-indirect-PARSEFILE-tA.tmp' because '__target-indirect-PARSEFILE-tA.tmp__' is defined -Parse_PushInput: file subdir/target-indirect-PARSEFILE-tA.tmp, line 1 -Skipping 'subdir/target-indirect-PARSEFILE-tA.tmp' because '__target-indirect-PARSEFILE-tA.tmp__' is defined -Parse_PushInput: file subdir2/target-indirect-PARSEFILE-tA.tmp, line 1 -Skipping 'subdir2/target-indirect-PARSEFILE-tA.tmp' because '__target-indirect-PARSEFILE-tA.tmp__' is defined Parse_PushInput: file target-indirect-PARSEDIR-PARSEFILE.tmp, line 1 Skipping 'target-indirect-PARSEDIR-PARSEFILE.tmp' because '__target-indirect-PARSEDIR-PARSEFILE.tmp__' is defined Parse_PushInput: file subdir/target-indirect-PARSEDIR-PARSEFILE.tmp, line 1 Index: src/usr.bin/make/unit-tests/directive-include-guard.mk diff -u src/usr.bin/make/unit-tests/directive-include-guard.mk:1.10 src/usr.bin/make/unit-tests/directive-include-guard.mk:1.11 --- src/usr.bin/make/unit-tests/directive-include-guard.mk:1.10 Wed Jun 21 14:33:36 2023 +++ src/usr.bin/make/unit-tests/directive-include-guard.mk Wed Jun 21 21:21:52 2023 @@ -1,4 +1,4 @@ -# $NetBSD: directive-include-guard.mk,v 1.10 2023/06/21 14:33:36 rillig Exp $ +# $NetBSD: directive-include-guard.mk,v 1.11 2023/06/21 21:21:52 sjg Exp $ # # Tests for multiple-inclusion guards in makefiles. # @@ -460,49 +460,8 @@ LINES.subdir/target-indirect-PARSEFILE= # expect: Parse_PushInput: file subdir/target-indirect-PARSEFILE.tmp, line 1 # expect: Skipping 'subdir/target-indirect-PARSEFILE.tmp' because '__target-indirect-PARSEFILE.tmp__' is defined -# Another common form of guard target is __${.PARSEFILE:tA}__. This form only -# works for files that are in the current working directory, it does not work -# for files from other directories, as the modifier ':tA' resolves a file -# relative to the current working directory ('.OBJDIR'). To get a robust -# pattern, use __${.PARSEDIR}/.${.PARSEFILE}__ instead. -INCS+= target-indirect-PARSEFILE-tA -LINES.target-indirect-PARSEFILE-tA= \ - '.if !target(__$${.PARSEFILE:tA}__)' \ - '__$${.PARSEFILE:tA}__: .NOTMAIN' \ - '.endif' -# expect: Parse_PushInput: file target-indirect-PARSEFILE-tA.tmp, line 1 -# expect: Skipping 'target-indirect-PARSEFILE-tA.tmp' because '__target-indirect-PARSEFILE-tA.tmp__' is defined -# The actual target starts with '__${.OBJDIR}/', see the .rawout file, but the -# string '${.OBJDIR}/' gets stripped in post processing. - -# Using the ':tA' modifier to construct guard target names is generally wrong, -# as the ':tA' modifier only works for files in the current working directory. -# For files from subdirectories that are not also found in the current working -# directory, applying the modifier ':tA' has no effect. -INCS+= subdir/target-indirect-PARSEFILE-tA -LINES.subdir/target-indirect-PARSEFILE-tA= \ - '.if !target(__$${.PARSEFILE:tA}__)' \ - '__$${.PARSEFILE:tA}__: .NOTMAIN' \ - '.endif' -# expect: Parse_PushInput: file subdir/target-indirect-PARSEFILE-tA.tmp, line 1 -# expect: Skipping 'subdir/target-indirect-PARSEFILE-tA.tmp' because '__target-indirect-PARSEFILE-tA.tmp__' is defined -# The guard target name does not include any directory since the ':tA' -# modifier file cannot resolve the file in the current working directory. - -# If there are two subdirectories that both have a file with the same basename -# that uses '${.PARSEFILE:tA}' as its guard target, the second file reuses the -# guard name from the first file. To get a robust scheme of guard target -# names, use
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: sjg Date: Wed Jun 21 21:21:52 UTC 2023 Modified Files: src/usr.bin/make/unit-tests: directive-include-guard.exp directive-include-guard.mk Log Message: Cleanup guard tests The .PARSEFILE:tA tests add no value, the correct form is ${.PARSEDIR:tA}/${.PARSEFILE} but even there :tA rarely matters. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 \ src/usr.bin/make/unit-tests/directive-include-guard.exp cvs rdiff -u -r1.10 -r1.11 \ src/usr.bin/make/unit-tests/directive-include-guard.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Wed Jun 21 04:20:21 UTC 2023 Modified Files: src/usr.bin/make: cond.c src/usr.bin/make/unit-tests: directive-include-guard.exp directive-include-guard.mk Log Message: Allow guard targets to use variables. I commonly use __${.PARSEDIR:tA}__ where a unique guard is needed, __${.PARSEDIR}__ is also useful in many cases. Combination of patch from rillig and mine To generate a diff of this commit: cvs rdiff -u -r1.350 -r1.351 src/usr.bin/make/cond.c cvs rdiff -u -r1.6 -r1.7 \ src/usr.bin/make/unit-tests/directive-include-guard.exp cvs rdiff -u -r1.7 -r1.8 \ src/usr.bin/make/unit-tests/directive-include-guard.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/cond.c diff -u src/usr.bin/make/cond.c:1.350 src/usr.bin/make/cond.c:1.351 --- src/usr.bin/make/cond.c:1.350 Tue Jun 20 09:25:33 2023 +++ src/usr.bin/make/cond.c Wed Jun 21 04:20:20 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: cond.c,v 1.350 2023/06/20 09:25:33 rillig Exp $ */ +/* $NetBSD: cond.c,v 1.351 2023/06/21 04:20:20 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -92,7 +92,7 @@ #include "dir.h" /* "@(#)cond.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: cond.c,v 1.350 2023/06/20 09:25:33 rillig Exp $"); +MAKE_RCSID("$NetBSD: cond.c,v 1.351 2023/06/21 04:20:20 sjg Exp $"); /* * Conditional expressions conform to this grammar: @@ -1252,22 +1252,6 @@ ParseVarnameGuard(const char **pp, const return false; } -static bool -ParseTargetGuard(const char **pp, const char **target) -{ - const char *p = *pp; - - if (ch_isalpha(*p) || *p == '_') { - while (ch_isalnum(*p) || *p == '_' || *p == '-' - || *p == '<' || *p == '>' || *p == '.' || *p == '/') - p++; - *target = *pp; - *pp = p; - return true; - } - return false; -} - /* Extracts the multiple-inclusion guard from a conditional, if any. */ Guard * Cond_ExtractGuard(const char *line) @@ -1292,9 +1276,17 @@ Cond_ExtractGuard(const char *line) && strcmp(p, ")") == 0) goto found_variable; } else if (skip_string(, "!target(")) { - if (ParseTargetGuard(, ) - && strcmp(p, ")") == 0) -goto found_target; + name = p; + free(ParseWord(, false)); + if (strcmp(p, ")") == 0) { +char *target; +p = name; +target = ParseWord(, true); +guard = bmake_malloc(sizeof(*guard)); +guard->kind = GK_TARGET; +guard->name = target; +return guard; + } } } else if (Substring_Equals(dir, "ifndef")) { if (ParseVarnameGuard(, ) && *p == '\0') @@ -1304,10 +1296,6 @@ Cond_ExtractGuard(const char *line) found_variable: kind = GK_VARIABLE; - goto found; -found_target: - kind = GK_TARGET; -found: guard = bmake_malloc(sizeof(*guard)); guard->kind = kind; guard->name = bmake_strsedup(name, p); Index: src/usr.bin/make/unit-tests/directive-include-guard.exp diff -u src/usr.bin/make/unit-tests/directive-include-guard.exp:1.6 src/usr.bin/make/unit-tests/directive-include-guard.exp:1.7 --- src/usr.bin/make/unit-tests/directive-include-guard.exp:1.6 Tue Jun 20 09:25:34 2023 +++ src/usr.bin/make/unit-tests/directive-include-guard.exp Wed Jun 21 04:20:21 2023 @@ -47,7 +47,13 @@ Skipping 'target.tmp' because '__target. Parse_PushInput: file target-sys.tmp, line 1 Skipping 'target-sys.tmp' because '' is defined Parse_PushInput: file target-indirect.tmp, line 1 -Parse_PushInput: file target-indirect.tmp, line 1 +Skipping 'target-indirect.tmp' because 'target-indirect.tmp' is defined +Parse_PushInput: file target-indirect-PARSEFILE.tmp, line 1 +Skipping 'target-indirect-PARSEFILE.tmp' because '__target-indirect-PARSEFILE.tmp__' is defined +Parse_PushInput: file target-indirect-PARSEFILE2.tmp, line 1 +Skipping 'target-indirect-PARSEFILE2.tmp' because '__target-indirect-PARSEFILE2.tmp__' is defined +Parse_PushInput: file target-indirect-PARSEFILE-tA.tmp, line 1 +Skipping 'target-indirect-PARSEFILE-tA.tmp' because '__target-indirect-PARSEFILE-tA.tmp__' is defined Parse_PushInput: file target-unguarded.tmp, line 1 Parse_PushInput: file target-unguarded.tmp, line 1 Parse_PushInput: file target-plus.tmp, line 1 Index: src/usr.bin/make/unit-tests/directive-include-guard.mk diff -u src/usr.bin/make/unit-tests/directive-include-guard.mk:1.7 src/usr.bin/make/unit-tests/directive-include-guard.mk:1.8 --- src/usr.bin/make/unit-tests/directive-include-guard.mk:1.7 Tue Jun 20 09:25:34 2023 +++ src/usr.bin/make/unit-tests/directive-include-guard.mk Wed Jun 21 04:20:21 2023 @@ -1,4 +1,4 @@ -# $NetBSD: directive-include-guard.mk,v 1.7 2023/06/20 09:25:34 rillig Exp $ +# $NetBSD: directive-include-guard.mk,v 1.8 2023/06/21 04:20:21 sjg Exp $ # # Tests for multiple-inclusion guards in makefiles. # @@ -282,14 +282,45 @@ LINES.target-sys= \ # expect: Parse_PushInput: file target-sys.tmp, line 1 # expect:
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Wed Jun 21 04:20:21 UTC 2023 Modified Files: src/usr.bin/make: cond.c src/usr.bin/make/unit-tests: directive-include-guard.exp directive-include-guard.mk Log Message: Allow guard targets to use variables. I commonly use __${.PARSEDIR:tA}__ where a unique guard is needed, __${.PARSEDIR}__ is also useful in many cases. Combination of patch from rillig and mine To generate a diff of this commit: cvs rdiff -u -r1.350 -r1.351 src/usr.bin/make/cond.c cvs rdiff -u -r1.6 -r1.7 \ src/usr.bin/make/unit-tests/directive-include-guard.exp cvs rdiff -u -r1.7 -r1.8 \ src/usr.bin/make/unit-tests/directive-include-guard.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: sjg Date: Mon Jun 19 15:37:48 UTC 2023 Modified Files: src/usr.bin/make/unit-tests: var-readonly.mk Log Message: Test that .undef of readOnly variable fails To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/var-readonly.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/unit-tests/var-readonly.mk diff -u src/usr.bin/make/unit-tests/var-readonly.mk:1.2 src/usr.bin/make/unit-tests/var-readonly.mk:1.3 --- src/usr.bin/make/unit-tests/var-readonly.mk:1.2 Thu Jun 1 20:56:35 2023 +++ src/usr.bin/make/unit-tests/var-readonly.mk Mon Jun 19 15:37:48 2023 @@ -1,4 +1,4 @@ -# $NetBSD: var-readonly.mk,v 1.2 2023/06/01 20:56:35 rillig Exp $ +# $NetBSD: var-readonly.mk,v 1.3 2023/06/19 15:37:48 sjg Exp $ # the answer N = 42 @@ -9,6 +9,12 @@ N = 666 .error N ($N) should be 42 .endif +# undef should fail +.undef N +.ifndef N +.error N should not be undef'd +.endif + .NOREADONLY: N # now we can change it N = 69
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: sjg Date: Mon Jun 19 15:37:48 UTC 2023 Modified Files: src/usr.bin/make/unit-tests: var-readonly.mk Log Message: Test that .undef of readOnly variable fails To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/var-readonly.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Fri Jun 16 22:30:35 UTC 2023 Modified Files: src/usr.bin/make: var.c Log Message: make: do not allow delete of readOnly variable. Sometimes we mark a variable readOnly to guard against .undef To generate a diff of this commit: cvs rdiff -u -r1.1055 -r1.1056 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.
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Fri Jun 16 22:30:35 UTC 2023 Modified Files: src/usr.bin/make: var.c Log Message: make: do not allow delete of readOnly variable. Sometimes we mark a variable readOnly to guard against .undef To generate a diff of this commit: cvs rdiff -u -r1.1055 -r1.1056 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/var.c diff -u src/usr.bin/make/var.c:1.1055 src/usr.bin/make/var.c:1.1056 --- src/usr.bin/make/var.c:1.1055 Thu Jun 1 07:44:10 2023 +++ src/usr.bin/make/var.c Fri Jun 16 22:30:35 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.1055 2023/06/01 07:44:10 rillig Exp $ */ +/* $NetBSD: var.c,v 1.1056 2023/06/16 22:30:35 sjg 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.1055 2023/06/01 07:44:10 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.1056 2023/06/16 22:30:35 sjg Exp $"); /* * Variables are defined using one of the VAR=value assignments. Their @@ -513,6 +513,11 @@ Var_Delete(GNode *scope, const char *var DEBUG2(VAR, "%s: delete %s\n", scope->name, varname); v = he->value; + if (v->readOnly) { + DEBUG2(VAR, "%s: delete %s (readOnly)\n", + scope->name, varname); + return; + } if (v->inUse) { Parse_Error(PARSE_FATAL, "Cannot delete variable \"%s\" while it is used",
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Wed May 10 18:22:33 UTC 2023 Modified Files: src/usr.bin/make: make.1 var.c Log Message: Make :mtime operate on each word in variable value. Reviewed by: rillig To generate a diff of this commit: cvs rdiff -u -r1.365 -r1.366 src/usr.bin/make/make.1 cvs rdiff -u -r1.1053 -r1.1054 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.
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Wed May 10 18:22:33 UTC 2023 Modified Files: src/usr.bin/make: make.1 var.c Log Message: Make :mtime operate on each word in variable value. Reviewed by: rillig To generate a diff of this commit: cvs rdiff -u -r1.365 -r1.366 src/usr.bin/make/make.1 cvs rdiff -u -r1.1053 -r1.1054 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.365 src/usr.bin/make/make.1:1.366 --- src/usr.bin/make/make.1:1.365 Tue May 9 20:53:23 2023 +++ src/usr.bin/make/make.1 Wed May 10 18:22:33 2023 @@ -1,4 +1,4 @@ -.\" $NetBSD: make.1,v 1.365 2023/05/09 20:53:23 sjg Exp $ +.\" $NetBSD: make.1,v 1.366 2023/05/10 18:22:33 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 May 9, 2023 +.Dd May 10, 2023 .Dt MAKE 1 .Os .Sh NAME @@ -1511,9 +1511,9 @@ If a .Ar timestamp value is not provided or is 0, the current time is used. .It Cm \&:mtime Ns Oo Cm = Ns Ar timestamp Oc -call +Call .Xr stat 2 -with the value as pathname; +with each word as pathname; use .Ql st_mtime as the new value. Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.1053 src/usr.bin/make/var.c:1.1054 --- src/usr.bin/make/var.c:1.1053 Tue May 9 21:24:56 2023 +++ src/usr.bin/make/var.c Wed May 10 18:22:33 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.1053 2023/05/09 21:24:56 rillig Exp $ */ +/* $NetBSD: var.c,v 1.1054 2023/05/10 18:22:33 sjg 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.1053 2023/05/09 21:24:56 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.1054 2023/05/10 18:22:33 sjg Exp $"); /* * Variables are defined using one of the VAR=value assignments. Their @@ -2833,49 +2833,69 @@ ApplyModifier_Match(const char **pp, Mod return AMR_OK; } +struct ModifyWord_MtimeArgs { + bool error; + bool fallback; + ApplyModifierResult rc; + time_t t; +}; + +static void +ModifyWord_Mtime(Substring word, SepBuf *buf, void *data) +{ + char tbuf[BUFSIZ]; + struct stat st; + struct ModifyWord_MtimeArgs *args = data; + + if (Substring_IsEmpty(word)) + return; + assert(word.end[0] == '\0'); /* assume null-terminated word */ + if (stat(word.start, ) < 0) { + if (args->error) { + Parse_Error(PARSE_FATAL, + "Cannot determine mtime for '%s': %s", + word.start, strerror(errno)); + args->rc = AMR_CLEANUP; + return; + } + if (args->fallback) + st.st_mtime = args->t; + else + time(_mtime); + } + snprintf(tbuf, sizeof(tbuf), "%u", (unsigned)st.st_mtime); + SepBuf_AddStr(buf, tbuf); +} + /* :mtime */ static ApplyModifierResult ApplyModifier_Mtime(const char **pp, ModChain *ch) { - char buf[BUFSIZ]; - Expr *expr = ch->expr; - const char *args, *mod = *pp; - struct stat st; - bool error = false; - int i = -1; + const char *p, *mod = *pp; + struct ModifyWord_MtimeArgs args; if (!ModMatchEq(mod, "mtime", ch)) return AMR_UNKNOWN; *pp += 5; - args = *pp; - if (args[0] == '=') { - args++; - if (!TryParseIntBase0(, )) { - if (strncmp(args, "error", 5) == 0) { -error = true; -args += 5; + p = *pp; + args.error = args.fallback = false; + args.rc = AMR_OK; + if (p[0] == '=') { + p++; + args.fallback = true; + if (!TryParseTime(, )) { + if (strncmp(p, "error", 5) == 0) { +args.error = true; +p += 5; } else return AMR_BAD; } - *pp = args; + *pp = p; } if (!ModChain_ShouldEval(ch)) return AMR_OK; - if (stat(Expr_Str(expr), ) < 0) { - if (error) { - Parse_Error(PARSE_FATAL, - "Cannot determine mtime for '%s': %s", - Expr_Str(expr), strerror(errno)); - return AMR_CLEANUP; - } - if (i < 0) - time(_mtime); - else - st.st_mtime = (time_t)i; - } - snprintf(buf, sizeof(buf), "%u", (unsigned)st.st_mtime); - Expr_SetValueOwn(expr, bmake_strdup(buf)); - return AMR_OK; + ModifyWords(ch, ModifyWord_Mtime, , ch->oneBigWord); + return args.rc; } static void
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Tue May 9 20:53:23 UTC 2023 Modified Files: src/usr.bin/make: make.1 var.c Log Message: make: :mtime=error throw error on stat(2) failure Sometimes we want fatal error if stat fails on the presumed pathname. To generate a diff of this commit: cvs rdiff -u -r1.364 -r1.365 src/usr.bin/make/make.1 cvs rdiff -u -r1.1051 -r1.1052 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.364 src/usr.bin/make/make.1:1.365 --- src/usr.bin/make/make.1:1.364 Tue May 9 20:14:27 2023 +++ src/usr.bin/make/make.1 Tue May 9 20:53:23 2023 @@ -1,4 +1,4 @@ -.\" $NetBSD: make.1,v 1.364 2023/05/09 20:14:27 sjg Exp $ +.\" $NetBSD: make.1,v 1.365 2023/05/09 20:53:23 sjg Exp $ .\" .\" Copyright (c) 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -1522,6 +1522,13 @@ If fails; use .Ar timestamp or current time. +If +.Ar timestamp +is set to +.Ql error , +then +.Xr stat 2 +failure will cause an error. .It Cm \&:tA Attempts to convert the value to an absolute path using .Xr realpath 3 . Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.1051 src/usr.bin/make/var.c:1.1052 --- src/usr.bin/make/var.c:1.1051 Tue May 9 20:14:27 2023 +++ src/usr.bin/make/var.c Tue May 9 20:53:23 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.1051 2023/05/09 20:14:27 sjg Exp $ */ +/* $NetBSD: var.c,v 1.1052 2023/05/09 20:53:23 sjg 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.1051 2023/05/09 20:14:27 sjg Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.1052 2023/05/09 20:53:23 sjg Exp $"); /* * Variables are defined using one of the VAR=value assignments. Their @@ -2841,6 +2841,7 @@ ApplyModifier_Mtime(const char **pp, Mod Expr *expr = ch->expr; const char *args, *mod = *pp; struct stat st; + bool error = false; int i = -1; if (!ModMatchEq(mod, "mtime", ch)) @@ -2849,13 +2850,20 @@ ApplyModifier_Mtime(const char **pp, Mod args = *pp; if (args[0] == '=') { args++; - if (!TryParseIntBase0(, )) - return AMR_BAD; + if (!TryParseIntBase0(, )) { + if (strncmp(args, "error", 5) == 0) { +error = true; +args += 5; + } else +return AMR_BAD; + } *pp = args; } if (!ModChain_ShouldEval(ch)) return AMR_OK; if (stat(Expr_Str(expr), ) < 0) { + if (error) + return AMR_BAD; if (i < 0) time(_mtime); else
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Tue May 9 20:53:23 UTC 2023 Modified Files: src/usr.bin/make: make.1 var.c Log Message: make: :mtime=error throw error on stat(2) failure Sometimes we want fatal error if stat fails on the presumed pathname. To generate a diff of this commit: cvs rdiff -u -r1.364 -r1.365 src/usr.bin/make/make.1 cvs rdiff -u -r1.1051 -r1.1052 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.
CVS commit: src
Module Name:src Committed By: sjg Date: Tue May 9 20:14:28 UTC 2023 Modified Files: src/distrib/sets/lists/tests: mi src/usr.bin/make: make.1 var.c src/usr.bin/make/unit-tests: Makefile Added Files: src/usr.bin/make/unit-tests: varmod-mtime.exp varmod-mtime.mk Log Message: make: add :mtime to provide mtime of file The value of the variable is passed to stat(2) and st_mtime is new value. An optional arg can be used if stat(2) fails, otherwise the current time is used. See varmod-mtime.mk for usage examples. To generate a diff of this commit: cvs rdiff -u -r1.1258 -r1.1259 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.363 -r1.364 src/usr.bin/make/make.1 cvs rdiff -u -r1.1050 -r1.1051 src/usr.bin/make/var.c cvs rdiff -u -r1.333 -r1.334 src/usr.bin/make/unit-tests/Makefile cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/varmod-mtime.exp \ src/usr.bin/make/unit-tests/varmod-mtime.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src
Module Name:src Committed By: sjg Date: Tue May 9 20:14:28 UTC 2023 Modified Files: src/distrib/sets/lists/tests: mi src/usr.bin/make: make.1 var.c src/usr.bin/make/unit-tests: Makefile Added Files: src/usr.bin/make/unit-tests: varmod-mtime.exp varmod-mtime.mk Log Message: make: add :mtime to provide mtime of file The value of the variable is passed to stat(2) and st_mtime is new value. An optional arg can be used if stat(2) fails, otherwise the current time is used. See varmod-mtime.mk for usage examples. To generate a diff of this commit: cvs rdiff -u -r1.1258 -r1.1259 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.363 -r1.364 src/usr.bin/make/make.1 cvs rdiff -u -r1.1050 -r1.1051 src/usr.bin/make/var.c cvs rdiff -u -r1.333 -r1.334 src/usr.bin/make/unit-tests/Makefile cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/varmod-mtime.exp \ src/usr.bin/make/unit-tests/varmod-mtime.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/tests/mi diff -u src/distrib/sets/lists/tests/mi:1.1258 src/distrib/sets/lists/tests/mi:1.1259 --- src/distrib/sets/lists/tests/mi:1.1258 Sun Apr 23 08:47:27 2023 +++ src/distrib/sets/lists/tests/mi Tue May 9 20:14:28 2023 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1258 2023/04/23 08:47:27 rillig Exp $ +# $NetBSD: mi,v 1.1259 2023/05/09 20:14:28 sjg Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -6099,6 +6099,8 @@ ./usr/tests/usr.bin/make/unit-tests/varmod-match-escape.mk tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/varmod-match.exptests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/varmod-match.mktests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/make/unit-tests/varmod-mtime.exptests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/make/unit-tests/varmod-mtime.mktests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/varmod-no-match.exptests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/varmod-no-match.mktests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/varmod-order-numeric.exp tests-usr.bin-tests compattestfile,atf Index: src/usr.bin/make/make.1 diff -u src/usr.bin/make/make.1:1.363 src/usr.bin/make/make.1:1.364 --- src/usr.bin/make/make.1:1.363 Sun May 7 16:43:50 2023 +++ src/usr.bin/make/make.1 Tue May 9 20:14:27 2023 @@ -1,4 +1,4 @@ -.\" $NetBSD: make.1,v 1.363 2023/05/07 16:43:50 sjg Exp $ +.\" $NetBSD: make.1,v 1.364 2023/05/09 20:14:27 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 May 6, 2023 +.Dd May 9, 2023 .Dt MAKE 1 .Os .Sh NAME @@ -1510,6 +1510,18 @@ producing the formatted timestamp. If a .Ar timestamp value is not provided or is 0, the current time is used. +.It Cm \&:mtime Ns Oo Cm = Ns Ar timestamp Oc +call +.Xr stat 2 +with the value as pathname; +use +.Ql st_mtime +as the new value. +If +.Xr stat 2 +fails; use +.Ar timestamp +or current time. .It Cm \&:tA Attempts to convert the value to an absolute path using .Xr realpath 3 . Index: src/usr.bin/make/var.c diff -u src/usr.bin/make/var.c:1.1050 src/usr.bin/make/var.c:1.1051 --- src/usr.bin/make/var.c:1.1050 Tue May 9 16:26:59 2023 +++ src/usr.bin/make/var.c Tue May 9 20:14:27 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.1050 2023/05/09 16:26:59 rillig Exp $ */ +/* $NetBSD: var.c,v 1.1051 2023/05/09 20:14:27 sjg 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.1050 2023/05/09 16:26:59 rillig Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.1051 2023/05/09 20:14:27 sjg Exp $"); /* * Variables are defined using one of the VAR=value assignments. Their @@ -2833,6 +2833,39 @@ ApplyModifier_Match(const char **pp, Mod return AMR_OK; } +/* :mtime */ +static ApplyModifierResult +ApplyModifier_Mtime(const char **pp, ModChain *ch) +{ + char buf[BUFSIZ]; + Expr *expr = ch->expr; + const char *args, *mod = *pp; + struct stat st; + int i = -1; + + if (!ModMatchEq(mod, "mtime", ch)) + return AMR_UNKNOWN; + *pp += 5; + args = *pp; + if (args[0] == '=') { + args++; + if (!TryParseIntBase0(, )) + return AMR_BAD; + *pp = args; + } + if (!ModChain_ShouldEval(ch)) + return AMR_OK; + if (stat(Expr_Str(expr), ) < 0) { + if (i < 0) + time(_mtime); + else + st.st_mtime = (time_t)i; + } + snprintf(buf, sizeof(buf), "%u", (unsigned)st.st_mtime); + Expr_SetValueOwn(expr, bmake_strdup(buf)); + return AMR_OK; +} + static void ParsePatternFlags(const char **pp, PatternFlags *pflags, bool *oneBigWord) { @@ -3815,6 +3848,8 @@ ApplyModifier(const char **pp, ModChain case
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Sun May 7 16:43:50 UTC 2023 Modified Files: src/usr.bin/make: make.1 Log Message: make.1: lose the trailing blank lines To generate a diff of this commit: cvs rdiff -u -r1.362 -r1.363 src/usr.bin/make/make.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Sun May 7 16:43:50 UTC 2023 Modified Files: src/usr.bin/make: make.1 Log Message: make.1: lose the trailing blank lines To generate a diff of this commit: cvs rdiff -u -r1.362 -r1.363 src/usr.bin/make/make.1 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.362 src/usr.bin/make/make.1:1.363 --- src/usr.bin/make/make.1:1.362 Sun May 7 16:32:47 2023 +++ src/usr.bin/make/make.1 Sun May 7 16:43:50 2023 @@ -1,4 +1,4 @@ -.\" $NetBSD: make.1,v 1.362 2023/05/07 16:32:47 sjg Exp $ +.\" $NetBSD: make.1,v 1.363 2023/05/07 16:43:50 sjg Exp $ .\" .\" Copyright (c) 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -2727,5 +2727,3 @@ using that token pool to abort the build Sometimes the attempt to suppress a cascade of unnecessary errors, can result in a seemingly unexplained .Ql *** Error code 6 - -
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Sun May 7 16:32:48 UTC 2023 Modified Files: src/usr.bin/make: make.1 Log Message: make: fix description of .PREFIX For at least 20 years, the setting of .PREFIX in make has not matched the documentation. Since the documented behavior does not match reality or POSIX make, fix the documentation. In FindDepsRegularPath str_basename is applied to .PREFIX this is wrong, but I was unable to verify fixing it was benign in NetBSD build - my NetBSD box (7.2) was unable to build known-good src with or without any patches. For now just document the behavior more accurately. To generate a diff of this commit: cvs rdiff -u -r1.361 -r1.362 src/usr.bin/make/make.1 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.361 src/usr.bin/make/make.1:1.362 --- src/usr.bin/make/make.1:1.361 Thu Mar 23 03:29:28 2023 +++ src/usr.bin/make/make.1 Sun May 7 16:32:47 2023 @@ -1,4 +1,4 @@ -.\" $NetBSD: make.1,v 1.361 2023/03/23 03:29:28 sjg Exp $ +.\" $NetBSD: make.1,v 1.362 2023/05/07 16:32:47 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 March 22, 2023 +.Dd May 6, 2023 .Dt MAKE 1 .Os .Sh NAME @@ -796,12 +796,10 @@ The list of sources for this target that known as .Sq Va \&? . .It Va .PREFIX -The file prefix of the target, containing only the file portion, no suffix -or preceding directory components; also known as +The name of the target with suffix (if declared in +.Ic .SUFFIXES ) +removed; also known as .Sq Va * . -The suffix must be one of the known suffixes declared with -.Ic .SUFFIXES , -or it is not recognized. .It Va .TARGET The name of the target; also known as .Sq Va @ .
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Sun May 7 16:32:48 UTC 2023 Modified Files: src/usr.bin/make: make.1 Log Message: make: fix description of .PREFIX For at least 20 years, the setting of .PREFIX in make has not matched the documentation. Since the documented behavior does not match reality or POSIX make, fix the documentation. In FindDepsRegularPath str_basename is applied to .PREFIX this is wrong, but I was unable to verify fixing it was benign in NetBSD build - my NetBSD box (7.2) was unable to build known-good src with or without any patches. For now just document the behavior more accurately. To generate a diff of this commit: cvs rdiff -u -r1.361 -r1.362 src/usr.bin/make/make.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Thu May 4 22:31:17 UTC 2023 Modified Files: src/usr.bin/make: compat.c Log Message: Compat_RunCommand mark bp volatile gcc 4.8.5 (NetBSD 7.2) gets upset about bp. To generate a diff of this commit: cvs rdiff -u -r1.246 -r1.247 src/usr.bin/make/compat.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/compat.c diff -u src/usr.bin/make/compat.c:1.246 src/usr.bin/make/compat.c:1.247 --- src/usr.bin/make/compat.c:1.246 Sat Mar 18 22:20:11 2023 +++ src/usr.bin/make/compat.c Thu May 4 22:31:17 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: compat.c,v 1.246 2023/03/18 22:20:11 sjg Exp $ */ +/* $NetBSD: compat.c,v 1.247 2023/05/04 22:31:17 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -91,7 +91,7 @@ #include "pathnames.h" /* "@(#)compat.c 8.2 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: compat.c,v 1.246 2023/03/18 22:20:11 sjg Exp $"); +MAKE_RCSID("$NetBSD: compat.c,v 1.247 2023/05/04 22:31:17 sjg Exp $"); static GNode *curTarg = NULL; static pid_t compatChild; @@ -221,7 +221,7 @@ bool Compat_RunCommand(const char *cmdp, GNode *gn, StringListNode *ln) { char *cmdStart; /* Start of expanded command */ - char *bp; + char *volatile bp; bool silent; /* Don't print command */ bool doIt; /* Execute even if -n */ volatile bool errCheck; /* Check errors */
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Thu May 4 22:31:17 UTC 2023 Modified Files: src/usr.bin/make: compat.c Log Message: Compat_RunCommand mark bp volatile gcc 4.8.5 (NetBSD 7.2) gets upset about bp. To generate a diff of this commit: cvs rdiff -u -r1.246 -r1.247 src/usr.bin/make/compat.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Thu Mar 23 03:29:28 UTC 2023 Modified Files: src/usr.bin/make: make.1 Log Message: Document unexplained *** Error code 6 To generate a diff of this commit: cvs rdiff -u -r1.360 -r1.361 src/usr.bin/make/make.1 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.360 src/usr.bin/make/make.1:1.361 --- src/usr.bin/make/make.1:1.360 Thu Jan 26 20:48:17 2023 +++ src/usr.bin/make/make.1 Thu Mar 23 03:29:28 2023 @@ -1,4 +1,4 @@ -.\" $NetBSD: make.1,v 1.360 2023/01/26 20:48:17 sjg Exp $ +.\" $NetBSD: make.1,v 1.361 2023/03/23 03:29:28 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 January 26, 2023 +.Dd March 22, 2023 .Dt MAKE 1 .Os .Sh NAME @@ -267,7 +267,9 @@ cooperate to avoid overloading the syste Specify the maximum number of jobs that .Nm may have running at any one time. -The value is saved in +The value of +.Ar max_jobs +is saved in .Va .MAKE.JOBS . Turns compatibility mode off, unless the .Fl B @@ -280,6 +282,13 @@ command invocation and then expect to st on the next line. It is more efficient to correct the scripts rather than turn backwards compatibility on. +.Pp +A job token pool with +.Ar max_jobs +tokens is used to control the total number of jobs running. +Each instance of +.Nm +will wait for a token from the pool before running a new job. .It Fl k Continue processing after errors are encountered, but only on those targets that do not depend on the target whose creation caused the error. @@ -2710,3 +2719,15 @@ In many places just counts {} and () in order to find the end of a variable expansion. .Pp There is no way of escaping a space character in a filename. +.Pp +In jobs mode, when a target fails; +.Nm +will put an error token into the job token pool. +This will cause all other instances of +.Nm +using that token pool to abort the build and exit with error code 6. +Sometimes the attempt to suppress a cascade of unnecessary errors, +can result in a seemingly unexplained +.Ql *** Error code 6 + +
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Thu Mar 23 03:29:28 UTC 2023 Modified Files: src/usr.bin/make: make.1 Log Message: Document unexplained *** Error code 6 To generate a diff of this commit: cvs rdiff -u -r1.360 -r1.361 src/usr.bin/make/make.1 Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Sat Mar 18 22:20:12 UTC 2023 Modified Files: src/usr.bin/make: compat.c src/usr.bin/make/unit-tests: cmd-interrupt.exp cmd-interrupt.mk deptgt-delete_on_error.exp Log Message: make: handle .PHONY consitently on interrupt JobDeleteTarget skips .PHONY targets CompatDeleteTarget should do the same This addresses https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=269663 To generate a diff of this commit: cvs rdiff -u -r1.245 -r1.246 src/usr.bin/make/compat.c cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/cmd-interrupt.exp \ src/usr.bin/make/unit-tests/deptgt-delete_on_error.exp cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/cmd-interrupt.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/compat.c diff -u src/usr.bin/make/compat.c:1.245 src/usr.bin/make/compat.c:1.246 --- src/usr.bin/make/compat.c:1.245 Tue Feb 14 21:38:31 2023 +++ src/usr.bin/make/compat.c Sat Mar 18 22:20:11 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: compat.c,v 1.245 2023/02/14 21:38:31 rillig Exp $ */ +/* $NetBSD: compat.c,v 1.246 2023/03/18 22:20:11 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -91,7 +91,7 @@ #include "pathnames.h" /* "@(#)compat.c 8.2 (Berkeley) 3/19/94" */ -MAKE_RCSID("$NetBSD: compat.c,v 1.245 2023/02/14 21:38:31 rillig Exp $"); +MAKE_RCSID("$NetBSD: compat.c,v 1.246 2023/03/18 22:20:11 sjg Exp $"); static GNode *curTarg = NULL; static pid_t compatChild; @@ -104,7 +104,8 @@ static int compatSigno; static void CompatDeleteTarget(GNode *gn) { - if (gn != NULL && !GNode_IsPrecious(gn)) { + if (gn != NULL && !GNode_IsPrecious(gn) && + (gn->type & OP_PHONY) == 0) { const char *file = GNode_VarTarget(gn); if (!opts.noExecute && unlink_file(file) == 0) { Index: src/usr.bin/make/unit-tests/cmd-interrupt.exp diff -u src/usr.bin/make/unit-tests/cmd-interrupt.exp:1.2 src/usr.bin/make/unit-tests/cmd-interrupt.exp:1.3 --- src/usr.bin/make/unit-tests/cmd-interrupt.exp:1.2 Fri Aug 28 18:16:22 2020 +++ src/usr.bin/make/unit-tests/cmd-interrupt.exp Sat Mar 18 22:20:12 2023 @@ -2,7 +2,6 @@ make: *** cmd-interrupt-ordinary removed interrupt-ordinary: ok > cmd-interrupt-phony -make: *** cmd-interrupt-phony removed interrupt-phony: ok > cmd-interrupt-precious interrupt-precious: ok Index: src/usr.bin/make/unit-tests/deptgt-delete_on_error.exp diff -u src/usr.bin/make/unit-tests/deptgt-delete_on_error.exp:1.2 src/usr.bin/make/unit-tests/deptgt-delete_on_error.exp:1.3 --- src/usr.bin/make/unit-tests/deptgt-delete_on_error.exp:1.2 Sun Oct 25 21:31:00 2020 +++ src/usr.bin/make/unit-tests/deptgt-delete_on_error.exp Sat Mar 18 22:20:12 2023 @@ -7,10 +7,8 @@ make: *** deptgt-delete_on_error-regular make: *** deptgt-delete_on_error-regular-delete removed > deptgt-delete_on_error-phony; false *** Error code 1 (continuing) -make: *** deptgt-delete_on_error-phony removed > deptgt-delete_on_error-phony-delete; false *** Error code 1 (continuing) -make: *** deptgt-delete_on_error-phony-delete removed > deptgt-delete_on_error-precious; false *** Error code 1 (continuing) > deptgt-delete_on_error-precious-delete; false Index: src/usr.bin/make/unit-tests/cmd-interrupt.mk diff -u src/usr.bin/make/unit-tests/cmd-interrupt.mk:1.3 src/usr.bin/make/unit-tests/cmd-interrupt.mk:1.4 --- src/usr.bin/make/unit-tests/cmd-interrupt.mk:1.3 Sun Nov 15 14:07:53 2020 +++ src/usr.bin/make/unit-tests/cmd-interrupt.mk Sat Mar 18 22:20:12 2023 @@ -1,4 +1,4 @@ -# $NetBSD: cmd-interrupt.mk,v 1.3 2020/11/15 14:07:53 rillig Exp $ +# $NetBSD: cmd-interrupt.mk,v 1.4 2023/03/18 22:20:12 sjg Exp $ # # Tests for interrupting a command. # @@ -30,7 +30,7 @@ interrupt-ordinary: interrupt-phony: .PHONY @${.MAKE} ${MAKEFLAGS} -f ${MAKEFILE} cmd-interrupt-phony || true # The ././ is necessary to work around the file cache. - @echo ${.TARGET}: ${exists(././cmd-interrupt-phony) :? error : ok } + @echo ${.TARGET}: ${exists(././cmd-interrupt-phony) :? ok : error } interrupt-precious: .PRECIOUS @${.MAKE} ${MAKEFLAGS} -f ${MAKEFILE} cmd-interrupt-precious || true
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Sat Mar 18 22:20:12 UTC 2023 Modified Files: src/usr.bin/make: compat.c src/usr.bin/make/unit-tests: cmd-interrupt.exp cmd-interrupt.mk deptgt-delete_on_error.exp Log Message: make: handle .PHONY consitently on interrupt JobDeleteTarget skips .PHONY targets CompatDeleteTarget should do the same This addresses https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=269663 To generate a diff of this commit: cvs rdiff -u -r1.245 -r1.246 src/usr.bin/make/compat.c cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/cmd-interrupt.exp \ src/usr.bin/make/unit-tests/deptgt-delete_on_error.exp cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/cmd-interrupt.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Re: CVS commit: src/usr.bin/make
Taylor R Campbell wrote: > That said, I don't see any reason why this should be a macro in the > first place. If there is a compelling reason, please write it down; > if not, please change it to a static function: > Sure. > static BuildMon * > BM(Job *job) > { > > return (job != NULL ? >bm : ); > }
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Tue Feb 28 06:04:28 UTC 2023 Modified Files: src/usr.bin/make: meta.c Log Message: Use inline function rather that macro BM To generate a diff of this commit: cvs rdiff -u -r1.203 -r1.204 src/usr.bin/make/meta.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/meta.c diff -u src/usr.bin/make/meta.c:1.203 src/usr.bin/make/meta.c:1.204 --- src/usr.bin/make/meta.c:1.203 Sat Feb 25 22:52:21 2023 +++ src/usr.bin/make/meta.c Tue Feb 28 06:04:28 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: meta.c,v 1.203 2023/02/25 22:52:21 sjg Exp $ */ +/* $NetBSD: meta.c,v 1.204 2023/02/28 06:04:28 sjg Exp $ */ /* * Implement 'meta' mode. @@ -99,8 +99,6 @@ extern char**environ; # define strsep(s, d) stresep((s), (d), '\0') #endif -#define BM(job) (job != NULL) ? >bm : - /* * Filemon is a kernel module which snoops certain syscalls. * @@ -636,6 +634,13 @@ meta_mode_init(const char *make_mode) metaCmpFilter = Var_Exists(SCOPE_GLOBAL, MAKE_META_CMP_FILTER); } +MAKE_INLINE BuildMon * +BM(Job *job) +{ + + return ((job != NULL) ? >bm : ); +} + /* * In each case below we allow for job==NULL */
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Tue Feb 28 06:04:28 UTC 2023 Modified Files: src/usr.bin/make: meta.c Log Message: Use inline function rather that macro BM To generate a diff of this commit: cvs rdiff -u -r1.203 -r1.204 src/usr.bin/make/meta.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Sat Feb 25 22:52:22 UTC 2023 Modified Files: src/usr.bin/make: meta.c Log Message: meta.c: use macro to access job->bm and if job is NULL use Mybm. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.202 -r1.203 src/usr.bin/make/meta.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Sat Feb 25 22:52:22 UTC 2023 Modified Files: src/usr.bin/make: meta.c Log Message: meta.c: use macro to access job->bm and if job is NULL use Mybm. No functional change. To generate a diff of this commit: cvs rdiff -u -r1.202 -r1.203 src/usr.bin/make/meta.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/meta.c diff -u src/usr.bin/make/meta.c:1.202 src/usr.bin/make/meta.c:1.203 --- src/usr.bin/make/meta.c:1.202 Tue Feb 14 21:38:31 2023 +++ src/usr.bin/make/meta.c Sat Feb 25 22:52:21 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: meta.c,v 1.202 2023/02/14 21:38:31 rillig Exp $ */ +/* $NetBSD: meta.c,v 1.203 2023/02/25 22:52:21 sjg Exp $ */ /* * Implement 'meta' mode. @@ -99,6 +99,8 @@ extern char**environ; # define strsep(s, d) stresep((s), (d), '\0') #endif +#define BM(job) (job != NULL) ? >bm : + /* * Filemon is a kernel module which snoops certain syscalls. * @@ -642,11 +644,7 @@ meta_job_start(Job *job, GNode *gn) { BuildMon *pbm; -if (job != NULL) { - pbm = >bm; -} else { - pbm = -} +pbm = BM(job); pbm->mfp = meta_create(pbm, gn); #ifdef USE_FILEMON_ONCE /* compat mode we open the filemon dev once per command */ @@ -673,11 +671,7 @@ meta_job_child(Job *job MAKE_ATTR_UNUSED #ifdef USE_FILEMON BuildMon *pbm; -if (job != NULL) { - pbm = >bm; -} else { - pbm = -} +pbm = BM(job); if (pbm->mfp != NULL) { close(fileno(pbm->mfp)); if (useFilemon && pbm->filemon != NULL) { @@ -698,11 +692,7 @@ meta_job_parent(Job *job MAKE_ATTR_UNUSE #if defined(USE_FILEMON) && !defined(USE_FILEMON_DEV) BuildMon *pbm; -if (job != NULL) { - pbm = >bm; -} else { - pbm = -} +pbm = BM(job); if (useFilemon && pbm->filemon != NULL) { filemon_setpid_parent(pbm->filemon, pid); } @@ -715,11 +705,7 @@ meta_job_fd(Job *job MAKE_ATTR_UNUSED) #if defined(USE_FILEMON) && !defined(USE_FILEMON_DEV) BuildMon *pbm; -if (job != NULL) { - pbm = >bm; -} else { - pbm = -} +pbm = BM(job); if (useFilemon && pbm->filemon != NULL) { return filemon_readfd(pbm->filemon); } @@ -733,11 +719,7 @@ meta_job_event(Job *job MAKE_ATTR_UNUSED #if defined(USE_FILEMON) && !defined(USE_FILEMON_DEV) BuildMon *pbm; -if (job != NULL) { - pbm = >bm; -} else { - pbm = -} +pbm = BM(job); if (useFilemon && pbm->filemon != NULL) { return filemon_process(pbm->filemon); } @@ -751,13 +733,9 @@ meta_job_error(Job *job, GNode *gn, bool char cwd[MAXPATHLEN]; BuildMon *pbm; -if (job != NULL) { - pbm = >bm; - if (gn == NULL) +pbm = BM(job); +if (job != NULL && gn == NULL) gn = job->node; -} else { - pbm = -} if (pbm->mfp != NULL) { fprintf(pbm->mfp, "\n*** Error code %d%s\n", status, ignerr ? "(ignored)" : ""); @@ -779,11 +757,7 @@ meta_job_output(Job *job, char *cp, cons { BuildMon *pbm; -if (job != NULL) { - pbm = >bm; -} else { - pbm = -} +pbm = BM(job); if (pbm->mfp != NULL) { if (metaVerbose) { static char *meta_prefix = NULL; @@ -851,11 +825,7 @@ meta_job_finish(Job *job) int error = 0; int x; -if (job != NULL) { - pbm = >bm; -} else { - pbm = -} +pbm = BM(job); if (pbm->mfp != NULL) { error = meta_cmd_finish(pbm); x = fclose(pbm->mfp);
CVS commit: src/tests/usr.bin/make
Module Name:src Committed By: sjg Date: Sat Feb 25 19:37:33 UTC 2023 Modified Files: src/tests/usr.bin/make: t_make.sh Log Message: t_make skip varname-dot-make-meta-ignore_* The meta-ignore tests will likely not work in this environment so skip them. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/tests/usr.bin/make/t_make.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/tests/usr.bin/make/t_make.sh diff -u src/tests/usr.bin/make/t_make.sh:1.16 src/tests/usr.bin/make/t_make.sh:1.17 --- src/tests/usr.bin/make/t_make.sh:1.16 Thu Jan 19 23:26:15 2023 +++ src/tests/usr.bin/make/t_make.sh Sat Feb 25 19:37:33 2023 @@ -1,4 +1,4 @@ -# $NetBSD: t_make.sh,v 1.16 2023/01/19 23:26:15 rillig Exp $ +# $NetBSD: t_make.sh,v 1.17 2023/02/25 19:37:33 sjg Exp $ # # Copyright (c) 2008, 2010, 2014, 2023 The NetBSD Foundation, Inc. # All rights reserved. @@ -71,6 +71,10 @@ atf_init_test_cases() basename="${filename##*/}" basename="${basename%.mk}" + case "${basename}" in + varname-dot-make-meta-ignore*) continue;; # won't work + esac + atfname=${basename} while :; do case "${atfname}" in
CVS commit: src/tests/usr.bin/make
Module Name:src Committed By: sjg Date: Sat Feb 25 19:37:33 UTC 2023 Modified Files: src/tests/usr.bin/make: t_make.sh Log Message: t_make skip varname-dot-make-meta-ignore_* The meta-ignore tests will likely not work in this environment so skip them. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/tests/usr.bin/make/t_make.sh Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: sjg Date: Sat Feb 25 19:30:32 UTC 2023 Modified Files: src/usr.bin/make/unit-tests: Makefile meta-ignore.inc varname-dot-make-meta-ignore_filter.exp varname-dot-make-meta-ignore_paths.exp varname-dot-make-meta-ignore_patterns.exp Log Message: make: meta-ignore tests will not work if TMPDIR is /tmp Since /tmp and /var/tmp are always part of .MAKE.META.IGNORE_PATHS the varname-dot-make-meta-ignore_* tests will not work if TMPDIR is either (or subdir) of those. To generate a diff of this commit: cvs rdiff -u -r1.332 -r1.333 src/usr.bin/make/unit-tests/Makefile cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/meta-ignore.inc cvs rdiff -u -r1.2 -r1.3 \ src/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_filter.exp \ src/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_paths.exp \ src/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_patterns.exp 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/unit-tests/Makefile diff -u src/usr.bin/make/unit-tests/Makefile:1.332 src/usr.bin/make/unit-tests/Makefile:1.333 --- src/usr.bin/make/unit-tests/Makefile:1.332 Thu Feb 23 05:20:45 2023 +++ src/usr.bin/make/unit-tests/Makefile Sat Feb 25 19:30:32 2023 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.332 2023/02/23 05:20:45 sjg Exp $ +# $NetBSD: Makefile,v 1.333 2023/02/25 19:30:32 sjg Exp $ # # Unit tests for make(1) # @@ -33,6 +33,21 @@ .MAKE.OS?= ${uname -s:L:sh} .MAKE.UID?= ${id -u:L:sh} +# for many tests we need a TMPDIR that will not collide +# with other users. +.if ${.OBJDIR} != ${.CURDIR} +# easy +TMPDIR:= ${.OBJDIR}/tmp +.elif defined(TMPDIR) +TMPDIR:= ${TMPDIR}/uid${.MAKE.UID} +.else +TMPDIR:= /tmp/uid${.MAKE.UID} +.endif +# make sure it exists +.if !exist(${TMPDIR}) +_!= mkdir -p ${TMPDIR} +.endif + # Each test is in a sub-makefile. # Keep the list sorted. # Any test that is commented out must be ignored in @@ -405,7 +420,9 @@ TESTS+= varname-dot-make-makefiles TESTS+= varname-dot-make-meta-bailiwick TESTS+= varname-dot-make-meta-created TESTS+= varname-dot-make-meta-files -.if ${.MAKE.PATH_FILEMON:Uno:Nktrace:N/dev*} == "" +.if ${.MAKE.PATH_FILEMON:Uno:Nktrace:N/dev*} == "" && ${TMPDIR:N/tmp*:N/var/tmp*} != "" +# these tests will not work if TMPDIR is or is a subdir of +# /tmp or /var/tmp TESTS+= varname-dot-make-meta-ignore_filter TESTS+= varname-dot-make-meta-ignore_paths TESTS+= varname-dot-make-meta-ignore_patterns @@ -667,22 +684,6 @@ LC_ALL= C LANG= C .export LANG LC_ALL - -# for many tests we need a TMPDIR that will not collide -# with other users. -.if ${.OBJDIR} != ${.CURDIR} -# easy -TMPDIR:= ${.OBJDIR}/tmp -.elif defined(TMPDIR) -TMPDIR:= ${TMPDIR}/uid${.MAKE.UID} -.else -TMPDIR:= /tmp/uid${.MAKE.UID} -.endif -# make sure it exists -.if !exist(${TMPDIR}) -_!= mkdir -p ${TMPDIR} -.endif - # Some Linux systems such as Fedora have deprecated egrep in favor of grep -E. .if ${.MAKE.OS:NLinux} == "" EGREP= grep -E Index: src/usr.bin/make/unit-tests/meta-ignore.inc diff -u src/usr.bin/make/unit-tests/meta-ignore.inc:1.1 src/usr.bin/make/unit-tests/meta-ignore.inc:1.2 --- src/usr.bin/make/unit-tests/meta-ignore.inc:1.1 Thu Feb 23 05:21:27 2023 +++ src/usr.bin/make/unit-tests/meta-ignore.inc Sat Feb 25 19:30:32 2023 @@ -1,9 +1,11 @@ -# $NetBSD: meta-ignore.inc,v 1.1 2023/02/23 05:21:27 sjg Exp $ +# $NetBSD: meta-ignore.inc,v 1.2 2023/02/25 19:30:32 sjg Exp $ # common logic for testing .MAKE.META.IGNORE_* # we want a directory outside of .OBJDIR to drop a file # that our meta file refers to. +# Note: these tests will not work if TMPDIR is /tmp or /var/tmp +# or a subdir thereof IGNORE:= ${TMPDIR}/ignore OBJ:= ${TMPDIR}/obj @@ -18,11 +20,11 @@ setup: @rm -f ${OBJ}/check-ignore makefile:= ${.INCLUDEDFROMDIR}/${.INCLUDEDFROMFILE} -TEST:= ${.INCLUDEDFROMFILE:R} +TEST:= ${.INCLUDEDFROMFILE:R:C,.*meta-,,:S,-,_,g:tu} DESC.one= Initialize check-ignore.meta -DESC.two= Use .MAKE.META.IGNORE_* - check-ignore is up to date -DESC.three= Skip .MAKE.META.IGNORE_* - check-ignore is out of date +DESC.two= Use .MAKE.META.${TEST} - check-ignore is up to date +DESC.three= Skip .MAKE.META.${TEST} - check-ignore is out of date # just in case someone runs us with -jN .ORDER: one two three @@ -35,16 +37,16 @@ one two three: .MAKE setup .MAKE.MODE = meta verbose silent=yes .OBJDIR: ${OBJ} .if ${parent} == "two" -.if ${TEST:M*ignore_paths} != "" +.if ${TEST} == "IGNORE_PATHS" # this is a prefix list - any path that matches # one of these prefixes will be ignored .MAKE.META.IGNORE_PATHS = ${IGNORE} -.elif ${TEST:M*ignore_patterns} != "" +.elif ${TEST} == "IGNORE_PATTERNS" # more flexible but more expensive # this example is equivalent to M*/ignore/* # a match means ignore .MAKE.META.IGNORE_PATTERNS = */ignore/* -.elif ${TEST:M*ignore_filter} != "" +.elif
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: sjg Date: Sat Feb 25 19:30:32 UTC 2023 Modified Files: src/usr.bin/make/unit-tests: Makefile meta-ignore.inc varname-dot-make-meta-ignore_filter.exp varname-dot-make-meta-ignore_paths.exp varname-dot-make-meta-ignore_patterns.exp Log Message: make: meta-ignore tests will not work if TMPDIR is /tmp Since /tmp and /var/tmp are always part of .MAKE.META.IGNORE_PATHS the varname-dot-make-meta-ignore_* tests will not work if TMPDIR is either (or subdir) of those. To generate a diff of this commit: cvs rdiff -u -r1.332 -r1.333 src/usr.bin/make/unit-tests/Makefile cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/meta-ignore.inc cvs rdiff -u -r1.2 -r1.3 \ src/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_filter.exp \ src/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_paths.exp \ src/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_patterns.exp Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: sjg Date: Thu Feb 23 05:21:27 UTC 2023 Added Files: src/usr.bin/make/unit-tests: meta-ignore.inc Log Message: Add unit-tests for .MAKE.META.IGNORE_* These unit-tests should only be run if TEST_MAKE has a valid .MAKE.PATH_FILEMON to indicate that filemon is supported. All three tests use the same meta-ignore.inc which runs three sub-makes one to initialize the target .meta file two to ignore a file using .MAKE.META.IGNORE_{PATHS,PATTERNS,FILTER} three to verify that without .MAKE.META.IGNORE_* the target is out of date. Fix the order of _SED_CMDS to avoid errors when ${MAKE:T} appears in .OBJDIR To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/meta-ignore.inc Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Added files: Index: src/usr.bin/make/unit-tests/meta-ignore.inc diff -u /dev/null src/usr.bin/make/unit-tests/meta-ignore.inc:1.1 --- /dev/null Thu Feb 23 05:21:27 2023 +++ src/usr.bin/make/unit-tests/meta-ignore.inc Thu Feb 23 05:21:27 2023 @@ -0,0 +1,61 @@ +# $NetBSD: meta-ignore.inc,v 1.1 2023/02/23 05:21:27 sjg Exp $ + +# common logic for testing .MAKE.META.IGNORE_* + +# we want a directory outside of .OBJDIR to drop a file +# that our meta file refers to. +IGNORE:= ${TMPDIR}/ignore +OBJ:= ${TMPDIR}/obj + +# this is always ignored so make sure it isn't used above +TMPDIR= /tmp/nothanks + +all: one two three + +setup: + @mkdir -p ${IGNORE} ${OBJ} + @echo > ${IGNORE}/check + @rm -f ${OBJ}/check-ignore + +makefile:= ${.INCLUDEDFROMDIR}/${.INCLUDEDFROMFILE} +TEST:= ${.INCLUDEDFROMFILE:R} + +DESC.one= Initialize check-ignore.meta +DESC.two= Use .MAKE.META.IGNORE_* - check-ignore is up to date +DESC.three= Skip .MAKE.META.IGNORE_* - check-ignore is out of date + +# just in case someone runs us with -jN +.ORDER: one two three +one two three: .MAKE setup + @echo "${DESC.${.TARGET}}"; \ + ${MAKE} -C ${.CURDIR} -f ${makefile} check-ignore parent=${.TARGET} + +.if make(check-ignore) +.MAKEFLAGS: -dM +.MAKE.MODE = meta verbose silent=yes +.OBJDIR: ${OBJ} +.if ${parent} == "two" +.if ${TEST:M*ignore_paths} != "" +# this is a prefix list - any path that matches +# one of these prefixes will be ignored +.MAKE.META.IGNORE_PATHS = ${IGNORE} +.elif ${TEST:M*ignore_patterns} != "" +# more flexible but more expensive +# this example is equivalent to M*/ignore/* +# a match means ignore +.MAKE.META.IGNORE_PATTERNS = */ignore/* +.elif ${TEST:M*ignore_filter} != "" +# this is the most flexible, but also most expensive +# if this expands to nothing - ignore the path +.MAKE.META.IGNORE_FILTER = N${IGNORE}/* +.endif +.endif + +# : < just reads from ${IGNORE}/check +# so that our filemon trace will have a reference to it +# we ensure it is always newer than the target. +check-ignore: .META .NOPATH + @: < ${IGNORE}/check > ${.TARGET} + @sleep 1; echo ${.TARGET} > ${IGNORE}/check + +.endif
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: sjg Date: Thu Feb 23 05:21:27 UTC 2023 Added Files: src/usr.bin/make/unit-tests: meta-ignore.inc Log Message: Add unit-tests for .MAKE.META.IGNORE_* These unit-tests should only be run if TEST_MAKE has a valid .MAKE.PATH_FILEMON to indicate that filemon is supported. All three tests use the same meta-ignore.inc which runs three sub-makes one to initialize the target .meta file two to ignore a file using .MAKE.META.IGNORE_{PATHS,PATTERNS,FILTER} three to verify that without .MAKE.META.IGNORE_* the target is out of date. Fix the order of _SED_CMDS to avoid errors when ${MAKE:T} appears in .OBJDIR To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/meta-ignore.inc Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: sjg Date: Thu Feb 23 05:20:45 UTC 2023 Modified Files: src/usr.bin/make/unit-tests: Makefile varname-dot-make-meta-ignore_filter.exp varname-dot-make-meta-ignore_filter.mk varname-dot-make-meta-ignore_paths.exp varname-dot-make-meta-ignore_paths.mk varname-dot-make-meta-ignore_patterns.exp varname-dot-make-meta-ignore_patterns.mk Log Message: Add unit-tests for .MAKE.META.IGNORE_* These unit-tests should only be run if TEST_MAKE has a valid .MAKE.PATH_FILEMON to indicate that filemon is supported. All three tests use the same meta-ignore.inc which runs three sub-makes one to initialize the target .meta file two to ignore a file using .MAKE.META.IGNORE_{PATHS,PATTERNS,FILTER} three to verify that without .MAKE.META.IGNORE_* the target is out of date. Fix the order of _SED_CMDS to avoid errors when ${MAKE:T} appears in .OBJDIR To generate a diff of this commit: cvs rdiff -u -r1.331 -r1.332 src/usr.bin/make/unit-tests/Makefile cvs rdiff -u -r1.1 -r1.2 \ src/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_filter.exp \ src/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_paths.exp \ src/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_patterns.exp cvs rdiff -u -r1.2 -r1.3 \ src/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_filter.mk \ src/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_paths.mk \ src/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_patterns.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/unit-tests/Makefile diff -u src/usr.bin/make/unit-tests/Makefile:1.331 src/usr.bin/make/unit-tests/Makefile:1.332 --- src/usr.bin/make/unit-tests/Makefile:1.331 Tue Jan 24 00:24:02 2023 +++ src/usr.bin/make/unit-tests/Makefile Thu Feb 23 05:20:45 2023 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.331 2023/01/24 00:24:02 sjg Exp $ +# $NetBSD: Makefile,v 1.332 2023/02/23 05:20:45 sjg Exp $ # # Unit tests for make(1) # @@ -405,12 +405,14 @@ TESTS+= varname-dot-make-makefiles TESTS+= varname-dot-make-meta-bailiwick TESTS+= varname-dot-make-meta-created TESTS+= varname-dot-make-meta-files +.if ${.MAKE.PATH_FILEMON:Uno:Nktrace:N/dev*} == "" TESTS+= varname-dot-make-meta-ignore_filter TESTS+= varname-dot-make-meta-ignore_paths TESTS+= varname-dot-make-meta-ignore_patterns +TESTS+= varname-dot-make-path_filemon +.endif TESTS+= varname-dot-make-meta-prefix TESTS+= varname-dot-make-mode -TESTS+= varname-dot-make-path_filemon TESTS+= varname-dot-make-pid TESTS+= varname-dot-make-ppid TESTS+= varname-dot-make-save_dollars @@ -501,6 +503,10 @@ SED_CMDS.job-output-long-lines= \ ${:D marker should always be at the beginning of the line. } \ -e '/^aa*--- job-b ---$$/d' \ -e '/^bb*--- job-a ---$$/d' + +# meta line numbers can vary based on filemon implementation +SED_CMDS.meta-ignore= -e 's,\(\.meta:\) [1-9][0-9]*:,\1 :,' + SED_CMDS.opt-chdir= -e 's,\(nonexistent\).[1-9][0-9]*,\1,' SED_CMDS.opt-debug-graph1= ${STD_SED_CMDS.dg1} SED_CMDS.opt-debug-graph2= ${STD_SED_CMDS.dg2} @@ -533,6 +539,9 @@ SED_CMDS.var-op-shell+= -e '/command/s, SED_CMDS.vardebug+= -e 's,${.SHELL},,' SED_CMDS.varmod-subst-regex+= ${STD_SED_CMDS.regex} SED_CMDS.varparse-errors+= ${STD_SED_CMDS.timestamp} +SED_CMDS.varname-dot-make-meta-ignore_filter+= ${SED_CMDS.meta-ignore} +SED_CMDS.varname-dot-make-meta-ignore_paths+= ${SED_CMDS.meta-ignore} +SED_CMDS.varname-dot-make-meta-ignore_patterns+= ${SED_CMDS.meta-ignore} SED_CMDS.varname-dot-parsedir= -e '/in some cases/ s,^make: "[^"]*,make: ",' SED_CMDS.varname-dot-parsefile= -e '/in some cases/ s,^make: "[^"]*,make: ",' SED_CMDS.varname-dot-shell= -e 's, = /[^ ]*, = (details omitted),g' @@ -713,23 +722,23 @@ LIMIT_RESOURCES?= : # Postprocess the test output to make the output platform-independent. # -# always pretend .MAKE was called 'make' -_SED_CMDS+= -e 's,^${TEST_MAKE:T:S,.,\\.,g}[][0-9]*:,make:,' -_SED_CMDS+= -e 's,${TEST_MAKE:S,.,\\.,g},make,' -_SED_CMDS+= -e 's,^usage: ${TEST_MAKE:T:S,.,\\.,g} ,usage: make ,' -# replace anything after 'stopped in' with unit-tests +# Replace anything after 'stopped in' with unit-tests _SED_CMDS+= -e '/stopped/s, /.*, unit-tests,' # Allow the test files to be placed anywhere. _SED_CMDS+= -e 's,\(\.PARSEDIR}\) = `'"/[^']*'"',\1 = ,' _SED_CMDS+= -e 's,\(\.INCLUDEDFROMDIR}\) = `'"/[^']*'"',\1 = ,' -_SED_CMDS+= -e 's,${TMPDIR},,g' +_SED_CMDS+= -e 's,${TMPDIR},,g' -e 's,${TMPDIR:tA},,g' # canonicalize ${.OBJDIR} and ${.CURDIR} +_SED_CMDS+= -e 's,${.CURDIR},,g' .if ${.OBJDIR} != ${.CURDIR} # yes this is inaccurate but none of the tests expect anywhere # which we get depending on how MAKEOBJDIR is set. -_SED_CMDS+= -e 's,${.OBJDIR},,g' +_SED_CMDS+= -e 's,${.OBJDIR},,g' -e 's,${.OBJDIR:tA},,g' .endif -_SED_CMDS+= -e 's,${.CURDIR},,g'
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: sjg Date: Thu Feb 23 05:20:45 UTC 2023 Modified Files: src/usr.bin/make/unit-tests: Makefile varname-dot-make-meta-ignore_filter.exp varname-dot-make-meta-ignore_filter.mk varname-dot-make-meta-ignore_paths.exp varname-dot-make-meta-ignore_paths.mk varname-dot-make-meta-ignore_patterns.exp varname-dot-make-meta-ignore_patterns.mk Log Message: Add unit-tests for .MAKE.META.IGNORE_* These unit-tests should only be run if TEST_MAKE has a valid .MAKE.PATH_FILEMON to indicate that filemon is supported. All three tests use the same meta-ignore.inc which runs three sub-makes one to initialize the target .meta file two to ignore a file using .MAKE.META.IGNORE_{PATHS,PATTERNS,FILTER} three to verify that without .MAKE.META.IGNORE_* the target is out of date. Fix the order of _SED_CMDS to avoid errors when ${MAKE:T} appears in .OBJDIR To generate a diff of this commit: cvs rdiff -u -r1.331 -r1.332 src/usr.bin/make/unit-tests/Makefile cvs rdiff -u -r1.1 -r1.2 \ src/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_filter.exp \ src/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_paths.exp \ src/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_patterns.exp cvs rdiff -u -r1.2 -r1.3 \ src/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_filter.mk \ src/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_paths.mk \ src/usr.bin/make/unit-tests/varname-dot-make-meta-ignore_patterns.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Thu Feb 9 07:34:15 UTC 2023 Modified Files: src/usr.bin/make: var.c src/usr.bin/make/unit-tests: varmod-remember.mk Log Message: make: ApplyModifier_Remember always use SCOPE_GLOBAL Conditionals evaluate vars with SCOPE_CMDLINE, if :_ is used within a conditional expression and is thus set in SCOPE_CMDLINE, it breaks any use of :_ in SCOPE_GLOBAL. The simplest solution is for :_ to always use SCOPE_GLOBAL Reviewed by: rillig To generate a diff of this commit: cvs rdiff -u -r1.1039 -r1.1040 src/usr.bin/make/var.c cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/varmod-remember.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/var.c diff -u src/usr.bin/make/var.c:1.1039 src/usr.bin/make/var.c:1.1040 --- src/usr.bin/make/var.c:1.1039 Thu Jan 26 20:48:17 2023 +++ src/usr.bin/make/var.c Thu Feb 9 07:34:15 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.1039 2023/01/26 20:48:17 sjg Exp $ */ +/* $NetBSD: var.c,v 1.1040 2023/02/09 07:34:15 sjg 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.1039 2023/01/26 20:48:17 sjg Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.1040 2023/02/09 07:34:15 sjg Exp $"); /* * Variables are defined using one of the VAR=value assignments. Their @@ -3578,7 +3578,7 @@ ApplyModifier_Remember(const char **pp, *pp = mod + 1; if (Expr_ShouldEval(expr)) - Var_Set(expr->scope, name.str, Expr_Str(expr)); + Var_Set(SCOPE_GLOBAL, name.str, Expr_Str(expr)); FStr_Done(); return AMR_OK; Index: src/usr.bin/make/unit-tests/varmod-remember.mk diff -u src/usr.bin/make/unit-tests/varmod-remember.mk:1.6 src/usr.bin/make/unit-tests/varmod-remember.mk:1.7 --- src/usr.bin/make/unit-tests/varmod-remember.mk:1.6 Sun Mar 14 17:27:27 2021 +++ src/usr.bin/make/unit-tests/varmod-remember.mk Thu Feb 9 07:34:15 2023 @@ -1,8 +1,14 @@ -# $NetBSD: varmod-remember.mk,v 1.6 2021/03/14 17:27:27 rillig Exp $ +# $NetBSD: varmod-remember.mk,v 1.7 2023/02/09 07:34:15 sjg Exp $ # # Tests for the :_ modifier, which saves the current variable value # in the _ variable or another, to be used later again. +# this should result in "1=A 2=B 3=C" +ABC= ${A B C:L:_:range:@i@$i=${_:[$i]}@} + +# we compare this with a repeat later +x:= ${ABC} + .if ${1 2 3:L:_:@var@${_}@} != "1 2 3 1 2 3 1 2 3" . error .endif @@ -32,4 +38,10 @@ S= INDIRECT_VARNAME . error .endif +# we *should* get the same result as for $x above +X:= ${ABC} +.if $X != $x +. error +.endif + all:
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Thu Feb 9 07:34:15 UTC 2023 Modified Files: src/usr.bin/make: var.c src/usr.bin/make/unit-tests: varmod-remember.mk Log Message: make: ApplyModifier_Remember always use SCOPE_GLOBAL Conditionals evaluate vars with SCOPE_CMDLINE, if :_ is used within a conditional expression and is thus set in SCOPE_CMDLINE, it breaks any use of :_ in SCOPE_GLOBAL. The simplest solution is for :_ to always use SCOPE_GLOBAL Reviewed by: rillig To generate a diff of this commit: cvs rdiff -u -r1.1039 -r1.1040 src/usr.bin/make/var.c cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/varmod-remember.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Thu Jan 26 20:48:18 UTC 2023 Modified Files: src/usr.bin/make: main.c make.1 make.h var.c src/usr.bin/make/unit-tests: varname-dot-newline.exp varname-dot-newline.mk Log Message: make: some variables should be read-only Make variables like .newline and .MAKE.{GID,PID,PPID,UID} read-only. Reviewed by: rillig To generate a diff of this commit: cvs rdiff -u -r1.588 -r1.589 src/usr.bin/make/main.c cvs rdiff -u -r1.359 -r1.360 src/usr.bin/make/make.1 cvs rdiff -u -r1.310 -r1.311 src/usr.bin/make/make.h cvs rdiff -u -r1.1038 -r1.1039 src/usr.bin/make/var.c cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/varname-dot-newline.exp cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/varname-dot-newline.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/main.c diff -u src/usr.bin/make/main.c:1.588 src/usr.bin/make/main.c:1.589 --- src/usr.bin/make/main.c:1.588 Tue Jan 24 00:24:02 2023 +++ src/usr.bin/make/main.c Thu Jan 26 20:48:17 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.588 2023/01/24 00:24:02 sjg Exp $ */ +/* $NetBSD: main.c,v 1.589 2023/01/26 20:48:17 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.588 2023/01/24 00:24:02 sjg Exp $"); +MAKE_RCSID("$NetBSD: main.c,v 1.589 2023/01/26 20:48:17 sjg Exp $"); #if defined(MAKE_NATIVE) && !defined(lint) __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 " "The Regents of the University of California. " @@ -1346,13 +1346,13 @@ main_Init(int argc, char **argv) */ Targ_Init(); Var_Init(); - Global_Set(".MAKE.OS", utsname.sysname); + Global_Set_ReadOnly(".MAKE.OS", utsname.sysname); Global_Set("MACHINE", machine); Global_Set("MACHINE_ARCH", machine_arch); #ifdef MAKE_VERSION Global_Set("MAKE_VERSION", MAKE_VERSION); #endif - Global_Set(".newline", "\n"); /* handy for :@ loops */ + Global_Set_ReadOnly(".newline", "\n"); /* handy for :@ loops */ #ifndef MAKEFILE_PREFERENCE_LIST /* This is the traditional preference for makefiles. */ # define MAKEFILE_PREFERENCE_LIST "makefile Makefile" @@ -1398,13 +1398,13 @@ main_Init(int argc, char **argv) snprintf(buf, sizeof buf, "%d", makelevel); Global_Set(MAKE_LEVEL, buf); snprintf(buf, sizeof buf, "%u", myPid); - Global_Set(".MAKE.PID", buf); + Global_Set_ReadOnly(".MAKE.PID", buf); snprintf(buf, sizeof buf, "%u", getppid()); - Global_Set(".MAKE.PPID", buf); + Global_Set_ReadOnly(".MAKE.PPID", buf); snprintf(buf, sizeof buf, "%u", getuid()); - Global_Set(".MAKE.UID", buf); + Global_Set_ReadOnly(".MAKE.UID", buf); snprintf(buf, sizeof buf, "%u", getgid()); - Global_Set(".MAKE.GID", buf); + Global_Set_ReadOnly(".MAKE.GID", buf); } if (makelevel > 0) { char pn[1024]; Index: src/usr.bin/make/make.1 diff -u src/usr.bin/make/make.1:1.359 src/usr.bin/make/make.1:1.360 --- src/usr.bin/make/make.1:1.359 Tue Jan 24 00:24:02 2023 +++ src/usr.bin/make/make.1 Thu Jan 26 20:48:17 2023 @@ -1,4 +1,4 @@ -.\" $NetBSD: make.1,v 1.359 2023/01/24 00:24:02 sjg Exp $ +.\" $NetBSD: make.1,v 1.360 2023/01/26 20:48:17 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 January 23, 2023 +.Dd January 26, 2023 .Dt MAKE 1 .Os .Sh NAME @@ -940,6 +940,7 @@ executes. .It Va .MAKE.GID The numeric group ID of the user running .Nm . +It is read-only. .It Va .MAKE.JOB.PREFIX If .Nm @@ -1130,6 +1131,7 @@ Used to create files in a separate direc .It Va .MAKE.OS The name of the operating system, see .Xr uname 1 . +It is read-only. .It Va .MAKEOVERRIDES This variable is used to record the names of variables assigned to on the command line, so that they may be exported as part of @@ -1154,9 +1156,11 @@ This allows makefiles to test for this s .It Va .MAKE.PID The process ID of .Nm . +It is read-only. .It Va .MAKE.PPID The parent process ID of .Nm . +It is read-only. .It Va MAKE_PRINT_VAR_ON_ERROR When .Nm @@ -1198,6 +1202,7 @@ treated as normal sources. .It Va .MAKE.UID The numeric ID of the user running .Nm . +It is read-only. .\" 'MAKE_VERSION' is intentionally undocumented .\" since it is only defined in the bmake distribution, .\" but not in NetBSD's native make. @@ -1209,6 +1214,7 @@ The numeric ID of the user running .\" since it is obsolete. .It Va .newline This variable is simply assigned a newline character as its value. +It is read-only. This allows expansions using the .Cm \&:@ modifier to put a newline between Index: src/usr.bin/make/make.h diff -u src/usr.bin/make/make.h:1.310 src/usr.bin/make/make.h:1.311 --- src/usr.bin/make/make.h:1.310 Mon Jan 23 23:01:52 2023 +++ src/usr.bin/make/make.h
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Thu Jan 26 20:48:18 UTC 2023 Modified Files: src/usr.bin/make: main.c make.1 make.h var.c src/usr.bin/make/unit-tests: varname-dot-newline.exp varname-dot-newline.mk Log Message: make: some variables should be read-only Make variables like .newline and .MAKE.{GID,PID,PPID,UID} read-only. Reviewed by: rillig To generate a diff of this commit: cvs rdiff -u -r1.588 -r1.589 src/usr.bin/make/main.c cvs rdiff -u -r1.359 -r1.360 src/usr.bin/make/make.1 cvs rdiff -u -r1.310 -r1.311 src/usr.bin/make/make.h cvs rdiff -u -r1.1038 -r1.1039 src/usr.bin/make/var.c cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/varname-dot-newline.exp cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/varname-dot-newline.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Tue Jan 24 00:24:02 UTC 2023 Modified Files: src/usr.bin/make: dir.c dir.h main.c make.1 parse.c src/usr.bin/make/unit-tests: Makefile dir.mk opt-debug-graph1.exp opt-debug-graph2.exp opt-debug-graph3.exp suff-main-several.exp suff-transform-debug.exp Log Message: make: .SYSPATH: to add dirs to sysIncPath .SYSPATH: with no sources will clear sysIncPath otherwise sources are added Reviewed by: rillig To generate a diff of this commit: cvs rdiff -u -r1.279 -r1.280 src/usr.bin/make/dir.c cvs rdiff -u -r1.46 -r1.47 src/usr.bin/make/dir.h cvs rdiff -u -r1.587 -r1.588 src/usr.bin/make/main.c cvs rdiff -u -r1.358 -r1.359 src/usr.bin/make/make.1 cvs rdiff -u -r1.691 -r1.692 src/usr.bin/make/parse.c cvs rdiff -u -r1.330 -r1.331 src/usr.bin/make/unit-tests/Makefile cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/dir.mk cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/opt-debug-graph1.exp cvs rdiff -u -r1.5 -r1.6 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.8 -r1.9 src/usr.bin/make/unit-tests/suff-main-several.exp 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/dir.c diff -u src/usr.bin/make/dir.c:1.279 src/usr.bin/make/dir.c:1.280 --- src/usr.bin/make/dir.c:1.279 Sat May 7 21:19:43 2022 +++ src/usr.bin/make/dir.c Tue Jan 24 00:24:02 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.279 2022/05/07 21:19:43 rillig Exp $ */ +/* $NetBSD: dir.c,v 1.280 2023/01/24 00:24:02 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -138,7 +138,7 @@ #include "job.h" /* "@(#)dir.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: dir.c,v 1.279 2022/05/07 21:19:43 rillig Exp $"); +MAKE_RCSID("$NetBSD: dir.c,v 1.280 2023/01/24 00:24:02 sjg Exp $"); /* * A search path is a list of CachedDir structures. A CachedDir has in it the @@ -577,6 +577,21 @@ Dir_SetPATH(void) } } + +void +Dir_SetSYSPATH(void) +{ + CachedDirListNode *ln; + + Var_ReadOnly(".SYSPATH", false); + Global_Delete(".SYSPATH"); + for (ln = sysIncPath->dirs.first; ln != NULL; ln = ln->next) { + CachedDir *dir = ln->datum; + Global_Append(".SYSPATH", dir->name); + } + Var_ReadOnly(".SYSPATH", true); +} + /* * See if the given name has any wildcard characters in it and all braces and * brackets are properly balanced. Index: src/usr.bin/make/dir.h diff -u src/usr.bin/make/dir.h:1.46 src/usr.bin/make/dir.h:1.47 --- src/usr.bin/make/dir.h:1.46 Wed Dec 15 12:08:25 2021 +++ src/usr.bin/make/dir.h Tue Jan 24 00:24:02 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: dir.h,v 1.46 2021/12/15 12:08:25 rillig Exp $ */ +/* $NetBSD: dir.h,v 1.47 2023/01/24 00:24:02 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -82,6 +82,7 @@ void Dir_InitCur(const char *); void Dir_InitDot(void); void Dir_End(void); void Dir_SetPATH(void); +void Dir_SetSYSPATH(void); bool Dir_HasWildcards(const char *) MAKE_ATTR_USE; void SearchPath_Expand(SearchPath *, const char *, StringList *); char *Dir_FindFile(const char *, SearchPath *) MAKE_ATTR_USE; Index: src/usr.bin/make/main.c diff -u src/usr.bin/make/main.c:1.587 src/usr.bin/make/main.c:1.588 --- src/usr.bin/make/main.c:1.587 Thu Jan 19 21:33:06 2023 +++ src/usr.bin/make/main.c Tue Jan 24 00:24:02 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.587 2023/01/19 21:33:06 rillig Exp $ */ +/* $NetBSD: main.c,v 1.588 2023/01/24 00:24:02 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.587 2023/01/19 21:33:06 rillig Exp $"); +MAKE_RCSID("$NetBSD: main.c,v 1.588 2023/01/24 00:24:02 sjg Exp $"); #if defined(MAKE_NATIVE) && !defined(lint) __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 " "The Regents of the University of California. " @@ -428,6 +428,7 @@ MainParseArgSysInc(const char *argvalue) } Global_Append(MAKEFLAGS, "-m"); Global_Append(MAKEFLAGS, argvalue); + Dir_SetSYSPATH(); } static bool @@ -1477,6 +1478,10 @@ static void main_ReadFiles(void) { + if (Lst_IsEmpty(>dirs)) + SearchPath_AddAll(sysIncPath, defSysIncPath); + + Dir_SetSYSPATH(); if (!opts.noBuiltins) ReadBuiltinRules(); Index: src/usr.bin/make/make.1 diff -u src/usr.bin/make/make.1:1.358 src/usr.bin/make/make.1:1.359 --- src/usr.bin/make/make.1:1.358 Mon Jan 23 23:01:52 2023 +++ src/usr.bin/make/make.1 Tue Jan 24 00:24:02 2023 @@ -1,4 +1,4 @@ -.\" $NetBSD: make.1,v 1.358 2023/01/23 23:01:52 sjg Exp $ +.\" $NetBSD: make.1,v 1.359 2023/01/24 00:24:02 sjg Exp $ .\" .\" Copyright (c) 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -299,6
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Tue Jan 24 00:24:02 UTC 2023 Modified Files: src/usr.bin/make: dir.c dir.h main.c make.1 parse.c src/usr.bin/make/unit-tests: Makefile dir.mk opt-debug-graph1.exp opt-debug-graph2.exp opt-debug-graph3.exp suff-main-several.exp suff-transform-debug.exp Log Message: make: .SYSPATH: to add dirs to sysIncPath .SYSPATH: with no sources will clear sysIncPath otherwise sources are added Reviewed by: rillig To generate a diff of this commit: cvs rdiff -u -r1.279 -r1.280 src/usr.bin/make/dir.c cvs rdiff -u -r1.46 -r1.47 src/usr.bin/make/dir.h cvs rdiff -u -r1.587 -r1.588 src/usr.bin/make/main.c cvs rdiff -u -r1.358 -r1.359 src/usr.bin/make/make.1 cvs rdiff -u -r1.691 -r1.692 src/usr.bin/make/parse.c cvs rdiff -u -r1.330 -r1.331 src/usr.bin/make/unit-tests/Makefile cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/dir.mk cvs rdiff -u -r1.10 -r1.11 src/usr.bin/make/unit-tests/opt-debug-graph1.exp cvs rdiff -u -r1.5 -r1.6 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.8 -r1.9 src/usr.bin/make/unit-tests/suff-main-several.exp Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: sjg Date: Tue Jan 24 00:20:00 UTC 2023 Added Files: src/usr.bin/make/unit-tests: var-readonly.exp var-readonly.mk Log Message: Add the unit tests To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/var-readonly.exp \ src/usr.bin/make/unit-tests/var-readonly.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Added files: Index: src/usr.bin/make/unit-tests/var-readonly.exp diff -u /dev/null src/usr.bin/make/unit-tests/var-readonly.exp:1.1 --- /dev/null Tue Jan 24 00:20:00 2023 +++ src/usr.bin/make/unit-tests/var-readonly.exp Tue Jan 24 00:20:00 2023 @@ -0,0 +1 @@ +exit status 0 Index: src/usr.bin/make/unit-tests/var-readonly.mk diff -u /dev/null src/usr.bin/make/unit-tests/var-readonly.mk:1.1 --- /dev/null Tue Jan 24 00:20:00 2023 +++ src/usr.bin/make/unit-tests/var-readonly.mk Tue Jan 24 00:20:00 2023 @@ -0,0 +1,20 @@ +# $NetBSD: var-readonly.mk,v 1.1 2023/01/24 00:20:00 sjg Exp $ + +# the answer +N = 42 +.READONLY: N +# this should be ignored +N = 666 +.if ${N} != 42 +.error N ($N) should be 42 +.endif + +.NOREADONLY: N +# now we can change it +N = 69 +.if ${N} == 42 +.error N should not be 42 +.endif + +all: +
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: sjg Date: Tue Jan 24 00:20:00 UTC 2023 Added Files: src/usr.bin/make/unit-tests: var-readonly.exp var-readonly.mk Log Message: Add the unit tests To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/var-readonly.exp \ src/usr.bin/make/unit-tests/var-readonly.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Tue Jan 24 00:19:15 UTC 2023 Modified Files: src/usr.bin/make: var.c Log Message: make: log adjustments of var.readOnly To generate a diff of this commit: cvs rdiff -u -r1.1037 -r1.1038 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/var.c diff -u src/usr.bin/make/var.c:1.1037 src/usr.bin/make/var.c:1.1038 --- src/usr.bin/make/var.c:1.1037 Mon Jan 23 23:01:52 2023 +++ src/usr.bin/make/var.c Tue Jan 24 00:19:14 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.1037 2023/01/23 23:01:52 sjg Exp $ */ +/* $NetBSD: var.c,v 1.1038 2023/01/24 00:19:14 sjg 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.1037 2023/01/23 23:01:52 sjg Exp $"); +MAKE_RCSID("$NetBSD: var.c,v 1.1038 2023/01/24 00:19:14 sjg Exp $"); /* * Variables are defined using one of the VAR=value assignments. Their @@ -192,6 +192,7 @@ typedef struct Var { * The variable value cannot be changed anymore, and the variable * cannot be deleted. Any attempts to do so are silently ignored, * they are logged with -dv though. + * Use .[NO]READONLY: to adjust. * * See VAR_SET_READONLY. */ @@ -1235,6 +1236,7 @@ Var_ReadOnly(const char *name, bool bf) return; } v->readOnly = bf; + DEBUG2(VAR, "Var_ReadOnly: %s %s\n", name, bf ? "true" : "false"); } /*
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Tue Jan 24 00:19:15 UTC 2023 Modified Files: src/usr.bin/make: var.c Log Message: make: log adjustments of var.readOnly To generate a diff of this commit: cvs rdiff -u -r1.1037 -r1.1038 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.
CVS commit: src
Module Name:src Committed By: sjg Date: Mon Jan 23 23:01:53 UTC 2023 Modified Files: src/distrib/sets/lists/tests: mi src/usr.bin/make: make.1 make.h parse.c var.c src/usr.bin/make/unit-tests: Makefile Log Message: make: .[NO]READONLY for control of read-only variables Reviewed by: rillig To generate a diff of this commit: cvs rdiff -u -r1.1247 -r1.1248 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.357 -r1.358 src/usr.bin/make/make.1 cvs rdiff -u -r1.309 -r1.310 src/usr.bin/make/make.h cvs rdiff -u -r1.690 -r1.691 src/usr.bin/make/parse.c cvs rdiff -u -r1.1036 -r1.1037 src/usr.bin/make/var.c cvs rdiff -u -r1.329 -r1.330 src/usr.bin/make/unit-tests/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/distrib/sets/lists/tests/mi diff -u src/distrib/sets/lists/tests/mi:1.1247 src/distrib/sets/lists/tests/mi:1.1248 --- src/distrib/sets/lists/tests/mi:1.1247 Sun Jan 22 17:17:24 2023 +++ src/distrib/sets/lists/tests/mi Mon Jan 23 23:01:52 2023 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1247 2023/01/22 17:17:24 rillig Exp $ +# $NetBSD: mi,v 1.1248 2023/01/23 23:01:52 sjg Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -6036,6 +6036,8 @@ ./usr/tests/usr.bin/make/unit-tests/var-op-sunsh.mktests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/var-op.exp tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/var-op.mk tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/make/unit-tests/var-readonly.exptests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/make/unit-tests/var-readonly.mktests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/var-recursive.exptests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/var-recursive.mktests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/var-scope-cmdline.exp tests-usr.bin-tests compattestfile,atf Index: src/usr.bin/make/make.1 diff -u src/usr.bin/make/make.1:1.357 src/usr.bin/make/make.1:1.358 --- src/usr.bin/make/make.1:1.357 Sun Jan 1 21:02:09 2023 +++ src/usr.bin/make/make.1 Mon Jan 23 23:01:52 2023 @@ -1,4 +1,4 @@ -.\" $NetBSD: make.1,v 1.357 2023/01/01 21:02:09 rillig Exp $ +.\" $NetBSD: make.1,v 1.358 2023/01/23 23:01:52 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 January 1, 2023 +.Dd January 23, 2023 .Dt MAKE 1 .Os .Sh NAME @@ -2390,6 +2390,8 @@ Disable parallel mode. Synonym for .Ic .NOTPARALLEL , for compatibility with other pmake variants. +.It Ic .NOREADONLY +clear the read-only attribute from the global variables specified as sources. .It Ic .OBJDIR The source is a new value for .Sq Va .OBJDIR . @@ -2458,6 +2460,8 @@ attribute to any specified sources. If no sources are specified, the .Ic .PRECIOUS attribute is applied to every target in the file. +.It Ic .READONLY +set the read-only attribute on the global variables specified as sources. .It Ic .SHELL Sets the shell that .Nm Index: src/usr.bin/make/make.h diff -u src/usr.bin/make/make.h:1.309 src/usr.bin/make/make.h:1.310 --- src/usr.bin/make/make.h:1.309 Thu Jan 19 21:33:06 2023 +++ src/usr.bin/make/make.h Mon Jan 23 23:01:52 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: make.h,v 1.309 2023/01/19 21:33:06 rillig Exp $ */ +/* $NetBSD: make.h,v 1.310 2023/01/23 23:01:52 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -1026,6 +1026,7 @@ void Var_ReexportVars(void); void Var_Export(VarExportMode, const char *); void Var_ExportVars(const char *); void Var_UnExport(bool, const char *); +void Var_ReadOnly(const char *, bool); void Global_Set(const char *, const char *); void Global_Append(const char *, const char *); Index: src/usr.bin/make/parse.c diff -u src/usr.bin/make/parse.c:1.690 src/usr.bin/make/parse.c:1.691 --- src/usr.bin/make/parse.c:1.690 Tue Jan 3 00:00:45 2023 +++ src/usr.bin/make/parse.c Mon Jan 23 23:01:52 2023 @@ -1,4 +1,4 @@ -/* $NetBSD: parse.c,v 1.690 2023/01/03 00:00:45 rillig Exp $ */ +/* $NetBSD: parse.c,v 1.691 2023/01/23 23:01:52 sjg 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.690 2023/01/03 00:00:45 rillig Exp $"); +MAKE_RCSID("$NetBSD: parse.c,v 1.691 2023/01/23 23:01:52 sjg Exp $"); /* * A file being read. @@ -149,6 +149,7 @@ typedef enum ParseSpecial { SP_NOMETA, /* .NOMETA */ SP_NOMETA_CMP, /* .NOMETA_CMP */ SP_NOPATH, /* .NOPATH */ + SP_NOREADONLY, /* .NOREADONLY */ SP_NOT, /* Not special */ SP_NOTPARALLEL, /* .NOTPARALLEL or .NO_PARALLEL */ SP_NULL, /* .NULL; not mentioned in the manual page */ @@ -161,6 +162,7 @@ typedef enum
CVS commit: src
Module Name:src Committed By: sjg Date: Mon Jan 23 23:01:53 UTC 2023 Modified Files: src/distrib/sets/lists/tests: mi src/usr.bin/make: make.1 make.h parse.c var.c src/usr.bin/make/unit-tests: Makefile Log Message: make: .[NO]READONLY for control of read-only variables Reviewed by: rillig To generate a diff of this commit: cvs rdiff -u -r1.1247 -r1.1248 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.357 -r1.358 src/usr.bin/make/make.1 cvs rdiff -u -r1.309 -r1.310 src/usr.bin/make/make.h cvs rdiff -u -r1.690 -r1.691 src/usr.bin/make/parse.c cvs rdiff -u -r1.1036 -r1.1037 src/usr.bin/make/var.c cvs rdiff -u -r1.329 -r1.330 src/usr.bin/make/unit-tests/Makefile Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Wed Sep 28 16:34:47 UTC 2022 Modified Files: src/usr.bin/make: main.c meta.c Log Message: Don't ignore return from snprintf or getcwd To generate a diff of this commit: cvs rdiff -u -r1.582 -r1.583 src/usr.bin/make/main.c cvs rdiff -u -r1.200 -r1.201 src/usr.bin/make/meta.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Wed Sep 28 16:34:47 UTC 2022 Modified Files: src/usr.bin/make: main.c meta.c Log Message: Don't ignore return from snprintf or getcwd To generate a diff of this commit: cvs rdiff -u -r1.582 -r1.583 src/usr.bin/make/main.c cvs rdiff -u -r1.200 -r1.201 src/usr.bin/make/meta.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/main.c diff -u src/usr.bin/make/main.c:1.582 src/usr.bin/make/main.c:1.583 --- src/usr.bin/make/main.c:1.582 Sat May 7 17:49:47 2022 +++ src/usr.bin/make/main.c Wed Sep 28 16:34:47 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.582 2022/05/07 17:49:47 rillig Exp $ */ +/* $NetBSD: main.c,v 1.583 2022/09/28 16:34:47 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.582 2022/05/07 17:49:47 rillig Exp $"); +MAKE_RCSID("$NetBSD: main.c,v 1.583 2022/09/28 16:34:47 sjg Exp $"); #if defined(MAKE_NATIVE) && !defined(lint) __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 " "The Regents of the University of California. " @@ -704,8 +704,10 @@ Main_SetObjdir(bool writable, const char va_end(ap); if (path[0] != '/') { - snprintf(buf2, MAXPATHLEN, "%s/%s", curdir, path); - path = buf2; + if (snprintf(buf2, MAXPATHLEN, "%s/%s", curdir, path) <= MAXPATHLEN) + path = buf2; + else + return false; } /* look for the directory and try to chdir there */ Index: src/usr.bin/make/meta.c diff -u src/usr.bin/make/meta.c:1.200 src/usr.bin/make/meta.c:1.201 --- src/usr.bin/make/meta.c:1.200 Fri Apr 15 12:28:16 2022 +++ src/usr.bin/make/meta.c Wed Sep 28 16:34:47 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: meta.c,v 1.200 2022/04/15 12:28:16 rillig Exp $ */ +/* $NetBSD: meta.c,v 1.201 2022/09/28 16:34:47 sjg Exp $ */ /* * Implement 'meta' mode. @@ -274,15 +274,19 @@ meta_name(char *mname, size_t mnamelen, /* on some systems dirname may modify its arg */ tp = bmake_strdup(tname); dtp = dirname(tp); -if (strcmp(dname, dtp) == 0) - snprintf(mname, mnamelen, "%s.meta", tname); -else { +if (strcmp(dname, dtp) == 0) { + if (snprintf(mname, mnamelen, "%s.meta", tname) >= (int)mnamelen) + mname[mnamelen - 1] = '\0'; +} else { + int x; + ldname = strlen(dname); if (strncmp(dname, dtp, ldname) == 0 && dtp[ldname] == '/') - snprintf(mname, mnamelen, "%s/%s.meta", dname, [ldname+1]); + x = snprintf(mname, mnamelen, "%s/%s.meta", dname, [ldname+1]); else - snprintf(mname, mnamelen, "%s/%s.meta", dname, tname); - + x = snprintf(mname, mnamelen, "%s/%s.meta", dname, tname); + if (x >= (int)mnamelen) + mname[mnamelen - 1] = '\0'; /* * Replace path separators in the file name after the * current object directory path. @@ -762,7 +766,9 @@ meta_job_error(Job *job, GNode *gn, bool } if (gn != NULL) Global_Set(".ERROR_TARGET", GNode_Path(gn)); -getcwd(cwd, sizeof cwd); +if (getcwd(cwd, sizeof cwd) == NULL) + Punt("Cannot get cwd: %s", strerror(errno)); + Global_Set(".ERROR_CWD", cwd); if (pbm->meta_fname[0] != '\0') { Global_Set(".ERROR_META_FILE", pbm->meta_fname); @@ -1436,18 +1442,18 @@ meta_oodate(GNode *gn, bool oodate) continue; /* no point */ /* Check vs latestdir */ - snprintf(fname1, sizeof fname1, "%s/%s", latestdir, p); - sdirs[sdx++] = fname1; + if (snprintf(fname1, sizeof fname1, "%s/%s", latestdir, p) < (int)(sizeof fname1)) +sdirs[sdx++] = fname1; if (strcmp(latestdir, lcwd) != 0) { /* Check vs lcwd */ -snprintf(fname2, sizeof fname2, "%s/%s", lcwd, p); -sdirs[sdx++] = fname2; +if (snprintf(fname2, sizeof fname2, "%s/%s", lcwd, p) < (int)(sizeof fname2)) +sdirs[sdx++] = fname2; } if (strcmp(lcwd, cwd) != 0) { /* Check vs cwd */ -snprintf(fname3, sizeof fname3, "%s/%s", cwd, p); -sdirs[sdx++] = fname3; +if (snprintf(fname3, sizeof fname3, "%s/%s", cwd, p) < (int)(sizeof fname3)) +sdirs[sdx++] = fname3; } } sdirs[sdx++] = NULL;
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Fri Sep 23 22:58:15 UTC 2022 Modified Files: src/usr.bin/make: cond.c make.h parse.c Log Message: Cond_reset_depth just use cond_min_depth To avoid errors from unclosed conditionals on .break it is sufficient to just set cond_depth = cond_min_depth. Patch from rillig To generate a diff of this commit: cvs rdiff -u -r1.337 -r1.338 src/usr.bin/make/cond.c cvs rdiff -u -r1.304 -r1.305 src/usr.bin/make/make.h cvs rdiff -u -r1.683 -r1.684 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.
CVS commit: src/usr.bin/make
Module Name:src Committed By: sjg Date: Fri Sep 23 22:58:15 UTC 2022 Modified Files: src/usr.bin/make: cond.c make.h parse.c Log Message: Cond_reset_depth just use cond_min_depth To avoid errors from unclosed conditionals on .break it is sufficient to just set cond_depth = cond_min_depth. Patch from rillig To generate a diff of this commit: cvs rdiff -u -r1.337 -r1.338 src/usr.bin/make/cond.c cvs rdiff -u -r1.304 -r1.305 src/usr.bin/make/make.h cvs rdiff -u -r1.683 -r1.684 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/cond.c diff -u src/usr.bin/make/cond.c:1.337 src/usr.bin/make/cond.c:1.338 --- src/usr.bin/make/cond.c:1.337 Thu Sep 8 05:52:56 2022 +++ src/usr.bin/make/cond.c Fri Sep 23 22:58:15 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: cond.c,v 1.337 2022/09/08 05:52:56 rillig Exp $ */ +/* $NetBSD: cond.c,v 1.338 2022/09/23 22:58:15 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -95,7 +95,7 @@ #include "dir.h" /* "@(#)cond.c 8.2 (Berkeley) 1/2/94" */ -MAKE_RCSID("$NetBSD: cond.c,v 1.337 2022/09/08 05:52:56 rillig Exp $"); +MAKE_RCSID("$NetBSD: cond.c,v 1.338 2022/09/23 22:58:15 sjg Exp $"); /* * Conditional expressions conform to this grammar: @@ -1284,7 +1284,7 @@ Cond_save_depth(void) * when the loop started. */ void -Cond_reset_depth(unsigned int depth) +Cond_reset_depth(void) { -cond_depth = depth; +cond_depth = cond_min_depth; } Index: src/usr.bin/make/make.h diff -u src/usr.bin/make/make.h:1.304 src/usr.bin/make/make.h:1.305 --- src/usr.bin/make/make.h:1.304 Fri Sep 2 16:24:31 2022 +++ src/usr.bin/make/make.h Fri Sep 23 22:58:15 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: make.h,v 1.304 2022/09/02 16:24:31 sjg Exp $ */ +/* $NetBSD: make.h,v 1.305 2022/09/23 22:58:15 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -800,7 +800,7 @@ void Compat_Make(GNode *, GNode *); CondResult Cond_EvalCondition(const char *) MAKE_ATTR_USE; CondResult Cond_EvalLine(const char *) MAKE_ATTR_USE; void Cond_restore_depth(unsigned int); -void Cond_reset_depth(unsigned int); +void Cond_reset_depth(void); unsigned int Cond_save_depth(void) MAKE_ATTR_USE; /* dir.c; see also dir.h */ Index: src/usr.bin/make/parse.c diff -u src/usr.bin/make/parse.c:1.683 src/usr.bin/make/parse.c:1.684 --- src/usr.bin/make/parse.c:1.683 Sat Sep 3 00:50:07 2022 +++ src/usr.bin/make/parse.c Fri Sep 23 22:58:15 2022 @@ -1,4 +1,4 @@ -/* $NetBSD: parse.c,v 1.683 2022/09/03 00:50:07 rillig Exp $ */ +/* $NetBSD: parse.c,v 1.684 2022/09/23 22:58:15 sjg 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.683 2022/09/03 00:50:07 rillig Exp $"); +MAKE_RCSID("$NetBSD: parse.c,v 1.684 2022/09/23 22:58:15 sjg Exp $"); /* * A file being read. @@ -2669,7 +2669,7 @@ HandleBreak(void) if (curFile->forLoop != NULL) { /* pretend we reached EOF */ For_Break(curFile->forLoop); - Cond_reset_depth(curFile->cond_depth); + Cond_reset_depth(); ParseEOF(); } else Parse_Error(PARSE_FATAL, "break outside of for loop");
CVS commit: src/usr.bin/make/unit-tests
Module Name:src Committed By: sjg Date: Fri Sep 9 18:36:16 UTC 2022 Modified Files: src/usr.bin/make/unit-tests: Makefile export.mk make-exported.mk Log Message: Handle deprecation of egrep To generate a diff of this commit: cvs rdiff -u -r1.324 -r1.325 src/usr.bin/make/unit-tests/Makefile cvs rdiff -u -r1.11 -r1.12 src/usr.bin/make/unit-tests/export.mk cvs rdiff -u -r1.6 -r1.7 src/usr.bin/make/unit-tests/make-exported.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.