-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
90 lines (69 loc) · 2.02 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
84
85
86
87
88
89
90
# A wrapper around CMake, based on <https://github.com/neovim/neovim/blob/v0.8.1/Makefile>
CMAKE_FLAGS = -G'$(CMAKE_GENERATOR)'
define cmake_var
$(1) ?= $(2)
CMAKE_FLAGS += $$(if $$($(1)),-D$(1)='$$($(1))',)
endef
-include local.mk
CMAKE ?= cmake
NINJA ?= ninja
CMAKE_GENERATOR ?= Unix Makefiles
# Based on <https://github.com/neovim/neovim/blob/v0.8.3/Makefile#L57-L66>
ifneq (,$(findstring Ninja,$(CMAKE_GENERATOR)))
BUILD_TOOL = $(NINJA)
ifneq ($(VERBOSE),)
BUILD_TOOL += -v
endif
ifeq (n,$(findstring n,$(firstword -$(MAKEFLAGS))))
BUILD_TOOL += -n
endif
ifeq (k,$(findstring k,$(firstword -$(MAKEFLAGS))))
BUILD_TOOL += -k0
endif
closeparen := )
BUILD_TOOL += $(shell \
for arg in $(MAKEFLAGS); do case "$$arg" in \
-[jl][0-9]*[!0-9]*$(closeparen) ;; \
-[jl][0-9]*$(closeparen) printf '%s\n' "$$arg";; \
--$(closeparen) break;; \
esac; done)
else
BUILD_TOOL = $(MAKE)
endif
$(eval $(call cmake_var,CMAKE_BUILD_TYPE,Debug))
$(eval $(call cmake_var,USE_SANITIZERS,))
$(eval $(call cmake_var,BUILD_WXWIDGETS_FROM_SOURCE,))
$(eval $(call cmake_var,BUILD_SHARED_LIBS,))
CMAKE_EXTRA_FLAGS ?=
BUILD_DIR ?= build
CMAKE_STAMP := $(BUILD_DIR)/.ran-cmake
all: $(CMAKE_STAMP)
+$(BUILD_TOOL) -C $(BUILD_DIR)
build: $(CMAKE_STAMP)
+$(BUILD_TOOL) -C $(BUILD_DIR) penguins
build-lib: $(CMAKE_STAMP)
+$(BUILD_TOOL) -C $(BUILD_DIR) penguins-lib
build-gui: $(CMAKE_STAMP)
+$(BUILD_TOOL) -C $(BUILD_DIR) penguins-gui
build-tests: $(CMAKE_STAMP)
+$(BUILD_TOOL) -C $(BUILD_DIR) penguins-tests
run: build
$(BUILD_DIR)/penguins
run-gui: build-gui
$(BUILD_DIR)/penguins-gui
test: build-tests
$(BUILD_DIR)/penguins-tests
docs: $(CMAKE_STAMP)
+$(BUILD_TOOL) -C $(BUILD_DIR) doxygen
clean:
+$(BUILD_TOOL) -C $(BUILD_DIR) clean
distclean:
rm -rf $(BUILD_DIR)
cmake:
rm -f $(CMAKE_STAMP)
$(MAKE) $(CMAKE_STAMP)
$(CMAKE_STAMP):
mkdir -p $(BUILD_DIR)
cd $(BUILD_DIR) && $(CMAKE) $(CMAKE_FLAGS) $(CMAKE_EXTRA_FLAGS) $$OLDPWD
touch $@
.PHONY: all build build-gui run run-gui test docs clean distclean cmake