include common.mk all: server server: $(BUILD_DIR)/server/main.o $(COMPILE_EXE) run: server ./$< $(RUN_ARGS) $(BUILD_DIR)/%.o: $(BUILD_DIR)/%.c.deps.mk $(MAKE) -f $(BUILD_DIR)/$*.c.deps.mk $(MFLAGS) $(MAKEOVERRIDES) $@ $(BUILD_DIR)/$*.c.deps.mk $(BUILD_DIR)/%.c.deps.mk: $(SRC_DIR)/%.c $(ENSURE_DIR) echo include common.mk > $@ @printf '%s: ' "$@" >> $@ @# SIC: not `read -r` @$(CPP) $(CPPFLAGS) -M $(SRC_DIR)/$*.c | { read target deps; echo "$$deps" ;} >> $@ @echo ' rm $@' >> $@ @echo ' $$(MAKE) -f Makefile $$(MFLAGS) $$(MAKEOVERRIDES) $@' >> $@ @printf '%s/%s' "$(BUILD_DIR)" "$(dir $*)" >> $@ $(CPP) $(CPPFLAGS) -M $(SRC_DIR)/$*.c >> $@ echo ' $(CC) -c $$< $$(CPPFLAGS) $$(CFLAGS) $$(INCPATH) -o $$@' >> $@ ifneq ($(BUILD_DIR),) # Avoid `rm /` clean: -rm main $(BUILD_DIR)/*.o $(BUILD_DIR)/*.deps.mk endif .PHONY: $(shell find $(BUILD_DIR) -name '*.deps.mk') .PHONY: all run clean .PRECIOUS: $(BUILD_DIR)/%.deps.mk $(shell find $(BUILD_DIR) -name '*.deps.mk') .SECONDARY: .SUFFIXES: