Refactor handling of build directories in Makefile

master
Nick Krichevsky 2018-09-03 18:47:01 -04:00
parent 83b764eb28
commit fccf0db890
1 changed files with 9 additions and 9 deletions

View File

@ -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)