freebsd-src/unit-tests/cond-func-defined.mk
Simon J. Gerraty 2935fe8237 Import bmake-20211212
Relevant changes see ChangeLog for details:

Add support for ${.SUFFIXES} as read-only variable.

Fix memory leak in cond.c

Punt on write errors - ENOSPC etc.

Lots of code refactoring, rework to reduce memory allocations.

More unit-tests.
2021-12-17 23:27:22 -08:00

53 lines
1.1 KiB
Makefile

# $NetBSD: cond-func-defined.mk,v 1.8 2021/12/12 08:55:28 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
all:
@:;