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