1# $NetBSD: directive-ifndef.mk,v 1.8 2023/06/19 20:44:06 rillig Exp $
2#
3# Tests for the .ifndef directive, which can be used for multiple-inclusion
4# guards.  In contrast to C, where #ifndef and #define nicely line up the
5# macro name, there is no such syntax in make.  Therefore, it is more
6# common to use .if !defined(GUARD) instead.
7#
8# See also:
9#	directive-include-guard.mk
10
11.ifndef GUARD
12GUARD=	# defined
13# expect+1: guarded section
14.  info guarded section
15.endif
16
17.ifndef GUARD
18GUARD=	# defined
19.  info guarded section
20.endif
21
22.if !defined(GUARD)
23GUARD=	# defined
24.  info guarded section
25.endif
26
27
28# The '.ifndef' directive can be used with multiple arguments, even negating
29# them.  Since these conditions are confusing for humans, they should be
30# replaced with easier-to-understand plain '.if' directives.
31DEFINED=
32.ifndef UNDEFINED && UNDEFINED
33.else
34.  error
35.endif
36.ifndef UNDEFINED && DEFINED
37.  error
38.endif
39.ifndef DEFINED && DEFINED
40.  error
41.endif
42.ifndef !UNDEFINED && !UNDEFINED
43.  error
44.endif
45.ifndef !UNDEFINED && !DEFINED
46.  error
47.endif
48.ifndef !DEFINED && !DEFINED
49.else
50.  error
51.endif
52
53all:
54