blob: 8a60fb4a2669af2010ca9194968b0415db98ef18 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
# $NetBSD: directive-ifdef.mk,v 1.5 2022/01/23 21:48:59 rillig Exp $
#
# Tests for the .ifdef directive, which evaluates bare words by calling
# 'defined(word)'.
DEFINED= defined
# There is no variable named 'UNDEF', therefore the condition evaluates to
# false.
.ifdef UNDEF
. error
.endif
# There is a variable named 'DEFINED', so the condition evaluates to true.
.ifdef DEFINED
.else
. error
.endif
# Since a bare word is an abbreviation for 'defined(word)', these can be
# used to construct complex conditions.
.ifdef UNDEF && DEFINED
. error
.endif
.ifdef UNDEF || DEFINED
.else
. error
.endif
# It looks redundant to have a call to defined() in an .ifdef, but it's
# possible. The '.ifdef' only affects bare words, not function calls.
.ifdef defined(DEFINED)
.else
. error
.endif
# String literals are handled the same in all variants of the '.if' directive,
# they evaluate to true if they are not empty, therefore this particular
# example looks confusing and is thus not found in practice.
.ifdef ""
. error
.else
.endif
# Whitespace counts as non-empty as well.
.ifdef " "
.else
. error
.endif
all: .PHONY
|