60 lines
1.2 KiB
Makefile
60 lines
1.2 KiB
Makefile
SRC_DIR := src
|
|
BUILD_DIR := build
|
|
RELEASE_DIR := $(BUILD_DIR)/release
|
|
DEBUG_DIR := $(BUILD_DIR)/debug
|
|
BINARY := stj
|
|
CORES := $(shell nproc --all)
|
|
|
|
all: debug
|
|
.PHONY: all
|
|
|
|
|
|
clean:
|
|
@ [ ! -e '$(BINARY)' ] || rm '$(BINARY)'
|
|
@ rm -rf '$(BUILD_DIR)'
|
|
.PHONY: clean
|
|
|
|
|
|
# Release
|
|
run-release: release
|
|
@ ./'$(RELEASE_DIR)/$(BINARY)'
|
|
.PHONY: run-release
|
|
|
|
release: $(RELEASE_DIR)/Makefile
|
|
@ make -C '$(RELEASE_DIR)' -j'$(CORES)' && \
|
|
ln -sf '$(RELEASE_DIR)'/'$(BINARY)' ./'$(BINARY)'
|
|
.PHONY: release
|
|
|
|
$(RELEASE_DIR)/Makefile: $(SRC_DIR)/CMakeLists.txt
|
|
@ cmake \
|
|
-H'$(SRC_DIR)' \
|
|
-B'$(RELEASE_DIR)' \
|
|
-DCMAKE_BUILD_TYPE=Release \
|
|
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
|
|
|
|
clean-release:
|
|
@ rm -rf '$(RELEASE_DIR)'
|
|
.PHONY: clean-release
|
|
|
|
|
|
# Debug
|
|
run-debug: debug
|
|
@ ./'$(DEBUG_DIR)/$(BINARY)'
|
|
.PHONY: run-debug
|
|
|
|
debug: $(DEBUG_DIR)/Makefile
|
|
@ make -C '$(DEBUG_DIR)' -j'$(CORES)' && \
|
|
ln -sf '$(DEBUG_DIR)/$(BINARY)' ./'$(BINARY)'
|
|
.PHONY: debug
|
|
|
|
$(DEBUG_DIR)/Makefile: $(SRC_DIR)/CMakeLists.txt
|
|
@ cmake \
|
|
-H'$(SRC_DIR)' \
|
|
-B'$(DEBUG_DIR)' \
|
|
-DCMAKE_BUILD_TYPE=Debug \
|
|
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
|
|
|
|
clean-debug:
|
|
@ rm -rf '$(DEBUG_DIR)'
|
|
.PHONY: clean-debug
|