summaryrefslogtreecommitdiff
path: root/cesar/common/make/lib.mk
blob: d8fad32af68ab5c0c0c046d0e2445899becd52dc (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
# Define general purpose functions.

# Return non null string if the variable name is defined.
# A = hello
# $(call defined,A)
# => file
# $(call defined,B)
# =>
defined = $(filter-out undefined,$(origin $1))

# Return $2 unless $1 is defined, in this case, return $($1).
# $(call default,A,hello)
# => hello
# A = world
# $(call default,A,hello)
# => world
default = $(if $(call defined,$1),$($1),$2)

# Return $3 unless $2 is defined, in this case, return $($2), unless $1 is
# defined, in this case, return $($1).
# $(call default2,A,B,hello)
# => hello
# B = world
# $(call default,A,B,hello)
# => world
# A = everybody
# $(call default,A,B,hello)
# => everybody
default2 = $(if $(call defined,$1),$($1),$(if $(call defined,$2),$($2),$3))

# Return null string if lists are the same.
# $(call list-neq,a b c,b a c)
# =>
# $(call list-neq,a b c,a c)
# => <non null>
list-neq = $(strip $(filter-out $1,$2) $(filter-out $2,$1))