1# 2# Build targets for a Cortex-M-based processor 3# 4 5# Cortex-M 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-g++ 19TARGET_LD = $(CORTEXM_TOOLS_PREFIX)/bin/arm-none-eabi-g++ 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# Sadly we must disable double promotion warnings due to logging macros. There 36# is a bug for this here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53431 37TARGET_CFLAGS += -Wno-double-promotion 38 39# Cortex-M Shared Object Linker Flags ########################################## 40 41TARGET_SO_LDFLAGS += -shared 42 43# Supported Cortex-M Architectures ############################################# 44 45CORTEXM_SUPPORTED_ARCHS = m4 46 47# Environment Checks ########################################################### 48 49# Ensure that an architecture is chosen. 50ifeq ($(filter $(CORTEXM_ARCH), $(CORTEXM_SUPPORTED_ARCHS)),) 51$(error "The CORTEXM_ARCH argument must be set to a supported architecture (\ 52 $(CORTEXM_SUPPORTED_ARCHS))") 53endif 54 55# Target Architecture ########################################################## 56 57# Set the Cortex-M architecture. 58ifeq ($(CORTEXM_ARCH), m4) 59TARGET_CFLAGS += -mcpu=cortex-m4 60TARGET_CFLAGS += -mfpu=fpv4-sp-d16 61endif 62 63# Optimization Level ########################################################### 64 65TARGET_CFLAGS += -O$(OPT_LEVEL) 66 67# Variant Specific Sources ##################################################### 68 69TARGET_VARIANT_SRCS += $(CORTEXM_SRCS) 70