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