util.mk (611B)
1 # util.mk - Miscellaneous utility functions for use in Makefiles 2 3 # Throws an error if the value of the variable named by $(1) is not in the list given by $(2) 4 define validate-option 5 # value must be part of the list 6 ifeq ($$(filter $($(1)),$(2)),) 7 $$(error Value of $(1) must be one of the following: $(2)) 8 endif 9 # value must be a single word (no whitespace) 10 ifneq ($$(words $($(1))),1) 11 $$(error Value of $(1) must be one of the following: $(2)) 12 endif 13 endef 14 15 # Returns the path to the command $(1) if exists. Otherwise returns an empty string. 16 find-command = $(shell which $(1) 2>/dev/null)