5 # Test for broken LHS expansion.
6 # This *must* cause make(1) to detect a recursive variable, and fail as such.
15 DATA3= ${DATA2:S/ll/rr/g}
16 DATA4:= ${DATA2:S/ll/rr/g}
18 DATA5:= ${DATA2:S/ll/ii/g} ${DATA1:S/ll/rr/g}
20 DATA1:= ${DATA5:S/l/r/g}
23 SMAKE= MAKEFLAGS= ${MAKE} -C ${.CURDIR}
27 @${SMAKE} C_check || { ${MAKE} -C ${.CURDIR} 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 - || \
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} arith_expr || ${SMAKE} failure
44 @echo "ok 8 arith_expr # Test arith_expr detected no regression."
45 @${SMAKE} PATH_exists || ${SMAKE} failure
46 @echo "ok 9 PATH_exists # Test PATH_exists detected no regression."
47 @${SMAKE} double_quotes || ${SMAKE} failure
48 @echo "ok 10 double_quotes # Test double_quotes detected no regression."
49 @! ${SMAKE} double_quotes2 >/dev/null 2>&1 && true || ${SMAKE} failure
50 @echo "ok 11 double_quotes2 # Test double_quotes2 detected no regression."
51 @${SMAKE} pass_cmd_vars || ${SMAKE} failure
52 @echo "ok 12 pass_cmd_vars # Test pass_cmd_vars detected no regression."
53 @${SMAKE} plus_flag || ${SMAKE} failure
54 @echo "ok 13 plus_flag # Test plus_flag detected no regression."
55 @! ${SMAKE} shell >/dev/null 2>&1 && true || ${SMAKE} failure
56 @echo "ok 14 shell # Test shell detected no regression."
57 @${SMAKE} shell_1 || ${SMAKE} failure
58 @echo "ok 15 shell_1 # Test shell_1 detected no regression."
59 .if !defined(.PARSEDIR)
60 @${SMAKE} shell_2 || ${SMAKE} failure
61 @echo "ok 16 shell_2 # Test shell_2 detected no regression."
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
80 # Some versions of FreeBSD make(1) do not handle a nil LHS in sysvsubst.
82 @echo EMPTY ${NIL:=foo} LHS | \
83 diff -u ${.CURDIR}/regress.sysvmatch.out - || false
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.
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.
97 .if defined(notdef) && ${notdef:M/}
102 .if defined(.PARSEDIR)
103 # check if bmake can expand plain variables
104 .MAKE.EXPAND_VARIABLES= yes
105 x!= ${SMAKE} -V .CURDIR:H
107 .if ${.CURDIR:H} != "$x"
111 # See if make(1) supports the C modifier.
113 @if ${SMAKE} -V .CURDIR:C/.// 2>&1 >/dev/null | \
114 grep -q "Unknown modifier 'C'"; then \
118 # check that make -V '${VAR}' works
119 V_expn != V_OK=ok ${SMAKE} -r -f /dev/null -V '$${V_OK}'
129 # See if arithmetic expression parsing is broken.
130 # The different spacing below is intentional.
132 .if (${VALUE} < 0)||(${VALUE}>0)
136 .if make(PATH_exists)
139 .if !exists(${.CURDIR}/) || !exists(${.CURDIR}/.) || !exists(${.CURDIR}/..)
140 .error exists() failed
144 .if make(double_quotes)
147 .if ${VALUE:S/$//} != ${VALUE}
148 .error "" reduced to "
152 .if make(double_quotes2)
158 # Check passing of variable via MAKEFLAGS
160 .if make(pass_cmd_vars)
162 @${SMAKE} CMD1=cmd1 CMD2=cmd2 pass_cmd_vars_1
163 @${SMAKE} CMD1=cmd1 CMD2=cmd2 pass_cmd_vars_2
164 @${SMAKE} CMD1=cmd1 CMD2=cmd2 pass_cmd_vars_3
165 @${SMAKE} CMD1=cmd1 CMD2=cmd2 pass_cmd_vars_4
169 # Check that the variable definition arrived from the calling make
171 .if make(pass_cmd_vars_1)
172 # These values should get overridden by the commandline
178 .if ${CMD1} != cmd1 || ${CMD2} != cmd2
179 .error variables not passed through MAKEFLAGS
183 .if make(pass_cmd_vars_2)
184 # Check that we cannot override the passed variables
188 .if ${CMD1} != cmd1 || ${CMD2} != cmd2
189 .error MAKEFLAGS-passed variables overridden
196 .if make(pass_cmd_vars_3)
197 # Check that we can override the passed variables on the next sub-make's
201 @${SMAKE} CMD1=foo1 pass_cmd_vars_3_1
204 .if make(pass_cmd_vars_3_1)
205 .if ${CMD1} != foo1 || ${CMD2} != cmd2
206 .error MAKEFLAGS-passed variables not overridden on command line
212 .if make(pass_cmd_vars_4)
213 # Ensure that a variable assignment passed via MAKEFLAGS may be overwritten
214 # by evaluating the .MAKEFLAGS target.
216 .MAKEFLAGS: CMD1=baz1
219 @${SMAKE} pass_cmd_vars_4_1
221 .if ${CMD1} != baz1 || ${CMD2} != cmd2
222 .error MAKEFLAGS-passed variables not overridden via .MAKEFLAGS target
226 .if make(pass_cmd_vars_4_1)
227 .if ${CMD1} != baz1 || ${CMD2} != cmd2
228 .error MAKEFLAGS-passed variables not overridden via .MAKEFLAGS target (2)
235 # Test whether make supports the '+' flag (meaning: execute even with -n)
238 OUT != ${SMAKE} -n plus_flag_1
239 .if ${OUT:M/tmp} != "/tmp"
240 .error make doesn't handle + flag
245 .if make(plus_flag_1)
251 # Test if make fully supports the .SHELL specification.
252 .SHELL: path=/nonexistent
258 # Test if setting the shell by name only works. Because we have no ksh
259 # in the base system we test that we can set sh and csh. We try only exact
260 # matching names and do not exercise the rather strange matching algorithm.
262 @${SMAKE} shell_1_csh
265 .if make(shell_1_csh)
268 @ps -ax -opid,command | awk '$$1=="'$$$$'" { print $$2 }' | grep -E -q '^(/bin/)?csh$$'
273 @ps -ax -opid,command | awk '$$1=="'$$$$'" { print $$2 }' | grep -E -q '^(/bin/)?sh$$'
277 # Test if we can replace the shell specification. We do this by using
278 # a shell scripts that prints us its arguments and standard input as the shell
280 @${SMAKE} -B shell_2B | \
281 diff -u ${.CURDIR}/regress.shell_2B.out - || false
282 @${SMAKE} -j1 shell_2j | \
283 diff -u ${.CURDIR}/regress.shell_2j.out - || false
287 .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"
295 .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"
303 @echo "not ok # Test failed: regression detected. See above."
306 CLEANFILES= shell_test
308 .include <bsd.obj.mk>