1# 2# Build targets for a Cortex-M-based processor 3# 4 5# Hexagon Environment Checks ################################################### 6 7# If building for the Cortex-M target, ensure that the user has specified a path 8# to the Cortex-M toolchain that they wish to use. 9ifeq ($(CORTEXM_TOOLS_PREFIX),) 10$(error "You must supply a CORTEXM_TOOLS_PREFIX environment variable \ 11 containing a path to the Cortex-M toolchain. Example: \ 12 export CORTEXM_TOOLS_PREFIX=$$HOME/bin/gcc-arm-none-eabi-5_3-2016q1") 13endif 14 15# Cortex-M Tools ############################################################### 16 17TARGET_AR = $(CORTEXM_TOOLS_PREFIX)/bin/arm-none-eabi-ar 18TARGET_CC = $(CORTEXM_TOOLS_PREFIX)/bin/arm-none-eabi-gcc 19TARGET_LD = $(CORTEXM_TOOLS_PREFIX)/bin/arm-none-eabi-ld 20 21# Cortex-M Compiler Flags ###################################################### 22 23# Add Cortex-M compiler flags. 24TARGET_CFLAGS += $(CORTEXM_CFLAGS) 25 26# TODO: Add more Cortex-M flags from the Nanohub build 27 28# Code generation flags. 29TARGET_CFLAGS += -mthumb 30TARGET_CFLAGS += -mfloat-abi=softfp 31TARGET_CFLAGS += -mno-thumb-interwork 32TARGET_CFLAGS += -ffast-math 33TARGET_CFLAGS += -fsingle-precision-constant 34 35# Cortex-M Shared Object Linker Flags ########################################## 36 37TARGET_SO_LDFLAGS += -shared 38 39# Supported Cortex-M Architectures ############################################# 40 41CORTEXM_SUPPORTED_ARCHS = m4 42 43# Environment Checks ########################################################### 44 45# Ensure that an architecture is chosen. 46ifeq ($(filter $(CORTEXM_ARCH), $(CORTEXM_SUPPORTED_ARCHS)),) 47$(error "The CORTEXM_ARCH argument must be set to a supported architecture (\ 48 $(CORTEXM_SUPPORTED_ARCHS))") 49endif 50 51# Target Architecture ########################################################## 52 53# Set the Cortex-M architecture. 54ifeq ($(CORTEXM_ARCH), m4) 55TARGET_CFLAGS += -mcpu=cortex-m4 56TARGET_CFLAGS += -mfpu=fpv4-sp-d16 57endif 58 59# Optimization Level ########################################################### 60 61TARGET_CFLAGS += -O$(OPT_LEVEL) 62 63# Variant Specific Sources ##################################################### 64 65TARGET_VARIANT_SRCS += $(CORTEXM_SRCS) 66