I've got a chained rule in my Makefile:
%.int: %.src
preprocess -i $< -o $@
%.dst: %.int
compile -i $< -o $@
SRCS=$(wildcard *.src)
DSTS=$(patsubst %.src,$.dst,$(SRCS))
all: $(DSTS)
It preprocesses .src to .int, and then compiles .int to .dst.
It works fine, except that GNU Make always deletes the intermediate files.
That's fine; I read the docs; I understand why it does that. I know that I can keep them around if I use .PRECIOUS or .SECONDARY pseudo-targets.
However, what I'd like to do is keep the intermediate file if and only if the int2dst step failed. Basically, I'd like to see what mess the preprocessor left me with.
Can I do that with GNU Make?
A possible solution, though perhaps not a pretty one, would be to go ahead and put those files into .PRECIOUS, but then manually delete from the build rule:
%.dst: %.int
compile -i $< -o $@
rm $<
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With