forked from AEFeinstein/Super-2023-Swadge-FW
-
Notifications
You must be signed in to change notification settings - Fork 0
/
emu.mk
247 lines (206 loc) · 7.24 KB
/
emu.mk
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
# Makefile by Adam, 2022
################################################################################
# What OS we're compiling on
################################################################################
ifeq ($(OS),Windows_NT)
HOST_OS = Windows
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
HOST_OS = Linux
endif
ifeq ($(UNAME_S),Darwin)
HOST_OS = Darwin
endif
endif
FIND:=find
ifeq ($(HOST_OS),Windows)
FIND:=$(shell cygpath `where find | grep bin | grep -v " "`)
endif
################################################################################
# Programs to use
################################################################################
ifeq ($(HOST_OS),Windows)
CC = x86_64-w64-mingw32-gcc.exe
endif
ifeq ($(HOST_OS),Linux)
CC = gcc
endif
################################################################################
# Source Files
################################################################################
# This is a list of directories to scan for c files recursively
SRC_DIRS_RECURSIVE = emu/src main/display main/modes main/colorchord main/utils
# This is a list of directories to scan for c files not recursively
SRC_DIRS_FLAT = main
# This is a list of files to compile directly. There's no scanning here
SRC_FILES = components/hdw-spiffs/heatshrink_decoder.c components/hdw-spiffs/spiffs_json.c components/hdw-spiffs/spiffs_txt.c
# This is all the source directories combined
SRC_DIRS = $(shell $(FIND) $(SRC_DIRS_RECURSIVE) -type d) $(SRC_DIRS_FLAT)
# This is all the source files combined
SOURCES = $(shell $(FIND) $(SRC_DIRS) -maxdepth 1 -iname "*.[c]") $(SRC_FILES)
################################################################################
# Compiler Flags
################################################################################
# These are flags for the compiler, all files
CFLAGS = \
-c \
-std=gnu99 \
-g \
-static-libgcc \
-static-libstdc++ \
-ggdb
ifeq ($(HOST_OS),Linux)
CFLAGS += \
-fsanitize=address \
-fno-omit-frame-pointer
endif
# These are warning flags that the IDF uses
CFLAGS_WARNINGS = \
-Wall \
-Werror=all \
-Wno-error=unused-function \
-Wno-error=unused-variable \
-Wno-error=deprecated-declarations \
-Wextra \
-Wno-unused-parameter \
-Wno-sign-compare \
-Wno-error=unused-but-set-variable \
-Wno-old-style-declaration
# These are warning flags that I like
CFLAGS_WARNINGS_EXTRA = \
-Wundef \
-Wformat=2 \
-Winvalid-pch \
-Wlogical-op \
-Wmissing-format-attribute \
-Wmissing-include-dirs \
-Wpointer-arith \
-Wunused-local-typedefs \
-Wuninitialized \
-Wshadow \
-Wredundant-decls \
-Wjump-misses-init \
-Wswitch-enum \
-Wcast-align \
-Wformat-nonliteral \
-Wno-switch-default \
-Wunused \
-Wunused-macros \
-Wmissing-declarations \
-Wmissing-prototypes \
-Wcast-qual \
-Wno-switch \
# -Wstrict-prototypes \
# -Wpedantic \
# -Wconversion \
# -Wsign-conversion \
# -Wdouble-promotion
################################################################################
# Defines
################################################################################
# Create a variable with the git hash and branch name
GIT_HASH = \"$(shell git rev-parse --short=7 HEAD)\"
# Used by the ESP SDK
DEFINES_LIST = \
CONFIG_GC9307_240x280=y \
CONFIG_IDF_TARGET_ESP32S2=y \
SOC_RMT_CHANNELS_PER_GROUP=4 \
SOC_TOUCH_SENSOR_NUM=14 \
SOC_TOUCH_PROXIMITY_MEAS_DONE_SUPPORTED \
WITH_PROFILING=0 \
LOG_LOCAL_LEVEL=5 \
EMU=1 \
SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP=1 \
SOC_PM_SUPPORT_CPU_PD=0 \
SOC_ULP_SUPPORTED=0 \
SOC_PM_SUPPORT_EXT_WAKEUP=0 \
SOC_GPIO_SUPPORT_SLP_SWITCH=0 \
CONFIG_MAC_BB_PD=0 \
CONFIG_SWADGE_PROTOTYPE=1 \
CONFIG_TFT_MAX_BRIGHTNESS=200 \
CONFIG_TFT_MIN_BRIGHTNESS=10 \
SOC_TIMER_GROUP_TIMERS_PER_GROUP=2 \
SOC_TIMER_GROUPS=2 \
GIT_SHA1=${GIT_HASH} \
HAS_XINERAMA=1 \
FULL_SCREEN_STEAL_FOCUS=1
DEFINES = $(patsubst %, -D%, $(DEFINES_LIST))
################################################################################
# Includes
################################################################################
# Look for folders with .h files in these directories, recursively
INC_DIRS_RECURSIVE = components
# Treat every source directory as one to search for headers in, also add a few more
INC_DIRS = $(SRC_DIRS) $(shell $(FIND) $(INC_DIRS_RECURSIVE) -type d)
# Prefix the directories for gcc
INC = $(patsubst %, -I%, $(INC_DIRS) )
################################################################################
# Output Objects
################################################################################
# This is the directory in which object files will be stored
OBJ_DIR = emu/obj
# This is a list of objects to build
OBJECTS = $(patsubst %.c, $(OBJ_DIR)/%.o, $(SOURCES))
################################################################################
# Linker options
################################################################################
# This is a list of libraries to include. Order doesn't matter
ifeq ($(HOST_OS),Windows)
LIBS = opengl32 gdi32 user32 winmm WSock32
endif
ifeq ($(HOST_OS),Linux)
LIBS = m X11 asound pulse rt GL GLX pthread Xext Xinerama
endif
# These are directories to look for library files in
LIB_DIRS =
# This combines the flags for the linker to find and use libraries
LIBRARY_FLAGS = $(patsubst %, -L%, $(LIB_DIRS)) $(patsubst %, -l%, $(LIBS)) \
-static-libgcc \
-static-libstdc++ \
-ggdb
ifeq ($(HOST_OS),Linux)
LIBRARY_FLAGS += \
-fsanitize=address \
-fno-omit-frame-pointer \
-static-libasan
endif
################################################################################
# Build Filenames
################################################################################
# These are the files to build
EXECUTABLE = swadge_emulator
################################################################################
# Targets for Building
################################################################################
# This list of targets do not build files which match their name
.PHONY: all assets clean docs cppcheck print-%
# Build everything!
all: $(EXECUTABLE) assets
assets:
$(MAKE) -C ./spiffs_file_preprocessor/
./spiffs_file_preprocessor/spiffs_file_preprocessor -i ./assets/ -o ./spiffs_image/
# To build the main file, you have to compile the objects
$(EXECUTABLE): $(OBJECTS)
$(CC) $(OBJECTS) $(LIBRARY_FLAGS) -o $@
# This compiles each c file into an o file
./$(OBJ_DIR)/%.o: ./%.c
@mkdir -p $(@D) # This creates a directory before building an object in it.
$(CC) $(CFLAGS) $(CFLAGS_WARNINGS) $(CFLAGS_WARNINGS_EXTRA) $(DEFINES) $(INC) $< -o $@
# This clean everything
clean:
$(MAKE) -C ./spiffs_file_preprocessor/ clean
-@rm -f $(OBJECTS) $(EXECUTABLE)
-@rm -rf docs
################################################################################
# Targets for Debugging
################################################################################
docs:
doxygen swadge2019.doxyfile
cppcheck:
cppcheck --std=c99 --platform=unix32 --suppress=missingIncludeSystem --enable=all $(DEFINES) $(INC) main > /dev/null
################################################################################
# Makefile Debugging
################################################################################
# Print any value from this makefile
print-% : ; @echo $* = $($*)