]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - tools/build/make_check/Makefile
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / tools / build / make_check / Makefile
1 # $FreeBSD$
2
3 .MAKE.MODE=     normal
4
5 # Test for broken LHS expansion.
6 # This *must* cause make(1) to detect a recursive variable, and fail as such.
7 .if make(lhs_expn)
8 FOO=            ${BAR}
9 BAR${NIL}=      ${FOO}
10 FOO${BAR}=      ${FOO}
11 .endif
12
13 DATA1=  helllo
14 DATA2:= ${DATA1}
15 DATA3=  ${DATA2:S/ll/rr/g}
16 DATA4:= ${DATA2:S/ll/rr/g}
17 DATA2?= allo
18 DATA5:= ${DATA2:S/ll/ii/g} ${DATA1:S/ll/rr/g}
19 DATA2=  yello
20 DATA1:= ${DATA5:S/l/r/g}
21 NIL=
22
23 SMAKE=  MAKEFLAGS= ${MAKE} -C ${.CURDIR}
24
25 all:
26         @echo '1..17'
27         @${SMAKE} C_check || { cd ${.CURDIR} ; ${MAKE} failure ; }
28         @echo "ok 1 - C_check # Test of -C flag existence detected no regression."
29         @echo 1:${DATA1} 2:${DATA2} 3:${DATA3} 4:${DATA4} 5:${DATA5} | \
30                 diff -u ${.CURDIR}/regress.variables.out - || \
31                 ${SMAKE} failure
32         @echo "ok 2 - test_variables # Test variables detected no regression, output matches."
33         @${SMAKE} double 2>/dev/null || ${SMAKE} failure
34         @echo "ok 3 - test_targets # Test targets detected no regression."
35         @${SMAKE} sysvmatch || ${SMAKE} failure
36         @echo "ok 4 - sysvmatch # Test sysvmatch detected no regression."
37         @! ${SMAKE} lhs_expn && true || ${SMAKE} failure
38         @echo "ok 5 lhs_expn # Test lhs_expn detected no regression."
39         @${SMAKE} notdef || ${SMAKE} failure
40         @echo "ok 6 - notdef # Test notdef detected no regression."
41         @${SMAKE} modifiers || ${SMAKE} failure
42         @echo "ok 7 - modifiers # Test modifiers detected no regression."
43         @${SMAKE} funny_targets || ${SMAKE} failure
44         @echo "ok 8 funny_targets # Test funny_targets detected no regression."
45         @${SMAKE} arith_expr || ${SMAKE} failure
46         @echo "ok 9 arith_expr # Test arith_expr detected no regression."
47         @${SMAKE} PATH_exists || ${SMAKE} failure
48         @echo "ok 10 PATH_exists # Test PATH_exists detected no regression."
49         @${SMAKE} double_quotes || ${SMAKE} failure
50         @echo "ok 11 double_quotes # Test double_quotes detected no regression."
51         @! ${SMAKE} double_quotes2 >/dev/null 2>&1 && true || ${SMAKE} failure
52         @echo "ok 12 double_quotes2 # Test double_quotes2 detected no regression."
53         @${SMAKE} pass_cmd_vars || ${SMAKE} failure
54         @echo "ok 13 pass_cmd_vars # Test pass_cmd_vars detected no regression."
55         @${SMAKE} plus_flag || ${SMAKE} failure
56         @echo "ok 14 plus_flag # Test plus_flag detected no regression."
57         @! ${SMAKE} shell >/dev/null 2>&1 && true || ${SMAKE} failure
58         @echo "ok 15 shell # Test shell detected no regression."
59         @${SMAKE} shell_1 || ${SMAKE} failure
60         @echo "ok 16 shell_1 # Test shell_1 detected no regression."
61         @${SMAKE} shell_2 || ${SMAKE} failure
62         @echo "ok 17 shell_2 # Test shell_2 detected no regression."
63
64 .if make(C_check)
65 C_check:
66 .endif
67
68 .if make(double)
69 # Doubly-defined targets.  make(1) will warn, but use the "right" one.  If it
70 # switches to using the "non-right" one, it breaks things worse than a little
71 # regression test.
72 double:
73         @true
74
75 double:
76         @false
77 .endif
78
79 .if make(sysvmatch)
80 # Some versions of FreeBSD make(1) do not handle a nil LHS in sysvsubst.
81 sysvmatch:
82         @echo EMPTY ${NIL:=foo} LHS | \
83                 diff -u ${.CURDIR}/regress.sysvmatch.out - || false
84 .endif
85
86 # A bogus target for the lhs_expn test;  If this is reached, then the make(1)
87 # program has not errored out because of the recursion caused by not expanding
88 # the left-hand-side's embedded variables above.
89 lhs_expn:
90         @true
91
92 .if make(notdef)
93 # make(1) claims to only evaluate a conditional as far as is necessary
94 # to determine its value; that was not always the case.
95 .undef notdef
96 notdef:
97 .if defined(notdef) && ${notdef:U}
98 .endif
99 .endif
100
101 .if make(modifiers)
102 # See if make(1) supports the C modifier.
103 modifiers:
104         @if ${SMAKE} -V .CURDIR:C/.// 2>&1 >/dev/null | \
105             grep -q "Unknown modifier 'C'"; then \
106                 false; \
107         fi
108 .endif
109
110 .if make(funny_targets)
111 funny_targets: colons::target exclamation!target
112 colons::target:
113 exclamation!target: 
114 .endif
115
116 .if make(arith_expr)
117 arith_expr:
118 # See if arithmetic expression parsing is broken.
119 # The different spacing below is intentional.
120 VALUE=  0
121 .if (${VALUE} < 0)||(${VALUE}>0)
122 .endif
123 .endif
124
125 .if make(PATH_exists)
126 PATH_exists:
127 .PATH: ${.CURDIR}
128 .if !exists(${.CURDIR}/) || !exists(${.CURDIR}/.) || !exists(${.CURDIR}/..)
129 .error exists() failed
130 .endif
131 .endif
132
133 .if make(double_quotes)
134 VALUE=  foo ""
135 double_quotes:
136 .if ${VALUE:S/$//} != ${VALUE}
137 .error "" reduced to "
138 .endif
139 .endif
140
141 .if make(double_quotes2)
142 double_quotes2:
143         @cat /dev/null ""
144 .endif
145
146 #
147 # Check passing of variable via MAKEFLAGS
148 #
149 .if make(pass_cmd_vars)
150 pass_cmd_vars:
151         @${SMAKE} CMD1=cmd1 CMD2=cmd2 pass_cmd_vars_1
152         @${SMAKE} CMD1=cmd1 CMD2=cmd2 pass_cmd_vars_2
153         @${SMAKE} CMD1=cmd1 CMD2=cmd2 pass_cmd_vars_3
154         @${SMAKE} CMD1=cmd1 CMD2=cmd2 pass_cmd_vars_4
155 .endif
156
157 #
158 # Check that the variable definition arrived from the calling make
159 #
160 .if make(pass_cmd_vars_1)
161 # These values should get overridden by the commandline
162 CMD1=oops1
163 CMD2=oops2
164 pass_cmd_vars_1:
165         @:
166
167 .if ${CMD1} != cmd1 || ${CMD2} != cmd2
168 .error variables not passed through MAKEFLAGS
169 .endif
170 .endif
171
172 .if make(pass_cmd_vars_2)
173 # Check that we cannot override the passed variables
174 CMD1=foo1
175 CMD2=foo2
176
177 .if ${CMD1} != cmd1 || ${CMD2} != cmd2
178 .error MAKEFLAGS-passed variables overridden
179 .endif
180
181 pass_cmd_vars_2:
182         @:
183 .endif
184
185 .if make(pass_cmd_vars_3)
186 # Check that we can override the passed variables on the next sub-make's
187 # command line
188
189 pass_cmd_vars_3:
190         @${SMAKE} CMD1=foo1 pass_cmd_vars_3_1
191 .endif
192
193 .if make(pass_cmd_vars_3_1)
194 .if ${CMD1} != foo1 || ${CMD2} != cmd2
195 .error MAKEFLAGS-passed variables not overridden on command line
196 .endif
197 pass_cmd_vars_3_1:
198         @:
199 .endif
200
201 .if make(pass_cmd_vars_4)
202 # Ensure that a variable assignment passed via MAKEFLAGS may be overwritten
203 # by evaluating the .MAKEFLAGS target.
204
205 .MAKEFLAGS: CMD1=baz1
206
207 pass_cmd_vars_4:
208         @${SMAKE} pass_cmd_vars_4_1
209
210 .if ${CMD1} != baz1 || ${CMD2} != cmd2
211 .error MAKEFLAGS-passed variables not overridden via .MAKEFLAGS target
212 .endif
213
214 .endif
215 .if make(pass_cmd_vars_4_1)
216 .if ${CMD1} != baz1 || ${CMD2} != cmd2
217 .error MAKEFLAGS-passed variables not overridden via .MAKEFLAGS target (2)
218 .endif
219 pass_cmd_vars_4_1:
220         @:
221 .endif
222
223 #
224 # Test whether make supports the '+' flag (meaning: execute even with -n)
225 #
226 .if make(plus_flag)
227 OUT != ${SMAKE} -n plus_flag_1
228 .if ${OUT:M/tmp} != "/tmp"
229 .error make doesn't handle + flag
230 .endif
231 plus_flag:
232         @:
233 .endif
234 .if make(plus_flag_1)
235 plus_flag_1:
236         +@cd /tmp; pwd
237 .endif
238
239 .if make(shell)
240 # Test if make fully supports the .SHELL specification.
241 .SHELL: path=/nonexistent
242 A!= echo ok
243 shell:
244 .endif
245
246 .if make(shell_1)
247 # Test if setting the shell by name only works. Because we have no ksh
248 # in the base system we test that we can set sh and csh. We try only exact
249 # matching names and do not exercise the rather strange matching algorithm.
250 shell_1:
251         @${SMAKE} shell_1_csh
252         @${SMAKE} shell_1_sh
253 .endif
254 .if make(shell_1_csh)
255 .SHELL: name="csh"
256 shell_1_csh:
257         @ps -ax -opid,command | awk '$$1=="'$$$$'" { print $$2 }' | grep -E -q '^(/bin/)?csh$$'
258 .endif
259 .if make(shell_1_sh)
260 .SHELL: name="sh"
261 shell_1_sh:
262         @ps -ax -opid,command | awk '$$1=="'$$$$'" { print $$2 }' | grep -E -q '^(/bin/)?sh$$'
263 .endif
264
265 .if make(shell_2)
266 # Test if we can replace the shell specification. We do this by using
267 # a shell scripts that prints us its arguments and standard input as the shell
268 shell_2: shell_test
269         @${SMAKE} -B shell_2B | \
270                 diff -u ${.CURDIR}/regress.shell_2B.out - || false
271         @${SMAKE} -j1 shell_2j | \
272                 diff -u ${.CURDIR}/regress.shell_2j.out - || false
273 .endif
274
275 .if make(shell_2B)
276 .SHELL: name="echo" path="${.OBJDIR}/shell_test" quiet="be quiet" echo="be verbose" filter="be verbose" echoFlag="x" errFlag="y" hasErrCtl=y check="check errors" ignore="ignore errors"
277
278 shell_2B:
279         -@funny $$
280         funnier $$
281 .endif
282
283 .if make(shell_2j)
284 .SHELL: name="echo" path="${.OBJDIR}/shell_test" quiet="be quiet" echo="be verbose" filter="be verbose" echoFlag="x" errFlag="y" hasErrCtl=y check="check errors" ignore="ignore errors"
285
286 shell_2j:
287         -@funny $$
288         funnier $$
289 .endif
290
291 failure:
292         @echo "not ok # Test failed: regression detected.  See above."
293         @false
294
295 CLEANFILES= shell_test
296
297 .include <bsd.obj.mk>