Newer
Older
build_scripts / config_cortex_m3.mk
@Razvan Turiac Razvan Turiac on 18 May 2023 1 KB ...
TOOLCHAIN_PREFIX = /opt/gcc-arm-none-eabi/bin/arm-none-eabi-
TOOLCHAIN_SUFFIX =

CC = $(TOOLCHAIN_PREFIX)gcc$(TOOLCHAIN_SUFFIX)
GDB = $(TOOLCHAIN_PREFIX)gdb$(TOOLCHAIN_SUFFIX)
SIZE = $(TOOLCHAIN_PREFIX)size$(TOOLCHAIN_SUFFIX)
OBJCOPY = $(TOOLCHAIN_PREFIX)objcopy$(TOOLCHAIN_SUFFIX)
OBJDUMP = $(TOOLCHAIN_PREFIX)objdump$(TOOLCHAIN_SUFFIX)
STRIP = $(TOOLCHAIN_PREFIX)strip$(TOOLCHAIN_SUFFIX)
READELF = $(TOOLCHAIN_PREFIX)readelf$(TOOLCHAIN_SUFFIX)
NM = $(TOOLCHAIN_PREFIX)nm$(TOOLCHAIN_SUFFIX)


#environment variables
ARCH_CFLAGS = -mcpu=cortex-m3 -mthumb -mlittle-endian -mfloat-abi=soft
OPT_CFLAGS = -fdata-sections -ffunction-sections

PLATFORM_CFLAGS = -Wno-unused-parameter -nostdinc -ffreestanding -fno-builtin -fsigned-char -fno-common -Wno-main -I$(shell $(CC) -print-search-dirs | $(AWK) '$$1 == "install:" {print $$NF}')include
PLATFORM_CFLAGS += -DARM_MATH_CM3

PLATFORM_CXXFLAGS = $(PLATFORM_CFLAGS) -fno-rtti -fno-exceptions -fno-use-cxa-atexit
PLATFORM_LDFLAGS = -nostdlib -nostartfiles -nodefaultlibs -Wl,-static,-gc-sections


define CONFIG_TARGETS

ifdef LINK_TARGET

.PHONY: link_target_size

config_final_target: $(BINDIR)/$(TARGET_VER).hex link_target_size $(BINDIR)/$(TARGET).lst $(BINDIR)/$(TARGET)_sym.rep

$(BINDIR)/$(TARGET)_sym.rep: $(BINDIR)/$(LINK_TARGET) | $(BINDIR)/
	$(NM) -t d -S --size-sort $(BINDIR)/$(LINK_TARGET) > $(BINDIR)/$(TARGET)_sym.rep
	@echo
	

$(BINDIR)/$(TARGET).lst: $(BINDIR)/$(LINK_TARGET) | $(BINDIR)/
	$(OBJDUMP) -xds -S -l $(BINDIR)/$(LINK_TARGET) > $(BINDIR)/$(TARGET).lst
	@echo
	

link_target_size: $(BINDIR)/$(LINK_TARGET)
	@$(SIZE) -A -d $(BINDIR)/$(LINK_TARGET)
	@echo


$(BINDIR)/$(TARGET_VER).hex: $(BINDIR)/$(LINK_TARGET) | $(BINDIR)/
	$(OBJCOPY) -O ihex $(BINDIR)/$(LINK_TARGET) $(BINDIR)/$(TARGET_VER).hex
	@echo

endif


endef

include $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/build.mk