forked from DualTachyon/radtel-rt-890-oefw
-
Notifications
You must be signed in to change notification settings - Fork 30
/
Makefile
279 lines (239 loc) · 5.3 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
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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
TARGET = firmware
UART_DEBUG ?= 0
MOTO_STARTUP_TONE ?= 1
ENABLE_AM_FIX ?= 1
ENABLE_ALT_SQUELCH ?= 1
ENABLE_STATUS_BAR_LINE ?= 0
ENABLE_NOAA ?= 1
ENABLE_RX_BAR ?= 1
ENABLE_TX_BAR ?= 1
ENABLE_SLOWER_RSSI_TIMER ?= 1
ENABLE_SPECTRUM ?= 1
ENABLE_KEEP_MONITOR_MODE_UP_DN ?= 0
PCB_VER_2_1 ?= 0
# Spectrum presets - 1.4 kB
ENABLE_SPECTRUM_PRESETS ?= 1
# FM radio = 2.6 kB
ENABLE_FM_RADIO ?= 1
# Register Editor = .5 kB
ENABLE_REGISTER_EDIT ?= 0
# Scanlist membership display - 252 B
ENABLE_SCANLIST_DISPLAY ?= 1
# Space saving options
ENABLE_LTO ?= 0
ENABLE_OPTIMIZED ?= 1
OBJS =
# Startup files
OBJS += startup/start.o
OBJS += startup/init.o
ifeq ($(UART_DEBUG),1)
OBJS += external/printf/printf.o
endif
# BSP
OBJS += bsp/crm.o
OBJS += bsp/gpio.o
OBJS += bsp/misc.o
OBJS += bsp/tmr.o
# Drivers
OBJS += driver/audio.o
OBJS += driver/battery.o
OBJS += driver/beep.o
ifeq ($(ENABLE_FM_RADIO), 1)
OBJS += driver/bk1080.o
endif
OBJS += driver/bk4819.o
OBJS += driver/crm.o
OBJS += driver/delay.o
OBJS += driver/key.o
OBJS += driver/led.o
OBJS += driver/pwm.o
OBJS += driver/serial-flash.o
OBJS += driver/speaker.o
OBJS += driver/st7735s.o
OBJS += driver/uart.o
# "App" logic
OBJS += app/css.o
OBJS += app/flashlight.o
ifeq ($(ENABLE_FM_RADIO), 1)
OBJS += app/fm.o
endif
OBJS += app/lock.o
OBJS += app/menu.o
OBJS += app/radio.o
ifeq ($(ENABLE_REGISTER_EDIT), 1)
OBJS += app/regedit.o
endif
ifeq ($(ENABLE_SPECTRUM), 1)
OBJS += app/spectrum.o
endif
OBJS += app/t9.o
OBJS += app/uart.o
# Helper code
OBJS += helper/dtmf.o
OBJS += helper/helper.o
OBJS += helper/inputbox.o
# Misc data
OBJS += misc.o
# Radio management
OBJS += radio/channels.o
OBJS += radio/data.o
OBJS += radio/detector.o
OBJS += radio/frequencies.o
OBJS += radio/hardware.o
OBJS += radio/scheduler.o
OBJS += radio/settings.o
# Tasks
OBJS += task/alarm.o
ifeq ($(ENABLE_AM_FIX), 1)
OBJS += task/am-fix.o
endif
OBJS += task/battery.o
OBJS += task/cursor.o
OBJS += task/encrypt.o
ifeq ($(ENABLE_FM_RADIO), 1)
OBJS += task/fmscanner.o
endif
OBJS += task/keyaction.o
OBJS += task/keys.o
OBJS += task/idle.o
OBJS += task/incoming.o
OBJS += task/lock.o
ifeq ($(ENABLE_NOAA), 1)
OBJS += task/noaa.o
endif
OBJS += task/ptt.o
OBJS += task/rssi.o
OBJS += task/scanner.o
OBJS += task/screen.o
OBJS += task/sidekeys.o
OBJS += task/timeout.o
OBJS += task/voice.o
OBJS += task/vox.o
# User Interface
OBJS += ui/boot.o
OBJS += ui/dialog.o
OBJS += ui/font.o
OBJS += ui/gfx.o
OBJS += ui/helper.o
OBJS += ui/logo.o
OBJS += ui/main.o
OBJS += ui/menu.o
ifeq ($(ENABLE_NOAA), 1)
OBJS += ui/noaa.o
endif
OBJS += ui/version.o
OBJS += ui/vfo.o
OBJS += ui/welcome.o
# Main
OBJS += main.o
ifeq ($(OS),Windows_NT)
TOP := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
else
TOP := $(shell pwd)
endif
SDK := $(TOP)/external/SDK
LINKER_SCRIPT := $(SDK)/libraries/cmsis/cm4/device_support/startup/gcc/linker/AT32F421x8_FLASH.ld
AS = arm-none-eabi-as
CC = arm-none-eabi-gcc
LD = arm-none-eabi-gcc
OBJCOPY = arm-none-eabi-objcopy
SIZE = arm-none-eabi-size
GIT_HASH_TMP := $(shell git rev-parse --short HEAD)
ifeq ($(GIT_HASH_TMP),)
GIT_HASH := "NOGIT"
else
GIT_HASH := $(GIT_HASH_TMP)
endif
ASFLAGS = -mcpu=cortex-m4
CFLAGS = -Os -Wall -Werror -mcpu=cortex-m4 -fno-builtin -fshort-enums -fno-delete-null-pointer-checks -std=c2x -MMD
CFLAGS += -DAT32F421C8T7
CFLAGS += -DPRINTF_INCLUDE_CONFIG_H
CFLAGS += -DGIT_HASH=\"$(GIT_HASH)\"
LDFLAGS = -mcpu=cortex-m4 -nostartfiles -Wl,-T,firmware.ld
ifeq ($(ENABLE_OPTIMIZED),1)
CFLAGS += --specs=nano.specs
LDFLAGS += --specs=nano.specs
CFLAGS += -ffunction-sections
LDFLAGS += -Wl,--gc-sections
CFLAGS += -finline-limit=0
CFLAGS += -fmerge-all-constants
endif
ifeq ($(DEBUG),1)
ASFLAGS += -g
CFLAGS += -g
LDFLAGS += -g
endif
INC =
INC += -I $(TOP)
INC += -I $(SDK)/libraries/cmsis/cm4/device_support
INC += -I $(SDK)/libraries/cmsis/cm4/core_support/
INC += -I $(SDK)/libraries/drivers/inc/
LIBS =
DEPS = $(OBJS:.o=.d)
ifeq ($(UART_DEBUG),1)
CFLAGS += -DUART_DEBUG
endif
ifeq ($(MOTO_STARTUP_TONE),1)
CFLAGS += -DMOTO_STARTUP_TONE
endif
ifeq ($(ENABLE_AM_FIX),1)
CFLAGS += -DENABLE_AM_FIX
endif
ifeq ($(PCB_VER_2_1),1)
CFLAGS += -DPCB_VER_2_1
endif
ifeq ($(ENABLE_ALT_SQUELCH),1)
CFLAGS += -DENABLE_ALT_SQUELCH
endif
ifeq ($(ENABLE_LTO),1)
CFLAGS += -flto=auto
endif
ifeq ($(ENABLE_NOAA),1)
CFLAGS += -DENABLE_NOAA
endif
ifeq ($(ENABLE_SPECTRUM), 1)
CFLAGS += -DENABLE_SPECTRUM
endif
ifeq ($(ENABLE_SPECTRUM_PRESETS), 1)
CFLAGS += -DENABLE_SPECTRUM_PRESETS
endif
ifeq ($(ENABLE_REGISTER_EDIT), 1)
CFLAGS += -DENABLE_REGISTER_EDIT
endif
ifeq ($(ENABLE_FM_RADIO), 1)
CFLAGS += -DENABLE_FM_RADIO
endif
ifeq ($(ENABLE_SLOWER_RSSI_TIMER), 1)
CFLAGS += -DENABLE_SLOWER_RSSI_TIMER
endif
ifeq ($(ENABLE_RX_BAR), 1)
CFLAGS += -DENABLE_RX_BAR
endif
ifeq ($(ENABLE_TX_BAR), 1)
CFLAGS += -DENABLE_TX_BAR
endif
ifeq ($(ENABLE_SCANLIST_DISPLAY), 1)
CFLAGS += -DENABLE_SCANLIST_DISPLAY
endif
ifeq ($(ENABLE_KEEP_MONITOR_MODE_UP_DN), 1)
CFLAGS += -DENABLE_KEEP_MONITOR_MODE_UP_DN
endif
ifeq ($(ENABLE_STATUS_BAR_LINE), 1)
CFLAGS += -DENABLE_STATUS_BAR_LINE
endif
all: $(TARGET)
$(OBJCOPY) -O binary $< $<.bin
$(SIZE) $<
ctags:
ctags -R -f .tags .
ui/version.o: .FORCE
$(TARGET): $(OBJS)
$(LD) $(LDFLAGS) $^ -o $@ $(LIBS)
%.o: %.c
$(CC) $(CFLAGS) $(INC) -c $< -o $@
%.o: %.S
$(AS) $(ASFLAGS) $< -o $@
.FORCE:
-include $(DEPS)
clean:
rm -f $(TARGET).bin $(TARGET) $(OBJS) $(DEPS)