forked from ballaswag/guppyscreen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
164 lines (125 loc) · 4.54 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
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
#
# Makefile
#
ifdef CROSS_COMPILE
CC = $(CROSS_COMPILE)gcc
CXX = $(CROSS_COMPILE)g++
CPP = $(CC) -E
AS = $(CROSS_COMPILE)as
LD = $(CROSS_COMPILE)ld
AR = $(CROSS_COMPILE)ar
NM = $(CROSS_COMPILE)nm
STRIP = $(CROSS_COMPILE)strip
endif
LVGL_DIR_NAME ?= lvgl
LVGL_DIR ?= .
WARNINGS := -Wall -Wextra -Wno-unused-function -Wno-error=strict-prototypes -Wpointer-arith \
-fno-strict-aliasing -Wno-error=cpp -Wuninitialized -Wmaybe-uninitialized -Wno-unused-parameter -Wno-missing-field-initializers -Wtype-limits -Wsizeof-pointer-memaccess \
-Wno-format-nonliteral -Wno-cast-qual -Wunreachable-code -Wno-switch-default -Wreturn-type -Wmultichar -Wformat-security -Wno-error=pedantic \
-Wno-sign-compare -Wdouble-promotion -Wclobbered -Wempty-body -Wtype-limits -Wshift-negative-value \
-Wno-unused-value -Wno-unused-parameter -Wno-missing-field-initializers -Wuninitialized -Wmaybe-uninitialized -Wall -Wextra -Wno-unused-parameter \
-Wno-missing-field-initializers -Wtype-limits -Wsizeof-pointer-memaccess -Wno-format-nonliteral -Wpointer-arith -Wno-cast-qual \
-Wunreachable-code -Wno-switch-default -Wreturn-type -Wmultichar -Wformat-security -Wno-sign-compare
CFLAGS ?= -O3 -g0 -MD -MP -I$(LVGL_DIR)/ $(WARNINGS)
LDFLAGS ?= -static -lm -Llibhv/lib -Lspdlog/build -l:libhv.a -latomic -lpthread -Lwpa_supplicant/wpa_supplicant/ -l:libwpa_client.a -lstdc++fs -l:libspdlog.a
BIN = guppyscreen
BUILD_DIR = ./build
BUILD_OBJ_DIR = $(BUILD_DIR)/obj
BUILD_BIN_DIR = $(BUILD_DIR)/bin
SPDLOG_DIR = spdlog
prefix ?= /usr
bindir ?= $(prefix)/bin
#Collect the files to compile
MAINSRC = $(filter-out $(LVGL_DIR)/src/kd_graphic_mode.cpp, $(wildcard $(LVGL_DIR)/src/*.cpp))
include $(LVGL_DIR)/lvgl/lvgl.mk
include $(LVGL_DIR)/lv_drivers/lv_drivers.mk
CSRCS += $(wildcard $(LVGL_DIR)/assets/*.c)
CSRCS += $(wildcard $(LVGL_DIR)/lv_touch_calibration/*.c)
ASSET_DIR = material
ifdef GUPPY_SMALL_SCREEN
ASSET_DIR = material_46
DEFINES += -D GUPPY_SMALL_SCREEN
endif
ifdef GUPPY_ROTATE
DEFINES += -D GUPPY_ROTATE
endif
ifeq ($(GUPPY_THEME),zbolt)
CSRCS += $(wildcard $(LVGL_DIR)/assets/zbolt/*.c)
DEFINES += -D ZBOLT
else
CSRCS += $(wildcard $(LVGL_DIR)/assets/$(ASSET_DIR)/*.c)
endif
ifdef GUPPYSCREEN_VERSION
DEFINES += -D GUPPYSCREEN_VERSION="\"${GUPPYSCREEN_VERSION}\""
endif
OBJEXT ?= .o
AOBJS = $(ASRCS:.S=$(OBJEXT))
COBJS = $(CSRCS:.c=$(OBJEXT))
MAINOBJ = $(MAINSRC:.cpp=$(OBJEXT))
DEPS = $(addprefix $(BUILD_OBJ_DIR)/, $(patsubst %.o, %.d, $(MAINOBJ)))
OBJS = $(AOBJS) $(COBJS) $(MAINOBJ)
TARGET = $(addprefix $(BUILD_OBJ_DIR)/, $(patsubst ./%, %, $(OBJS)))
INC := -I./ -I./lvgl/ -I./lv_touch_calibration -I./spdlog/include -Ilibhv/include -Iwpa_supplicant/src/common
LDLIBS := -lm
DEFINES += -D _GNU_SOURCE -DSPDLOG_COMPILED_LIB
ifdef EVDEV_CALIBRATE
DEFINES += -D EVDEV_CALIBRATE
endif
# SIMULATION is enabled by default, need CROSS_COMPILE variable to do MIPS build
ifndef CROSS_COMPILE
DEFINES += -D LV_BUILD_TEST=0 -D SIMULATOR
LDLIBS += -lSDL2
endif
COMPILE_CC = $(CC) $(CFLAGS) $(INC) $(DEFINES)
COMPILE_CXX = $(CC) $(CFLAGS) $(INC) $(DEFINES)
## MAINOBJ -> OBJFILES
all: default
libhv.a:
$(MAKE) -C libhv -j$(nproc) libhv
libspdlog.a:
@mkdir -p $(SPDLOG_DIR)/build
@cmake -B $(SPDLOG_DIR)/build -S $(SPDLOG_DIR)/ -DCMAKE_CXX_COMPILER=$(CXX)
$(MAKE) -C $(SPDLOG_DIR)/build -j$(nproc)
wpaclient:
$(MAKE) -C wpa_supplicant/wpa_supplicant -j$(nproc) libwpa_client.a
$(BUILD_OBJ_DIR)/%.o: %.cpp
@mkdir -p $(dir $@)
@$(COMPILE_CXX) -std=c++17 $(CFLAGS) -c $< -o $@
@echo "CXX $<"
$(BUILD_OBJ_DIR)/%.o: %.c
@mkdir -p $(dir $@)
@$(COMPILE_CC) $(CFLAGS) -c $< -o $@
@echo "CC $<"
$(BUILD_OBJ_DIR)/kd_graphic_mode.o: src/kd_graphic_mode.cpp
@mkdir -p $(dir $@)
@$(COMPILE_CC) $(CFLAGS) -c $< -o $@
@echo "CC $<"
kd_graphic_mode: $(BUILD_OBJ_DIR)/kd_graphic_mode.o
$(CC) -o $(BUILD_BIN_DIR)/kd_graphic_mode $(BUILD_OBJ_DIR)/kd_graphic_mode.o
default: $(TARGET)
@mkdir -p $(dir $(BUILD_BIN_DIR)/)
$(CXX) -o $(BUILD_BIN_DIR)/$(BIN) $(TARGET) $(LDFLAGS) $(LDLIBS)
@echo "CXX $<"
spdlogclean:
rm -rf $(SPDLOG_DIR)/build
libhvclean:
$(MAKE) -C libhv clean
wpaclean:
$(MAKE) -C wpa_supplicant/wpa_supplicant clean
clean:
rm -rf $(BUILD_DIR)
install:
install -d $(DESTDIR)$(bindir)
install $(BUILD_BIN_DIR)/$(BIN) $(DESTDIR)$(bindir)
uninstall:
$(RM) -r $(addprefix $(DESTDIR)$(bindir)/,$(BIN))
build:
$(MAKE) wpaclean
$(MAKE) wpaclient
$(MAKE) libhvclean
$(MAKE) libhv.a
$(MAKE) spdlogclean
$(MAKE) libspdlog.a
$(MAKE) clean
$(MAKE) -j$(nproc)
-include $(DEPS)