mirror of
https://github.com/mirror/make.git
synced 2025-01-10 20:30:20 +08:00
e72c5e021f
The fix for SV 60595 introduced a backward-incompatibility: rules that purported to rebuild included files, but didn't actually do so, were treated as errors whereas before they were ignored. This breaks a common idiom in makefiles where an empty recipe is created for an included makefile so make doesn't complain if it doesn't exist. Unfortunately this means make cannot diagnose some types of errors. Extra tests supplied by Dmitry Goncharov <dgoncharov@users.sf.net>. * doc/make.texi (Including Other Makefiles): Clarify this behavior. * src/main.c (main): Don't run the new check-for-errors behavior. * tests/scripts/features/reinvoke: Reset tests of the "old" behavior and add new tests for this situation.
168 lines
4.4 KiB
Perl
168 lines
4.4 KiB
Perl
# -*-mode: perl-*-
|
|
|
|
$description = "Test GNU make's auto-reinvocation feature.";
|
|
|
|
$details = "\
|
|
If the makefile or one it includes can be rebuilt then it is, and make
|
|
is reinvoked. We create a rule to rebuild the makefile from a temp
|
|
file, then touch the temp file to make it newer than the makefile.";
|
|
|
|
$omkfile = $makefile;
|
|
|
|
&utouch(-600, 'incl.mk');
|
|
# For some reason if we don't do this then the test fails for systems
|
|
# with sub-second timestamps, maybe + NFS? Not sure.
|
|
&utouch(-1, 'incl-1.mk');
|
|
|
|
run_make_test('
|
|
all: ; @echo running rules.
|
|
|
|
#MAKEFILE# incl.mk: incl-1.mk ; @echo rebuilding $@; echo >> $@
|
|
|
|
include incl.mk',
|
|
'', "rebuilding incl.mk\nrunning rules.\n");
|
|
|
|
# Make sure updating the makefile itself also works
|
|
|
|
&utouch(-600, $omkfile);
|
|
|
|
run_make_test(undef, '', "rebuilding #MAKEFILE#\nrunning rules.\n");
|
|
|
|
&rmfiles('incl.mk', 'incl-1.mk');
|
|
|
|
|
|
# In this test we create an included file that's out-of-date, but then
|
|
# the rule doesn't update it. Make shouldn't re-exec.
|
|
|
|
&utouch(-600, 'b','a');
|
|
#&utouch(-10, 'a');
|
|
&touch('c');
|
|
|
|
run_make_test('
|
|
all: ; @echo hello
|
|
|
|
a : b ; echo >> $@
|
|
|
|
b : c ; test -f $@ || echo >> $@
|
|
|
|
c: ; echo >> $@
|
|
|
|
include $(F)',
|
|
'F=a', "test -f b || echo >> b\nhello\n");
|
|
|
|
# Now try with the file we're not updating being the actual file we're
|
|
# including: this and the previous one test different parts of the code.
|
|
|
|
run_make_test(undef, 'F=b', "test -f b || echo >> b\nhello\n");
|
|
|
|
&rmfiles('a','b','c');
|
|
|
|
# Ensure command line variables are preserved properly across re-exec
|
|
# Tests for Savannah bug #30723
|
|
|
|
run_make_test('
|
|
ifdef RECURSE
|
|
-include foo30723
|
|
endif
|
|
recurse: ; @$(MAKE) -f $(MAKEFILE_LIST) RECURSE=1 test
|
|
test: ; @echo F.O=$(F.O)
|
|
foo30723: ; @touch $@
|
|
',
|
|
'--no-print-directory F.O=bar', "F.O=bar\n");
|
|
|
|
unlink('foo30723');
|
|
|
|
# If ANY makefile is rebuilt then we should re-exec
|
|
|
|
run_make_test('
|
|
all: ; @echo RESTARTS=$(MAKE_RESTARTS)
|
|
|
|
m1.d: ; @echo $@; touch $@
|
|
|
|
m2.d: m1.d ; @test -f $< || { echo $@; touch $@; }
|
|
|
|
include m1.d
|
|
-include m2.d
|
|
',
|
|
'', "m1.d\nRESTARTS=1\n");
|
|
|
|
unlink('m1.d', 'm2.d');
|
|
|
|
# Same as before but be sure we get error messages for un-created makefiles
|
|
run_make_test('
|
|
all: ; @echo RESTARTS=$(MAKE_RESTARTS)
|
|
|
|
m1.d: ; @echo $@; touch $@
|
|
|
|
m2.d: m1.d ; @test -f $< || { echo $@; touch $@; }
|
|
|
|
include m1.d m2.d
|
|
', '',
|
|
# This runs afoul of https://savannah.gnu.org/bugs/?61226
|
|
0 ? "m1.d\n#MAKEFILE#:8: m2.d: $ERR_no_such_file"
|
|
: "m1.d\nRESTARTS=1",
|
|
0 ? 512 : 0);
|
|
|
|
unlink('m1.d', 'm2.d');
|
|
|
|
# sv 61226.
|
|
# This set of four cases tests two aspects of make.
|
|
#
|
|
# 1. If a rule has no prerequisites or recipe, and the target of the rule is a
|
|
# nonexistent file, then make imagines this target to have been updated
|
|
# whenever its rule is run.
|
|
#
|
|
# 2. Make does not re-execute itself in this case of imagined target.
|
|
#
|
|
# Test case 1.
|
|
# Make imagines hello.d was updated by a rule without recipe and without
|
|
# prereqs.
|
|
# This should succeed.
|
|
# Make should not re-execute itself.
|
|
run_make_test('
|
|
hello.o: hello.d; $(info RESTARTS=$(MAKE_RESTARTS))
|
|
hello.d:
|
|
include hello.d
|
|
', '', "RESTARTS=\n#MAKE#: 'hello.o' is up to date.");
|
|
|
|
# Test case 2.
|
|
# Make imagines hello.d was updated by a rule with a recipe and without
|
|
# prereqs.
|
|
# This should succeed.
|
|
# Make should not re-execute itself.
|
|
run_make_test('
|
|
hello.o: hello.d; $(info RESTARTS=$(MAKE_RESTARTS))
|
|
hello.d:; $(info $@)
|
|
include hello.d
|
|
', '', "hello.d\nRESTARTS=\n#MAKE#: 'hello.o' is up to date.");
|
|
|
|
&touch('hello.td');
|
|
# Test case 3.
|
|
# Make imagines hello.d was updated by a rule without a recipe and with
|
|
# prereqs.
|
|
# This should succeed.
|
|
# Make should not re-execute itself.
|
|
run_make_test('
|
|
hello.o: hello.d; $(info RESTARTS=$(MAKE_RESTARTS))
|
|
hello.d: hello.td
|
|
include hello.d
|
|
', '', "RESTARTS=\n#MAKE#: 'hello.o' is up to date.");
|
|
|
|
# Test case 4.
|
|
# Same test as three tests above, but the rule has both recipe and prereqs.
|
|
# Make should report this error.
|
|
run_make_test('
|
|
hello.o: hello.d; $(info $@)
|
|
hello.d: hello.td; $(info $@)
|
|
include hello.d
|
|
', '',
|
|
# This runs afoul of https://savannah.gnu.org/bugs/?61226
|
|
0 ? "hello.d\n#MAKEFILE#:4: hello.d: $ERR_no_such_file"
|
|
: "hello.d\nhello.o\n#MAKE#: 'hello.o' is up to date.",
|
|
0 ? 512 : 0);
|
|
|
|
unlink('hello.td');
|
|
|
|
# This tells the test driver that the perl test script executed properly.
|
|
1;
|