@@ -38,28 +38,20 @@ MERGED_FILE = $(OUT_FILE)_$(SD_NAME)_$(SD_VERSION)
38
38
# Toolchain commands
39
39
# Should be added to your PATH
40
40
CROSS_COMPILE = arm-none-eabi-
41
- CC := $(CROSS_COMPILE ) gcc
42
- AS := $(CROSS_COMPILE ) as
43
- AR := $(CROSS_COMPILE ) ar -r
44
- LD := $(CROSS_COMPILE ) ld
45
- NM := $(CROSS_COMPILE ) nm
46
- OBJDUMP := $(CROSS_COMPILE ) objdump
47
- OBJCOPY := $(CROSS_COMPILE ) objcopy
48
- SIZE := $(CROSS_COMPILE ) size
49
- GDB := $(CROSS_COMPILE ) gdb
41
+ CC = $(CROSS_COMPILE ) gcc
42
+ AS = $(CROSS_COMPILE ) as
43
+ AR = $(CROSS_COMPILE ) ar -r
44
+ NM = $(CROSS_COMPILE ) nm
45
+ OBJDUMP = $(CROSS_COMPILE ) objdump
46
+ OBJCOPY = $(CROSS_COMPILE ) objcopy
47
+ SIZE = $(CROSS_COMPILE ) size
48
+ GDB = $(CROSS_COMPILE ) gdb
50
49
51
50
NRFUTIL = adafruit-nrfutil
52
51
NRFJPROG = nrfjprog
53
52
54
- MK := mkdir -p
55
- RM := rm -rf
56
-
57
- # Verbose mode (V=). 0: default, 1: print out CFLAG, LDFLAG 2: print all compile command
58
- ifeq ("$(V ) ","2")
59
- QUIET =
60
- else
61
- QUIET = @
62
- endif
53
+ MK = mkdir -p
54
+ RM = rm -rf
63
55
64
56
# auto-detect BMP on macOS, otherwise have to specify
65
57
BMP_PORT ?= $(shell ls -1 /dev/cu.usbmodem????????1 | head -1)
@@ -226,7 +218,7 @@ CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
226
218
227
219
# keep every function in separate section. This will allow linker to dump unused functions
228
220
CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing
229
- CFLAGS += -fno-builtin --short -enums -fstack-usage
221
+ CFLAGS += -fno-builtin -fshort -enums -fstack-usage
230
222
231
223
# Defined Symbol (MACROS)
232
224
CFLAGS += -D__HEAP_SIZE=0
@@ -248,17 +240,13 @@ CFLAGS += -DMK_BOOTLOADER_VERSION='($(word 1,$(_VER)) << 16) + ($(word 2,$(_VER)
248
240
#
249
241
# ******************************************************************************
250
242
251
- # keep every function in separate section. This will allow linker to dump unused functions
252
- LDFLAGS += -Xlinker -Map=$(BUILD ) /$(OUT_FILE ) .map
253
- LDFLAGS += -mthumb -mabi=aapcs -Llinker -T$(LD_FILE )
254
- LDFLAGS += -mcpu=cortex-m4
255
- LDFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
256
-
257
- # let linker to dump unused sections
258
- LDFLAGS += -Wl,--gc-sections
243
+ LDFLAGS += \
244
+ $(CFLAGS) \
245
+ -Wl,-L,linker -Wl,-T,$(LD_FILE) \
246
+ -Wl,
[email protected] -Wl,-cref -Wl,-gc-sections \
247
+ -specs=nosys.specs -specs=nano.specs
259
248
260
- # use newlib in nano version
261
- LDFLAGS += --specs=nano.specs -lc -lnosys
249
+ LIBS += -lm -lc
262
250
263
251
# ******************************************************************************
264
252
# Assembler flags
@@ -290,6 +278,7 @@ OBJECTS = $(C_OBJECTS) $(ASM_OBJECTS)
290
278
# BUILD TARGETS
291
279
# ******************************************************************************
292
280
281
+ # Verbose mode (V=). 0: default, 1: print out CFLAG, LDFLAG 2: print all compile command
293
282
ifeq ("$(V ) ","1")
294
283
$(info CFLAGS $(CFLAGS))
295
284
$(info )
@@ -299,6 +288,12 @@ $(info ASMFLAGS $(ASMFLAGS))
299
288
$(info )
300
289
endif
301
290
291
+ ifeq ("$(V ) ","2")
292
+ QUIET =
293
+ else
294
+ QUIET = @
295
+ endif
296
+
302
297
.phony : all clean size flash sd erase
303
298
304
299
# default target to build
@@ -359,7 +354,7 @@ $(BUILD)/%.o: %.S
359
354
# Link
360
355
$(BUILD ) /$(OUT_FILE ) -nosd.out : $(BUILD ) $(OBJECTS )
361
356
@echo LD $(OUT_FILE ) -nosd.out
362
- $(QUIET )$(CC ) $ (LDFLAGS ) $(OBJECTS ) $(LIBS ) -lm -o $@
357
+ $(QUIET )$(CC ) -o $@ $ (LDFLAGS ) $(OBJECTS ) -Wl,--start-group $(LIBS ) -Wl,--end-group
363
358
364
359
size : $(BUILD ) /$(OUT_FILE ) -nosd.out
365
360
-@echo ' '
0 commit comments