-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
83 lines (68 loc) · 1.88 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
BASE_DIR=$(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
BUILD_TYPE=debug
BUILD_INFO=Debug
ifdef RELEASE_DBG_INFO
BUILD_TYPE=release_dbg_info
BUILD_INFO=RelWithDebInfo
export RELEASE_DBG_INFO=1
endif
ifdef RELEASE
BUILD_TYPE=release
BUILD_INFO=Release
export RELEASE=1
endif
ifdef PREFIX
CMAKE_PREFIX="-DCMAKE_INSTALL_PREFIX=$(shell readlink -f $(PREFIX))"
endif
.PHONY: all build externals distclean clean release release_dbg_info debug install verifybuildtype
.SILENT:
all: release
build: build/Makefile
$(MAKE) -C build/
externals: externals/libgit2/build/Makefile
$(MAKE) -C externals/libgit2/build
externals/libgit2/build/Makefile: externals/libgit2/CMakeLists.txt
@cd "externals/libgit2" && mkdir -p "build" && cd "build" && \
cmake \
-DCMAKE_BUILD_TYPE=$(BUILD_INFO) \
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_CLAR=OFF \
-DUSE_NSEC=OFF \
-DUSE_SSH=OFF \
-DUSE_HTTPS=OFF \
-DUSE_NTLMCLIENT=OFF \
-DUSE_ICONV=OFF \
-DREGEX_BACKEND=builtin \
"$(BASE_DIR)/externals/libgit2"
build/Makefile: src/CMakeLists.txt
@mkdir -p "build"
@cd "build" && \
cmake \
-DCMAKE_BUILD_TYPE=$(BUILD_INFO) \
-DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
"$(BASE_DIR)/src" \
$(CMAKE_PREFIX)
verifybuildtype: build/Makefile
if ! grep -q "^CMAKE_BUILD_TYPE:STRING=$(BUILD_TYPE)$$" build/CMakeCache.txt > /dev/null; \
then cd build;cmake -DCMAKE_BUILD_TYPE=$(BUILD_TYPE) $(BASE_DIR)/src; \
fi
debug:
$(MAKE) verifybuildtype DEBUG=1
$(MAKE) externals DEBUG=1
$(MAKE) build DEBUG=1
release:
$(MAKE) verifybuildtype RELEASE=1
$(MAKE) externals RELEASE=1
$(MAKE) build RELEASE=1
release_dbg_info:
$(MAKE) verifybuildtype RELEASE_DBG_INFO=1
$(MAKE) externals RELEASE_DBG_INFO=1
$(MAKE) build RELEASE_DBG_INFO=1
install: build
$(MAKE) -C build install
clean:
$(MAKE) -C "externals/libgit2/build" clean
$(MAKE) -C "build" clean
distclean:
@rm -rf externals/libgit2/build
@rm -rf build