2018-02-02 14:29:35 +00:00
|
|
|
MAKEFILE := $(lastword $(MAKEFILE_LIST))
|
|
|
|
BASE_DIR := $(realpath $(dir $(MAKEFILE)))
|
|
|
|
|
2017-11-28 15:55:07 +00:00
|
|
|
CC = arm-none-eabi-gcc
|
|
|
|
CPP = arm-none-eabi-cpp
|
|
|
|
LD = arm-none-eabi-gcc
|
|
|
|
AR = arm-none-eabi-ar
|
|
|
|
OBJCOPY = arm-none-eabi-objcopy
|
|
|
|
OBJDUMP = arm-none-eabi-objdump
|
|
|
|
NM = arm-none-eabi-nm
|
|
|
|
SIZE = arm-none-eabi-size
|
|
|
|
SREC_CAT = srec_cat
|
|
|
|
|
|
|
|
CFLAGS += -mthumb -mabi=aapcs -mlittle-endian
|
|
|
|
CFLAGS += -Werror -Wall
|
|
|
|
CFLAGS += -std=c99
|
|
|
|
CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing
|
2018-06-07 08:29:47 +00:00
|
|
|
# A weird behaviour of GCC garbage collection has been observed, where unitialized
|
|
|
|
# global variables put in the COMMON section weren't analyzed by the garbage collector
|
|
|
|
# at all. No idea why. The fix is to dissallow the common section, which subsequently
|
|
|
|
# places all unitialized global variables in the .bss section and enables the
|
|
|
|
# garbage collector to analyze the variables.
|
|
|
|
CFLAGS += -fno-common
|
2017-11-28 15:55:07 +00:00
|
|
|
CFLAGS += -fshort-enums -fomit-frame-pointer -fno-builtin
|
|
|
|
|
|
|
|
LDFLAGS += -mthumb -mlittle-endian
|
|
|
|
|
|
|
|
OBJDUMP_FLAGS += --disassemble --source --disassembler-options=force-thumb
|
|
|
|
|
|
|
|
### Are we building with code size optimisations?
|
|
|
|
SMALL ?= 1
|
|
|
|
ifeq ($(SMALL),1)
|
|
|
|
CFLAGS += -Os
|
|
|
|
else
|
2018-05-08 19:39:20 +00:00
|
|
|
CFLAGS += -O0
|
2017-11-28 15:55:07 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
### Use CMSIS and the existing dbg-io from arch/cpu/arm/common
|
2018-02-02 14:29:35 +00:00
|
|
|
CONTIKI_ARM_DIRS += .
|
|
|
|
CONTIKI_ARM_DIRS += ../common/dbg-io
|
|
|
|
CONTIKI_CPU_DIRS += $(realpath $(addprefix $(BASE_DIR)/, $(CONTIKI_ARM_DIRS)))
|
2017-11-28 15:55:07 +00:00
|
|
|
|
|
|
|
### CPU-dependent cleanup files
|
2018-03-30 19:20:28 +00:00
|
|
|
CLEAN += *.elf *.bin *.lst *.hex *.i16hex
|
2017-11-28 15:55:07 +00:00
|
|
|
|
|
|
|
### Don't treat the following files as intermediate
|
|
|
|
.PRECIOUS: %.elf %.hex %.bin
|
|
|
|
|
|
|
|
%.i16hex: %.elf
|
|
|
|
$(OBJCOPY) -O ihex $< $@
|
|
|
|
|
|
|
|
%.hex: %.i16hex
|
|
|
|
$(SREC_CAT) $< -intel -o $@ -intel
|
|
|
|
|
|
|
|
%.bin: %.elf
|
|
|
|
$(OBJCOPY) -O binary $(OBJCOPY_FLAGS) $< $@
|
|
|
|
|
|
|
|
%.lst: %.elf
|
|
|
|
$(OBJDUMP) $(OBJDUMP_FLAGS) $< > $@
|
|
|
|
|
|
|
|
### We don't really need the .hex and .bin for the .$(TARGET) but let's make
|
|
|
|
### sure they get built
|
|
|
|
%.$(TARGET): %.elf %.hex %.bin
|
|
|
|
cp $< $@
|