Home | History | Annotate | Line # | Download | only in features
      1  1.1  christos $description = "The following test creates a makefile to test the \n"
      2  1.1  christos               ."vpath directive which allows you to specify a search \n"
      3  1.1  christos               ."path for a particular class of filenames, those that\n"
      4  1.1  christos               ."match a particular pattern.";
      5  1.1  christos 
      6  1.1  christos $details = "This tests the vpath directive by specifying search directories\n"
      7  1.1  christos          ."for one class of filenames with the form: vpath pattern directories"
      8  1.1  christos          ."\nIn this test, we specify the working directory for all files\n"
      9  1.1  christos          ."that end in c or h.  We also test the variables $@ (which gives\n"
     10  1.1  christos          ."target name) and $^ (which is a list of all dependencies \n"
     11  1.1  christos          ."including the directories in which they were found).  It also\n"
     12  1.1  christos          ."uses the function firstword used to extract just the first\n"
     13  1.1  christos          ."dependency from the entire list.";
     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 "vpath %.c foo\n";
     20  1.1  christos print MAKEFILE "vpath %.c $workdir\n";
     21  1.1  christos print MAKEFILE "vpath %.h $workdir\n";
     22  1.1  christos print MAKEFILE "objects = main.o kbd.o commands.o display.o insert.o\n";
     23  1.1  christos print MAKEFILE "edit:  \$(objects)\n";
     24  1.1  christos print MAKEFILE "\t\@echo cc -o \$@ \$^\n";
     25  1.1  christos print MAKEFILE "main.o : main.c defs.h\n";
     26  1.1  christos print MAKEFILE "\t\@echo cc -c \$(firstword \$^)\n";
     27  1.1  christos print MAKEFILE "kbd.o : kbd.c defs.h command.h\n";
     28  1.1  christos print MAKEFILE "\t\@echo cc -c kbd.c\n";
     29  1.1  christos print MAKEFILE "commands.o : command.c defs.h command.h\n";
     30  1.1  christos print MAKEFILE "\t\@echo cc -c commands.c\n";
     31  1.1  christos print MAKEFILE "display.o : display.c defs.h buffer.h\n";
     32  1.1  christos print MAKEFILE "\t\@echo cc -c display.c\n";
     33  1.1  christos print MAKEFILE "insert.o : insert.c defs.h buffer.h\n";
     34  1.1  christos print MAKEFILE "\t\@echo cc -c insert.c\n";
     35  1.1  christos 
     36  1.1  christos # END of Contents of MAKEFILE
     37  1.1  christos 
     38  1.1  christos close(MAKEFILE);
     39  1.1  christos 
     40  1.1  christos 
     41  1.1  christos @files_to_touch = ("$workdir${pathsep}main.c","$workdir${pathsep}defs.h",
     42  1.1  christos                "$workdir${pathsep}kbd.c","$workdir${pathsep}command.h",
     43  1.1  christos                "$workdir${pathsep}commands.c","$workdir${pathsep}display.c",
     44  1.1  christos                "$workdir${pathsep}buffer.h","$workdir${pathsep}insert.c",
     45  1.1  christos 	       "$workdir${pathsep}command.c");
     46  1.1  christos 
     47  1.1  christos &touch(@files_to_touch);
     48  1.1  christos 
     49  1.1  christos &run_make_with_options($makefile,"",&get_logfile);
     50  1.1  christos 
     51  1.1  christos # Create the answer to what should be produced by this Makefile
     52  1.1  christos $answer = "cc -c $workdir${pathsep}main.c\ncc -c kbd.c\ncc -c commands.c\n"
     53  1.1  christos          ."cc -c display.c\n"
     54  1.1  christos          ."cc -c insert.c\ncc -o edit main.o kbd.o commands.o display.o "
     55  1.1  christos          ."insert.o\n";
     56  1.1  christos 
     57  1.1  christos if (&compare_output($answer,&get_logfile(1)))
     58  1.1  christos {
     59  1.1  christos   unlink @files_to_touch;
     60  1.1  christos }
     61  1.1  christos 
     62  1.1  christos 1;
     63