1 |
581 |
jeremybenn |
#******************************************************************************
|
2 |
|
|
#
|
3 |
|
|
# makedefs - Definitions common to all makefiles.
|
4 |
|
|
#
|
5 |
|
|
# Copyright (c) 2005,2006 Luminary Micro, Inc. All rights reserved.
|
6 |
|
|
#
|
7 |
|
|
# Software License Agreement
|
8 |
|
|
#
|
9 |
|
|
# Luminary Micro, Inc. (LMI) is supplying this software for use solely and
|
10 |
|
|
# exclusively on LMI's Stellaris Family of microcontroller products.
|
11 |
|
|
#
|
12 |
|
|
# The software is owned by LMI and/or its suppliers, and is protected under
|
13 |
|
|
# applicable copyright laws. All rights are reserved. Any use in violation
|
14 |
|
|
# of the foregoing restrictions may subject the user to criminal sanctions
|
15 |
|
|
# under applicable laws, as well as to civil liability for the breach of the
|
16 |
|
|
# terms and conditions of this license.
|
17 |
|
|
#
|
18 |
|
|
# THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
|
19 |
|
|
# OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
|
20 |
|
|
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
|
21 |
|
|
# LMI SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
|
22 |
|
|
# CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
|
23 |
|
|
#
|
24 |
|
|
#******************************************************************************
|
25 |
|
|
|
26 |
|
|
#******************************************************************************
|
27 |
|
|
#
|
28 |
|
|
# Get the operating system name. If this is Cygwin, the .d files will be
|
29 |
|
|
# munged to convert c: into /cygdrive/c so that "make" will be happy with the
|
30 |
|
|
# auto-generated dependencies.
|
31 |
|
|
#
|
32 |
|
|
#******************************************************************************
|
33 |
|
|
os:=${shell uname -s}
|
34 |
|
|
|
35 |
|
|
#******************************************************************************
|
36 |
|
|
#
|
37 |
|
|
# The compiler to be used.
|
38 |
|
|
#
|
39 |
|
|
#******************************************************************************
|
40 |
|
|
ifndef COMPILER
|
41 |
|
|
COMPILER=gcc
|
42 |
|
|
endif
|
43 |
|
|
|
44 |
|
|
#******************************************************************************
|
45 |
|
|
#
|
46 |
|
|
# The debugger to be used.
|
47 |
|
|
#
|
48 |
|
|
#******************************************************************************
|
49 |
|
|
ifndef DEBUGGER
|
50 |
|
|
DEBUGGER=gdb
|
51 |
|
|
endif
|
52 |
|
|
|
53 |
|
|
#******************************************************************************
|
54 |
|
|
#
|
55 |
|
|
# Definitions for using GCC.
|
56 |
|
|
#
|
57 |
|
|
#******************************************************************************
|
58 |
|
|
ifeq (${COMPILER}, gcc)
|
59 |
|
|
|
60 |
|
|
#
|
61 |
|
|
# The command for calling the compiler.
|
62 |
|
|
#
|
63 |
|
|
CC=arm-none-eabi-gcc
|
64 |
|
|
|
65 |
|
|
#
|
66 |
|
|
# The flags passed to the assembler.
|
67 |
|
|
#
|
68 |
|
|
AFLAGS=-mthumb \
|
69 |
|
|
-mcpu=cortex-m3 \
|
70 |
|
|
-MD
|
71 |
|
|
|
72 |
|
|
#
|
73 |
|
|
# The flags passed to the compiler.
|
74 |
|
|
#
|
75 |
|
|
CFLAGS=-mthumb \
|
76 |
|
|
-mcpu=cortex-m3 \
|
77 |
|
|
-O2 \
|
78 |
|
|
-MD
|
79 |
|
|
|
80 |
|
|
#
|
81 |
|
|
# The command for calling the library archiver.
|
82 |
|
|
#
|
83 |
|
|
AR=arm-none-eabi-ar
|
84 |
|
|
|
85 |
|
|
#
|
86 |
|
|
# The command for calling the linker.
|
87 |
|
|
#
|
88 |
|
|
LD=arm-none-eabi-ld
|
89 |
|
|
|
90 |
|
|
#
|
91 |
|
|
# The flags passed to the linker.
|
92 |
|
|
#
|
93 |
|
|
LDFLAGS= -Map gcc/out.map
|
94 |
|
|
|
95 |
|
|
#
|
96 |
|
|
# Get the location of libgcc.a from the GCC front-end.
|
97 |
|
|
#
|
98 |
|
|
LIBGCC=${shell ${CC} -mthumb -march=armv6t2 -print-libgcc-file-name}
|
99 |
|
|
|
100 |
|
|
#
|
101 |
|
|
# Get the location of libc.a from the GCC front-end.
|
102 |
|
|
#
|
103 |
|
|
LIBC=${shell ${CC} -mthumb -march=armv6t2 -print-file-name=libc.a}
|
104 |
|
|
|
105 |
|
|
#
|
106 |
|
|
# The command for extracting images from the linked executables.
|
107 |
|
|
#
|
108 |
|
|
OBJCOPY=arm-none-eabi-objcopy
|
109 |
|
|
|
110 |
|
|
endif
|
111 |
|
|
|
112 |
|
|
#******************************************************************************
|
113 |
|
|
#
|
114 |
|
|
# Tell the compiler to include debugging information if the DEBUG environment
|
115 |
|
|
# variable is set.
|
116 |
|
|
#
|
117 |
|
|
#******************************************************************************
|
118 |
|
|
ifdef DEBUG
|
119 |
|
|
CFLAGS += -g
|
120 |
|
|
endif
|
121 |
|
|
|
122 |
|
|
#******************************************************************************
|
123 |
|
|
#
|
124 |
|
|
# The rule for building the object file from each C source file.
|
125 |
|
|
#
|
126 |
|
|
#******************************************************************************
|
127 |
|
|
${COMPILER}/%.o: %.c
|
128 |
|
|
@if [ 'x${VERBOSE}' = x ]; \
|
129 |
|
|
then \
|
130 |
|
|
echo " CC ${<}"; \
|
131 |
|
|
else \
|
132 |
|
|
echo ${CC} ${CFLAGS} -D${COMPILER} -o ${@} -c ${<}; \
|
133 |
|
|
fi
|
134 |
|
|
@${CC} ${CFLAGS} -D${COMPILER} -o ${@} -c ${<}
|
135 |
|
|
ifeq (${COMPILER}, rvds)
|
136 |
|
|
@mv -f ${notdir ${@:.o=.d}} ${COMPILER}
|
137 |
|
|
endif
|
138 |
|
|
ifneq ($(findstring CYGWIN, ${os}), )
|
139 |
|
|
@perl -i.bak -p -e 's/[Cc]:/\/cygdrive\/c/g' ${@:.o=.d}
|
140 |
|
|
endif
|
141 |
|
|
|
142 |
|
|
#******************************************************************************
|
143 |
|
|
#
|
144 |
|
|
# The rule for building the object file from each assembly source file.
|
145 |
|
|
#
|
146 |
|
|
#******************************************************************************
|
147 |
|
|
${COMPILER}/%.o: %.S
|
148 |
|
|
@if [ 'x${VERBOSE}' = x ]; \
|
149 |
|
|
then \
|
150 |
|
|
echo " CC ${<}"; \
|
151 |
|
|
else \
|
152 |
|
|
echo ${CC} ${AFLAGS} -D${COMPILER} -o ${@} -c ${<}; \
|
153 |
|
|
fi
|
154 |
|
|
ifeq (${COMPILER}, rvds)
|
155 |
|
|
@${CC} ${AFLAGS} -D${COMPILER} -E ${<} > ${@:.o=_.S}
|
156 |
|
|
@${CC} ${AFLAGS} -o ${@} -c ${@:.o=_.S}
|
157 |
|
|
@rm ${@:.o=_.S}
|
158 |
|
|
@${CC} ${AFLAGS} -D${COMPILER} --md -E ${<}
|
159 |
|
|
@sed 's,,${@},g' ${notdir ${<:.S=.d}} > ${@:.o=.d}
|
160 |
|
|
@rm ${notdir ${<:.S=.d}}
|
161 |
|
|
endif
|
162 |
|
|
ifeq (${COMPILER}, gcc)
|
163 |
|
|
@${CC} ${AFLAGS} -D${COMPILER} -o ${@} -c ${<}
|
164 |
|
|
endif
|
165 |
|
|
ifneq ($(findstring CYGWIN, ${os}), )
|
166 |
|
|
@perl -i.bak -p -e 's/[Cc]:/\/cygdrive\/c/g' ${@:.o=.d}
|
167 |
|
|
endif
|
168 |
|
|
|
169 |
|
|
#******************************************************************************
|
170 |
|
|
#
|
171 |
|
|
# The rule for creating an object library.
|
172 |
|
|
#
|
173 |
|
|
#******************************************************************************
|
174 |
|
|
${COMPILER}/%.a:
|
175 |
|
|
@if [ 'x${VERBOSE}' = x ]; \
|
176 |
|
|
then \
|
177 |
|
|
echo " AR ${@}"; \
|
178 |
|
|
else \
|
179 |
|
|
echo ${AR} -cr ${@} ${^}; \
|
180 |
|
|
fi
|
181 |
|
|
@${AR} -cr ${@} ${^}
|
182 |
|
|
|
183 |
|
|
#******************************************************************************
|
184 |
|
|
#
|
185 |
|
|
# The rule for linking the application.
|
186 |
|
|
#
|
187 |
|
|
#******************************************************************************
|
188 |
|
|
${COMPILER}/%.axf:
|
189 |
|
|
@if [ 'x${VERBOSE}' = x ]; \
|
190 |
|
|
then \
|
191 |
|
|
echo " LD ${@}"; \
|
192 |
|
|
fi
|
193 |
|
|
ifeq (${COMPILER}, gcc)
|
194 |
|
|
@if [ 'x${VERBOSE}' != x ]; \
|
195 |
|
|
then \
|
196 |
|
|
echo ${LD} -T ${SCATTER_${notdir ${@:.axf=}}} \
|
197 |
|
|
--entry ${ENTRY_${notdir ${@:.axf=}}} \
|
198 |
|
|
${LDFLAGSgcc_${notdir ${@:.axf=}}} \
|
199 |
|
|
${LDFLAGS} -o ${@} ${^} \
|
200 |
|
|
'${LIBC}' '${LIBGCC}'; \
|
201 |
|
|
fi
|
202 |
|
|
@${LD} -T ${SCATTER_${notdir ${@:.axf=}}} \
|
203 |
|
|
--entry ${ENTRY_${notdir ${@:.axf=}}} \
|
204 |
|
|
${LDFLAGSgcc_${notdir ${@:.axf=}}} \
|
205 |
|
|
${LDFLAGS} -o ${@} ${^} \
|
206 |
|
|
'${LIBC}' '${LIBGCC}'
|
207 |
|
|
@${OBJCOPY} -O binary ${@} ${@:.axf=.bin}
|
208 |
|
|
endif
|