summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDmitry Goncharov <dgoncharov@users.sf.net>2023-02-20 15:17:24 -0500
committerPaul Smith <psmith@gnu.org>2023-02-20 15:17:24 -0500
commite9dd614d73fc625845a0de089edae3a8433e30c1 (patch)
treef87efeed8549e634939f513131b0f945619e53f8 /tests
parentf5dc17ac2dcf9093d15c67facc8a481212c4c360 (diff)
downloadmake-git-e9dd614d73fc625845a0de089edae3a8433e30c1.tar.gz
[SV 63821] Don't set up default suffix rules if makefile sets -r
When built-in rules are disabled by adding -r to MAKEFLAGS in the makefile, don't add suffix rules at all so that if suffixes are added back via .SUFFIXES, the rules are still not there. * src/main.c (main): Set default suffix rules after parsing makefiles. * src/default.c (install_default_suffix_rules): Install a default suffix rule only if there is no user defined rule. * tests/scripts/features/suffixrules: Add tests.
Diffstat (limited to 'tests')
-rw-r--r--tests/scripts/features/suffixrules65
1 files changed, 65 insertions, 0 deletions
diff --git a/tests/scripts/features/suffixrules b/tests/scripts/features/suffixrules
index b8f46526..5e969b2a 100644
--- a/tests/scripts/features/suffixrules
+++ b/tests/scripts/features/suffixrules
@@ -95,5 +95,70 @@ run_make_test(undef,
unlink('foo.baz', 'foo.biz', 'foo.bar');
+
+touch('hello.c');
+unlink('hello.o');
+
+# sv 63821.
+# Default suffix rule .c.o.
+
+run_make_test('all: hello.o', 'COMPILE.c=@echo OUTPUT_OPTION=', 'hello.c');
+
+# User defined rules beat built-in rules.
+
+run_make_test(q!
+all: hello.o
+.c.o:; $(info $@ user defined .c.o rule)
+!, '', "hello.o user defined .c.o rule\n#MAKE#: Nothing to be done for 'all'.\n");
+
+# sv 63821.
+# The same as above, but suffixes are cleared.
+
+run_make_test(q!
+all: hello.o
+.SUFFIXES:
+.c.o:; $(info $@ user defined .c.o rule)
+!, '', "#MAKE#: *** No rule to make target 'hello.o', needed by 'all'. Stop.\n", 512);
+
+# sv 63821.
+# Suffixes are cleared and defined in the makefile.
+
+run_make_test(q!
+all: hello.o
+.SUFFIXES:
+.SUFFIXES: .c .o
+.c.o:; $(info $@ user defined .c.o rule)
+!, '', "hello.o user defined .c.o rule\n#MAKE#: Nothing to be done for 'all'.\n");
+
+# sv 63821.
+# When built-in rules are disabled, but certain suffixes are added to
+# .SUFFIXES, make should exit with the 'No rule...' error message.
+
+run_make_test(q!
+.SUFFIXES: .c .o
+all: hello.o
+!, '-r', "#MAKE#: *** No rule to make target 'hello.o', needed by 'all'. Stop.\n", 512);
+
+# sv 63821.
+# Same as above, but this time built-in rules are disabled inside the makefile.
+
+run_make_test(q!
+MAKEFLAGS += -r
+.SUFFIXES: .c .o
+all: hello.o
+!, '', "#MAKE#: *** No rule to make target 'hello.o', needed by 'all'. Stop.\n", 512);
+
+# sv 63821.
+# Same as above, but this time there is a rule.
+
+run_make_test(q!
+all: hello.o
+MAKEFLAGS += -r
+.SUFFIXES: .c .o
+.c.o:; $(info $@ user defined .c.o rule)
+!, '', "hello.o user defined .c.o rule\n#MAKE#: Nothing to be done for 'all'.\n");
+
+unlink('hello.c', 'hello.o');
+
# Complete
1;