xref: /netbsd-src/external/gpl2/gmake/dist/tests/scripts/variables/DEFAULT_GOAL (revision 69606e3f5c9388e52aed8c120ad63c049ca45d8f)
1*69606e3fSchristos#                                                                    -*-perl-*-
2*69606e3fSchristos$description = "Test the .DEFAULT_GOAL special variable.";
3*69606e3fSchristos
4*69606e3fSchristos$details = "";
5*69606e3fSchristos
6*69606e3fSchristos
7*69606e3fSchristos# Test #1: basic logic.
8*69606e3fSchristos#
9*69606e3fSchristosrun_make_test('
10*69606e3fSchristos# Basics.
11*69606e3fSchristos#
12*69606e3fSchristosfoo: ; @:
13*69606e3fSchristos
14*69606e3fSchristosifneq ($(.DEFAULT_GOAL),foo)
15*69606e3fSchristos$(error )
16*69606e3fSchristosendif
17*69606e3fSchristos
18*69606e3fSchristos# Reset to empty.
19*69606e3fSchristos#
20*69606e3fSchristos.DEFAULT_GOAL :=
21*69606e3fSchristos
22*69606e3fSchristosbar: ; @:
23*69606e3fSchristos
24*69606e3fSchristosifneq ($(.DEFAULT_GOAL),bar)
25*69606e3fSchristos$(error )
26*69606e3fSchristosendif
27*69606e3fSchristos
28*69606e3fSchristos# Change to a different goal.
29*69606e3fSchristos#
30*69606e3fSchristos
31*69606e3fSchristos.DEFAULT_GOAL := baz
32*69606e3fSchristos
33*69606e3fSchristosbaz: ; @echo $@
34*69606e3fSchristos',
35*69606e3fSchristos'',
36*69606e3fSchristos'baz');
37*69606e3fSchristos
38*69606e3fSchristos
39*69606e3fSchristos# Test #2: unknown goal.
40*69606e3fSchristos#
41*69606e3fSchristosrun_make_test('
42*69606e3fSchristos.DEFAULT_GOAL = foo
43*69606e3fSchristos',
44*69606e3fSchristos'',
45*69606e3fSchristos'#MAKE#: *** No rule to make target `foo\'.  Stop.',
46*69606e3fSchristos512);
47*69606e3fSchristos
48*69606e3fSchristos
49*69606e3fSchristos# Test #3: more than one goal.
50*69606e3fSchristos#
51*69606e3fSchristosrun_make_test('
52*69606e3fSchristos.DEFAULT_GOAL := foo bar
53*69606e3fSchristos',
54*69606e3fSchristos'',
55*69606e3fSchristos'#MAKE#: *** .DEFAULT_GOAL contains more than one target.  Stop.',
56*69606e3fSchristos512);
57*69606e3fSchristos
58*69606e3fSchristos
59*69606e3fSchristos# Test #4: Savannah bug #12226.
60*69606e3fSchristos#
61*69606e3fSchristosrun_make_test('
62*69606e3fSchristosdefine rule
63*69606e3fSchristosfoo: ; @echo $$@
64*69606e3fSchristosendef
65*69606e3fSchristos
66*69606e3fSchristosdefine make-rule
67*69606e3fSchristos$(eval $(rule))
68*69606e3fSchristosendef
69*69606e3fSchristos
70*69606e3fSchristos$(call make-rule)
71*69606e3fSchristos
72*69606e3fSchristos',
73*69606e3fSchristos'',
74*69606e3fSchristos'foo');
75*69606e3fSchristos
76*69606e3fSchristos
77*69606e3fSchristos# This tells the test driver that the perl test script executed properly.
78*69606e3fSchristos1;
79