Using makefile targets to set build options

makefile

This is either trivial or runs counter to the philosophy of how make should be used, but I'd like to have a command line that reads as "make debug" rather than "make DEBUG=1". I tried creating a phony target called debug that did nothing except set the DEBUG variable, but then there was a difference between "make debug build" and "make build debug"–namely that in one case, the variable got set after the build happened.

Is there a way to give certain targets precedence?

Thanks for your help.

Best Answer

See 'Target-specific variable values' in this page.