-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
80 lines (68 loc) · 1.81 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
# -----------------------------------------------------------------------------
# CMake project wrapper Makefile ----------------------------------------------
# -----------------------------------------------------------------------------
SHELL := /bin/bash
RM := rm -f
RMF := rm -rf
MKDIR := mkdir -p
RMDIR := rmdir
CMAKE := cmake
WEB_INSTALL_DIR ?= bin/www/
# detect host build system
ifneq ($(USE_NINJA),)
CMAKE_OPTS := -G "Ninja"
else ifneq ($(MINGW_CHOST),)
CMAKE_OPTS := -G "MinGW Makefiles"
else
CMAKE_OPTS := -G "Unix Makefiles"
endif
CMAKE_OPTS += -DCMAKE_VERBOSE_MAKEFILE=ON
ifneq ($(USE_CLANG),)
CC := $(shell which clang)
endif
CMAKE_OPTS += -DCMAKE_C_COMPILER="$(CC)"
CMAKE_OPTS += -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
.PHONY: all clean distclean
all: ./build/Makefile
@ $(CMAKE) --build build
install: all
ifneq ($(USE_NINJA),)
@ ninja -C build install
else
@ $(MAKE) -C build install
endif
./build/Makefile:
@ ($(MKDIR) build > /dev/null)
@ (cd build > /dev/null 2>&1 && $(CMAKE) .. $(CMAKE_OPTS))
clean: ./build/Makefile
ifneq ($(USE_NINJA),)
@- echo "Clean not supported"
else
$(CMAKE) --build build -t clean
endif
distclean:
@ echo Removing build/
@ ($(MKDIR) build > /dev/null)
@- $(MAKE) --silent -C build clean > /dev/null 2>&1 || true
@- $(RM) ./build/Makefile
@- $(RM) ./build/.ninja*
@- $(RM) ./build/build.ninja
@- $(RMF) ./build/CMake*
@- $(RM) ./build/cmake.*
@- $(RM) ./build/*.cmake
@- $(RM) ./build/*.txt
@- $(RMF) ./build/test
@- $(RMF) ./build/src
@- $(RMF) ./build/include
@- $(RMF) ./build/lib
@- $(RM) ./build/compile_commands.json
@- ${RMF} ./build/.cache
@ $(RMDIR) ./build
ifeq ($(findstring distclean,$(MAKECMDGOALS)),)
$(MAKECMDGOALS): ./build/Makefile
ifneq ($(USE_NINJA),)
@ ninja -C build $(MAKECMDGOALS)
else
@ $(MAKE) -C build $(MAKECMDGOALS)
endif
endif