xref: /netbsd-src/external/gpl2/gmake/dist/tests/scripts/targets/PHONY (revision 69606e3f5c9388e52aed8c120ad63c049ca45d8f)
1*69606e3fSchristos#                                                                    -*-perl-*-
2*69606e3fSchristos
3*69606e3fSchristos$description = "The following tests the use of a PHONY target.  It makes\n"
4*69606e3fSchristos              ."sure that the rules under a target get executed even if\n"
5*69606e3fSchristos              ."a filename of the same name of the target exists in the\n"
6*69606e3fSchristos              ."directory.\n";
7*69606e3fSchristos
8*69606e3fSchristos$details = "This makefile in this test declares the target clean to be a \n"
9*69606e3fSchristos          ."PHONY target.  We then create a file named \"clean\" in the \n"
10*69606e3fSchristos          ."directory.  Although this file exists, the rule under the target\n"
11*69606e3fSchristos          ."clean should still execute because of it's phony status.";
12*69606e3fSchristos
13*69606e3fSchristos$example = "EXAMPLE_FILE";
14*69606e3fSchristos
15*69606e3fSchristosopen(MAKEFILE,"> $makefile");
16*69606e3fSchristos
17*69606e3fSchristos# The Contents of the MAKEFILE ...
18*69606e3fSchristos
19*69606e3fSchristosprint MAKEFILE ".PHONY : clean \n";
20*69606e3fSchristosprint MAKEFILE "all: \n";
21*69606e3fSchristosprint MAKEFILE "\t\@echo This makefile did not clean the dir ... good\n";
22*69606e3fSchristosprint MAKEFILE "clean: \n";
23*69606e3fSchristosprint MAKEFILE "\t$delete_command $example clean\n";
24*69606e3fSchristos
25*69606e3fSchristos# END of Contents of MAKEFILE
26*69606e3fSchristos
27*69606e3fSchristosclose(MAKEFILE);
28*69606e3fSchristos
29*69606e3fSchristos&touch($example);
30*69606e3fSchristos
31*69606e3fSchristos# Create a file named "clean".  This is the same name as the target clean
32*69606e3fSchristos# and tricks the target into thinking that it is up to date.  (Unless you
33*69606e3fSchristos# use the .PHONY target.
34*69606e3fSchristos&touch("clean");
35*69606e3fSchristos
36*69606e3fSchristos$answer = "$delete_command $example clean\n";
37*69606e3fSchristos&run_make_with_options($makefile,"clean",&get_logfile);
38*69606e3fSchristos
39*69606e3fSchristosif (-f $example) {
40*69606e3fSchristos  $test_passed = 0;
41*69606e3fSchristos}
42*69606e3fSchristos
43*69606e3fSchristos&compare_output($answer,&get_logfile(1));
44*69606e3fSchristos
45*69606e3fSchristos1;
46*69606e3fSchristos
47*69606e3fSchristos
48*69606e3fSchristos
49*69606e3fSchristos
50*69606e3fSchristos
51*69606e3fSchristos
52*69606e3fSchristos
53*69606e3fSchristos
54*69606e3fSchristos
55