-
Notifications
You must be signed in to change notification settings - Fork 86
/
Makefile
63 lines (50 loc) · 1.16 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
-include Makefile.config
# External commands
CMAKE ?= cmake
CLANG_FORMAT ?= clang-format
FIND ?= find
MKDIR ?= mkdir -p
PYTHON ?= python
RM_R ?= rm -fr
XARGS ?= xargs
## Path and build flags
FLAVOR ?= optimize
BUILD = build/$(FLAVOR)
#prefix ?= /usr/local
#libdir ?= lib
## Temporary staging directory
# DESTDIR =
## Specified by `git make-pkg` when building .pkg files
# mac_pkg =
ifdef prefix
CMAKE_ARGS += -DCMAKE_INSTALL_PREFIX=$(prefix)
endif
ifdef libdir
CMAKE_ARGS += -DCMAKE_INSTALL_LIBDIR=$(libdir)
endif
ifdef FLAVOR
CMAKE_ARGS += -DFLAVOR=$(FLAVOR)
endif
CMAKE_FILES += Makefile
CMAKE_FILES += $(wildcard CMakeLists.txt */*/CMakeLists.txt)
export ARGS
export CXX
export DESTDIR
export prefix
all: $(BUILD)
$(MAKE) -C $(BUILD) $@
install: all
$(MAKE) -C $(BUILD) $@
test: install
$(MAKE) -C $(BUILD) $@
clean:
$(RM_R) $(BUILD) Linux-* Darwin-*
$(BUILD): $(CMAKE_FILES)
mkdir -p $(BUILD)
cd $(BUILD) && $(CMAKE) $(CMAKE_ARGS) $(EXTRA_CMAKE_ARGS) ../..
touch $@
rm -f build/compile_commands.json
ln -s $(FLAVOR)/compile_commands.json build/compile_commands.json
format:
git ls-files '*.cpp' '*.h' | $(XARGS) $(CLANG_FORMAT) -i
precommit: format