freebsd-src/unit-tests/cond-func-defined.mk
Simon J. Gerraty 308a28d6cd Import bmake-20220724
Relevant/interesting changes:

	o parse.c: fix out-of-bounds read when parsing an invalid line
        https://bugs.freebsd.org/265119
	fix memory leak in wildcard targets and sources
	fix off-by-one error in buffer for .WAIT nodes
	o allow to randomize build order of targets
	.MAKE.MODE += randomize-targets can help uncover dependency bugs
2022-07-26 08:52:53 -07:00

58 lines
1.3 KiB
Makefile

# $NetBSD: cond-func-defined.mk,v 1.9 2022/05/08 06:51:27 rillig Exp $
#
# Tests for the defined() function in .if conditions.
DEF= defined
${:UA B}= variable name with spaces
.if !defined(DEF)
. error
.endif
# Horizontal whitespace (space tab) after the opening parenthesis is ignored.
.if !defined( DEF)
. error
.endif
# Horizontal whitespace (space tab) before the closing parenthesis is ignored.
.if !defined(DEF )
. error
.endif
# The argument of a function must not directly contain whitespace.
.if !defined(A B)
. error
.endif
# If necessary, the whitespace can be generated by a variable expression.
.if !defined(${:UA B})
. error
.endif
# Parse error: missing closing parenthesis; see ParseWord.
.if defined(DEF
. error
.else
. error
.endif
# Variables from .for loops are not defined.
# See directive-for.mk for more details.
.for var in value
. if defined(var)
. error
. else
. info In .for loops, variable expressions for the loop variables are
. info substituted at evaluation time. There is no actual variable
. info involved, even if it feels like it.
. endif
.endfor
# Neither of the conditions is true. Before July 2020, the right-hand
# condition was evaluated even though it was irrelevant.
.if defined(UNDEF) && ${UNDEF:Mx} != ""
. error
.endif
all: .PHONY