forked from n64decomp/mk64
-
Notifications
You must be signed in to change notification settings - Fork 1
/
util.mk
24 lines (21 loc) · 805 Bytes
/
util.mk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# util.mk - Miscellaneous utility functions for use in Makefiles
# Throws an error if the value of the variable named by $(1) is not in the list given by $(2)
define validate-option
# value must be part of the list
ifeq ($$(filter $($(1)),$(2)),)
$$(error Value of $(1) must be one of the following: $(2))
endif
# value must be a single word (no whitespace)
ifneq ($$(words $($(1))),1)
$$(error Value of $(1) must be one of the following: $(2))
endif
endef
ifeq ($(OS),Windows_NT)
NULL_OUT := nul
else
NULL_OUT = /dev/null
endif
# Returns the path to the command $(1) if exists. Otherwise returns an empty string.
find-command = $(shell which $(1) 2> $(NULL_OUT))
# recursive wildcard
rwildcard=$(foreach d,$(wildcard $(1:=/*)),$(call rwildcard,$d,$2) $(filter $(subst *,%,$2),$d))