3 ms·
You can avoid editing the Makefile to add the rule with GNU make 3.81 or older, which does not support --eval. Create a new file in your home named ~/Makefile.d
by raimue 12y ago
You can avoid editing the Makefile to add the rule with GNU make 3.81 or older, which does not support --eval. Create a new file in your home named ~/Makefile.debug with the contents:
print-%: ; @echo $*=$($*)
include Makefile
Now you can use it the following way from any source directory:
$ make -f ~/Makefile.debug print-SOURCE_FILES
- kazinator 12y agoYou're missing the final tail call which includes Makefile.debug again. With this, we can make a REPL: $ cat Makefile FOO := bar target: Next: $ cat Makefile.debug ifeq ($(MAKEFILE_INCLUDED),) -include Makefile MAKEFILE_INCLUDED := y endif REPL_COMMAND := $(shell read line; printf "%s\n" $$line) $(eval $(REPL_COMMAND)) -include Makefile.debug Now, here we go: $ make -f Makefile.debug $(warning $(FOO)) <--- typed by me Makefile.debug:8: bar ABC := xyz <--- $(warning $(ABC)) <--- Makefile.debug:8: xyz :)
- david-given 12y agoThis is the kind of idea for which the phrase 'genius crazy' was invented. I might actually use this some time, god help me. I won't thank you, but I will remember you and curse a little every time I do.