lander/Makefile

65 lines
1.6 KiB
Makefile
Raw Normal View History

2022-11-15 16:05:47 +01:00
# =====CONFIG=====
BUILD_DIR := ./build
SRC_DIRS := ./src ./trie/src
INCLUDE_DIRS := ./trie/include
2022-11-15 16:05:47 +01:00
TEST_DIR := test
CORES != nproc
SRCS := $(shell find $(SRC_DIRS) $(INCLUDE_DIRS) \( -iname '*.cpp' -or -iname '*.c' -or -iname '*.h' \))
2022-11-15 16:05:47 +01:00
# =====RECIPES=====
all: build
.PHONY: cmake
cmake: $(BUILD_DIR)/Debug/Makefile
$(BUILD_DIR)/Debug/Makefile: CMakeLists.txt
@ cmake -B'$(BUILD_DIR)/Debug' -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=1 .
2022-11-15 16:05:47 +01:00
@ ln -sf '$(BUILD_DIR)/Debug/compile_commands.json' compile_commands.json
.PHONY: cmake-test
cmake-test: $(BUILD_DIR)/Test/Makefile
$(BUILD_DIR)/Test/Makefile: CMakeLists.txt
@ cmake -B'$(BUILD_DIR)/Test' -DCMAKE_BUILD_TYPE=Test .
2022-11-15 16:05:47 +01:00
.PHONY: build
build: cmake
@ make -C '$(BUILD_DIR)/Debug'
.PHONY: build-test
build-test: cmake-test
@ make -C '$(BUILD_DIR)/Test'
2022-11-15 16:21:27 +01:00
.PHONY: cmake-release
cmake-release: $(BUILD_DIR)/Release/Makefile
$(BUILD_DIR)/Release/Makefile: CMakeLists.txt
@ cmake -B'$(BUILD_DIR)/Release' -DCMAKE_BUILD_TYPE=Release .
.PHONY: prod
prod: cmake-release
@ make -C '$(BUILD_DIR)/Release'
2022-11-15 16:05:47 +01:00
.PHONY: run
run: build
@ LANDER_DATA_DIR=data LANDER_BASE_URL=http://localhost:18080/ LANDER_API_KEY=test ./build/Debug/lander
2022-11-15 16:05:47 +01:00
.PHONY: gdb
gdb: build
@ LANDER_DATA_DIR=data LANDER_BASE_URL=http://localhost:18080/ LANDER_API_KEY=test gdb --args ./build/Debug/lander
.PHONY: test
test: build-test
@ $(MAKE) -C '$(BUILD_DIR)/Test' test ARGS=-j$(CORES) CTEST_OUTPUT_ON_FAILURE=1
2022-11-15 16:05:47 +01:00
.PHONY: clean
clean:
@ rm -rf '$(BUILD_DIR)' compile_commands.json
.PHONY: lint
lint:
@ clang-format --Werror -n $(SRCS)
.PHONY: format
format:
@ clang-format -i $(SRCS)