2024-10-23 14:44:02 +03:00
|
|
|
include common.mk
|
|
|
|
|
|
|
|
all: server
|
|
|
|
|
2024-10-25 03:27:30 +03:00
|
|
|
$(BUILD_DIR)/common/util/thread.o: $(BUILD_DIR)/common/util/thread.std.o
|
2024-10-23 15:15:11 +03:00
|
|
|
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
|
2024-10-23 14:44:02 +03:00
|
|
|
$(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`
|
2024-10-23 15:01:58 +03:00
|
|
|
@$(CPP) $(CPPFLAGS) $(INCPATH) -M $(SRC_DIR)/$*.c | { read target deps; echo "$$deps" ;} >> $@
|
2024-10-23 14:44:02 +03:00
|
|
|
@echo ' rm $@' >> $@
|
|
|
|
@echo ' $$(MAKE) -f Makefile $$(MFLAGS) $$(MAKEOVERRIDES) $@' >> $@
|
|
|
|
@printf '%s/%s' "$(BUILD_DIR)" "$(dir $*)" >> $@
|
2024-10-23 15:01:58 +03:00
|
|
|
$(CPP) $(CPPFLAGS) $(INCPATH) -M $(SRC_DIR)/$*.c >> $@
|
2024-10-23 14:44:02 +03:00
|
|
|
echo ' $(CC) -c $$< $$(CPPFLAGS) $$(CFLAGS) $$(INCPATH) -o $$@' >> $@
|
|
|
|
|
|
|
|
ifneq ($(BUILD_DIR),)
|
|
|
|
# Avoid `rm /`
|
|
|
|
clean:
|
2024-10-23 15:01:58 +03:00
|
|
|
-rm server
|
|
|
|
-rm -r $(BUILD_DIR)
|
2024-10-23 14:44:02 +03:00
|
|
|
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:
|