- Rework secondary expansion so we only defer it if there's a possibility
[make.git] / tests / scripts / features / reinvoke
blob9952ced1a5a97e293b48448a03509cf7c5b3851d
1 #                                                              -*-mode: perl-*-
3 $description = "Test GNU make's auto-reinvocation feature.";
5 $details = "\
6 If the makefile or one it includes can be rebuilt then it is, and make
7 is reinvoked.  We create a rule to rebuild the makefile from a temp
8 file, then touch the temp file to make it newer than the makefile.";
10 $omkfile = $makefile;
12 &utouch(-600, 'incl.mk');
13 # For some reason if we don't do this then the test fails for systems
14 # with sub-second timestamps, maybe + NFS?  Not sure.
15 &utouch(-1, 'incl-1.mk');
17 run_make_test('
18 all: ; @echo running rules.
20 #MAKEFILE# incl.mk: incl-1.mk
21         @echo rebuilding $@
22         @echo >> $@
24 include incl.mk',
25               '', "rebuilding incl.mk\nrunning rules.\n");
27 # Make sure updating the makefile itself also works
29 &utouch(-600, $omkfile);
31 run_make_test(undef, '', "rebuilding #MAKEFILE#\nrunning rules.\n");
33 &rmfiles('incl.mk', 'incl-1.mk');
36 # In this test we create an included file that's out-of-date, but then
37 # the rule doesn't update it.  Make shouldn't re-exec.
39 &utouch(-600, 'b','a');
40 #&utouch(-10, 'a');
41 &touch('c');
43 run_make_test('
44 SHELL = /bin/sh
46 all: ; @echo hello
48 a : b ; echo >> $@
50 b : c ; [ -f $@ ] || echo >> $@
52 c: ; echo >> $@
54 include $(F)',
55               'F=a', "[ -f b ] || echo >> b\nhello\n");
57 # Now try with the file we're not updating being the actual file we're
58 # including: this and the previous one test different parts of the code.
60 run_make_test(undef, "F=b", "[ -f b ] || echo >> b\nhello\n")
62 &rmfiles('a','b','c');
64 # This tells the test driver that the perl test script executed properly.