xref: /freebsd/contrib/bmake/unit-tests/directive-ifdef.mk (revision 517e52b6c21ccff22c46df0dcd15c19baee3d86c)
1# $NetBSD: directive-ifdef.mk,v 1.4 2021/01/21 23:03:41 rillig Exp $
2#
3# Tests for the .ifdef directive.
4
5# TODO: Implementation
6
7DEFINED=	defined
8
9# It looks redundant to have a call to defined() in an .ifdef, but it's
10# possible.  The .ifdef only affects plain symbols, not function calls.
11.ifdef defined(DEFINED)
12.  info Function calls in .ifdef are possible.
13.else
14.  error
15.endif
16
17# String literals are handled the same in all variants of the .if directive.
18# They evaluate to true if they are not empty.  Whitespace counts as non-empty
19# as well.
20.ifdef ""
21.  error
22.else
23.  info String literals are tested for emptiness.
24.endif
25
26.ifdef " "
27.  info String literals are tested for emptiness.  Whitespace is non-empty.
28.else
29.  error
30.endif
31
32all:
33	@:;
34