xref: /btstack/port/msp432p401lp-cc256x/Makefile.defs (revision 9a7ee89c0937a377b7a18eb15b435385fd4ddf72)
1f7529f1dSMatthias Ringwald#******************************************************************************
2f7529f1dSMatthias Ringwald#
3f7529f1dSMatthias Ringwald# Get the operating system name.  If this is Cygwin, the .d files will be
4f7529f1dSMatthias Ringwald# munged to convert c: into /cygdrive/c so that "make" will be happy with the
5f7529f1dSMatthias Ringwald# auto-generated dependencies.
6f7529f1dSMatthias Ringwald#
7f7529f1dSMatthias Ringwald#******************************************************************************
8f7529f1dSMatthias Ringwaldos:=${shell uname -s}
9f7529f1dSMatthias Ringwald
10f7529f1dSMatthias Ringwald#******************************************************************************
11f7529f1dSMatthias Ringwald#
12f7529f1dSMatthias Ringwald# The compiler to be used.
13f7529f1dSMatthias Ringwald#
14f7529f1dSMatthias Ringwald#******************************************************************************
15f7529f1dSMatthias Ringwaldifndef COMPILER
16f7529f1dSMatthias RingwaldCOMPILER=gcc
17f7529f1dSMatthias Ringwaldendif
18f7529f1dSMatthias Ringwald
19f7529f1dSMatthias Ringwald#******************************************************************************
20f7529f1dSMatthias Ringwald#
21f7529f1dSMatthias Ringwald# Definitions for using GCC.
22f7529f1dSMatthias Ringwald#
23f7529f1dSMatthias Ringwald#******************************************************************************
24f7529f1dSMatthias Ringwaldifeq (${COMPILER}, gcc)
25f7529f1dSMatthias Ringwald
26f7529f1dSMatthias Ringwald#
27f7529f1dSMatthias Ringwald# The command for calling the compiler.
28f7529f1dSMatthias Ringwald#
29f7529f1dSMatthias RingwaldCC=arm-none-eabi-gcc
30f7529f1dSMatthias Ringwald
31f7529f1dSMatthias Ringwald#
32f7529f1dSMatthias Ringwald# The location of the C compiler
33f7529f1dSMatthias Ringwald# ARMGCC_ROOT is used by some makefiles that need to know where the compiler
34f7529f1dSMatthias Ringwald# is installed.
35f7529f1dSMatthias Ringwald#
36f7529f1dSMatthias RingwaldARMGCC_ROOT:=${shell dirname '${shell sh -c "which ${CC}"}'}/..
37f7529f1dSMatthias Ringwald
38f7529f1dSMatthias Ringwald#
39f7529f1dSMatthias Ringwald# Set the compiler CPU/FPU options.
40f7529f1dSMatthias Ringwald#
41f7529f1dSMatthias RingwaldCPU=-mcpu=cortex-m4
42f7529f1dSMatthias RingwaldFPU=-mfpu=fpv4-sp-d16 -mfloat-abi=hard
43f7529f1dSMatthias Ringwald
44f7529f1dSMatthias Ringwald#
45f7529f1dSMatthias Ringwald# The flags passed to the assembler.
46f7529f1dSMatthias Ringwald#
47f7529f1dSMatthias RingwaldAFLAGS=-mthumb \
48f7529f1dSMatthias Ringwald       ${CPU}  \
49f7529f1dSMatthias Ringwald       ${FPU}  \
50f7529f1dSMatthias Ringwald       -MD
51f7529f1dSMatthias Ringwald
52f7529f1dSMatthias Ringwald#
53f7529f1dSMatthias Ringwald# The flags passed to the compiler.
54f7529f1dSMatthias Ringwald#
55f7529f1dSMatthias RingwaldCFLAGS=-mthumb             \
56f7529f1dSMatthias Ringwald       ${CPU}              \
57f7529f1dSMatthias Ringwald       ${FPU}              \
58f7529f1dSMatthias Ringwald       -ffunction-sections \
59f7529f1dSMatthias Ringwald       -fdata-sections     \
60f7529f1dSMatthias Ringwald       -MD                 \
61f7529f1dSMatthias Ringwald       -std=c99            \
62f7529f1dSMatthias Ringwald       -Dgcc               \
63f7529f1dSMatthias Ringwald       -D${PART}           \
64e2cc5349SMatthias Ringwald       -specs=nano.specs   \
65f7529f1dSMatthias Ringwald       -c
66f7529f1dSMatthias Ringwald
67f7529f1dSMatthias Ringwald#
68f7529f1dSMatthias Ringwald# The command for calling the library archiver.
69f7529f1dSMatthias Ringwald#
70f7529f1dSMatthias RingwaldAR=arm-none-eabi-ar
71f7529f1dSMatthias Ringwald
72f7529f1dSMatthias Ringwald#
73f7529f1dSMatthias Ringwald# The command for calling the linker.
74f7529f1dSMatthias Ringwald#
75f7529f1dSMatthias RingwaldLD=arm-none-eabi-ld
76f7529f1dSMatthias Ringwald
77f7529f1dSMatthias Ringwald#
78f7529f1dSMatthias Ringwald# The flags passed to the linker.
79f7529f1dSMatthias Ringwald#
80f7529f1dSMatthias RingwaldLDFLAGS= --gc-sections
81f7529f1dSMatthias Ringwald
82f7529f1dSMatthias Ringwald#
83f7529f1dSMatthias Ringwald# The command for extracting images from the linked executables.
84f7529f1dSMatthias Ringwald#
85f7529f1dSMatthias RingwaldOBJCOPY=arm-none-eabi-objcopy
86f7529f1dSMatthias Ringwald
87f7529f1dSMatthias Ringwald#
88f7529f1dSMatthias Ringwald# Tell the compiler to include debugging information if the DEBUG environment
89f7529f1dSMatthias Ringwald# variable is set.
90f7529f1dSMatthias Ringwald#
91*9a7ee89cSMatthias Ringwald# ifdef DEBUG
92*9a7ee89cSMatthias Ringwald# CFLAGS+=-g -D DEBUG -O0
93*9a7ee89cSMatthias Ringwald# else
94*9a7ee89cSMatthias Ringwald# CFLAGS+=-Os
95*9a7ee89cSMatthias Ringwald# endif
96*9a7ee89cSMatthias RingwaldCFLAGS+=-g -Os
97f7529f1dSMatthias Ringwald
98f7529f1dSMatthias Ringwald#
99f7529f1dSMatthias Ringwald# Add the tool specific CFLAGS.
100f7529f1dSMatthias Ringwald#
101f7529f1dSMatthias RingwaldCFLAGS+=${CFLAGSgcc}
102f7529f1dSMatthias Ringwald
103f7529f1dSMatthias Ringwald#
104f7529f1dSMatthias Ringwald# Add the include file paths to AFLAGS and CFLAGS.
105f7529f1dSMatthias Ringwald#
106f7529f1dSMatthias RingwaldAFLAGS+=${patsubst %,-I%,${subst :, ,${IPATH}}}
107f7529f1dSMatthias RingwaldCFLAGS+=${patsubst %,-I%,${subst :, ,${IPATH}}}
108f7529f1dSMatthias Ringwald
109f7529f1dSMatthias Ringwald#
110f7529f1dSMatthias Ringwald# The rule for building the object file from each C source file.
111f7529f1dSMatthias Ringwald#
112f7529f1dSMatthias Ringwald${COMPILER}${SUFFIX}/%.o: %.c
113f7529f1dSMatthias Ringwald	@if [ 'x${VERBOSE}' = x ];                            \
114f7529f1dSMatthias Ringwald	 then                                                 \
115f7529f1dSMatthias Ringwald	     echo "  CC          ${<}";                             \
116f7529f1dSMatthias Ringwald	 else                                                 \
117f7529f1dSMatthias Ringwald	     echo ${CC} ${CFLAGS} -D${COMPILER} -o ${@} ${<}; \
118f7529f1dSMatthias Ringwald	 fi
119f7529f1dSMatthias Ringwald	@${CC} ${CFLAGS} -D${COMPILER} -o ${@} ${<}
120f7529f1dSMatthias Ringwaldifneq ($(findstring CYGWIN, ${os}), )
121f7529f1dSMatthias Ringwald	@sed -i -r 's/ ([A-Za-z]):/ \/cygdrive\/\1/g' ${@:.o=.d}
122f7529f1dSMatthias Ringwaldendif
123f7529f1dSMatthias Ringwald
124f7529f1dSMatthias Ringwald#
125f7529f1dSMatthias Ringwald# The rule for building the object file from each assembly source file.
126f7529f1dSMatthias Ringwald#
127f7529f1dSMatthias Ringwald${COMPILER}${SUFFIX}/%.o: %.S
128f7529f1dSMatthias Ringwald	@if [ 'x${VERBOSE}' = x ];                               \
129f7529f1dSMatthias Ringwald	 then                                                    \
130f7529f1dSMatthias Ringwald	     echo "  AS          ${<}";                                \
131f7529f1dSMatthias Ringwald	 else                                                    \
132f7529f1dSMatthias Ringwald	     echo ${CC} ${AFLAGS} -D${COMPILER} -o ${@} -c ${<}; \
133f7529f1dSMatthias Ringwald	 fi
134f7529f1dSMatthias Ringwald	@${CC} ${AFLAGS} -D${COMPILER} -o ${@} -c ${<}
135f7529f1dSMatthias Ringwaldifneq ($(findstring CYGWIN, ${os}), )
136f7529f1dSMatthias Ringwald	@sed -i -r 's/ ([A-Za-z]):/ \/cygdrive\/\1/g' ${@:.o=.d}
137f7529f1dSMatthias Ringwaldendif
138f7529f1dSMatthias Ringwald
139f7529f1dSMatthias Ringwald#
140f7529f1dSMatthias Ringwald# The rule for creating an object library.
141f7529f1dSMatthias Ringwald#
142f7529f1dSMatthias Ringwald${COMPILER}${SUFFIX}/%.a:
143f7529f1dSMatthias Ringwald	@if [ 'x${VERBOSE}' = x ];     \
144f7529f1dSMatthias Ringwald	 then                          \
145f7529f1dSMatthias Ringwald	     echo "  AR          ${@}";      \
146f7529f1dSMatthias Ringwald	 else                          \
147f7529f1dSMatthias Ringwald	     echo ${AR} -cr ${@} ${^}; \
148f7529f1dSMatthias Ringwald	 fi
149f7529f1dSMatthias Ringwald	@${AR} -cr ${@} ${^}
150f7529f1dSMatthias Ringwald
151f7529f1dSMatthias Ringwaldendif
152f7529f1dSMatthias Ringwald
153