xref: /netbsd-src/external/gpl2/gmake/dist/tests/scripts/features/include (revision 69606e3f5c9388e52aed8c120ad63c049ca45d8f)
1*69606e3fSchristos#                                     -*-mode: perl; rm-trailing-spaces: nil-*-
2*69606e3fSchristos
3*69606e3fSchristos$description = "Test various forms of the GNU make `include' command.";
4*69606e3fSchristos
5*69606e3fSchristos$details = "\
6*69606e3fSchristosTest include, -include, sinclude and various regressions involving them.
7*69606e3fSchristosTest extra whitespace at the end of the include, multiple -includes and
8*69606e3fSchristossincludes (should not give an error) and make sure that errors are reported
9*69606e3fSchristosfor targets that were also -included.";
10*69606e3fSchristos
11*69606e3fSchristos$makefile2 = &get_tmpfile;
12*69606e3fSchristos
13*69606e3fSchristosopen(MAKEFILE,"> $makefile");
14*69606e3fSchristos
15*69606e3fSchristos# The contents of the Makefile ...
16*69606e3fSchristos
17*69606e3fSchristosprint MAKEFILE <<EOF;
18*69606e3fSchristos\#Extra space at the end of the following file name
19*69606e3fSchristosinclude $makefile2
20*69606e3fSchristosall: ; \@echo There should be no errors for this makefile.
21*69606e3fSchristos
22*69606e3fSchristos-include nonexistent.mk
23*69606e3fSchristos-include nonexistent.mk
24*69606e3fSchristossinclude nonexistent.mk
25*69606e3fSchristossinclude nonexistent-2.mk
26*69606e3fSchristos-include makeit.mk
27*69606e3fSchristossinclude makeit.mk
28*69606e3fSchristos
29*69606e3fSchristoserror: makeit.mk
30*69606e3fSchristosEOF
31*69606e3fSchristos
32*69606e3fSchristosclose(MAKEFILE);
33*69606e3fSchristos
34*69606e3fSchristos
35*69606e3fSchristosopen(MAKEFILE,"> $makefile2");
36*69606e3fSchristos
37*69606e3fSchristosprint MAKEFILE "ANOTHER: ; \@echo This is another included makefile\n";
38*69606e3fSchristos
39*69606e3fSchristosclose(MAKEFILE);
40*69606e3fSchristos
41*69606e3fSchristos# Create the answer to what should be produced by this Makefile
42*69606e3fSchristos&run_make_with_options($makefile, "all", &get_logfile);
43*69606e3fSchristos$answer = "There should be no errors for this makefile.\n";
44*69606e3fSchristos&compare_output($answer, &get_logfile(1));
45*69606e3fSchristos
46*69606e3fSchristos&run_make_with_options($makefile, "ANOTHER", &get_logfile);
47*69606e3fSchristos$answer = "This is another included makefile\n";
48*69606e3fSchristos&compare_output($answer, &get_logfile(1));
49*69606e3fSchristos
50*69606e3fSchristos$makefile = undef;
51*69606e3fSchristos
52*69606e3fSchristos# Try to build the "error" target; this will fail since we don't know
53*69606e3fSchristos# how to create makeit.mk, but we should also get a message (even though
54*69606e3fSchristos# the -include suppressed it during the makefile read phase, we should
55*69606e3fSchristos# see one during the makefile run phase).
56*69606e3fSchristos
57*69606e3fSchristosrun_make_test
58*69606e3fSchristos  ('
59*69606e3fSchristos-include foo.mk
60*69606e3fSchristoserror: foo.mk ; @echo $@
61*69606e3fSchristos',
62*69606e3fSchristos   '',
63*69606e3fSchristos   "#MAKE#: *** No rule to make target `foo.mk', needed by `error'.  Stop.\n",
64*69606e3fSchristos   512
65*69606e3fSchristos  );
66*69606e3fSchristos
67*69606e3fSchristos# Make sure that target-specific variables don't impact things.  This could
68*69606e3fSchristos# happen because a file record is created when a target-specific variable is
69*69606e3fSchristos# set.
70*69606e3fSchristos
71*69606e3fSchristosrun_make_test
72*69606e3fSchristos  ('
73*69606e3fSchristosbar.mk: foo := baz
74*69606e3fSchristos-include bar.mk
75*69606e3fSchristoshello: ; @echo hello
76*69606e3fSchristos',
77*69606e3fSchristos   '',
78*69606e3fSchristos   "hello\n"
79*69606e3fSchristos  );
80*69606e3fSchristos
81*69606e3fSchristos
82*69606e3fSchristos# Test inheritance of dontcare flag when rebuilding makefiles.
83*69606e3fSchristos#
84*69606e3fSchristosrun_make_test('
85*69606e3fSchristos.PHONY: all
86*69606e3fSchristosall: ; @:
87*69606e3fSchristos
88*69606e3fSchristos-include foo
89*69606e3fSchristos
90*69606e3fSchristosfoo: bar; @:
91*69606e3fSchristos', '', '');
92*69606e3fSchristos
93*69606e3fSchristos1;
94*69606e3fSchristos
95*69606e3fSchristos
96*69606e3fSchristos# Make sure that we don't die when the command fails but we dontcare.
97*69606e3fSchristos# (Savannah bug #13216).
98*69606e3fSchristos#
99*69606e3fSchristosrun_make_test('
100*69606e3fSchristos.PHONY: all
101*69606e3fSchristosall:; @:
102*69606e3fSchristos
103*69606e3fSchristos-include foo
104*69606e3fSchristos
105*69606e3fSchristosfoo: bar; @:
106*69606e3fSchristos
107*69606e3fSchristosbar:; @exit 1
108*69606e3fSchristos', '', '');
109*69606e3fSchristos
110*69606e3fSchristos# Check include, sinclude, -include with no filenames.
111*69606e3fSchristos# (Savannah bug #1761).
112*69606e3fSchristos
113*69606e3fSchristosrun_make_test('
114*69606e3fSchristos.PHONY: all
115*69606e3fSchristosall:; @:
116*69606e3fSchristosinclude
117*69606e3fSchristos-include
118*69606e3fSchristossinclude', '', '');
119*69606e3fSchristos
120*69606e3fSchristos1;
121