2018-04-16 19:03:33 +02:00
|
|
|
# Target architecture for the build.
|
2020-09-07 22:21:42 +02:00
|
|
|
TARGET_ARCH_RISCV ?= riscv-none-elf
|
|
|
|
|
|
|
|
# If TARGET_ARCH wasn't set by user, also check if riscv64-unknown-elf
|
|
|
|
# or riscv-none-embed is present.
|
|
|
|
ifeq (riscv-none-elf,$(TARGET_ARCH_RISCV))
|
|
|
|
ifeq (,$(shell which $(TARGET_ARCH_RISCV)-gcc))
|
|
|
|
ifneq (,$(shell which riscv64-unknown-elf-gcc))
|
|
|
|
TARGET_ARCH_RISCV := riscv64-unknown-elf
|
|
|
|
else ifneq (,$(shell which riscv-none-embed-gcc))
|
|
|
|
$(info Falling back to legacy riscv-none-embed toolchain)
|
|
|
|
TARGET_ARCH_RISCV := riscv-none-embed
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2020-09-08 22:28:41 +02:00
|
|
|
TARGET_ARCH ?= $(TARGET_ARCH_RISCV)
|
2018-04-16 19:03:33 +02:00
|
|
|
|
|
|
|
# define build specific options
|
|
|
|
CFLAGS_CPU = -march=rv32imac -mabi=ilp32 -mcmodel=medlow -msmall-data-limit=8
|
|
|
|
CFLAGS_LINK = -nostartfiles -ffunction-sections -fdata-sections
|
2019-10-21 11:27:21 +02:00
|
|
|
CFLAGS_DBG ?= -g3
|
|
|
|
CFLAGS_OPT ?= -Os
|
2018-04-16 19:03:33 +02:00
|
|
|
|
2020-01-02 09:51:20 +01:00
|
|
|
LINKFLAGS += -L$(RIOTCPU)/$(CPU)/ldscripts
|
|
|
|
LINKER_SCRIPT ?= $(CPU_MODEL).ld
|
|
|
|
LINKFLAGS += -T$(LINKER_SCRIPT)
|
2018-04-16 19:03:33 +02:00
|
|
|
|
2019-08-27 16:06:41 +02:00
|
|
|
CFLAGS += $(CFLAGS_CPU) $(CFLAGS_DBG) $(CFLAGS_OPT) $(CFLAGS_LINK)
|
|
|
|
ASFLAGS += $(CFLAGS_CPU) $(CFLAGS_DBG)
|
2018-04-16 19:03:33 +02:00
|
|
|
# export linker flags
|
2020-01-02 09:51:20 +01:00
|
|
|
LINKFLAGS += $(CFLAGS_CPU) $(CFLAGS_LINK) $(CFLAGS_DBG) $(CFLAGS_OPT) -Wl,--gc-sections -static -lgcc
|