2018-05-14 19:25:21 +02:00
|
|
|
# Target architecture for the build. Use avr if you are unsure.
|
2020-09-08 22:28:41 +02:00
|
|
|
TARGET_ARCH_AVR ?= avr
|
|
|
|
TARGET_ARCH ?= $(TARGET_ARCH_AVR)
|
2018-05-14 19:25:21 +02:00
|
|
|
|
2021-01-02 19:29:08 +01:00
|
|
|
ifeq (atxmega,$(CPU))
|
|
|
|
ifeq (,$(CPU_MODEL))
|
|
|
|
$(error CPU_MODEL must have been defined by the board Makefile.features)
|
|
|
|
endif
|
|
|
|
CFLAGS_CPU ?= -mmcu=$(CPU_MODEL) $(CFLAGS_FPU)
|
|
|
|
else
|
|
|
|
CFLAGS_CPU ?= -mmcu=$(CPU) $(CFLAGS_FPU)
|
|
|
|
endif
|
2018-05-14 19:25:21 +02:00
|
|
|
CFLAGS_LINK = -ffunction-sections -fdata-sections -fno-builtin -fshort-enums
|
|
|
|
CFLAGS_DBG ?= -ggdb -g3
|
|
|
|
CFLAGS_OPT ?= -Os
|
|
|
|
|
2022-05-30 18:22:02 +02:00
|
|
|
# Use of __flash requires gnu11 instead of c11
|
|
|
|
CFLAGS += -std=gnu11
|
|
|
|
|
2018-05-14 19:25:21 +02:00
|
|
|
CFLAGS += $(CFLAGS_CPU) $(CFLAGS_LINK) $(CFLAGS_DBG) $(CFLAGS_OPT)
|
|
|
|
ASFLAGS += $(CFLAGS_CPU) $(CFLAGS_DBG)
|
2018-05-09 07:52:32 +02:00
|
|
|
|
2018-05-14 19:25:21 +02:00
|
|
|
LINKFLAGS += $(CFLAGS_CPU) $(CFLAGS_DBG) $(CFLAGS_OPT) -static -lgcc -e reset_handler -Wl,--gc-sections
|
2021-08-31 14:42:09 +02:00
|
|
|
LINKFLAGS += -L$(RIOTCPU)/avr8_common/ldscripts
|
|
|
|
LINKFLAGS += -T$(LINKER_SCRIPT)
|
2018-05-14 19:25:21 +02:00
|
|
|
|
|
|
|
# Use ROM_LEN and RAM_LEN during link
|
|
|
|
$(if $(ROM_LEN),,$(error ROM_LEN is not defined))
|
|
|
|
$(if $(RAM_LEN),,$(error RAM_LEN is not defined))
|
|
|
|
LINKFLAGS += $(LINKFLAGPREFIX)--defsym=__TEXT_REGION_LENGTH__=$(ROM_LEN)$(if $(ROM_RESERVED),-$(ROM_RESERVED))
|
|
|
|
LINKFLAGS += $(LINKFLAGPREFIX)--defsym=__DATA_REGION_LENGTH__=$(RAM_LEN)
|
2021-01-23 22:19:29 +01:00
|
|
|
LINKFLAGS += $(LDSCRIPT_EXTRA)
|
2018-05-14 19:25:21 +02:00
|
|
|
|
|
|
|
ifeq ($(LTO),1)
|
|
|
|
# avr-gcc <4.8.3 has a bug when using LTO which causes a warning to be printed always:
|
|
|
|
# '_vector_25' appears to be a misspelled signal handler [enabled by default]
|
|
|
|
# See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59396
|
|
|
|
LINKFLAGS += -Wno-error
|
|
|
|
endif
|
2019-08-28 19:43:17 +02:00
|
|
|
|
|
|
|
OPTIONAL_CFLAGS_BLACKLIST += -Wformat-overflow
|
|
|
|
OPTIONAL_CFLAGS_BLACKLIST += -Wformat-truncation
|
2019-08-28 18:40:38 +02:00
|
|
|
OPTIONAL_CFLAGS_BLACKLIST += -gz
|