2002-04-20 20:57:00 +00:00
|
|
|
# $FreeBSD$
|
|
|
|
|
2002-06-19 18:57:04 +00:00
|
|
|
# Test for broken LHS expansion.
|
2002-11-28 13:08:09 +00:00
|
|
|
# This *must* cause make(1) to detect a recursive variable, and fail as such.
|
2002-06-19 18:57:04 +00:00
|
|
|
.if make(lhs_expn)
|
|
|
|
FOO= ${BAR}
|
|
|
|
BAR${NIL}= ${FOO}
|
|
|
|
FOO${BAR}= ${FOO}
|
|
|
|
.endif
|
|
|
|
|
2002-04-20 20:57:00 +00:00
|
|
|
DATA1= helllo
|
|
|
|
DATA2:= ${DATA1}
|
|
|
|
DATA3= ${DATA2:S/ll/rr/g}
|
|
|
|
DATA4:= ${DATA2:S/ll/rr/g}
|
|
|
|
DATA2?= allo
|
|
|
|
DATA5:= ${DATA2:S/ll/ii/g} ${DATA1:S/ll/rr/g}
|
|
|
|
DATA2= yello
|
|
|
|
DATA1:= ${DATA5:S/l/r/g}
|
2002-05-05 19:02:30 +00:00
|
|
|
NIL=
|
2002-04-20 20:57:00 +00:00
|
|
|
|
2004-12-02 17:00:58 +00:00
|
|
|
SMAKE= ${MAKE} -C ${.CURDIR}
|
|
|
|
|
2002-04-20 20:57:00 +00:00
|
|
|
all:
|
2004-12-02 17:00:58 +00:00
|
|
|
@if [ ! -x ./shell_test ] ; then \
|
|
|
|
${INSTALL} -m 555 ${.CURDIR}/shell_test.sh shell_test ; \
|
|
|
|
fi
|
|
|
|
@echo '1..17'
|
|
|
|
@${SMAKE} C_check || { cd ${.CURDIR} ; ${MAKE} failure ; }
|
|
|
|
@echo "ok 1 - C_check # Test of -C flag existence detected no regression."
|
2002-04-20 20:57:00 +00:00
|
|
|
@echo 1:${DATA1} 2:${DATA2} 3:${DATA3} 4:${DATA4} 5:${DATA5} | \
|
2004-12-02 17:00:58 +00:00
|
|
|
diff -u ${.CURDIR}/regress.variables.out - || \
|
|
|
|
${SMAKE} failure
|
|
|
|
@echo "ok 2 - test_variables # Test variables detected no regression, output matches."
|
|
|
|
@${SMAKE} double 2>/dev/null || ${SMAKE} failure
|
|
|
|
@echo "ok 3 - test_targets # Test targets detected no regression."
|
|
|
|
@${SMAKE} sysvmatch || ${SMAKE} failure
|
|
|
|
@echo "ok 4 - sysvmatch # Test sysvmatch detected no regression."
|
|
|
|
@! ${SMAKE} lhs_expn && true || ${SMAKE} failure
|
|
|
|
@echo "ok 5 lhs_expn # Test lhs_expn detected no regression."
|
|
|
|
@${SMAKE} notdef || ${SMAKE} failure
|
|
|
|
@echo "ok 6 - notdef # Test notdef detected no regression."
|
|
|
|
@${SMAKE} modifiers || ${SMAKE} failure
|
|
|
|
@echo "ok 7 - modifiers # Test modifiers detected no regression."
|
|
|
|
@${SMAKE} funny_targets || ${SMAKE} failure
|
|
|
|
@echo "ok 8 funny_targets # Test funny_targets detected no regression."
|
|
|
|
@${SMAKE} arith_expr || ${SMAKE} failure
|
|
|
|
@echo "ok 9 arith_expr # Test arith_expr detected no regression."
|
|
|
|
@${SMAKE} PATH_exists || ${SMAKE} failure
|
|
|
|
@echo "ok 10 PATH_exists # Test PATH_exists detected no regression."
|
|
|
|
@${SMAKE} double_quotes || ${SMAKE} failure
|
|
|
|
@echo "ok 11 double_quotes # Test double_quotes detected no regression."
|
|
|
|
@! ${SMAKE} double_quotes2 >/dev/null 2>&1 && true || ${SMAKE} failure
|
|
|
|
@echo "ok 12 double_quotes2 # Test double_quotes2 detected no regression."
|
|
|
|
@${SMAKE} pass_cmd_vars || ${SMAKE} failure
|
|
|
|
@echo "ok 13 pass_cmd_vars # Test pass_cmd_vars detected no regression."
|
|
|
|
@${SMAKE} plus_flag || ${SMAKE} failure
|
|
|
|
@echo "ok 14 plus_flag # Test plus_flag detected no regression."
|
|
|
|
@! ${SMAKE} shell >/dev/null 2>&1 && true || ${SMAKE} failure
|
|
|
|
@echo "ok 15 shell # Test shell detected no regression."
|
|
|
|
@${SMAKE} shell_1 || ${SMAKE} failure
|
|
|
|
@echo "ok 16 shell_1 # Test shell_1 detected no regression."
|
|
|
|
@${SMAKE} shell_2 || ${SMAKE} failure
|
|
|
|
@echo "ok 17 shell_2 # Test shell_2 detected no regression."
|
|
|
|
|
|
|
|
.if make(C_check)
|
|
|
|
C_check:
|
|
|
|
.endif
|
2002-04-21 00:41:37 +00:00
|
|
|
|
2002-10-25 06:17:44 +00:00
|
|
|
.if make(double)
|
2002-07-28 03:57:08 +00:00
|
|
|
# Doubly-defined targets. make(1) will warn, but use the "right" one. If it
|
|
|
|
# switches to using the "non-right" one, it breaks things worse than a little
|
|
|
|
# regression test.
|
2002-04-21 00:41:37 +00:00
|
|
|
double:
|
|
|
|
@true
|
|
|
|
|
|
|
|
double:
|
|
|
|
@false
|
2002-10-25 06:17:44 +00:00
|
|
|
.endif
|
2002-04-20 20:57:00 +00:00
|
|
|
|
2002-10-25 06:17:44 +00:00
|
|
|
.if make(sysvmatch)
|
2002-05-05 19:02:30 +00:00
|
|
|
# Some versions of FreeBSD make(1) do not handle a nil LHS in sysvsubst.
|
|
|
|
sysvmatch:
|
|
|
|
@echo EMPTY ${NIL:=foo} LHS | \
|
|
|
|
diff -u ${.CURDIR}/regress.sysvmatch.out - || false
|
2002-10-25 06:17:44 +00:00
|
|
|
.endif
|
2002-05-05 19:02:30 +00:00
|
|
|
|
2002-06-19 18:57:04 +00:00
|
|
|
# A bogus target for the lhs_expn test; If this is reached, then the make(1)
|
|
|
|
# program has not errored out because of the recursion caused by not expanding
|
|
|
|
# the left-hand-side's embedded variables above.
|
|
|
|
lhs_expn:
|
2002-06-20 03:08:20 +00:00
|
|
|
@true
|
2002-06-19 18:57:04 +00:00
|
|
|
|
2002-11-28 13:08:09 +00:00
|
|
|
.if make(notdef)
|
|
|
|
# make(1) claims to only evaluate a conditional as far as is necessary
|
|
|
|
# to determine its value; that was not always the case.
|
|
|
|
.undef notdef
|
|
|
|
notdef:
|
|
|
|
.if defined(notdef) && ${notdef:U}
|
|
|
|
.endif
|
|
|
|
.endif
|
|
|
|
|
|
|
|
.if make(modifiers)
|
|
|
|
# See if make(1) supports the C modifier.
|
|
|
|
modifiers:
|
2004-12-02 17:00:58 +00:00
|
|
|
@if ${SMAKE} -V .CURDIR:C/.// 2>&1 >/dev/null | \
|
2002-11-28 13:08:09 +00:00
|
|
|
grep -q "Unknown modifier 'C'"; then \
|
|
|
|
false; \
|
|
|
|
fi
|
|
|
|
.endif
|
|
|
|
|
2002-11-28 13:21:32 +00:00
|
|
|
.if make(funny_targets)
|
|
|
|
funny_targets: colons::target exclamation!target
|
|
|
|
colons::target:
|
|
|
|
exclamation!target:
|
|
|
|
.endif
|
|
|
|
|
2003-07-04 13:33:48 +00:00
|
|
|
.if make(arith_expr)
|
|
|
|
arith_expr:
|
|
|
|
# See if arithmetic expression parsing is broken.
|
|
|
|
# The different spacing below is intentional.
|
|
|
|
VALUE= 0
|
|
|
|
.if (${VALUE} < 0)||(${VALUE}>0)
|
|
|
|
.endif
|
|
|
|
.endif
|
|
|
|
|
2003-10-02 21:30:30 +00:00
|
|
|
.if make(PATH_exists)
|
|
|
|
PATH_exists:
|
|
|
|
.PATH: ${.CURDIR}
|
|
|
|
.if !exists(${.CURDIR}/) || !exists(${.CURDIR}/.) || !exists(${.CURDIR}/..)
|
|
|
|
.error exists() failed
|
|
|
|
.endif
|
|
|
|
.endif
|
|
|
|
|
2004-01-29 22:51:36 +00:00
|
|
|
.if make(double_quotes)
|
|
|
|
VALUE= foo ""
|
|
|
|
double_quotes:
|
|
|
|
.if ${VALUE:S/$//} != ${VALUE}
|
|
|
|
.error "" reduced to "
|
|
|
|
.endif
|
|
|
|
.endif
|
|
|
|
|
2004-01-30 09:46:28 +00:00
|
|
|
.if make(double_quotes2)
|
|
|
|
double_quotes2:
|
|
|
|
@cat /dev/null ""
|
|
|
|
.endif
|
|
|
|
|
2004-08-04 07:40:58 +00:00
|
|
|
#
|
|
|
|
# Check passing of variable via MAKEFLAGS
|
|
|
|
#
|
|
|
|
.if make(pass_cmd_vars)
|
|
|
|
pass_cmd_vars:
|
2004-12-02 17:00:58 +00:00
|
|
|
@${SMAKE} CMD1=cmd1 CMD2=cmd2 pass_cmd_vars_1
|
|
|
|
@${SMAKE} CMD1=cmd1 CMD2=cmd2 pass_cmd_vars_2
|
|
|
|
@${SMAKE} CMD1=cmd1 CMD2=cmd2 pass_cmd_vars_3
|
|
|
|
@${SMAKE} CMD1=cmd1 CMD2=cmd2 pass_cmd_vars_4
|
2004-08-04 07:40:58 +00:00
|
|
|
.endif
|
|
|
|
|
|
|
|
.if make(pass_cmd_vars_1)
|
|
|
|
# Check that the variable definition arrived from the calling make
|
|
|
|
pass_cmd_vars_1:
|
|
|
|
@:
|
|
|
|
|
|
|
|
.if ${CMD1} != cmd1 || ${CMD2} != cmd2
|
2004-08-05 08:44:00 +00:00
|
|
|
.error variables not passed through MAKEFLAGS
|
2004-08-04 07:40:58 +00:00
|
|
|
.endif
|
|
|
|
|
|
|
|
# Check that the variable definition is in MAKEFLAGS
|
|
|
|
.if ${.MAKEFLAGS:MCMD1=*} != "CMD1=cmd1" || ${.MAKEFLAGS:MCMD2=*} != "CMD2=cmd2"
|
2004-08-05 08:44:00 +00:00
|
|
|
.error variable assignment not found in $${MAKEFLAGS}
|
2004-08-04 07:40:58 +00:00
|
|
|
.endif
|
|
|
|
|
|
|
|
# Check that the variable definition is not in MFLAGS
|
|
|
|
.if ${MFLAGS:MCMD1=*} != "" || ${MFLAGS:MCMD2=*} != ""
|
2004-08-05 08:44:00 +00:00
|
|
|
.error variable assignment found in $${MFLAGS}
|
2004-08-04 07:40:58 +00:00
|
|
|
.endif
|
|
|
|
.endif
|
|
|
|
|
|
|
|
.if make(pass_cmd_vars_2)
|
|
|
|
# Check that we cannot override the passed variables
|
|
|
|
CMD1=foo1
|
|
|
|
CMD2=foo2
|
|
|
|
|
|
|
|
.if ${CMD1} != cmd1 || ${CMD2} != cmd2
|
2004-08-05 08:44:00 +00:00
|
|
|
.error MAKEFLAGS-passed variables overridden
|
2004-08-04 07:40:58 +00:00
|
|
|
.endif
|
|
|
|
|
|
|
|
pass_cmd_vars_2:
|
|
|
|
@:
|
|
|
|
.endif
|
|
|
|
|
|
|
|
.if make(pass_cmd_vars_3)
|
|
|
|
# Check that we can override the passed variables on the next sub-make's
|
|
|
|
# command line
|
|
|
|
|
|
|
|
pass_cmd_vars_3:
|
2004-12-02 17:00:58 +00:00
|
|
|
@${SMAKE} CMD1=foo1 pass_cmd_vars_3_1
|
2004-08-04 07:40:58 +00:00
|
|
|
.endif
|
|
|
|
|
|
|
|
.if make(pass_cmd_vars_3_1)
|
|
|
|
.if ${CMD1} != foo1 || ${CMD2} != cmd2
|
2004-08-05 08:44:00 +00:00
|
|
|
.error MAKEFLAGS-passed variables not overridden on command line
|
2004-08-04 07:40:58 +00:00
|
|
|
.endif
|
|
|
|
pass_cmd_vars_3_1:
|
|
|
|
@:
|
|
|
|
.endif
|
|
|
|
|
|
|
|
.if make(pass_cmd_vars_4)
|
|
|
|
# Ensure that a variable assignment passed via MAKEFLAGS may be overwritten
|
|
|
|
# by evaluating the .MAKEFLAGS target.
|
|
|
|
|
|
|
|
.MAKEFLAGS: CMD1=baz1
|
|
|
|
|
|
|
|
pass_cmd_vars_4:
|
2004-12-02 17:00:58 +00:00
|
|
|
@${SMAKE} pass_cmd_vars_4_1
|
2004-08-04 07:40:58 +00:00
|
|
|
|
|
|
|
.if ${CMD1} != baz1 || ${CMD2} != cmd2
|
2004-08-05 08:44:00 +00:00
|
|
|
.error MAKEFLAGS-passed variables not overridden via .MAKEFLAGS target
|
2004-08-04 07:40:58 +00:00
|
|
|
.endif
|
|
|
|
|
|
|
|
.endif
|
|
|
|
.if make(pass_cmd_vars_4_1)
|
|
|
|
.if ${CMD1} != baz1 || ${CMD2} != cmd2
|
2004-08-05 08:44:00 +00:00
|
|
|
.error MAKEFLAGS-passed variables not overridden via .MAKEFLAGS target (2)
|
2004-08-04 07:40:58 +00:00
|
|
|
.endif
|
|
|
|
pass_cmd_vars_4_1:
|
|
|
|
@:
|
|
|
|
.endif
|
|
|
|
|
2004-08-05 07:24:06 +00:00
|
|
|
#
|
|
|
|
# Test whether make supports the '+' flag (meaning: execute even with -n)
|
|
|
|
#
|
|
|
|
.if make(plus_flag)
|
2004-12-02 17:00:58 +00:00
|
|
|
OUT != ${SMAKE} -n plus_flag_1
|
2004-08-05 07:24:06 +00:00
|
|
|
.if ${OUT} != "/tmp"
|
2004-08-05 08:44:00 +00:00
|
|
|
.error make doesn't handle + flag
|
2004-08-05 07:24:06 +00:00
|
|
|
.endif
|
|
|
|
plus_flag:
|
|
|
|
@:
|
|
|
|
.endif
|
|
|
|
.if make(plus_flag_1)
|
|
|
|
plus_flag_1:
|
|
|
|
+@cd /tmp; pwd
|
|
|
|
.endif
|
|
|
|
|
2004-10-23 21:38:58 +00:00
|
|
|
.if make(shell)
|
|
|
|
# Test if make fully supports the .SHELL specification.
|
|
|
|
.SHELL: path=/nonexistent
|
|
|
|
A!= echo ok
|
|
|
|
shell:
|
|
|
|
.endif
|
|
|
|
|
2004-11-25 10:03:29 +00:00
|
|
|
.if make(shell_1)
|
|
|
|
# Test if setting the shell by name only works. Because we have no ksh
|
|
|
|
# in the base system we test that we can set sh and csh. We try only exact
|
|
|
|
# matching names and do not exercise the rather strange matching algorithm.
|
|
|
|
shell_1:
|
2004-12-02 17:00:58 +00:00
|
|
|
@${SMAKE} shell_1_csh
|
|
|
|
@${SMAKE} shell_1_sh
|
2004-11-25 10:03:29 +00:00
|
|
|
.endif
|
|
|
|
.if make(shell_1_csh)
|
|
|
|
.SHELL: name="csh"
|
|
|
|
shell_1_csh:
|
2004-12-02 17:00:58 +00:00
|
|
|
@ps -ax -opid,command | awk '$$1=="'$$$$'" { print $$2 }' | grep -E -q '^(/bin/)?csh$$'
|
2004-11-25 10:03:29 +00:00
|
|
|
.endif
|
|
|
|
.if make(shell_1_sh)
|
|
|
|
.SHELL: name="sh"
|
|
|
|
shell_1_sh:
|
|
|
|
@ps -ax -opid,command | awk '$$1=="'$$$$'" { print $$2 }' | grep -q '^/bin/sh$$'
|
|
|
|
.endif
|
|
|
|
|
|
|
|
.if make(shell_2)
|
|
|
|
# Test if we can replace the shell specification. We do this by using
|
|
|
|
# a shell scripts that prints us its arguments and standard input as the shell
|
|
|
|
shell_2:
|
2004-12-02 17:00:58 +00:00
|
|
|
@${SMAKE} -B shell_2B | \
|
2004-11-25 10:03:29 +00:00
|
|
|
diff -u ${.CURDIR}/regress.shell_2B.out - || false
|
2004-12-02 17:00:58 +00:00
|
|
|
@${SMAKE} -j1 shell_2j | \
|
2004-11-25 10:03:29 +00:00
|
|
|
diff -u ${.CURDIR}/regress.shell_2j.out - || false
|
|
|
|
.endif
|
|
|
|
|
|
|
|
.if make(shell_2B)
|
2004-12-02 17:00:58 +00:00
|
|
|
.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"
|
2004-11-25 10:03:29 +00:00
|
|
|
|
|
|
|
shell_2B:
|
|
|
|
-@funny $$
|
|
|
|
funnier $$
|
|
|
|
.endif
|
|
|
|
|
|
|
|
.if make(shell_2j)
|
2004-12-02 17:00:58 +00:00
|
|
|
.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"
|
2004-11-25 10:03:29 +00:00
|
|
|
|
|
|
|
shell_2j:
|
|
|
|
-@funny $$
|
|
|
|
funnier $$
|
|
|
|
.endif
|
|
|
|
|
2002-04-20 20:57:00 +00:00
|
|
|
failure:
|
2004-11-11 19:47:55 +00:00
|
|
|
@echo "not ok # Test failed: regression detected. See above."
|
2002-04-20 20:57:00 +00:00
|
|
|
@false
|
2004-12-02 17:00:58 +00:00
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -f shell_test
|