Created
July 13, 2019 12:10
-
-
Save bbl/bf4bf5875d0c705c4cd78d264f98a8b1 to your computer and use it in GitHub Desktop.
Revisions
-
bbl created this gist
Jul 13, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ # Check if variable is defined in a Makefile ### Using `ifndef` ```make ifndef MY_FLAG $(error MY_FLAG is not set) endif ``` ### Using custom function ```make check_defined = \ $(strip $(foreach 1,$1, \ $(call __check_defined,$1,$(strip $(value 2))))) __check_defined = \ $(if $(value $1),, \ $(error Undefined $1$(if $2, ($2)))) install: $(call check_defined, var1) $(call check_defined, var2) # do stuff here.. ```