freebsd-dev/contrib/bmake/unit-tests/cond-func-exists.mk
Simon J. Gerraty 06b9b3e0ad Merge bmake-20210110
Quite a lot of churn on style, but lots of
good work refactoring complicated functions
and lots more unit-tests.
Thanks mostly to rillig at NetBSD

Some interesting entries from ChangeLog

o .MAKE.{UID,GID} represent uid and gid running make.

o allow env var MAKE_OBJDIR_CHECK_WRITABLE=no to skip writable
  checks in InitObjdir.  Explicit .OBJDIR target always allows
  read-only directory.

o add more unit tests for META MODE

Merge commit '8e11a9b4250be3c3379c45fa820bff78d99d5946' into main

Change-Id: I464fd4c013067f0915671c1ccc96d2d8090b2b9c
2021-01-13 22:21:37 -08:00

52 lines
1.2 KiB
Makefile

# $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:
@:;