• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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# Code generation flags.
27TARGET_CFLAGS += -mthumb
28TARGET_CFLAGS += -mfloat-abi=softfp
29TARGET_CFLAGS += -mno-thumb-interwork
30TARGET_CFLAGS += -ffast-math
31TARGET_CFLAGS += -fsingle-precision-constant
32
33# Sadly we must disable double promotion warnings due to logging macros. There
34# is a bug for this here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53431
35TARGET_CFLAGS += -Wno-double-promotion
36
37# Cortex-M Shared Object Linker Flags ##########################################
38
39TARGET_SO_LDFLAGS += -shared
40
41# Supported Cortex-M Architectures #############################################
42
43CORTEXM_SUPPORTED_ARCHS = m4
44
45# Environment Checks ###########################################################
46
47# Ensure that an architecture is chosen.
48ifeq ($(filter $(CORTEXM_ARCH), $(CORTEXM_SUPPORTED_ARCHS)),)
49$(error "The CORTEXM_ARCH argument must be set to a supported architecture (\
50         $(CORTEXM_SUPPORTED_ARCHS))")
51endif
52
53# Target Architecture ##########################################################
54
55# Set the Cortex-M architecture.
56ifeq ($(CORTEXM_ARCH), m4)
57TARGET_CFLAGS += -mcpu=cortex-m4
58TARGET_CFLAGS += -mfpu=fpv4-sp-d16
59endif
60
61# Optimization Level ###########################################################
62
63TARGET_CFLAGS += -O$(OPT_LEVEL)
64
65# Variant Specific Sources #####################################################
66
67TARGET_VARIANT_SRCS += $(CORTEXM_SRCS)
68