| 1 |
# -*-perl-*- |
| 2 |
|
| 3 |
$description = "The following tests the use of a PHONY target. It makes\n" |
| 4 |
."sure that the rules under a target get executed even if\n" |
| 5 |
."a filename of the same name of the target exists in the\n" |
| 6 |
."directory.\n"; |
| 7 |
|
| 8 |
$details = "This makefile in this test declares the target clean to be a \n" |
| 9 |
."PHONY target. We then create a file named \"clean\" in the \n" |
| 10 |
."directory. Although this file exists, the rule under the target\n" |
| 11 |
."clean should still execute because of it's phony status."; |
| 12 |
|
| 13 |
$example = "EXAMPLE_FILE"; |
| 14 |
|
| 15 |
touch($example); |
| 16 |
|
| 17 |
# Create a file named "clean". This is the same name as the target clean |
| 18 |
# and tricks the target into thinking that it is up to date. (Unless you |
| 19 |
# use the .PHONY target. |
| 20 |
touch('clean'); |
| 21 |
|
| 22 |
open(MAKEFILE, "> $makefile"); |
| 23 |
print MAKEFILE qq! |
| 24 |
.PHONY : clean |
| 25 |
all: ; \@echo This makefile did not clean the dir ... good |
| 26 |
clean: ; $CMD_rmfile $example clean |
| 27 |
!; |
| 28 |
close(MAKEFILE); |
| 29 |
|
| 30 |
$answer = "$CMD_rmfile $example clean\n"; |
| 31 |
&run_make_with_options($makefile,"clean",&get_logfile); |
| 32 |
|
| 33 |
if (-f $example) { |
| 34 |
$test_passed = 0; |
| 35 |
} |
| 36 |
|
| 37 |
&compare_output($answer,&get_logfile(1)); |
| 38 |
|
| 39 |
# Just in case |
| 40 |
unlink($example, 'clean'); |
| 41 |
|
| 42 |
1; |