2021-01-14 01:24:34 +00:00
|
|
|
# $NetBSD: cond-func-exists.mk,v 1.6 2020/11/30 20:12:29 rillig Exp $
|
2020-09-05 16:11:04 +00:00
|
|
|
#
|
|
|
|
# Tests for the exists() function in .if conditions.
|
|
|
|
|
|
|
|
.if !exists(.)
|
2020-11-07 19:39:21 +00:00
|
|
|
. error
|
2020-09-05 16:11:04 +00:00
|
|
|
.endif
|
|
|
|
|
|
|
|
# The argument to the function must not be enclosed in quotes.
|
|
|
|
# Neither double quotes nor single quotes are allowed.
|
|
|
|
.if exists(".")
|
2020-11-07 19:39:21 +00:00
|
|
|
. error
|
2020-09-05 16:11:04 +00:00
|
|
|
.endif
|
|
|
|
|
|
|
|
.if exists('.')
|
2020-11-07 19:39:21 +00:00
|
|
|
. error
|
2020-09-05 16:11:04 +00:00
|
|
|
.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(\.)
|
2020-11-07 19:39:21 +00:00
|
|
|
. error
|
2020-09-05 16:11:04 +00:00
|
|
|
.endif
|
|
|
|
|
|
|
|
.if !exists(${:U.})
|
2020-11-07 19:39:21 +00:00
|
|
|
. error
|
2020-09-05 16:11:04 +00:00
|
|
|
.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})
|
2020-11-07 19:39:21 +00:00
|
|
|
. error
|
2020-09-05 16:11:04 +00:00
|
|
|
.endif
|
|
|
|
|
|
|
|
# Whitespace is trimmed on both sides of the function argument.
|
|
|
|
.if !exists( . )
|
2020-11-07 19:39:21 +00:00
|
|
|
. error
|
2020-09-05 16:11:04 +00:00
|
|
|
.endif
|
|
|
|
|
2021-01-14 01:24:34 +00:00
|
|
|
# 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
|
|
|
|
|
2020-09-05 16:11:04 +00:00
|
|
|
all:
|
|
|
|
@:;
|