-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
127 lines (93 loc) · 2.71 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
include defs.mk
#### Standard builds
.PHONY: default all
default: docker
all: docker_build release
.PHONY: release
release: BUILD=release
release: default
.PHONY: debug
debug: BUILD=debug
debug: default
.PHONY: prof
prof: BUILD=prof
prof: default
.PHONY: puzzle_icons
puzzle_icons: BUILD=icons
puzzle_icons: default
.PHONY: resim
resim: BUILD=resim
resim: ARCH=dev
resim: default
#### rmkit
RMKIT_FLAGS = -D"RMKIT_IMPLEMENTATION" -D'FONT_EMBED_H="${BUILD_DIR}/font_embed.h"'\
-pthread -lpthread
ifeq ($(ARCH),kobo)
RMKIT_FLAGS+= -D"KOBO=1"
endif
$(BUILD_DIR)/rmkit.h:
cd vendor/rmkit && $(MAKE) rmkit.h
mkdir -p $(dir $@)
mv vendor/rmkit/src/build/rmkit.h $(BUILD_DIR)
cp vendor/rmkit/src/rmkit/font_embed.h $(BUILD_DIR)
cp vendor/rmkit/src/build/$(STB) $(BUILD_DIR)
#### Game files -- defines GAME_OBJS
include Makefile.games
#### Remarkable app
TARGET = puzzles
SRCS = $(shell find src/ -type f -name '*.cpp')
OBJS = $(addprefix $(BUILD_DIR)/, $(SRCS:.cpp=.o))
INCLUDES = -I./ -Isrc/ -Ivendor/inih -Ivendor/puzzles
# rmkit produces a lot of warnings; making it a "system" header disables those
INCLUDES += -isystem $(BUILD_DIR)/
CXXFLAGS = -Wall $(INCLUDES) $(RMKIT_FLAGS) $(BUILD_FLAGS)
ifeq ($(ARCH), kobo)
CXXFLAGS += -static -static-libstdc++ -static-libgcc -D"KOBO=1"
endif
ifeq ($(ARCH), rm)
CXXFLAGS += -D"REMARKABLE=1"
endif
ifeq ($(ARCH), dev)
CXXFLAGS += -D"DEV=1"
endif
CXXFLAGS += -fdata-sections -ffunction-sections -Wl,--gc-sections
CXXFLAGS += -D'RMP_COMPILE_DATE="$(RMP_COMPILE_DATE)"'
ifneq ($(strip $(RMP_VERSION)),)
CXXFLAGS += -D'RMP_VERSION="$(RMP_VERSION)"'
endif
# rmkit has to be built as a monolith, so combine all the sources into one
MAIN_OBJ = $(BUILD_DIR)/main.o
MAIN_SRC = $(MAIN_OBJ:.o=.cpp)
OBJS = $(MAIN_OBJ)
$(MAIN_SRC): $(SRCS)
echo -n "" > $(MAIN_SRC)
for f in $(SRCS); do echo "#include \"$$f\"" >> $(MAIN_SRC); done
$(MAIN_OBJ): $(BUILD_DIR)/rmkit.h $(MAIN_SRC)
$(CXX) $(CXXFLAGS) -c -o $@ $(MAIN_SRC)
$(BUILD_DIR)/$(TARGET): $(GAME_OBJS) $(OBJS)
$(CXX) $(CXXFLAGS) -o $@ $(GAME_OBJS) $(OBJS) $(BUILD_DIR)/$(STB)
.PHONY: $(TARGET)
$(TARGET): $(BUILD_DIR)/$(TARGET)
#### auto-generate deps
CXXFLAGS += -MMD -MP
DEPS=$(OBJS:.o=.d)
-include $(DEPS)
#### Docker version of the toolchain
DOCKER_TAG = remarkable_puzzles_toolchain:latest
DOCKER_MAKEFLAGS=$(if $(shell echo $(firstword $(MAKEFLAGS)) | grep -v '='), -)$(MAKEFLAGS)
.PHONY: docker
docker:
docker run \
--user $(shell id -u):$(shell id -g) \
-v "$(CURDIR):$(CURDIR)" -w "$(CURDIR)" \
$(DOCKER_ENV) \
--rm $(DOCKER_TAG) \
make $(TARGET) $(DOCKER_MAKEFLAGS)
.PHONY: docker_build
docker_build:
docker build -t $(DOCKER_TAG) .
#### Clean
.PHONY: clean
clean:
$(RM) -rf $(BUILD_ROOT)
cd vendor/rmkit && make clean