]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_LM3S102_GCC/makedefs
commit 9f316c246baafa15c542a5aea81a94f26e3d6507
[freertos] / FreeRTOS / Demo / CORTEX_LM3S102_GCC / makedefs
1 #******************************************************************************
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 # The compiler to be used.
29 #
30 #******************************************************************************
31 ifndef COMPILER
32 COMPILER=gcc
33 endif
34
35 #******************************************************************************
36 #
37 # The debugger to be used.
38 #
39 #******************************************************************************
40 ifndef DEBUGGER
41 DEBUGGER=gdb
42 endif
43
44 #******************************************************************************
45 #
46 # Definitions for using GCC.
47 #
48 #******************************************************************************
49 ifeq (${COMPILER}, gcc)
50
51 #
52 # The command for calling the compiler.
53 #
54 CC=arm-none-eabi-gcc
55
56 #
57 # The flags passed to the assembler.
58 #
59 AFLAGS=-mthumb         \
60        -mcpu=cortex-m3 \
61        -MD
62
63 #
64 # The flags passed to the compiler.
65 #
66 CFLAGS=-mthumb         \
67        -mcpu=cortex-m3 \
68        -O2             \
69        -MD
70
71 #
72 # The command for calling the library archiver.
73 #
74 AR=arm-none-eabi-ar
75
76 #
77 # The command for calling the linker.
78 #
79 LD=arm-none-eabi-ld
80
81 #
82 # The flags passed to the linker.
83 #
84 LDFLAGS= -Map gcc/out.map
85
86 #
87 # Get the location of libgcc.a from the GCC front-end.
88 #
89 LIBGCC=${shell ${CC} -mthumb -march=armv6t2 -print-libgcc-file-name}
90
91 #
92 # Get the location of libc.a from the GCC front-end.
93 #
94 LIBC=${shell ${CC} -mthumb -march=armv6t2 -print-file-name=libc.a}
95
96 #
97 # The command for extracting images from the linked executables.
98 #
99 OBJCOPY=arm-none-eabi-objcopy
100
101 endif
102
103 #******************************************************************************
104 #
105 # Tell the compiler to include debugging information if the DEBUG environment
106 # variable is set.
107 #
108 #******************************************************************************
109 ifdef DEBUG
110 CFLAGS += -g
111 endif
112
113 #******************************************************************************
114 #
115 # The rule for building the object file from each C source file.
116 #
117 #******************************************************************************
118 ${COMPILER}/%.o: %.c
119         @if [ 'x${VERBOSE}' = x ];                               \
120          then                                                    \
121              echo "  CC    ${<}";                                \
122          else                                                    \
123              echo ${CC} ${CFLAGS} -D${COMPILER} -o ${@} -c ${<}; \
124          fi
125         @${CC} ${CFLAGS} -D${COMPILER} -o ${@} -c ${<}
126 ifeq (${COMPILER}, rvds)
127         @mv -f ${notdir ${@:.o=.d}} ${COMPILER}
128 endif
129
130 #******************************************************************************
131 #
132 # The rule for building the object file from each assembly source file.
133 #
134 #******************************************************************************
135 ${COMPILER}/%.o: %.S
136         @if [ 'x${VERBOSE}' = x ];                               \
137          then                                                    \
138              echo "  CC    ${<}";                                \
139          else                                                    \
140              echo ${CC} ${AFLAGS} -D${COMPILER} -o ${@} -c ${<}; \
141          fi
142 ifeq (${COMPILER}, rvds)
143         @${CC} ${AFLAGS} -D${COMPILER} -E ${<} > ${@:.o=_.S}
144         @${CC} ${AFLAGS} -o ${@} -c ${@:.o=_.S}
145         @rm ${@:.o=_.S}
146         @${CC} ${AFLAGS} -D${COMPILER} --md -E ${<}
147         @sed 's,<stdout>,${@},g' ${notdir ${<:.S=.d}} > ${@:.o=.d}
148         @rm ${notdir ${<:.S=.d}}
149 endif
150 ifeq (${COMPILER}, gcc)
151         @${CC} ${AFLAGS} -D${COMPILER} -o ${@} -c ${<}
152 endif
153
154 #******************************************************************************
155 #
156 # The rule for creating an object library.
157 #
158 #******************************************************************************
159 ${COMPILER}/%.a:
160         @if [ 'x${VERBOSE}' = x ];     \
161          then                          \
162              echo "  AR    ${@}";      \
163          else                          \
164              echo ${AR} -cr ${@} ${^}; \
165          fi
166         @${AR} -cr ${@} ${^}
167
168 #******************************************************************************
169 #
170 # The rule for linking the application.
171 #
172 #******************************************************************************
173 ${COMPILER}/%.axf:
174         @if [ 'x${VERBOSE}' = x ]; \
175          then                      \
176              echo "  LD    ${@}";  \
177          fi
178 ifeq (${COMPILER}, gcc)
179         @if [ 'x${VERBOSE}' != x ];                           \
180          then                                                 \
181              echo ${LD} -T ${SCATTER_${notdir ${@:.axf=}}}    \
182                         --entry ${ENTRY_${notdir ${@:.axf=}}} \
183                         ${LDFLAGSgcc_${notdir ${@:.axf=}}}    \
184                         ${LDFLAGS} -o ${@} ${^}               \
185                         '${LIBC}' '${LIBGCC}';                \
186          fi
187         @${LD} -T ${SCATTER_${notdir ${@:.axf=}}}    \
188                --entry ${ENTRY_${notdir ${@:.axf=}}} \
189                ${LDFLAGSgcc_${notdir ${@:.axf=}}}    \
190                ${LDFLAGS} -o ${@} ${^}               \
191                '${LIBC}' '${LIBGCC}'
192         @${OBJCOPY} -O binary ${@} ${@:.axf=.bin}
193 endif