Home | History | Annotate | Line # | Download | only in unit-tests
cond-func-exists.mk revision 1.6
      1  1.6  rillig # $NetBSD: cond-func-exists.mk,v 1.6 2020/11/30 20:12:29 rillig Exp $
      2  1.1  rillig #
      3  1.2  rillig # Tests for the exists() function in .if conditions.
      4  1.1  rillig 
      5  1.4  rillig .if !exists(.)
      6  1.5  rillig .  error
      7  1.3  rillig .endif
      8  1.3  rillig 
      9  1.3  rillig # The argument to the function must not be enclosed in quotes.
     10  1.3  rillig # Neither double quotes nor single quotes are allowed.
     11  1.3  rillig .if exists(".")
     12  1.5  rillig .  error
     13  1.3  rillig .endif
     14  1.3  rillig 
     15  1.3  rillig .if exists('.')
     16  1.5  rillig .  error
     17  1.3  rillig .endif
     18  1.3  rillig 
     19  1.3  rillig # The only way to escape characters that would otherwise influence the parser
     20  1.3  rillig # is to enclose them in a variable expression.  For function arguments,
     21  1.3  rillig # neither the backslash nor the dollar sign act as escape character.
     22  1.3  rillig .if exists(\.)
     23  1.5  rillig .  error
     24  1.3  rillig .endif
     25  1.3  rillig 
     26  1.4  rillig .if !exists(${:U.})
     27  1.5  rillig .  error
     28  1.3  rillig .endif
     29  1.3  rillig 
     30  1.3  rillig # The argument to the function can have several variable expressions.
     31  1.3  rillig # See cond-func.mk for the characters that cannot be used directly.
     32  1.4  rillig .if !exists(${.PARSEDIR}/${.PARSEFILE})
     33  1.5  rillig .  error
     34  1.4  rillig .endif
     35  1.4  rillig 
     36  1.4  rillig # Whitespace is trimmed on both sides of the function argument.
     37  1.4  rillig .if !exists(	.	)
     38  1.5  rillig .  error
     39  1.3  rillig .endif
     40  1.1  rillig 
     41  1.6  rillig # The exists function does not really look up the file in the file system,
     42  1.6  rillig # instead it uses a cache that is preloaded very early, before parsing the
     43  1.6  rillig # first makefile.  At that time, the file did not exist yet.
     44  1.6  rillig _!=	> cond-func-exists.just-created
     45  1.6  rillig .if exists(cond-func-exists.just-created)
     46  1.6  rillig .  error
     47  1.6  rillig .endif
     48  1.6  rillig _!=	rm cond-func-exists.just-created
     49  1.6  rillig 
     50  1.1  rillig all:
     51  1.1  rillig 	@:;
     52