From ef4756eb0994bc25de66cbb04e1752dda217ff5d Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Sun, 20 Oct 2024 12:52:42 +0100 Subject: make: changes to .DEFAULT/inference rules The POSIX standard allows inference rules to be redefined but not the .DEFAULT rule. There is no explicit exception for .DEFAULT to: Only one target rule for any given target can contain commands. Treat redefinition of a .DEFAULT rule as an error in POSIX mode but allow it as an extension. Also, the code didn't allow an inference rule with dependencies to redefine an existing inference rule. This is no longer the case. Adds 64-96 bytes. --- testsuite/make.tests | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'testsuite/make.tests') diff --git a/testsuite/make.tests b/testsuite/make.tests index a12e50b8b..376bdcc15 100755 --- a/testsuite/make.tests +++ b/testsuite/make.tests @@ -12,18 +12,6 @@ target: @echo target ' -# .DEFAULT rules with no commands or some prerequisites are ignored. -# .DEFAULT rules with commands can be redefined. -testing "make .DEFAULT rule" \ - "make -f - default" "default2\n" "" ' -.DEFAULT: ignored -.DEFAULT: - @echo default1 -.DEFAULT: - @echo default2 -target: -' - testing "make .DEFAULT rule for prerequisite" \ "make -f - 2>/dev/null" "source\n" "" ' .DEFAULT: @@ -721,6 +709,26 @@ target:: file2 file3 file3 ' cd .. || exit 1; rm -rf make.tempdir 2>/dev/null +# .DEFAULT rules with no commands or some prerequisites are ignored. +# .DEFAULT rules with commands can be redefined. +testing "make: .DEFAULT rule" \ + "make -f - default" "default2\n" "" ' +.DEFAULT: ignored +.DEFAULT: + @echo default1 +.DEFAULT: + @echo default2 +target: +' + +testing "make: double-colon rule" \ + "make -f -" "target1\ntarget2\n" "" ' +target:: + @echo target1 +target:: + @echo target2 +' + # Double-colon rules didn't work properly if their target was phony: # - they didn't ignore the presence of a file matching the target name; # - they were also invoked as if they were a single-colon rule. -- cgit v1.2.3-55-g6feb