tile-terminal-game/Makefile

42 lines
1.2 KiB
Makefile

include common.mk
all: server
$(BUILD_DIR)/common/util/thread.o: $(BUILD_DIR)/common/util/thread.posix.o
cp $< $@
server: $(BUILD_DIR)/server/main.o $(BUILD_DIR)/common/util/hash_table.o $(BUILD_DIR)/common/util/byte_stream.o $(BUILD_DIR)/common/util/thread.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) $(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) $(INCPATH) -M $(SRC_DIR)/$*.c >> $@
echo ' $(CC) -c $$< $$(CPPFLAGS) $$(CFLAGS) $$(INCPATH) -o $$@' >> $@
ifneq ($(BUILD_DIR),)
# Avoid `rm /`
clean:
-rm server
-rm -r $(BUILD_DIR)
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: