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