1999-09-14 10:03:19 +08:00
|
|
|
# -*-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.";
|
|
|
|
|
2005-06-28 06:18:47 +08:00
|
|
|
$omkfile = $makefile;
|
1999-09-14 10:03:19 +08:00
|
|
|
|
2005-06-28 06:18:47 +08:00
|
|
|
&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');
|
1999-09-14 10:03:19 +08:00
|
|
|
|
2005-06-28 06:18:47 +08:00
|
|
|
run_make_test('
|
|
|
|
all: ; @echo running rules.
|
1999-09-14 10:03:19 +08:00
|
|
|
|
2021-06-01 02:37:09 +08:00
|
|
|
#MAKEFILE# incl.mk: incl-1.mk ; @echo rebuilding $@; echo >> $@
|
1999-09-14 10:03:19 +08:00
|
|
|
|
2005-06-28 06:18:47 +08:00
|
|
|
include incl.mk',
|
|
|
|
'', "rebuilding incl.mk\nrunning rules.\n");
|
1999-09-14 10:03:19 +08:00
|
|
|
|
2005-06-28 06:18:47 +08:00
|
|
|
# Make sure updating the makefile itself also works
|
1999-09-14 10:03:19 +08:00
|
|
|
|
2005-06-28 06:18:47 +08:00
|
|
|
&utouch(-600, $omkfile);
|
1999-09-14 10:03:19 +08:00
|
|
|
|
2005-06-28 06:18:47 +08:00
|
|
|
run_make_test(undef, '', "rebuilding #MAKEFILE#\nrunning rules.\n");
|
1999-09-14 10:03:19 +08:00
|
|
|
|
2005-06-28 06:18:47 +08:00
|
|
|
&rmfiles('incl.mk', 'incl-1.mk');
|
1999-09-14 10:03:19 +08:00
|
|
|
|
|
|
|
|
|
|
|
# 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.
|
|
|
|
|
2005-06-28 06:18:47 +08:00
|
|
|
&utouch(-600, 'b','a');
|
|
|
|
#&utouch(-10, 'a');
|
|
|
|
&touch('c');
|
1999-09-14 10:03:19 +08:00
|
|
|
|
2005-06-28 06:18:47 +08:00
|
|
|
run_make_test('
|
1999-09-14 10:03:19 +08:00
|
|
|
all: ; @echo hello
|
|
|
|
|
1999-09-17 11:15:37 +08:00
|
|
|
a : b ; echo >> $@
|
1999-09-14 10:03:19 +08:00
|
|
|
|
2020-05-04 01:39:55 +08:00
|
|
|
b : c ; test -f $@ || echo >> $@
|
1999-09-14 10:03:19 +08:00
|
|
|
|
1999-09-17 11:15:37 +08:00
|
|
|
c: ; echo >> $@
|
1999-09-14 10:03:19 +08:00
|
|
|
|
2005-06-28 06:18:47 +08:00
|
|
|
include $(F)',
|
2020-05-04 01:39:55 +08:00
|
|
|
'F=a', "test -f b || echo >> b\nhello\n");
|
1999-09-14 10:03:19 +08:00
|
|
|
|
|
|
|
# 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.
|
|
|
|
|
2020-05-04 01:39:55 +08:00
|
|
|
run_make_test(undef, 'F=b', "test -f b || echo >> b\nhello\n");
|
1999-09-14 10:03:19 +08:00
|
|
|
|
2005-06-28 06:18:47 +08:00
|
|
|
&rmfiles('a','b','c');
|
1999-09-14 10:03:19 +08:00
|
|
|
|
2010-08-10 15:35:34 +08:00
|
|
|
# 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');
|
|
|
|
|
2021-06-01 02:37:09 +08:00
|
|
|
# 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
|
2022-01-18 07:23:42 +08:00
|
|
|
', '',
|
|
|
|
# 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);
|
2021-06-01 02:37:09 +08:00
|
|
|
|
|
|
|
unlink('m1.d', 'm2.d');
|
|
|
|
|
2022-01-18 07:23:42 +08:00
|
|
|
# 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');
|
|
|
|
|
2022-02-27 06:12:03 +08:00
|
|
|
# Test DV 62088 : make sure we don't re-invoke for stdin makefiles.
|
|
|
|
# The test framework doesn't seem to have a good way to do this.
|
|
|
|
|
|
|
|
create_file('input.mk', "all:;\$(info all)\n");
|
|
|
|
|
|
|
|
close(STDIN);
|
|
|
|
open(STDIN, "<", 'input.mk') || die "input.mk: $!\n";
|
|
|
|
|
|
|
|
run_make_test('', '-sf -', "all\n");
|
|
|
|
|
|
|
|
unlink('input.mk');
|
|
|
|
|
1999-09-14 10:03:19 +08:00
|
|
|
# This tells the test driver that the perl test script executed properly.
|
|
|
|
1;
|