From fccf0db890395b0bdf263a32b43bc048702ae77a Mon Sep 17 00:00:00 2001 From: Nick Krichevsky Date: Mon, 3 Sep 2018 18:47:01 -0400 Subject: [PATCH] Refactor handling of build directories in Makefile --- Makefile | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index c201174..48a7047 100644 --- a/Makefile +++ b/Makefile @@ -14,23 +14,23 @@ clean: rm -rf $(BUILD_DIR) rm -f http_client -http_client: $(BUILD_DIR) $(COMMON_OBJ_FILES) $(CLIENT_OBJ_FILES) - $(CC) -o $@ $(LDFLAGS) $(filter-out $(BUILD_DIR),$^) +http_client: $(BUILD_DIR)/client $(BUILD_DIR)/common $(COMMON_OBJ_FILES) $(CLIENT_OBJ_FILES) + $(CC) -o $@ $(LDFLAGS) $(filter-out $(BUILD_DIR)/common $(BUILD_DIR)/client,$^) -http_server: $(BUILD_DIR) $(COMMON_OBJ_FILES) $(SERVER_OBJ_FILES) - $(CC) -o $@ $(LDFLAGS) $(filter-out $(BUILD_DIR),$^) +http_server: $(BUILD_DIR)/server $(BUILD_DIR)/common $(COMMON_OBJ_FILES) $(SERVER_OBJ_FILES) + $(CC) -o $@ $(LDFLAGS) $(filter-out $(BUILD_DIR)/common $(BUILD_DIR)/server,$^) $(BUILD_DIR)/%.o: %.c $(CC) $(CFLAGS) -o $@ $< -$(BUILD_DIR)/server: +$(BUILD_DIR)/server: $(BUILD_DIR) mkdir -p $(BUILD_DIR)/server -$(BUILD_DIR)/client: +$(BUILD_DIR)/client: $(BUILD_DIR) mkdir -p $(BUILD_DIR)/client -$(BUILD_DIR)/common: +$(BUILD_DIR)/common: $(BUILD_DIR) mkdir -p $(BUILD_DIR)/common -$(BUILD_DIR): $(BUILD_DIR)/client $(BUILD_DIR)/common - -mkdir -p $(BUILD_DIR) +$(BUILD_DIR): + mkdir -p $(BUILD_DIR)