Fix Makefile

- Pass INCPATH to CPP
- Delete whole build dir
This commit is contained in:
Vftdan 2024-10-23 14:01:58 +02:00
parent 19b21f65d5
commit bf9677f2ae
1 changed files with 4 additions and 3 deletions

View File

@ -16,17 +16,18 @@ $(BUILD_DIR)/%.c.deps.mk: $(SRC_DIR)/%.c
echo include common.mk > $@
@printf '%s: ' "$@" >> $@
@# SIC: not `read -r`
@$(CPP) $(CPPFLAGS) -M $(SRC_DIR)/$*.c | { read target deps; echo "$$deps" ;} >> $@
@$(CPP) $(CPPFLAGS) $(INCPATH) -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 >> $@
$(CPP) $(CPPFLAGS) $(INCPATH) -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
-rm server
-rm -r $(BUILD_DIR)
endif
.PHONY: $(shell find $(BUILD_DIR) -name '*.deps.mk')