7 |
is reinvoked. We create a rule to rebuild the makefile from a temp |
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."; |
file, then touch the temp file to make it newer than the makefile."; |
9 |
|
|
10 |
$makefile2 = &get_tmpfile; |
$omkfile = $makefile; |
|
$makefile_orig = &get_tmpfile; |
|
11 |
|
|
12 |
open(MAKEFILE,"> $makefile"); |
&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'); |
16 |
|
|
17 |
print MAKEFILE <<EOM; |
run_make_test(' |
18 |
|
all: ; @echo running rules. |
19 |
|
|
20 |
all: ; \@echo 'running rules.' |
#MAKEFILE# incl.mk: incl-1.mk |
21 |
|
@echo rebuilding $@ |
22 |
|
@echo >> $@ |
23 |
|
|
24 |
$makefile $makefile2: $makefile_orig |
include incl.mk', |
25 |
\@echo 'rebuilding \$\@.' |
'', "rebuilding incl.mk\nrunning rules.\n"); |
|
\@echo >> \$\@ |
|
26 |
|
|
27 |
include $makefile2 |
# Make sure updating the makefile itself also works |
28 |
|
|
29 |
EOM |
&utouch(-600, $omkfile); |
30 |
|
|
31 |
close(MAKEFILE); |
run_make_test(undef, '', "rebuilding #MAKEFILE#\nrunning rules.\n"); |
32 |
|
|
33 |
&utouch(-10, $makefile, $makefile2); |
&rmfiles('incl.mk', 'incl-1.mk'); |
|
&touch($makefile_orig); |
|
34 |
|
|
|
&run_make_with_options($makefile, "", &get_logfile, 0); |
|
|
|
|
|
# Create the answer to what should be produced by this Makefile |
|
|
|
|
|
$answer = "rebuilding $makefile2.\nrebuilding $makefile.\nrunning rules.\n"; |
|
|
|
|
|
&compare_output($answer,&get_logfile(1)) |
|
|
&& unlink "$makefile_orig"; |
|
35 |
|
|
36 |
# In this test we create an included file that's out-of-date, but then |
# 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. |
# the rule doesn't update it. Make shouldn't re-exec. |
38 |
|
|
39 |
$makefile3 = &get_tmpfile; |
&utouch(-600, 'b','a'); |
40 |
|
#&utouch(-10, 'a'); |
41 |
|
&touch('c'); |
42 |
|
|
43 |
open(MAKEFILE, "> $makefile3"); |
run_make_test(' |
|
print MAKEFILE <<'EOM'; |
|
44 |
SHELL = /bin/sh |
SHELL = /bin/sh |
45 |
|
|
46 |
all: ; @echo hello |
all: ; @echo hello |
51 |
|
|
52 |
c: ; echo >> $@ |
c: ; echo >> $@ |
53 |
|
|
54 |
include $(F) |
include $(F)', |
55 |
EOM |
'F=a', "[ -f b ] || echo >> b\nhello\n"); |
|
|
|
|
close(MAKEFILE); |
|
|
|
|
|
&utouch(-20, 'b','a'); |
|
|
#&utouch(-10, 'a'); |
|
|
&touch('c'); |
|
|
|
|
|
# First try with the file that's not updated "once removed" from the |
|
|
# file we're including. |
|
|
|
|
|
&run_make_with_options($makefile3, "F=a", &get_logfile, 0); |
|
|
|
|
|
$answer = "[ -f b ] || echo >> b\nhello\n"; |
|
|
&compare_output($answer,&get_logfile(1)); |
|
56 |
|
|
57 |
# Now try with the file we're not updating being the actual file we're |
# 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. |
# including: this and the previous one test different parts of the code. |
59 |
|
|
60 |
&run_make_with_options($makefile3, "F=b", &get_logfile, 0); |
run_make_test(undef, "F=b", "[ -f b ] || echo >> b\nhello\n") |
|
|
|
|
$answer = "[ -f b ] || echo >> b\nhello\n"; |
|
|
&compare_output($answer,&get_logfile(1)); |
|
61 |
|
|
62 |
unlink('a','b','c'); |
&rmfiles('a','b','c'); |
63 |
|
|
64 |
# This tells the test driver that the perl test script executed properly. |
# This tells the test driver that the perl test script executed properly. |
65 |
1; |
1; |