Since you’re using GNU Make, you can make the following adjustment to your Makefile:
.PRECIOUS: $(BUILD)/%.pp # ADD THIS LINE
$(BUILD)/%.pp: %.c
$(ECHO) "PreProcess $<"
$(Q)$(CC) $(CFLAGS) -E -Wp,-C,-dD,-dI -o $@ $<
The documentation has this to say about .PRECIOUS
directives:
The targets which
.PRECIOUS
depends on are given the following special treatment: if make is killed or interrupted during the execution of their recipes, the target is not deleted.[…]
Also, if the target is an intermediate file, it will not be deleted after it is no longer needed, as is normally done.
[…]
You can also list the target pattern of an implicit rule (such as ‘%.o’) as a prerequisite file of the special target
.PRECIOUS
to preserve intermediate files created by rules whose target patterns match that file’s name.
This has the benefit of not creating an unwanted additional rule. It’s also clearer what you’re trying to do: keep the precious intermediate files that might be expensive to recreate.