Skip to content

Instantly share code, notes, and snippets.

@Integralist
Last active May 26, 2025 16:16
Show Gist options
  • Select an option

  • Save Integralist/a4418dc1fc7940e2ee77183461e6ed9d to your computer and use it in GitHub Desktop.

Select an option

Save Integralist/a4418dc1fc7940e2ee77183461e6ed9d to your computer and use it in GitHub Desktop.
Make: 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