1# -*-perl-*- 2$description = "Tests the new VPATH+ functionality added in 3.76."; 3 4$details = ""; 5 6$VP = "$workdir$pathsep"; 7 8open(MAKEFILE,"> $makefile"); 9 10# The Contents of the MAKEFILE ... 11 12print MAKEFILE "VPATH = $VP\n"; 13 14print MAKEFILE <<'EOMAKE'; 15 16SHELL = /bin/sh 17 18.SUFFIXES: .a .b .c .d 19.PHONY: general rename notarget intermediate 20 21%.a: 22%.b: 23%.c: 24%.d: 25 26%.a : %.b 27 cat $^ > $@ 28%.b : %.c 29 cat $^ > $@ 2>/dev/null || exit 1 30%.c :: %.d 31 cat $^ > $@ 32 33# General testing info: 34 35general: foo.b 36foo.b: foo.c bar.c 37 38# Rename testing info: 39 40rename: $(VPATH)/foo.c foo.d 41 42# Target not made testing info: 43 44notarget: notarget.b 45notarget.c: notarget.d 46 -@echo "not creating $@ from $^" 47 48# Intermediate files: 49 50intermediate: inter.a 51 52EOMAKE 53 54close(MAKEFILE); 55 56@touchedfiles = (); 57 58$off = -500; 59 60sub touchfiles { 61 foreach (@_) { 62 &utouch($off, $_); 63 $off += 10; 64 push(@touchedfiles, $_); 65 } 66} 67 68# Run the general-case test 69 70&touchfiles("$VP/foo.d", "$VP/bar.d", "$VP/foo.c", "$VP/bar.c", "foo.b", "bar.d"); 71 72&run_make_with_options($makefile,"general",&get_logfile); 73 74push(@touchedfiles, "bar.c"); 75 76$answer = "cat bar.d > bar.c 77cat ${VP}foo.c bar.c > foo.b 2>/dev/null || exit 1 78"; 79&compare_output($answer,&get_logfile(1)); 80 81# Test rules that don't make the target correctly 82 83&touchfiles("$VP/notarget.c", "notarget.b", "notarget.d"); 84 85&run_make_with_options($makefile,"notarget",&get_logfile,512); 86 87$answer = "not creating notarget.c from notarget.d 88cat notarget.c > notarget.b 2>/dev/null || exit 1 89$make_name: *** [notarget.b] Error 1 90"; 91 92&compare_output($answer,&get_logfile(1)); 93 94# Test intermediate file handling (part 1) 95 96&touchfiles("$VP/inter.d"); 97 98&run_make_with_options($makefile,"intermediate",&get_logfile); 99 100push(@touchedfiles, "inter.a", "inter.b"); 101 102$answer = "cat ${VP}inter.d > inter.c 103cat inter.c > inter.b 2>/dev/null || exit 1 104cat inter.b > inter.a 105rm inter.b inter.c 106"; 107&compare_output($answer,&get_logfile(1)); 108 109# Test intermediate file handling (part 2) 110 111&utouch(-20, "inter.a"); 112&utouch(-10, "$VP/inter.b"); 113&touch("$VP/inter.d"); 114 115push(@touchedfiles, "$VP/inter.b", "$VP/inter.d"); 116 117&run_make_with_options($makefile,"intermediate",&get_logfile); 118 119$answer = "cat ${VP}inter.d > inter.c 120cat inter.c > inter.b 2>/dev/null || exit 1 121cat inter.b > inter.a 122rm inter.c 123"; 124&compare_output($answer,&get_logfile(1)); 125 126unlink @touchedfiles unless $keep; 127 1281; 129