xref: /netbsd-src/external/gpl2/gmake/dist/tests/scripts/features/order_only (revision 69606e3f5c9388e52aed8c120ad63c049ca45d8f)
1*69606e3fSchristos#                                                                    -*-perl-*-
2*69606e3fSchristos$description = "Test order-only prerequisites.";
3*69606e3fSchristos
4*69606e3fSchristos$details = "\
5*69606e3fSchristosCreate makefiles with various combinations of normal and order-only
6*69606e3fSchristosprerequisites and ensure they behave properly.  Test the \$| variable.";
7*69606e3fSchristos
8*69606e3fSchristos# TEST #0 -- Basics
9*69606e3fSchristos
10*69606e3fSchristosrun_make_test('
11*69606e3fSchristos%r: | baz ; @echo $< $^ $|
12*69606e3fSchristosbar: foo
13*69606e3fSchristosfoo:;@:
14*69606e3fSchristosbaz:;@:',
15*69606e3fSchristos              '', "foo foo baz\n");
16*69606e3fSchristos
17*69606e3fSchristos# TEST #1 -- First try: the order-only prereqs need to be built.
18*69606e3fSchristos
19*69606e3fSchristosrun_make_test(q!
20*69606e3fSchristosfoo: bar | baz
21*69606e3fSchristos	@echo '$$^ = $^'
22*69606e3fSchristos	@echo '$$| = $|'
23*69606e3fSchristos	touch $@
24*69606e3fSchristos
25*69606e3fSchristos.PHONY: baz
26*69606e3fSchristos
27*69606e3fSchristosbar baz:
28*69606e3fSchristos	touch $@!,
29*69606e3fSchristos              '', "touch bar\ntouch baz\n\$^ = bar\n\$| = baz\ntouch foo\n");
30*69606e3fSchristos
31*69606e3fSchristos
32*69606e3fSchristos# TEST #2 -- now we do it again: baz is PHONY but foo should _NOT_ be updated
33*69606e3fSchristos
34*69606e3fSchristosrun_make_test(undef, '', "touch baz\n");
35*69606e3fSchristos
36*69606e3fSchristosunlink(qw(foo bar baz));
37*69606e3fSchristos
38*69606e3fSchristos# TEST #3 -- Make sure the order-only prereq was promoted to normal.
39*69606e3fSchristos
40*69606e3fSchristosrun_make_test(q!
41*69606e3fSchristosfoo: bar | baz
42*69606e3fSchristos	@echo '$$^ = $^'
43*69606e3fSchristos	@echo '$$| = $|'
44*69606e3fSchristos	touch $@
45*69606e3fSchristos
46*69606e3fSchristosfoo: baz
47*69606e3fSchristos
48*69606e3fSchristos.PHONY: baz
49*69606e3fSchristos
50*69606e3fSchristosbar baz:
51*69606e3fSchristos	touch $@!,
52*69606e3fSchristos              '', "touch bar\ntouch baz\n\$^ = bar baz\n\$| = \ntouch foo\n");
53*69606e3fSchristos
54*69606e3fSchristos
55*69606e3fSchristos# TEST #4 -- now we do it again
56*69606e3fSchristos
57*69606e3fSchristosrun_make_test(undef, '', "touch baz\n\$^ = bar baz\n\$| = \ntouch foo\n");
58*69606e3fSchristos
59*69606e3fSchristosunlink(qw(foo bar baz));
60*69606e3fSchristos
61*69606e3fSchristos# Test empty normal prereqs
62*69606e3fSchristos
63*69606e3fSchristos# TEST #5 -- make sure the parser was correct.
64*69606e3fSchristos
65*69606e3fSchristosrun_make_test(q!
66*69606e3fSchristosfoo:| baz
67*69606e3fSchristos	@echo '$$^ = $^'
68*69606e3fSchristos	@echo '$$| = $|'
69*69606e3fSchristos	touch $@
70*69606e3fSchristos
71*69606e3fSchristos.PHONY: baz
72*69606e3fSchristos
73*69606e3fSchristosbaz:
74*69606e3fSchristos	touch $@!,
75*69606e3fSchristos              '', "touch baz\n\$^ = \n\$| = baz\ntouch foo\n");
76*69606e3fSchristos
77*69606e3fSchristos# TEST #6 -- now we do it again: this time foo won't be built
78*69606e3fSchristos
79*69606e3fSchristosrun_make_test(undef, '', "touch baz\n");
80*69606e3fSchristos
81*69606e3fSchristosunlink(qw(foo baz));
82*69606e3fSchristos
83*69606e3fSchristos# Test order-only in pattern rules
84*69606e3fSchristos
85*69606e3fSchristos# TEST #7 -- make sure the parser was correct.
86*69606e3fSchristos
87*69606e3fSchristosrun_make_test(q!
88*69606e3fSchristos%.w : %.x | baz
89*69606e3fSchristos	@echo '$$^ = $^'
90*69606e3fSchristos	@echo '$$| = $|'
91*69606e3fSchristos	touch $@
92*69606e3fSchristos
93*69606e3fSchristosall: foo.w
94*69606e3fSchristos
95*69606e3fSchristos.PHONY: baz
96*69606e3fSchristosfoo.x baz:
97*69606e3fSchristos	touch $@!,
98*69606e3fSchristos              '',
99*69606e3fSchristos              "touch foo.x\ntouch baz\n\$^ = foo.x\n\$| = baz\ntouch foo.w\n");
100*69606e3fSchristos
101*69606e3fSchristos# TEST #8 -- now we do it again: this time foo.w won't be built
102*69606e3fSchristos
103*69606e3fSchristosrun_make_test(undef, '', "touch baz\n");
104*69606e3fSchristos
105*69606e3fSchristosunlink(qw(foo.w foo.x baz));
106*69606e3fSchristos
107*69606e3fSchristos# TEST #9 -- make sure that $< is set correctly in the face of order-only
108*69606e3fSchristos# prerequisites in pattern rules.
109*69606e3fSchristos
110*69606e3fSchristosrun_make_test('
111*69606e3fSchristos%r: | baz ; @echo $< $^ $|
112*69606e3fSchristosbar: foo
113*69606e3fSchristosfoo:;@:
114*69606e3fSchristosbaz:;@:',
115*69606e3fSchristos              '', "foo foo baz\n");
116*69606e3fSchristos
117*69606e3fSchristos
118*69606e3fSchristos1;
119