-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
54 lines (44 loc) · 1.46 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
SOURCES := $(shell find src/ -type f | grep -E '\.(h|c)(pp)?$$')
MAKE_OPTS := -j4
GDB_OPTS := -ex "set style enabled on"
.PHONY: help
help:
@echo -e "Try one of these make targets:\n"
@grep "^\.PHONY: " Makefile | cut -d" " -f2- | tr -s " " | sed -e "s/ /\n/g" | grep -v "^_" | sed -e "s/^/make /"
.PHONY: run run-with-music run-debug
run: build
cd build && ./glowbox
run-with-music: build
cd build && ./glowbox --enable-music
run-debug: build-debug | has-gdb
cd build-debug && gdb -batch $(GDB_OPTS) -ex "run" -ex "backtrace" ./glowbox
.PHONY: build
build: build/glowbox
build/glowbox: ${SOURCES} | build/Makefile has-make
make -C build $(MAKE_OPTS)
build/Makefile: | build/ _submodules has-cmake
cd build && cmake ..
.PHONY: build-debug
build-debug: build-debug/glowbox
build-debug/glowbox: ${SOURCES} | build-debug/Makefile has-make
make -C build-debug $(MAKE_OPTS)
build-debug/Makefile: | build-debug/ _submodules has-cmake
cd build-debug && cmake -DCMAKE_BUILD_TYPE=Debug ..
.PHONY: _submodules
_submodules: | has-git
@git submodule update --init
.PHONY: clean
clean:
@# TODO: submodules
@test -d build-debug && rm -rfv build-debug/ || true
@rm -rfv build/*
# === helpers: ===
# make folders, use as order-only prerequisite
%/:
mkdir -p $*
# check if program is available in PATH, use as order-only prerequisite
has-%:
@command -v $* >/dev/null || ( \
echo "ERROR: Command '$*' not found! Make sure it is installed and available in PATH"; \
false; \
) >&2