Skip to content

Instantly share code, notes, and snippets.

@Integralist
Created March 1, 2024 10:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Integralist/a4418dc1fc7940e2ee77183461e6ed9d to your computer and use it in GitHub Desktop.
Save Integralist/a4418dc1fc7940e2ee77183461e6ed9d to your computer and use it in GitHub Desktop.
[Check if Makefile target is called with a required input arg] #Makefile #make
# Check that given variables are set and all have non-empty values,
# die with an error otherwise.
#
# PARAMS:
# 1. Variable name(s) to test.
# 2. (optional) Error message to print.
#
# EXAMPLE:
# @:$(call check_defined, ENV_REGION, you must set ENV_REGION=usc1|awsuse2)
#
check_defined = \
$(strip $(foreach 1,$1, \
$(call __check_defined,$1,$(strip $(value 2)))))
__check_defined = \
$(if $(value $1),, \
$(error Undefined $1$(if $2, ($2))$(if $(value @), \
required by target `$@')))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment