-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
64 lines (52 loc) · 1.6 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# Copyright (c) 2022 ETH Zurich and University of Bologna.
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
# Author: Philippe Sauter <[email protected]>
BUILD_DIR ?= build
BUILD_TYPE ?= Debug
DEPS := deps/fmt/build deps/slang/build deps/cxxopts/build
## build svase in debug mode (default)
all: debug
## calls build in release mode
release: $(DEPS)
@$(MAKE) build BUILD_TYPE=Release
## calls build with debug mode
debug: $(DEPS)
@$(MAKE) build BUILD_TYPE=Debug
build: $(DEPS)
scripts/gen_version.sh > include/version.h
@rm -rf $(BUILD_DIR)
@mkdir -p $(BUILD_DIR)
cmake -S . -B $(BUILD_DIR) -DCMAKE_BUILD_TYPE=$(BUILD_TYPE)
cmake --build $(BUILD_DIR)
## install each dependency
deps/%/build: .git
git submodule update --init deps/$*
@echo "Installing $*..."
@$(MAKE) -C deps/ install_$*
# if downloaded as zip, the submodules need to be restored
.git:
@if [ ! -d ".git" ]; then \
git init; \
.github/restore_submodules.sh; \
fi
## format code to match linter
format:
clang-format -style=LLVM -i src/*.cpp include/svase/*.h
## remove svase-build and dependencies
clean:
@rm -rf build
@rm -rf $(DEPS)
#rm -rf deps/install
.PHONY: all release debug build format clean help
help: Makefile
@printf "Available targets:\n\n"
@awk '/^[a-zA-Z\-_0-9]+:/ { \
helpMessage = match(lastLine, /^## (.*)/); \
if (helpMessage) { \
helpCommand = substr($$1, 0, index($$1, ":")-1); \
helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \
printf "%-15s %s\n", helpCommand, helpMessage; \
} \
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST)