using makefile variables in shell script without running make using makefile variables in shell script without running make shell shell

using makefile variables in shell script without running make


You could use (a modified version of) the print-% target from Makefile hacks: print the value of any variable in your makefile to let you query it for values.

print-%:        @echo '$(subst ','\'',$($*))'


TEST_ENV=$(make -qp | awk -F' = ' '$1=="TEST_ENV" {print $2}')

I'm sure there are edge cases this doesn't handle, but it's a decent start. Rudimentary testing shows this handles multi-line variables.