@@ -38,28 +38,20 @@ MERGED_FILE = $(OUT_FILE)_$(SD_NAME)_$(SD_VERSION)
3838# Toolchain commands
3939# Should be added to your PATH
4040CROSS_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
5049
5150NRFUTIL = adafruit-nrfutil
5251NRFJPROG = nrfjprog
5352
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
6355
6456# auto-detect BMP on macOS, otherwise have to specify
6557BMP_PORT ?= $(shell ls -1 /dev/cu.usbmodem????????1 | head -1)
@@ -226,7 +218,7 @@ CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
226218
227219# keep every function in separate section. This will allow linker to dump unused functions
228220CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing
229- CFLAGS += -fno-builtin --short -enums -fstack-usage
221+ CFLAGS += -fno-builtin -fshort -enums -fstack-usage
230222
231223# Defined Symbol (MACROS)
232224CFLAGS += -D__HEAP_SIZE=0
@@ -248,17 +240,13 @@ CFLAGS += -DMK_BOOTLOADER_VERSION='($(word 1,$(_VER)) << 16) + ($(word 2,$(_VER)
248240#
249241# ******************************************************************************
250242
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
259248
260- # use newlib in nano version
261- LDFLAGS += --specs=nano.specs -lc -lnosys
249+ LIBS += -lm -lc
262250
263251# ******************************************************************************
264252# Assembler flags
@@ -290,6 +278,7 @@ OBJECTS = $(C_OBJECTS) $(ASM_OBJECTS)
290278# BUILD TARGETS
291279# ******************************************************************************
292280
281+ # Verbose mode (V=). 0: default, 1: print out CFLAG, LDFLAG 2: print all compile command
293282ifeq ("$(V ) ","1")
294283$(info CFLAGS $(CFLAGS))
295284$(info )
@@ -299,6 +288,12 @@ $(info ASMFLAGS $(ASMFLAGS))
299288$(info )
300289endif
301290
291+ ifeq ("$(V ) ","2")
292+ QUIET =
293+ else
294+ QUIET = @
295+ endif
296+
302297.phony : all clean size flash sd erase
303298
304299# default target to build
@@ -359,7 +354,7 @@ $(BUILD)/%.o: %.S
359354# Link
360355$(BUILD ) /$(OUT_FILE ) -nosd.out : $(BUILD ) $(OBJECTS )
361356 @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
363358
364359size : $(BUILD ) /$(OUT_FILE ) -nosd.out
365360 -@echo ' '
0 commit comments