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