xref: /netbsd-src/external/gpl2/gmake/dist/tests/scripts/features/reinvoke (revision 69606e3f5c9388e52aed8c120ad63c049ca45d8f)
1*69606e3fSchristos#                                                              -*-mode: perl-*-
2*69606e3fSchristos
3*69606e3fSchristos$description = "Test GNU make's auto-reinvocation feature.";
4*69606e3fSchristos
5*69606e3fSchristos$details = "\
6*69606e3fSchristosIf the makefile or one it includes can be rebuilt then it is, and make
7*69606e3fSchristosis reinvoked.  We create a rule to rebuild the makefile from a temp
8*69606e3fSchristosfile, then touch the temp file to make it newer than the makefile.";
9*69606e3fSchristos
10*69606e3fSchristos$omkfile = $makefile;
11*69606e3fSchristos
12*69606e3fSchristos&utouch(-600, 'incl.mk');
13*69606e3fSchristos# For some reason if we don't do this then the test fails for systems
14*69606e3fSchristos# with sub-second timestamps, maybe + NFS?  Not sure.
15*69606e3fSchristos&utouch(-1, 'incl-1.mk');
16*69606e3fSchristos
17*69606e3fSchristosrun_make_test('
18*69606e3fSchristosall: ; @echo running rules.
19*69606e3fSchristos
20*69606e3fSchristos#MAKEFILE# incl.mk: incl-1.mk
21*69606e3fSchristos	@echo rebuilding $@
22*69606e3fSchristos	@echo >> $@
23*69606e3fSchristos
24*69606e3fSchristosinclude incl.mk',
25*69606e3fSchristos              '', "rebuilding incl.mk\nrunning rules.\n");
26*69606e3fSchristos
27*69606e3fSchristos# Make sure updating the makefile itself also works
28*69606e3fSchristos
29*69606e3fSchristos&utouch(-600, $omkfile);
30*69606e3fSchristos
31*69606e3fSchristosrun_make_test(undef, '', "rebuilding #MAKEFILE#\nrunning rules.\n");
32*69606e3fSchristos
33*69606e3fSchristos&rmfiles('incl.mk', 'incl-1.mk');
34*69606e3fSchristos
35*69606e3fSchristos
36*69606e3fSchristos# In this test we create an included file that's out-of-date, but then
37*69606e3fSchristos# the rule doesn't update it.  Make shouldn't re-exec.
38*69606e3fSchristos
39*69606e3fSchristos&utouch(-600, 'b','a');
40*69606e3fSchristos#&utouch(-10, 'a');
41*69606e3fSchristos&touch('c');
42*69606e3fSchristos
43*69606e3fSchristosrun_make_test('
44*69606e3fSchristosSHELL = /bin/sh
45*69606e3fSchristos
46*69606e3fSchristosall: ; @echo hello
47*69606e3fSchristos
48*69606e3fSchristosa : b ; echo >> $@
49*69606e3fSchristos
50*69606e3fSchristosb : c ; [ -f $@ ] || echo >> $@
51*69606e3fSchristos
52*69606e3fSchristosc: ; echo >> $@
53*69606e3fSchristos
54*69606e3fSchristosinclude $(F)',
55*69606e3fSchristos              'F=a', "[ -f b ] || echo >> b\nhello\n");
56*69606e3fSchristos
57*69606e3fSchristos# Now try with the file we're not updating being the actual file we're
58*69606e3fSchristos# including: this and the previous one test different parts of the code.
59*69606e3fSchristos
60*69606e3fSchristosrun_make_test(undef, "F=b", "[ -f b ] || echo >> b\nhello\n")
61*69606e3fSchristos
62*69606e3fSchristos&rmfiles('a','b','c');
63*69606e3fSchristos
64*69606e3fSchristos# This tells the test driver that the perl test script executed properly.
65*69606e3fSchristos1;
66