Skip to content

Instantly share code, notes, and snippets.

@Dragonink
Created January 25, 2022 21:15
Show Gist options
  • Save Dragonink/e05c91e4b703016497eb46a2c11cd427 to your computer and use it in GitHub Desktop.
Save Dragonink/e05c91e4b703016497eb46a2c11cd427 to your computer and use it in GitHub Desktop.
Util Makefile snippets
# DEBUG VARIABLE FUNCTION
#
# USAGE: $(call debug,<var_name>)
# <var_name> is the identifier of the variable to debug
#
# EXAMPLE:
# $(call debug,ARCH) print "ARCH = x86" provided the variable ARCH has the value "x86"
debug = $(info $1 = $($1))
# RECURSIVE WILDCARD FUNCTION
#
# USAGE: $(call rwildcard,<rootdir>,<wildcard>)
# <rootdir> is the directory from which to start the search (empty for current directory)
# <wilcard> is the argument of the standard wilcard function
#
# EXAMPLES:
# $(call rwildcard,,*.c *.h) search all .c and .h files from the current directory
# $(call rwdilcard,src/,*.ts) search all *.ts files from the src/ directory
rwildcard = $(strip $(foreach d,$(wildcard $(patsubst %/,%,$1)/*),$(filter $(subst *,%,$2),$(d)) $(call rwildcard,$(d)/,$2)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment