This repository has been archived by the owner on May 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
74 lines (60 loc) · 1.49 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
MAKEFLAGS=--no-print-directory --quiet
ifdef OS
path = $(subst /,\,$1)
OS_NAME:=windows
OS_ARCH:=x86_x64
else
path = $1
OS_NAME:=$(shell uname -s | tr A-Z a-z)
OS_ARCH:=$(shell uname -p)
endif
PROJECT_NAME=flappy-bird
CMAKE_DIR:=.cmake
OUTPUT_DIR:=bin
EXE=$(call path, $(OUTPUT_DIR)/$(PROJECT_NAME))
CONFIGURE:=configure c
BUILD:=build b
RUN:=run r
DEBUG:=debug d
DIST:=dist
_CONFIGURE:=cmake -B $(CMAKE_DIR) -S . -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=1
_COPY_CCOMMANDS:=cp -f $(call path, $(CMAKE_DIR)/compile_commands.json) compile_commands.json
_BUILD:=cmake --build $(CMAKE_DIR) -j
_COPY_ASSETS:=cp -rf assets $(OUTPUT_DIR)
all: $(CMAKE_DIR) build run
$(CONFIGURE):
echo ----- Configuring -----
mkdir -p $(CMAKE_DIR)
$(_CONFIGURE)
-$(_COPY_CCOMMANDS)
$(BUILD):
echo ----- Building -----
mkdir -p $(OUTPUT_DIR)
$(_BUILD)
$(_COPY_ASSETS)
$(RUN):
echo ----- Running -----
$(_COPY_ASSETS)
cd $(OUTPUT_DIR)
$(EXE)
$(DEBUG):
echo ----- Debugging -----
$(_COPY_ASSETS)
cd $(OUTPUT_DIR)
gdb -q --return-child-result $(EXE)
$(DIST): $(OUTPUT_DIR)
echo ----- Packing distribution -----
$(_COPY_ASSETS)
-rm -f $(PROJECT_NAME)-$(OS_NAME)-$(OS_ARCH).zip
zip -9 -r $(PROJECT_NAME)-$(OS_NAME)-$(OS_ARCH).zip $(call path, $(OUTPUT_DIR)/*)
$(CMAKE_DIR):
echo ----- Configuring -----
mkdir -p $(CMAKE_DIR)
$(_CONFIGURE)
-$(_COPY_CCOMMANDS)
$(OUTPUT_DIR):
mkdir -p $(OUTPUT_DIR)
$(_BUILD)
clean:
git clean -Xdfq
.PHONY=$(CONFIGURE) $(BUILD) $(RUN) $(DEBUG) $(DIST) clean