Skip to content

Instantly share code, notes, and snippets.

@bbolli
Created September 18, 2018 20:22
Show Gist options
  • Save bbolli/cd4c442860efce0a6d3f95fe75f70517 to your computer and use it in GitHub Desktop.
Save bbolli/cd4c442860efce0a6d3f95fe75f70517 to your computer and use it in GitHub Desktop.
Makefile fragment for printing all MAKE variables
# debug support
# escape single quotes
SQ = '$(subst ','\'',$(1))'
# simple "name = value" list
print_vars = printf '%s\n' $(foreach v,$(sort ${.VARIABLES}),'$v = '$(call SQ,$($v)))
# TAB-separated list of "name origin value1 value2", where
# value1 is the unexpanded value, and value2 is the expanded value.
# Watch out for embedded TABs below!
print_rawvars = printf '%s\n' $(foreach v,$(sort ${.VARIABLES}),'$v $(origin $v) '$(call SQ,$(value $v))' '$(call SQ,$($v))')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment