aboutsummaryrefslogtreecommitdiff
path: root/contrib/bmake/unit-tests/cond-func-exists.mk
blob: 48d7e727dc3ff1feaeaa8979dbbd7a457597a260 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# $NetBSD: cond-func-exists.mk,v 1.6 2020/11/30 20:12:29 rillig Exp $
#
# Tests for the exists() function in .if conditions.

.if !exists(.)
.  error
.endif

# The argument to the function must not be enclosed in quotes.
# Neither double quotes nor single quotes are allowed.
.if exists(".")
.  error
.endif

.if exists('.')
.  error
.endif

# The only way to escape characters that would otherwise influence the parser
# is to enclose them in a variable expression.  For function arguments,
# neither the backslash nor the dollar sign act as escape character.
.if exists(\.)
.  error
.endif

.if !exists(${:U.})
.  error
.endif

# The argument to the function can have several variable expressions.
# See cond-func.mk for the characters that cannot be used directly.
.if !exists(${.PARSEDIR}/${.PARSEFILE})
.  error
.endif

# Whitespace is trimmed on both sides of the function argument.
.if !exists(	.	)
.  error
.endif

# The exists function does not really look up the file in the file system,
# instead it uses a cache that is preloaded very early, before parsing the
# first makefile.  At that time, the file did not exist yet.
_!=	> cond-func-exists.just-created
.if exists(cond-func-exists.just-created)
.  error
.endif
_!=	rm cond-func-exists.just-created

all:
	@:;