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