[build] Refine Makefile
@@ -16,23 +16,34 @@ ifeq ($(OS),Windows_NT)
endif
endif
-.PHONY: all release debug clean
+BUILD_RULES := \
+ vendor deps \
+ aergocli aergosvr aergoluac polaris colaris brick \
+ libtool libtool-clean \
+ libluajit liblmdb libgmp \
+ libluajit-clean liblmdb-clean libgmp-clean \
+ check cover-check \
+ distclean \
+ protoc protoclean
+
+.PHONY: all release debug clean $(BUILD_RULES)
all: $(BUILD_FILE)
@$(MAKE) --no-print-directory -C $(BUILD_DIR)
-$(BUILD_FILE):
+$(BUILD_DIR):
@mkdir -p $(BUILD_DIR)
- cd $(BUILD_DIR) && $(CMAKE_CMD) -G "Unix Makefiles" -D CMAKE_BUILD_TYPE="Release" $(MAKE_FLAG) ..
-release:
- @mkdir -p $(BUILD_DIR)
- cd $(BUILD_DIR) && $(CMAKE_CMD) -G "Unix Makefiles" -D CMAKE_BUILD_TYPE="Release" $(MAKE_FLAG) ..
+$(BUILD_FILE): $(BUILD_DIR)
+ @if ! [ -f $(BUILD_FILE) ]; then \
+ cd $(BUILD_DIR) && $(CMAKE_CMD) -G "Unix Makefiles" -D CMAKE_BUILD_TYPE="Release" $(MAKE_FLAG) ..; \
+ fi
+
+release: $(BUILD_FILE)
@$(MAKE) --no-print-directory -C $(BUILD_DIR)
-debug:
- @mkdir -p $(BUILD_DIR)
- cd $(BUILD_DIR) && $(CMAKE_CMD) -G "Unix Makefiles" -D CMAKE_BUILD_TYPE="Debug" $(MAKE_FLAG) ..
+debug: $(BUILD_DIR)
+ @cd $(BUILD_DIR) && $(CMAKE_CMD) -G "Unix Makefiles" -D CMAKE_BUILD_TYPE="Debug" $(MAKE_FLAG) ..
@$(MAKE) --no-print-directory -C $(BUILD_DIR)
clean:
@@ -41,5 +52,5 @@ clean:
realclean: clean
@rm -rf $(BUILD_DIR)
-%: $(BUILD_DIR)
- @$(MAKE) --no-print-directory -C $(BUILD_DIR) $(MAKECMDGOALS)
+$(BUILD_RULES): $(BUILD_FILE)
+ @$(MAKE) --no-print-directory -C $(BUILD_DIR) $@
