Module Name: src Committed By: rillig Date: Fri Jan 10 23:00:38 UTC 2025
Modified Files: src/distrib/sets/lists/tests: mi src/usr.bin/make/unit-tests: Makefile archive.exp archive.mk cond-func-commands.mk cond-func-defined.mk cond-func-empty.mk cond-func-exists.mk cond-func-make.mk cond-func-target.mk cond-token-var.exp cond-token-var.mk deptgt.exp deptgt.mk opt-debug-var.exp opt-debug-var.mk varmod-assign-shell.exp varmod-assign-shell.mk Added Files: src/usr.bin/make/unit-tests: suff.exp suff.mk Log Message: tests/make: test expressions based on undefined variables When an undefined variable is used in a conditional, make complains about "Malformed conditional", which is wrong since the conditional is well-formed but errors out during evaluation. In order to fix this wrong error message and preserve the remaining behavior, cover the places in which an expression is evaluated with undefined expressions being an error (VARE_EVAL_DEFINED), but with neither producing an error message nor handling errors. This combination results in the same behavior as evaluating the expressions in the mode that allows undefined variables to be used in expressions. To generate a diff of this commit: cvs rdiff -u -r1.1355 -r1.1356 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.353 -r1.354 src/usr.bin/make/unit-tests/Makefile cvs rdiff -u -r1.8 -r1.9 src/usr.bin/make/unit-tests/archive.exp cvs rdiff -u -r1.13 -r1.14 src/usr.bin/make/unit-tests/archive.mk \ src/usr.bin/make/unit-tests/cond-func-defined.mk cvs rdiff -u -r1.5 -r1.6 src/usr.bin/make/unit-tests/cond-func-commands.mk \ src/usr.bin/make/unit-tests/cond-func-make.mk \ src/usr.bin/make/unit-tests/cond-token-var.exp cvs rdiff -u -r1.26 -r1.27 src/usr.bin/make/unit-tests/cond-func-empty.mk cvs rdiff -u -r1.7 -r1.8 src/usr.bin/make/unit-tests/cond-func-exists.mk cvs rdiff -u -r1.4 -r1.5 src/usr.bin/make/unit-tests/cond-func-target.mk cvs rdiff -u -r1.9 -r1.10 src/usr.bin/make/unit-tests/cond-token-var.mk \ src/usr.bin/make/unit-tests/varmod-assign-shell.exp \ src/usr.bin/make/unit-tests/varmod-assign-shell.mk cvs rdiff -u -r1.19 -r1.20 src/usr.bin/make/unit-tests/deptgt.exp cvs rdiff -u -r1.21 -r1.22 src/usr.bin/make/unit-tests/deptgt.mk cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/opt-debug-var.exp \ src/usr.bin/make/unit-tests/opt-debug-var.mk cvs rdiff -u -r0 -r1.1 src/usr.bin/make/unit-tests/suff.exp \ src/usr.bin/make/unit-tests/suff.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.1355 src/distrib/sets/lists/tests/mi:1.1356 --- src/distrib/sets/lists/tests/mi:1.1355 Thu Jan 2 01:45:19 2025 +++ src/distrib/sets/lists/tests/mi Fri Jan 10 23:00:37 2025 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.1355 2025/01/02 01:45:19 kre Exp $ +# $NetBSD: mi,v 1.1356 2025/01/10 23:00:37 rillig Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -6185,6 +6185,8 @@ ./usr/tests/usr.bin/make/unit-tests/suff-transform-select.mk tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/suff-use.exp tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/suff-use.mk tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/make/unit-tests/suff.exp tests-usr.bin-tests compattestfile,atf +./usr/tests/usr.bin/make/unit-tests/suff.mk tests-usr.bin-tests compattestfile,atf ./usr/tests/usr.bin/make/unit-tests/suffixes.exp tests-obsolete obsolete ./usr/tests/usr.bin/make/unit-tests/suffixes.mk tests-obsolete obsolete ./usr/tests/usr.bin/make/unit-tests/sunshcmd.exp tests-usr.bin-tests compattestfile,atf Index: src/usr.bin/make/unit-tests/Makefile diff -u src/usr.bin/make/unit-tests/Makefile:1.353 src/usr.bin/make/unit-tests/Makefile:1.354 --- src/usr.bin/make/unit-tests/Makefile:1.353 Fri Nov 22 05:36:33 2024 +++ src/usr.bin/make/unit-tests/Makefile Fri Jan 10 23:00:38 2025 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.353 2024/11/22 05:36:33 rillig Exp $ +# $NetBSD: Makefile,v 1.354 2025/01/10 23:00:38 rillig Exp $ # # Unit tests for make(1) # @@ -24,7 +24,7 @@ # and it should be added to the TESTS list. # # Any added files must also be added to src/distrib/sets/lists/tests/mi. -# To do that, just run "make sync-mi" in this directory. +# To do that, run "make sync-mi" in this directory. # .MAIN: all @@ -313,6 +313,7 @@ TESTS+= shell-csh TESTS+= shell-custom TESTS+= shell-ksh TESTS+= shell-sh +TESTS+= suff TESTS+= suff-add-later TESTS+= suff-clear-regular TESTS+= suff-clear-single Index: src/usr.bin/make/unit-tests/archive.exp diff -u src/usr.bin/make/unit-tests/archive.exp:1.8 src/usr.bin/make/unit-tests/archive.exp:1.9 --- src/usr.bin/make/unit-tests/archive.exp:1.8 Sat Apr 27 20:23:22 2024 +++ src/usr.bin/make/unit-tests/archive.exp Fri Jan 10 23:00:38 2025 @@ -18,6 +18,18 @@ list-archive-wildcard: archive-suffix.mk list-archive-wildcard: archive.mk list-archive-wildcard: ternary.mk +make: "archive.mk" line 61: Error in source archive spec "libprog.a${UNDEF}(archive.mk) pre post" + in directory <curdir> +make: Fatal errors encountered -- cannot continue +make: stopped making "list-archive-undef-archive" in unit-tests +exit 1 + +make: "archive.mk" line 68: Error in source archive spec "libprog.a" + in directory <curdir> +make: Fatal errors encountered -- cannot continue +make: stopped making "list-archive-undef-member" in unit-tests +exit 1 + Making depend-on-existing-member out-of-date archive.mk depend-on-existing-member Index: src/usr.bin/make/unit-tests/archive.mk diff -u src/usr.bin/make/unit-tests/archive.mk:1.13 src/usr.bin/make/unit-tests/archive.mk:1.14 --- src/usr.bin/make/unit-tests/archive.mk:1.13 Sat Apr 27 20:23:22 2024 +++ src/usr.bin/make/unit-tests/archive.mk Fri Jan 10 23:00:38 2025 @@ -1,4 +1,4 @@ -# $NetBSD: archive.mk,v 1.13 2024/04/27 20:23:22 rillig Exp $ +# $NetBSD: archive.mk,v 1.14 2025/01/10 23:00:38 rillig Exp $ # # Very basic demonstration of handling archives, based on the description # in PSD.doc/tutorial.ms. @@ -21,6 +21,10 @@ all: @${MAKE} -f ${MAKEFILE} create-archive @${MAKE} -f ${MAKEFILE} list-archive @${MAKE} -f ${MAKEFILE} list-archive-wildcard + @${MAKE} -f ${MAKEFILE} list-archive-undef-archive || echo "exit $$?" + @echo + @${MAKE} -f ${MAKEFILE} list-archive-undef-member || echo "exit $$?" + @echo @${MAKE} -f ${MAKEFILE} depend-on-existing-member @${MAKE} -f ${MAKEFILE} depend-on-nonexistent-member @${MAKE} -f ${MAKEFILE} remove-archive @@ -51,6 +55,20 @@ list-archive: ${ARCHIVE} pre post list-archive-wildcard: ${ARCHIVE}([at]*.mk) pre post @printf '%s\n' ${.ALLSRC:O:@member@${.TARGET:Q}': '${member:Q}@} +.if make(list-archive-undef-archive) +# TODO: Be more specific: mention that the variable "UNDEF" is not defined. +# expect+1: Error in source archive spec "libprog.a${UNDEF}(archive.mk) pre post" +list-archive-undef-archive: ${ARCHIVE}$${UNDEF}(archive.mk) pre post + @printf '%s\n' ${.ALLSRC:O:@member@${.TARGET:Q}': '${member:Q}@} +.endif + +.if make(list-archive-undef-member) +# TODO: Be more specific: mention that the variable "UNDEF" is not defined. +# expect+1: Error in source archive spec "libprog.a" +list-archive-undef-member: ${ARCHIVE}(archive$${UNDEF}.mk) pre post + @printf '%s\n' ${.ALLSRC:O:@member@${.TARGET:Q}': '${member:Q}@} +.endif + depend-on-existing-member: ${ARCHIVE}(archive.mk) pre post @echo $@ Index: src/usr.bin/make/unit-tests/cond-func-defined.mk diff -u src/usr.bin/make/unit-tests/cond-func-defined.mk:1.13 src/usr.bin/make/unit-tests/cond-func-defined.mk:1.14 --- src/usr.bin/make/unit-tests/cond-func-defined.mk:1.13 Tue Aug 6 17:46:01 2024 +++ src/usr.bin/make/unit-tests/cond-func-defined.mk Fri Jan 10 23:00:38 2025 @@ -1,4 +1,4 @@ -# $NetBSD: cond-func-defined.mk,v 1.13 2024/08/06 17:46:01 rillig Exp $ +# $NetBSD: cond-func-defined.mk,v 1.14 2025/01/10 23:00:38 rillig Exp $ # # Tests for the defined() function in .if conditions. @@ -49,6 +49,11 @@ ${:UA B}= variable name with spaces . endif .endfor +# Expressions in the argument of a function call don't have to be defined. +.if defined(${UNDEF}) +. error +.endif + # Neither of the conditions is true. Before July 2020, the right-hand # condition was evaluated even though it was irrelevant. .if defined(UNDEF) && ${UNDEF:Mx} != "" Index: src/usr.bin/make/unit-tests/cond-func-commands.mk diff -u src/usr.bin/make/unit-tests/cond-func-commands.mk:1.5 src/usr.bin/make/unit-tests/cond-func-commands.mk:1.6 --- src/usr.bin/make/unit-tests/cond-func-commands.mk:1.5 Sun Nov 15 14:07:53 2020 +++ src/usr.bin/make/unit-tests/cond-func-commands.mk Fri Jan 10 23:00:38 2025 @@ -1,4 +1,4 @@ -# $NetBSD: cond-func-commands.mk,v 1.5 2020/11/15 14:07:53 rillig Exp $ +# $NetBSD: cond-func-commands.mk,v 1.6 2025/01/10 23:00:38 rillig Exp $ # # Tests for the commands() function in .if conditions. @@ -33,5 +33,10 @@ target: . error .endif +# Expressions in the argument of a function call don't have to be defined. +.if commands(${UNDEF}) +. error +.endif + all: @:; Index: src/usr.bin/make/unit-tests/cond-func-make.mk diff -u src/usr.bin/make/unit-tests/cond-func-make.mk:1.5 src/usr.bin/make/unit-tests/cond-func-make.mk:1.6 --- src/usr.bin/make/unit-tests/cond-func-make.mk:1.5 Fri Jun 23 04:56:54 2023 +++ src/usr.bin/make/unit-tests/cond-func-make.mk Fri Jan 10 23:00:38 2025 @@ -1,4 +1,4 @@ -# $NetBSD: cond-func-make.mk,v 1.5 2023/06/23 04:56:54 rillig Exp $ +# $NetBSD: cond-func-make.mk,v 1.6 2025/01/10 23:00:38 rillig Exp $ # # Tests for the make() function in .if conditions, which tests whether # the argument has been passed as a target via the command line or later @@ -25,5 +25,10 @@ . error .endif +# Expressions in the argument of a function call don't have to be defined. +.if make(${UNDEF}) +. error +.endif + via-cmdline via-dot-makeflags: : $@ Index: src/usr.bin/make/unit-tests/cond-token-var.exp diff -u src/usr.bin/make/unit-tests/cond-token-var.exp:1.5 src/usr.bin/make/unit-tests/cond-token-var.exp:1.6 --- src/usr.bin/make/unit-tests/cond-token-var.exp:1.5 Tue Aug 6 18:00:17 2024 +++ src/usr.bin/make/unit-tests/cond-token-var.exp Fri Jan 10 23:00:38 2025 @@ -1,7 +1,18 @@ -make: "cond-token-var.mk" line 21: ok -make: "cond-token-var.mk" line 28: Malformed conditional '${UNDEF} == ${DEF}' -make: "cond-token-var.mk" line 34: Malformed conditional '${DEF} == ${UNDEF}' -make: "cond-token-var.mk" line 44: Malformed conditional '${UNDEF}' +make: "cond-token-var.mk" line 23: ok +make: "cond-token-var.mk" line 30: Malformed conditional '${UNDEF} == ${DEF}' +make: "cond-token-var.mk" line 36: Malformed conditional '${DEF} == ${UNDEF}' +make: "cond-token-var.mk" line 46: Malformed conditional '${UNDEF}' +make: "cond-token-var.mk" line 65: Malformed conditional '$U == $D' +make: "cond-token-var.mk" line 71: Malformed conditional '$D == $U' +make: "cond-token-var.mk" line 81: Malformed conditional '$U' +Var_Parse: ${UNDEF1}y == "${UNDEF2}" || 0x${UNDEF3} (eval-defined) +make: "cond-token-var.mk" line 109: Malformed conditional 'x${UNDEF1}y == "${UNDEF2}" || 0x${UNDEF3}' +Var_Parse: ${DEF}y == "${UNDEF2}" || 0x${UNDEF3} (eval-defined) +make: "cond-token-var.mk" line 114: Malformed conditional 'x${DEF}y == "${UNDEF2}" || 0x${UNDEF3}' +Var_Parse: ${DEF}y == "${DEF}" || 0x${UNDEF3} (eval-defined) +make: "cond-token-var.mk" line 119: Malformed conditional 'x${DEF}y == "${DEF}" || 0x${UNDEF3}' +Global: .MAKEFLAGS = -r -k -d v -d +Global: .MAKEFLAGS = -r -k -d v -d 0 make: Fatal errors encountered -- cannot continue make: stopped in unit-tests exit status 1 Index: src/usr.bin/make/unit-tests/cond-func-empty.mk diff -u src/usr.bin/make/unit-tests/cond-func-empty.mk:1.26 src/usr.bin/make/unit-tests/cond-func-empty.mk:1.27 --- src/usr.bin/make/unit-tests/cond-func-empty.mk:1.26 Tue Aug 6 18:00:16 2024 +++ src/usr.bin/make/unit-tests/cond-func-empty.mk Fri Jan 10 23:00:38 2025 @@ -1,4 +1,4 @@ -# $NetBSD: cond-func-empty.mk,v 1.26 2024/08/06 18:00:16 rillig Exp $ +# $NetBSD: cond-func-empty.mk,v 1.27 2025/01/10 23:00:38 rillig Exp $ # # Tests for the empty() function in .if conditions, which tests an # expression for emptiness. @@ -207,6 +207,10 @@ VARNAME= ${VARNAME${:U1}} .if defined(VARNAME${:U2}) && !empty(VARNAME${:U2}) .endif +# Expressions in the argument of a function call don't have to be defined. +.if !empty(${UNDEF}) +. error +.endif # If the word 'empty' is not followed by '(', it is not a function call but an # ordinary bare word. This bare word is interpreted as 'defined(empty)', and Index: src/usr.bin/make/unit-tests/cond-func-exists.mk diff -u src/usr.bin/make/unit-tests/cond-func-exists.mk:1.7 src/usr.bin/make/unit-tests/cond-func-exists.mk:1.8 --- src/usr.bin/make/unit-tests/cond-func-exists.mk:1.7 Sun Nov 19 21:47:52 2023 +++ src/usr.bin/make/unit-tests/cond-func-exists.mk Fri Jan 10 23:00:38 2025 @@ -1,4 +1,4 @@ -# $NetBSD: cond-func-exists.mk,v 1.7 2023/11/19 21:47:52 rillig Exp $ +# $NetBSD: cond-func-exists.mk,v 1.8 2025/01/10 23:00:38 rillig Exp $ # # Tests for the exists() function in .if conditions. @@ -38,6 +38,11 @@ . error .endif +# Expressions in the argument of a function call don't have to be defined. +.if exists(${UNDEF}) +. error +.endif + # The exists function does not really look up the file in the file system, # instead it uses a cache that is preloaded very early, before parsing the # first makefile. At that time, the file did not exist yet. Index: src/usr.bin/make/unit-tests/cond-func-target.mk diff -u src/usr.bin/make/unit-tests/cond-func-target.mk:1.4 src/usr.bin/make/unit-tests/cond-func-target.mk:1.5 --- src/usr.bin/make/unit-tests/cond-func-target.mk:1.4 Sat Oct 24 08:46:08 2020 +++ src/usr.bin/make/unit-tests/cond-func-target.mk Fri Jan 10 23:00:38 2025 @@ -1,4 +1,4 @@ -# $NetBSD: cond-func-target.mk,v 1.4 2020/10/24 08:46:08 rillig Exp $ +# $NetBSD: cond-func-target.mk,v 1.5 2025/01/10 23:00:38 rillig Exp $ # # Tests for the target() function in .if conditions. @@ -34,5 +34,10 @@ target: . error .endif +# Expressions in the argument of a function call don't have to be defined. +.if target(${UNDEF}) +. error +.endif + all: @:; Index: src/usr.bin/make/unit-tests/cond-token-var.mk diff -u src/usr.bin/make/unit-tests/cond-token-var.mk:1.9 src/usr.bin/make/unit-tests/cond-token-var.mk:1.10 --- src/usr.bin/make/unit-tests/cond-token-var.mk:1.9 Tue Aug 6 18:00:17 2024 +++ src/usr.bin/make/unit-tests/cond-token-var.mk Fri Jan 10 23:00:38 2025 @@ -1,4 +1,4 @@ -# $NetBSD: cond-token-var.mk,v 1.9 2024/08/06 18:00:17 rillig Exp $ +# $NetBSD: cond-token-var.mk,v 1.10 2025/01/10 23:00:38 rillig Exp $ # # Tests for expressions in .if conditions. # @@ -13,8 +13,10 @@ # Well, except for the assignment modifiers, these do indeed change the value # of the variable. +D= defined DEF= defined + # A defined variable may appear on either side of the comparison. .if ${DEF} == ${DEF} # expect+1: ok @@ -49,6 +51,37 @@ DEF= defined .if ${UNDEF:U} .endif + +# The same as above, for single-letter variables without braces or +# parentheses. + +# A defined variable may appear on either side of the comparison. +.if $D == $D +.endif + +# A variable on the left-hand side must be defined. +# FIXME: Replace "Malformed" with "Undefined variable". +# expect+1: Malformed conditional '$U == $D' +.if $U == $D +.endif + +# A variable on the right-hand side must be defined. +# FIXME: Replace "Malformed" with "Undefined variable". +# expect+1: Malformed conditional '$D == $U' +.if $D == $U +.endif + +# A defined variable may appear as an expression of its own. +.if $D +.endif + +# An undefined variable without a comparison operator generates a parse error. +# FIXME: Replace "Malformed" with "Undefined variable". +# expect+1: Malformed conditional '$U' +.if $U +.endif + + # If the value of the expression is a number, it is compared against # zero. .if ${:U0} @@ -69,3 +102,20 @@ DEF= defined .if !${:Uanything} . error .endif + +.MAKEFLAGS: -dv +# FIXME: Replace "Malformed" with "Undefined variable". +# expect+1: Malformed conditional 'x${UNDEF1}y == "${UNDEF2}" || 0x${UNDEF3}' +.if x${UNDEF1}y == "${UNDEF2}" || 0x${UNDEF3} +.endif + +# FIXME: Replace "Malformed" with "Undefined variable". +# expect+1: Malformed conditional 'x${DEF}y == "${UNDEF2}" || 0x${UNDEF3}' +.if x${DEF}y == "${UNDEF2}" || 0x${UNDEF3} +.endif + +# FIXME: Replace "Malformed" with "Undefined variable". +# expect+1: Malformed conditional 'x${DEF}y == "${DEF}" || 0x${UNDEF3}' +.if x${DEF}y == "${DEF}" || 0x${UNDEF3} +.endif +.MAKEFLAGS: -d0 Index: src/usr.bin/make/unit-tests/varmod-assign-shell.exp diff -u src/usr.bin/make/unit-tests/varmod-assign-shell.exp:1.9 src/usr.bin/make/unit-tests/varmod-assign-shell.exp:1.10 --- src/usr.bin/make/unit-tests/varmod-assign-shell.exp:1.9 Thu Aug 29 20:20:36 2024 +++ src/usr.bin/make/unit-tests/varmod-assign-shell.exp Fri Jan 10 23:00:38 2025 @@ -4,7 +4,7 @@ Var_Parse: ${ASSIGNED::!=echo output; ${ Evaluating modifier ${ASSIGNED::...} on value "previous" (eval-keep-dollar-and-undefined, regular) Modifier part: "echo output; (exit 13)" Capturing the output of command "echo output; (exit 13)" -make: "varmod-assign-shell.mk" line 26: warning: Command "echo output; (exit 13)" exited with status 13 +make: "varmod-assign-shell.mk" line 32: warning: Command "echo output; (exit 13)" exited with status 13 Result of ${ASSIGNED::!=echo output; ${:U(exit 13)}} is "" (eval-keep-dollar-and-undefined, regular) Global: _ = # (empty) Global: .MAKEFLAGS = -r -k -d v -d Index: src/usr.bin/make/unit-tests/varmod-assign-shell.mk diff -u src/usr.bin/make/unit-tests/varmod-assign-shell.mk:1.9 src/usr.bin/make/unit-tests/varmod-assign-shell.mk:1.10 --- src/usr.bin/make/unit-tests/varmod-assign-shell.mk:1.9 Thu Aug 29 20:20:36 2024 +++ src/usr.bin/make/unit-tests/varmod-assign-shell.mk Fri Jan 10 23:00:38 2025 @@ -1,4 +1,4 @@ -# $NetBSD: varmod-assign-shell.mk,v 1.9 2024/08/29 20:20:36 rillig Exp $ +# $NetBSD: varmod-assign-shell.mk,v 1.10 2025/01/10 23:00:38 rillig Exp $ # # Tests for the variable modifier '::!=', which assigns the output of a shell # command to the variable, but only if the command exited successfully. This @@ -20,6 +20,12 @@ DIRECT= previous # expect+1: warning: Command "echo output; (exit 13)" exited with status 13 DIRECT!= echo output; (exit 13) +# An undefined expression results in an empty string. +OUTPUT_OF_UNDEF!= echo x${UNDEF}y +.if ${OUTPUT_OF_UNDEF} != "xy" +. error +.endif + ASSIGNED= previous .MAKEFLAGS: -dv # to see the "Capturing" debug output # expect+1: warning: Command "echo output; (exit 13)" exited with status 13 Index: src/usr.bin/make/unit-tests/deptgt.exp diff -u src/usr.bin/make/unit-tests/deptgt.exp:1.19 src/usr.bin/make/unit-tests/deptgt.exp:1.20 --- src/usr.bin/make/unit-tests/deptgt.exp:1.19 Thu Oct 31 09:12:13 2024 +++ src/usr.bin/make/unit-tests/deptgt.exp Fri Jan 10 23:00:38 2025 @@ -8,13 +8,19 @@ ParseDependency(: empty-source) Parsing deptgt.mk:39: : command for empty targets list Parsing deptgt.mk:40: .MAKEFLAGS: -d0 ParseDependency(.MAKEFLAGS: -d0) -make: "deptgt.mk" line 45: Unknown modifier "Z" +Var_Parse: ${UNDEF}: depsrc-${UNDEF} (eval-defined) +Var_Parse: ${UNDEF} (eval-defined) +Global: .ALLTARGETS = target1 target2 sources empty-source deptgt- +Global: .ALLTARGETS = target1 target2 sources empty-source deptgt- depsrc- +Global: .MAKEFLAGS = -r -k -d p -d 0 -d v -d +Global: .MAKEFLAGS = -r -k -d p -d 0 -d v -d 0 +make: "deptgt.mk" line 51: Unknown modifier "Z" while evaluating "${:U:Z}:" with value "" -make: "deptgt.mk" line 49: Unknown modifier "Z" +make: "deptgt.mk" line 55: Unknown modifier "Z" while parsing "${:U:Z}:" -make: "deptgt.mk" line 52: warning: Extra target 'ordinary' ignored -make: "deptgt.mk" line 55: warning: Extra target (ordinary) ignored -make: "deptgt.mk" line 58: warning: Special and mundane targets don't mix. Mundane ones ignored +make: "deptgt.mk" line 58: warning: Extra target 'ordinary' ignored +make: "deptgt.mk" line 61: warning: Extra target (ordinary) ignored +make: "deptgt.mk" line 64: warning: Special and mundane targets don't mix. Mundane ones ignored make: Fatal errors encountered -- cannot continue make: stopped making "target1" in unit-tests exit status 1 Index: src/usr.bin/make/unit-tests/deptgt.mk diff -u src/usr.bin/make/unit-tests/deptgt.mk:1.21 src/usr.bin/make/unit-tests/deptgt.mk:1.22 --- src/usr.bin/make/unit-tests/deptgt.mk:1.21 Thu Aug 29 20:20:36 2024 +++ src/usr.bin/make/unit-tests/deptgt.mk Fri Jan 10 23:00:38 2025 @@ -1,4 +1,4 @@ -# $NetBSD: deptgt.mk,v 1.21 2024/08/29 20:20:36 rillig Exp $ +# $NetBSD: deptgt.mk,v 1.22 2025/01/10 23:00:38 rillig Exp $ # # Tests for special targets like .BEGIN or .SUFFIXES in dependency # declarations. @@ -39,6 +39,12 @@ ${:U}: empty-source : command for empty targets list .MAKEFLAGS: -d0 +# An expression based on an undefined variable is allowed on both sides of +# the dependency declaration. +.MAKEFLAGS: -dv +deptgt-${UNDEF}: depsrc-${UNDEF} +.MAKEFLAGS: -d0 + # In a dependency declaration, the whole line is expanded before interpreting # the line. # expect+1: Unknown modifier "Z" Index: src/usr.bin/make/unit-tests/opt-debug-var.exp diff -u src/usr.bin/make/unit-tests/opt-debug-var.exp:1.3 src/usr.bin/make/unit-tests/opt-debug-var.exp:1.4 --- src/usr.bin/make/unit-tests/opt-debug-var.exp:1.3 Sat Mar 26 14:34:07 2022 +++ src/usr.bin/make/unit-tests/opt-debug-var.exp Fri Jan 10 23:00:38 2025 @@ -2,6 +2,12 @@ Global: ASSIGNED = value Global: SUBST = # (empty) Global: SUBST = value Var_Parse: y(ASSIGNED) (eval) +Var_Parse: $U (eval-defined) +make: "opt-debug-var.mk" line 35: Malformed conditional '$U' +Var_Parse: $< (eval-defined) +make: "opt-debug-var.mk" line 42: Malformed conditional '$<' Global: .MAKEFLAGS = -r -k -d v -d Global: .MAKEFLAGS = -r -k -d v -d 0 -exit status 0 +make: Fatal errors encountered -- cannot continue +make: stopped in unit-tests +exit status 1 Index: src/usr.bin/make/unit-tests/opt-debug-var.mk diff -u src/usr.bin/make/unit-tests/opt-debug-var.mk:1.3 src/usr.bin/make/unit-tests/opt-debug-var.mk:1.4 --- src/usr.bin/make/unit-tests/opt-debug-var.mk:1.3 Sun Nov 19 21:47:52 2023 +++ src/usr.bin/make/unit-tests/opt-debug-var.mk Fri Jan 10 23:00:38 2025 @@ -1,4 +1,4 @@ -# $NetBSD: opt-debug-var.mk,v 1.3 2023/11/19 21:47:52 rillig Exp $ +# $NetBSD: opt-debug-var.mk,v 1.4 2025/01/10 23:00:38 rillig Exp $ # # Tests for the -dv command line option, which adds debug logging about # variable assignment and evaluation. @@ -9,6 +9,7 @@ ASSIGNED= value # TODO: Explain why the empty assignment "Global: SUBST = " is needed. +# expect: Global: SUBST = # (empty) # expect: Global: SUBST = value SUBST:= value @@ -26,6 +27,20 @@ SUBST:= value .if !empty(ASSIGNED) .endif -.MAKEFLAGS: -d0 -all: .PHONY +# An expression for a variable with a single-character ordinary name. +# expect: Var_Parse: $U (eval-defined) +# FIXME: Replace "Malformed" with "Undefined variable". +# expect+1: Malformed conditional '$U' +.if $U +.endif + +# An expression for a target-specific variable with a single-character name. +# expect: Var_Parse: $< (eval-defined) +# FIXME: Replace "Malformed" with "Undefined variable". +# expect+1: Malformed conditional '$<' +.if $< +.endif + + +.MAKEFLAGS: -d0 Added files: Index: src/usr.bin/make/unit-tests/suff.exp diff -u /dev/null src/usr.bin/make/unit-tests/suff.exp:1.1 --- /dev/null Fri Jan 10 23:00:38 2025 +++ src/usr.bin/make/unit-tests/suff.exp Fri Jan 10 23:00:38 2025 @@ -0,0 +1,147 @@ +Adding suffix ".from" +Adding suffix ".to" +defining transformation from `.from' to `.to' +inserting ".from" (1) at end of list +inserting ".to" (2) at end of list +transformation .from.to complete +Var_Parse: ${.PREFIX}${.ARCHIVE}.additional (eval-defined) +Var_Parse: ${.ARCHIVE}.additional (eval-defined) +Global: .ALLTARGETS = all edge-case.to everything ${.PREFIX}${.ARCHIVE}.additional +Global: .ALLTARGETS = all edge-case.to everything ${.PREFIX}${.ARCHIVE}.additional edge-case.from +Global: .ALLTARGETS = all edge-case.to everything ${.PREFIX}${.ARCHIVE}.additional edge-case.from edge-case.additional +Global: .ALLTARGETS = all edge-case.to everything ${.PREFIX}${.ARCHIVE}.additional edge-case.from edge-case.additional a*.mk +Global: delete .PARSEDIR +Global: delete .PARSEFILE +Global: ignoring delete '.INCLUDEDFROMDIR' as it is not found +Global: ignoring delete '.INCLUDEDFROMFILE' as it is not found +Var_Parse: ${.MAKE.DEPENDFILE} (eval) +Var_Parse: ${.MAKE.MODE:tl} (eval) +Evaluating modifier ${.MAKE.MODE:t...} on value "" (eval, undefined) +Result of ${.MAKE.MODE:tl} is "" (eval, undefined) +Global: MFLAGS = -r -k -d sv +Var_Parse: ${.MAKEFLAGS} ${.MAKEOVERRIDES:O:u:@v@$v=${$v:Q}@} (eval) +Var_Parse: ${.MAKEOVERRIDES:O:u:@v@$v=${$v:Q}@} (eval) +Evaluating modifier ${.MAKEOVERRIDES:O} on value "" +Result of ${.MAKEOVERRIDES:O} is "" +Evaluating modifier ${.MAKEOVERRIDES:u} on value "" +Result of ${.MAKEOVERRIDES:u} is "" +Evaluating modifier ${.MAKEOVERRIDES:@...} on value "" +Modifier part: "v" +Modifier part: "$v=${$v:Q}" +ModifyWords: split "" into 1 word +Command: ignoring delete 'v' as it is not found +Result of ${.MAKEOVERRIDES:@v@$v=${$v:Q}@} is "" +Global: .INCLUDES = # (empty) +Global: .LIBS = # (empty) +Global: .TARGETS = all +Global: ignoring delete '.SHELL' as it is not found +Command: .SHELL = /bin/sh +Global: .ALLTARGETS = all edge-case.to everything ${.PREFIX}${.ARCHIVE}.additional edge-case.from edge-case.additional a*.mk .END +all: @ = all +all: @ = all +all: * = all +SuffFindDeps "all" +all: @ = all +all: * = all + No valid suffix on all +Wildcard expanding "edge-case.to"...suffix is ".to"... +edge-case.to: @ = edge-case.to +edge-case.to: @ = edge-case.to +edge-case.to: * = edge-case.to +SuffFindDeps "edge-case.to" + trying edge-case.from...got it +edge-case.to: @ = edge-case.to +edge-case.to: * = edge-case +Expanding "${.PREFIX}${.ARCHIVE}.additional"...Var_Parse: ${.PREFIX}${.ARCHIVE}.additional (eval-defined) +Var_Parse: ${.ARCHIVE}.additional (eval-defined) +edge-case.additional... + applying .from -> .to to "edge-case.to" +everything: @ = everything +everything: @ = everything +everything: * = everything +SuffFindDeps "everything" +everything: @ = everything +everything: * = everything +Wildcard expanding "a*.mk"... +archive-suffix.mk...Global: .ALLTARGETS = all edge-case.to everything ${.PREFIX}${.ARCHIVE}.additional edge-case.from edge-case.additional a*.mk .END archive-suffix.mk +archive.mk...Global: .ALLTARGETS = all edge-case.to everything ${.PREFIX}${.ARCHIVE}.additional edge-case.from edge-case.additional a*.mk .END archive-suffix.mk archive.mk + + No valid suffix on everything +Wildcard expanding "edge-case.additional"... +edge-case.additional: @ = edge-case.additional +edge-case.additional: @ = edge-case.additional +edge-case.additional: * = edge-case.additional +SuffFindDeps "edge-case.additional" + No known suffix on edge-case.additional. Using .NULL suffix +not adding suffix rules +edge-case.additional: @ = edge-case.additional +edge-case.additional: * = edge-case.additional +suffix is ".from"... +edge-case.from: @ = edge-case.from +edge-case.from: @ = edge-case.from +edge-case.from: * = edge-case.from +SuffFindDeps "edge-case.from" +edge-case.from: @ = edge-case.from +edge-case.from: * = edge-case +Wildcard expanding "archive-suffix.mk"... +archive-suffix.mk: @ = archive-suffix.mk +archive-suffix.mk: @ = archive-suffix.mk +archive-suffix.mk: * = archive-suffix.mk +SuffFindDeps "archive-suffix.mk" + No known suffix on archive-suffix.mk. Using .NULL suffix +adding suffix rules +archive-suffix.mk: @ = archive-suffix.mk +archive-suffix.mk: * = archive-suffix.mk +archive-suffix.mk: @ = archive-suffix.mk +archive-suffix.mk: * = archive-suffix.mk +Wildcard expanding "archive.mk"... +archive.mk: @ = archive.mk +archive.mk: @ = archive.mk +archive.mk: * = archive.mk +SuffFindDeps "archive.mk" + No known suffix on archive.mk. Using .NULL suffix +adding suffix rules +archive.mk: @ = archive.mk +archive.mk: * = archive.mk +archive.mk: @ = archive.mk +archive.mk: * = archive.mk +Wildcard expanding "edge-case.additional"... +edge-case.additional: ? = # (empty) +edge-case.additional: > = # (empty) +Var_Parse: ${.TARGET} out of nothing. (eval) +: Making edge-case.additional out of nothing. +edge-case.to: < = edge-case.from +suffix is ".from"... +edge-case.from: ? = # (empty) +edge-case.from: > = # (empty) +Var_Parse: ${.TARGET} out of nothing. (eval) +: Making edge-case.from out of nothing. +edge-case.to: > = edge-case.additional +edge-case.to: ? = edge-case.additional +edge-case.to: > = edge-case.additional edge-case.from +edge-case.to: ? = edge-case.additional edge-case.from +Var_Parse: ${.TARGET} from ${.ALLSRC}. (eval) +Var_Parse: ${.ALLSRC}. (eval) +: Making edge-case.to from edge-case.additional edge-case.from. +everything: > = archive-suffix.mk +everything: ? = archive-suffix.mk +everything: > = archive-suffix.mk archive.mk +everything: ? = archive-suffix.mk archive.mk +Var_Parse: ${.TARGET} from ${.ALLSRC}. (eval) +Var_Parse: ${.ALLSRC}. (eval) +: Making everything from archive-suffix.mk archive.mk. +all: > = edge-case.to +all: ? = edge-case.to +all: > = edge-case.to everything +all: ? = edge-case.to everything +.END: @ = .END +.END: * = .END +SuffFindDeps ".END" + No known suffix on .END. Using .NULL suffix +adding suffix rules +.END: @ = .END +.END: * = .END +Wildcard expanding ".END"... +.END: ? = # (empty) +.END: > = # (empty) +exit status 0 Index: src/usr.bin/make/unit-tests/suff.mk diff -u /dev/null src/usr.bin/make/unit-tests/suff.mk:1.1 --- /dev/null Fri Jan 10 23:00:38 2025 +++ src/usr.bin/make/unit-tests/suff.mk Fri Jan 10 23:00:38 2025 @@ -0,0 +1,22 @@ +# $NetBSD: suff.mk,v 1.1 2025/01/10 23:00:38 rillig Exp $ +# +# Demonstrate suffix rules and dependency resolution. + +all: .PHONY edge-case.to everything + +.MAKEFLAGS: -dsv + +.SUFFIXES: .from .to + +.from.to: + : Making ${.TARGET} from ${.ALLSRC}. + +# When making this target, ${.ARCHIVE} is undefined, but there's no warning. +# expect: Var_Parse: ${.ARCHIVE}.additional (eval-defined) +edge-case.to: ${.PREFIX}${.ARCHIVE}.additional + +edge-case.from edge-case.additional: + : Making ${.TARGET} out of nothing. + +everything: .PHONY a*.mk + : Making ${.TARGET} from ${.ALLSRC}.