16541d27cSJuli Mallett# $FreeBSD$ 26541d27cSJuli Mallett 33c24f8e8SDavid E. O'Brien.MAKE.MODE= normal 43c24f8e8SDavid E. O'Brien 50aa9e01cSJuli Mallett# Test for broken LHS expansion. 6113cf9e6SRuslan Ermilov# This *must* cause make(1) to detect a recursive variable, and fail as such. 70aa9e01cSJuli Mallett.if make(lhs_expn) 80aa9e01cSJuli MallettFOO= ${BAR} 90aa9e01cSJuli MallettBAR${NIL}= ${FOO} 100aa9e01cSJuli MallettFOO${BAR}= ${FOO} 110aa9e01cSJuli Mallett.endif 120aa9e01cSJuli Mallett 136541d27cSJuli MallettDATA1= helllo 146541d27cSJuli MallettDATA2:= ${DATA1} 156541d27cSJuli MallettDATA3= ${DATA2:S/ll/rr/g} 166541d27cSJuli MallettDATA4:= ${DATA2:S/ll/rr/g} 176541d27cSJuli MallettDATA2?= allo 186541d27cSJuli MallettDATA5:= ${DATA2:S/ll/ii/g} ${DATA1:S/ll/rr/g} 196541d27cSJuli MallettDATA2= yello 206541d27cSJuli MallettDATA1:= ${DATA5:S/l/r/g} 21a9b736adSJuli MallettNIL= 226541d27cSJuli Mallett 23d29cf9e2SRuslan ErmilovSMAKE= MAKEFLAGS= ${MAKE} -C ${.CURDIR} 249c1f3ca3SHartmut Brandt 256541d27cSJuli Mallettall: 26*6e501706SDavid E. O'Brien @echo '1..16' 279c1f3ca3SHartmut Brandt @${SMAKE} C_check || { cd ${.CURDIR} ; ${MAKE} failure ; } 289c1f3ca3SHartmut Brandt @echo "ok 1 - C_check # Test of -C flag existence detected no regression." 296541d27cSJuli Mallett @echo 1:${DATA1} 2:${DATA2} 3:${DATA3} 4:${DATA4} 5:${DATA5} | \ 309c1f3ca3SHartmut Brandt diff -u ${.CURDIR}/regress.variables.out - || \ 319c1f3ca3SHartmut Brandt ${SMAKE} failure 329c1f3ca3SHartmut Brandt @echo "ok 2 - test_variables # Test variables detected no regression, output matches." 339c1f3ca3SHartmut Brandt @${SMAKE} double 2>/dev/null || ${SMAKE} failure 349c1f3ca3SHartmut Brandt @echo "ok 3 - test_targets # Test targets detected no regression." 359c1f3ca3SHartmut Brandt @${SMAKE} sysvmatch || ${SMAKE} failure 369c1f3ca3SHartmut Brandt @echo "ok 4 - sysvmatch # Test sysvmatch detected no regression." 379c1f3ca3SHartmut Brandt @! ${SMAKE} lhs_expn && true || ${SMAKE} failure 389c1f3ca3SHartmut Brandt @echo "ok 5 lhs_expn # Test lhs_expn detected no regression." 399c1f3ca3SHartmut Brandt @${SMAKE} notdef || ${SMAKE} failure 409c1f3ca3SHartmut Brandt @echo "ok 6 - notdef # Test notdef detected no regression." 419c1f3ca3SHartmut Brandt @${SMAKE} modifiers || ${SMAKE} failure 429c1f3ca3SHartmut Brandt @echo "ok 7 - modifiers # Test modifiers detected no regression." 439c1f3ca3SHartmut Brandt @${SMAKE} arith_expr || ${SMAKE} failure 44*6e501706SDavid E. O'Brien @echo "ok 8 arith_expr # Test arith_expr detected no regression." 459c1f3ca3SHartmut Brandt @${SMAKE} PATH_exists || ${SMAKE} failure 46*6e501706SDavid E. O'Brien @echo "ok 9 PATH_exists # Test PATH_exists detected no regression." 479c1f3ca3SHartmut Brandt @${SMAKE} double_quotes || ${SMAKE} failure 48*6e501706SDavid E. O'Brien @echo "ok 10 double_quotes # Test double_quotes detected no regression." 499c1f3ca3SHartmut Brandt @! ${SMAKE} double_quotes2 >/dev/null 2>&1 && true || ${SMAKE} failure 50*6e501706SDavid E. O'Brien @echo "ok 11 double_quotes2 # Test double_quotes2 detected no regression." 519c1f3ca3SHartmut Brandt @${SMAKE} pass_cmd_vars || ${SMAKE} failure 52*6e501706SDavid E. O'Brien @echo "ok 12 pass_cmd_vars # Test pass_cmd_vars detected no regression." 539c1f3ca3SHartmut Brandt @${SMAKE} plus_flag || ${SMAKE} failure 54*6e501706SDavid E. O'Brien @echo "ok 13 plus_flag # Test plus_flag detected no regression." 559c1f3ca3SHartmut Brandt @! ${SMAKE} shell >/dev/null 2>&1 && true || ${SMAKE} failure 56*6e501706SDavid E. O'Brien @echo "ok 14 shell # Test shell detected no regression." 579c1f3ca3SHartmut Brandt @${SMAKE} shell_1 || ${SMAKE} failure 58*6e501706SDavid E. O'Brien @echo "ok 15 shell_1 # Test shell_1 detected no regression." 599c1f3ca3SHartmut Brandt @${SMAKE} shell_2 || ${SMAKE} failure 60*6e501706SDavid E. O'Brien @echo "ok 16 shell_2 # Test shell_2 detected no regression." 619c1f3ca3SHartmut Brandt 629c1f3ca3SHartmut Brandt.if make(C_check) 639c1f3ca3SHartmut BrandtC_check: 649c1f3ca3SHartmut Brandt.endif 656d3ca9deSJuli Mallett 665661d4a7SJuli Mallett.if make(double) 6789d22e2fSJuli Mallett# Doubly-defined targets. make(1) will warn, but use the "right" one. If it 6889d22e2fSJuli Mallett# switches to using the "non-right" one, it breaks things worse than a little 6989d22e2fSJuli Mallett# regression test. 706d3ca9deSJuli Mallettdouble: 716d3ca9deSJuli Mallett @true 726d3ca9deSJuli Mallett 736d3ca9deSJuli Mallettdouble: 746d3ca9deSJuli Mallett @false 755661d4a7SJuli Mallett.endif 766541d27cSJuli Mallett 775661d4a7SJuli Mallett.if make(sysvmatch) 78a9b736adSJuli Mallett# Some versions of FreeBSD make(1) do not handle a nil LHS in sysvsubst. 79a9b736adSJuli Mallettsysvmatch: 80a9b736adSJuli Mallett @echo EMPTY ${NIL:=foo} LHS | \ 81a9b736adSJuli Mallett diff -u ${.CURDIR}/regress.sysvmatch.out - || false 825661d4a7SJuli Mallett.endif 83a9b736adSJuli Mallett 840aa9e01cSJuli Mallett# A bogus target for the lhs_expn test; If this is reached, then the make(1) 850aa9e01cSJuli Mallett# program has not errored out because of the recursion caused by not expanding 860aa9e01cSJuli Mallett# the left-hand-side's embedded variables above. 870aa9e01cSJuli Mallettlhs_expn: 886d5fda5fSJuli Mallett @true 890aa9e01cSJuli Mallett 90113cf9e6SRuslan Ermilov.if make(notdef) 91113cf9e6SRuslan Ermilov# make(1) claims to only evaluate a conditional as far as is necessary 92113cf9e6SRuslan Ermilov# to determine its value; that was not always the case. 93113cf9e6SRuslan Ermilov.undef notdef 94113cf9e6SRuslan Ermilovnotdef: 95113cf9e6SRuslan Ermilov.if defined(notdef) && ${notdef:U} 96113cf9e6SRuslan Ermilov.endif 97113cf9e6SRuslan Ermilov.endif 98113cf9e6SRuslan Ermilov 99113cf9e6SRuslan Ermilov.if make(modifiers) 100113cf9e6SRuslan Ermilov# See if make(1) supports the C modifier. 101113cf9e6SRuslan Ermilovmodifiers: 1029c1f3ca3SHartmut Brandt @if ${SMAKE} -V .CURDIR:C/.// 2>&1 >/dev/null | \ 103113cf9e6SRuslan Ermilov grep -q "Unknown modifier 'C'"; then \ 104113cf9e6SRuslan Ermilov false; \ 105113cf9e6SRuslan Ermilov fi 106113cf9e6SRuslan Ermilov.endif 107113cf9e6SRuslan Ermilov 108c94d7043SRuslan Ermilov.if make(arith_expr) 109c94d7043SRuslan Ermilovarith_expr: 110c94d7043SRuslan Ermilov# See if arithmetic expression parsing is broken. 111c94d7043SRuslan Ermilov# The different spacing below is intentional. 112c94d7043SRuslan ErmilovVALUE= 0 113c94d7043SRuslan Ermilov.if (${VALUE} < 0)||(${VALUE}>0) 114c94d7043SRuslan Ermilov.endif 115c94d7043SRuslan Ermilov.endif 116c94d7043SRuslan Ermilov 11721159d16SRuslan Ermilov.if make(PATH_exists) 11821159d16SRuslan ErmilovPATH_exists: 11921159d16SRuslan Ermilov.PATH: ${.CURDIR} 12021159d16SRuslan Ermilov.if !exists(${.CURDIR}/) || !exists(${.CURDIR}/.) || !exists(${.CURDIR}/..) 12121159d16SRuslan Ermilov.error exists() failed 12221159d16SRuslan Ermilov.endif 12321159d16SRuslan Ermilov.endif 12421159d16SRuslan Ermilov 1259608d7e2SRuslan Ermilov.if make(double_quotes) 1269608d7e2SRuslan ErmilovVALUE= foo "" 1279608d7e2SRuslan Ermilovdouble_quotes: 1289608d7e2SRuslan Ermilov.if ${VALUE:S/$//} != ${VALUE} 1299608d7e2SRuslan Ermilov.error "" reduced to " 1309608d7e2SRuslan Ermilov.endif 1319608d7e2SRuslan Ermilov.endif 1329608d7e2SRuslan Ermilov 13399d3652eSRuslan Ermilov.if make(double_quotes2) 13499d3652eSRuslan Ermilovdouble_quotes2: 13599d3652eSRuslan Ermilov @cat /dev/null "" 13699d3652eSRuslan Ermilov.endif 13799d3652eSRuslan Ermilov 13848ec21e7SHartmut Brandt# 13948ec21e7SHartmut Brandt# Check passing of variable via MAKEFLAGS 14048ec21e7SHartmut Brandt# 14148ec21e7SHartmut Brandt.if make(pass_cmd_vars) 14248ec21e7SHartmut Brandtpass_cmd_vars: 1439c1f3ca3SHartmut Brandt @${SMAKE} CMD1=cmd1 CMD2=cmd2 pass_cmd_vars_1 1449c1f3ca3SHartmut Brandt @${SMAKE} CMD1=cmd1 CMD2=cmd2 pass_cmd_vars_2 1459c1f3ca3SHartmut Brandt @${SMAKE} CMD1=cmd1 CMD2=cmd2 pass_cmd_vars_3 1469c1f3ca3SHartmut Brandt @${SMAKE} CMD1=cmd1 CMD2=cmd2 pass_cmd_vars_4 14748ec21e7SHartmut Brandt.endif 14848ec21e7SHartmut Brandt 1493c24f8e8SDavid E. O'Brien# 15048ec21e7SHartmut Brandt# Check that the variable definition arrived from the calling make 1513c24f8e8SDavid E. O'Brien# 1523c24f8e8SDavid E. O'Brien.if make(pass_cmd_vars_1) 1533c24f8e8SDavid E. O'Brien# These values should get overridden by the commandline 1543c24f8e8SDavid E. O'BrienCMD1=oops1 1553c24f8e8SDavid E. O'BrienCMD2=oops2 15648ec21e7SHartmut Brandtpass_cmd_vars_1: 15748ec21e7SHartmut Brandt @: 15848ec21e7SHartmut Brandt 15948ec21e7SHartmut Brandt.if ${CMD1} != cmd1 || ${CMD2} != cmd2 16082eb7072SHartmut Brandt.error variables not passed through MAKEFLAGS 16148ec21e7SHartmut Brandt.endif 16248ec21e7SHartmut Brandt.endif 16348ec21e7SHartmut Brandt 16448ec21e7SHartmut Brandt.if make(pass_cmd_vars_2) 16548ec21e7SHartmut Brandt# Check that we cannot override the passed variables 16648ec21e7SHartmut BrandtCMD1=foo1 16748ec21e7SHartmut BrandtCMD2=foo2 16848ec21e7SHartmut Brandt 16948ec21e7SHartmut Brandt.if ${CMD1} != cmd1 || ${CMD2} != cmd2 17082eb7072SHartmut Brandt.error MAKEFLAGS-passed variables overridden 17148ec21e7SHartmut Brandt.endif 17248ec21e7SHartmut Brandt 17348ec21e7SHartmut Brandtpass_cmd_vars_2: 17448ec21e7SHartmut Brandt @: 17548ec21e7SHartmut Brandt.endif 17648ec21e7SHartmut Brandt 17748ec21e7SHartmut Brandt.if make(pass_cmd_vars_3) 17848ec21e7SHartmut Brandt# Check that we can override the passed variables on the next sub-make's 17948ec21e7SHartmut Brandt# command line 18048ec21e7SHartmut Brandt 18148ec21e7SHartmut Brandtpass_cmd_vars_3: 1829c1f3ca3SHartmut Brandt @${SMAKE} CMD1=foo1 pass_cmd_vars_3_1 18348ec21e7SHartmut Brandt.endif 18448ec21e7SHartmut Brandt 18548ec21e7SHartmut Brandt.if make(pass_cmd_vars_3_1) 18648ec21e7SHartmut Brandt.if ${CMD1} != foo1 || ${CMD2} != cmd2 18782eb7072SHartmut Brandt.error MAKEFLAGS-passed variables not overridden on command line 18848ec21e7SHartmut Brandt.endif 18948ec21e7SHartmut Brandtpass_cmd_vars_3_1: 19048ec21e7SHartmut Brandt @: 19148ec21e7SHartmut Brandt.endif 19248ec21e7SHartmut Brandt 19348ec21e7SHartmut Brandt.if make(pass_cmd_vars_4) 19448ec21e7SHartmut Brandt# Ensure that a variable assignment passed via MAKEFLAGS may be overwritten 19548ec21e7SHartmut Brandt# by evaluating the .MAKEFLAGS target. 19648ec21e7SHartmut Brandt 19748ec21e7SHartmut Brandt.MAKEFLAGS: CMD1=baz1 19848ec21e7SHartmut Brandt 19948ec21e7SHartmut Brandtpass_cmd_vars_4: 2009c1f3ca3SHartmut Brandt @${SMAKE} pass_cmd_vars_4_1 20148ec21e7SHartmut Brandt 20248ec21e7SHartmut Brandt.if ${CMD1} != baz1 || ${CMD2} != cmd2 20382eb7072SHartmut Brandt.error MAKEFLAGS-passed variables not overridden via .MAKEFLAGS target 20448ec21e7SHartmut Brandt.endif 20548ec21e7SHartmut Brandt 20648ec21e7SHartmut Brandt.endif 20748ec21e7SHartmut Brandt.if make(pass_cmd_vars_4_1) 20848ec21e7SHartmut Brandt.if ${CMD1} != baz1 || ${CMD2} != cmd2 20982eb7072SHartmut Brandt.error MAKEFLAGS-passed variables not overridden via .MAKEFLAGS target (2) 21048ec21e7SHartmut Brandt.endif 21148ec21e7SHartmut Brandtpass_cmd_vars_4_1: 21248ec21e7SHartmut Brandt @: 21348ec21e7SHartmut Brandt.endif 21448ec21e7SHartmut Brandt 215c997f47bSHartmut Brandt# 216c997f47bSHartmut Brandt# Test whether make supports the '+' flag (meaning: execute even with -n) 217c997f47bSHartmut Brandt# 218c997f47bSHartmut Brandt.if make(plus_flag) 2199c1f3ca3SHartmut BrandtOUT != ${SMAKE} -n plus_flag_1 2203c24f8e8SDavid E. O'Brien.if ${OUT:M/tmp} != "/tmp" 22182eb7072SHartmut Brandt.error make doesn't handle + flag 222c997f47bSHartmut Brandt.endif 223c997f47bSHartmut Brandtplus_flag: 224c997f47bSHartmut Brandt @: 225c997f47bSHartmut Brandt.endif 226c997f47bSHartmut Brandt.if make(plus_flag_1) 227c997f47bSHartmut Brandtplus_flag_1: 228c997f47bSHartmut Brandt +@cd /tmp; pwd 229c997f47bSHartmut Brandt.endif 230c997f47bSHartmut Brandt 2319a5cf326SRuslan Ermilov.if make(shell) 2329a5cf326SRuslan Ermilov# Test if make fully supports the .SHELL specification. 2339a5cf326SRuslan Ermilov.SHELL: path=/nonexistent 2349a5cf326SRuslan ErmilovA!= echo ok 2359a5cf326SRuslan Ermilovshell: 2369a5cf326SRuslan Ermilov.endif 2379a5cf326SRuslan Ermilov 2387b54cddaSHartmut Brandt.if make(shell_1) 2397b54cddaSHartmut Brandt# Test if setting the shell by name only works. Because we have no ksh 2407b54cddaSHartmut Brandt# in the base system we test that we can set sh and csh. We try only exact 2417b54cddaSHartmut Brandt# matching names and do not exercise the rather strange matching algorithm. 2427b54cddaSHartmut Brandtshell_1: 2439c1f3ca3SHartmut Brandt @${SMAKE} shell_1_csh 2449c1f3ca3SHartmut Brandt @${SMAKE} shell_1_sh 2457b54cddaSHartmut Brandt.endif 2467b54cddaSHartmut Brandt.if make(shell_1_csh) 2477b54cddaSHartmut Brandt.SHELL: name="csh" 2487b54cddaSHartmut Brandtshell_1_csh: 2499c1f3ca3SHartmut Brandt @ps -ax -opid,command | awk '$$1=="'$$$$'" { print $$2 }' | grep -E -q '^(/bin/)?csh$$' 2507b54cddaSHartmut Brandt.endif 2517b54cddaSHartmut Brandt.if make(shell_1_sh) 2527b54cddaSHartmut Brandt.SHELL: name="sh" 2537b54cddaSHartmut Brandtshell_1_sh: 2541b647f44SRuslan Ermilov @ps -ax -opid,command | awk '$$1=="'$$$$'" { print $$2 }' | grep -E -q '^(/bin/)?sh$$' 2557b54cddaSHartmut Brandt.endif 2567b54cddaSHartmut Brandt 2577b54cddaSHartmut Brandt.if make(shell_2) 2587b54cddaSHartmut Brandt# Test if we can replace the shell specification. We do this by using 2597b54cddaSHartmut Brandt# a shell scripts that prints us its arguments and standard input as the shell 26089f087e8SHartmut Brandtshell_2: shell_test 2619c1f3ca3SHartmut Brandt @${SMAKE} -B shell_2B | \ 2627b54cddaSHartmut Brandt diff -u ${.CURDIR}/regress.shell_2B.out - || false 2639c1f3ca3SHartmut Brandt @${SMAKE} -j1 shell_2j | \ 2647b54cddaSHartmut Brandt diff -u ${.CURDIR}/regress.shell_2j.out - || false 2657b54cddaSHartmut Brandt.endif 2667b54cddaSHartmut Brandt 2677b54cddaSHartmut Brandt.if make(shell_2B) 2689c1f3ca3SHartmut Brandt.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" 2697b54cddaSHartmut Brandt 2707b54cddaSHartmut Brandtshell_2B: 2717b54cddaSHartmut Brandt -@funny $$ 2727b54cddaSHartmut Brandt funnier $$ 2737b54cddaSHartmut Brandt.endif 2747b54cddaSHartmut Brandt 2757b54cddaSHartmut Brandt.if make(shell_2j) 2769c1f3ca3SHartmut Brandt.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" 2777b54cddaSHartmut Brandt 2787b54cddaSHartmut Brandtshell_2j: 2797b54cddaSHartmut Brandt -@funny $$ 2807b54cddaSHartmut Brandt funnier $$ 2817b54cddaSHartmut Brandt.endif 2827b54cddaSHartmut Brandt 2836541d27cSJuli Mallettfailure: 28400e13b1dSNik Clayton @echo "not ok # Test failed: regression detected. See above." 2856541d27cSJuli Mallett @false 2869c1f3ca3SHartmut Brandt 28789f087e8SHartmut BrandtCLEANFILES= shell_test 28889f087e8SHartmut Brandt 28989f087e8SHartmut Brandt.include <bsd.obj.mk> 290