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