1 | ## |
---|
2 | ## $Id$ |
---|
3 | ## |
---|
4 | |
---|
5 | ## ------------------------------------------------------------------------- |
---|
6 | ## NOTE: This file is rather immature and has to be considered to be |
---|
7 | ## almost experimental. |
---|
8 | ## |
---|
9 | ## Expect frequent changes -- It deserves to be cleaned up :( |
---|
10 | ## ------------------------------------------------------------------------- |
---|
11 | |
---|
12 | ## The section below is based on make/compilers/gcc-target-default.cfg |
---|
13 | ## used in former versions of RTEMS. |
---|
14 | |
---|
15 | ## |
---|
16 | ## Set up the flags for the toolchains: |
---|
17 | ## |
---|
18 | ## We are considering 3 different building schemes here: |
---|
19 | ## * Using gcc's being able to accept -specs (aka gcc-2.8 building scheme) |
---|
20 | ## * Using gcc's not being able to accept -specs (aka gcc-2.7.2 building |
---|
21 | ## scheme) |
---|
22 | ## * Using third party toolchains (aka non-gcc building scheme) |
---|
23 | ## |
---|
24 | ## Automake conditionals in use: |
---|
25 | ## RTEMS_USE_GCC .. if we are using GCC |
---|
26 | ## RTEMS_USE_GCC272 .. if using gcc and if requested not to apply |
---|
27 | ## gcc <= 2.7.2 incompatible rules |
---|
28 | |
---|
29 | ## NOTES: |
---|
30 | ## * The gcc-2.8 building scheme is the nominal building scheme and |
---|
31 | ## is actively supported. |
---|
32 | ## * The gcc-2.7.2 building scheme is not supported by all BSPs and |
---|
33 | ## is not extensively tested. |
---|
34 | ## * The non-gcc building scheme requires manually setting up environment |
---|
35 | ## variables and is hardly tested at all |
---|
36 | |
---|
37 | ## CFLAGS_OPTIMIZE_V, CFLAGS_DEBUG_V, CFLAGS_PROFILE_V are the values we |
---|
38 | ## would want the corresponding macros to be set to. |
---|
39 | ## |
---|
40 | ## CFLAGS_OPTIMIZE, CFLAGS_DEBUG, CFLAGS_PROFILE are set by the |
---|
41 | ## 'VARIANT=<OPTIMIZE|DEBUG|PROFILE>' targets to their _V values. |
---|
42 | |
---|
43 | ## XCPPFLAGS, XCFLAGS, XCXXFLAGS, XASFLAGS |
---|
44 | ## are used to add flags from the shell |
---|
45 | ## cf. make.info ("Implicit rules/variables" for details) |
---|
46 | |
---|
47 | if RTEMS_USE_GCC |
---|
48 | ## All the stuff below is specific to gcc |
---|
49 | |
---|
50 | CFLAGS_DEFAULT=-g -Wall |
---|
51 | |
---|
52 | if RTEMS_USE_GCC272 |
---|
53 | ## gcc <= 2.7.2 |
---|
54 | RTEMS_CPPFLAGS = -isystem $(PROJECT_INCLUDE) |
---|
55 | |
---|
56 | # default location of Standard C Library |
---|
57 | LIBC_LIBC = `$(CC) $(CPU_CFLAGS) -print-file-name=libc.a $(GCCSED)` |
---|
58 | LIBC_LIBM = `$(CC) $(CPU_CFLAGS) -print-file-name=libm.a $(GCCSED)` |
---|
59 | LIBC_LIBGCC = `$(CC) $(CPU_CFLAGS) -print-libgcc-file-name $(GCCSED)` |
---|
60 | |
---|
61 | ### FIXME: False if using multilibbed RTEMS |
---|
62 | LINK_LIBS_RTEMS = $(PROJECT_RELEASE)/lib/librtemsall$(LIBSUFFIX_VA) |
---|
63 | |
---|
64 | LINK_LIBS_GCC272 = $(LINK_LIBS_RTEMS) $(LIBC_LIBC) $(LIBC_LIBGCC) |
---|
65 | GCCSPECS = |
---|
66 | else |
---|
67 | ## gcc >= 2.8.x |
---|
68 | GCCSPECS = $(GCC_SPECS) $(RTEMS_BSP_SPECS) |
---|
69 | endif |
---|
70 | else |
---|
71 | ## fall back to the old style compilers/*.cfg |
---|
72 | ## CONFIG.CC is supposed to be provided by <BSP>.cfg |
---|
73 | include $(CONFIG.CC) |
---|
74 | endif # RTEMS_USE_GCC |
---|
75 | |
---|
76 | DEFS = @DEFS@ |
---|
77 | |
---|
78 | CPPFLAGS = @CPPFLAGS@ $(CPU_DEFINES) \ |
---|
79 | $(DEFINES) $(XCPPFLAGS) $(CPPFLAGS_GCC) |
---|
80 | CFLAGS = $(CFLAGS_DEFAULT) $(CPU_CFLAGS) $(XCFLAGS) |
---|
81 | CXXFLAGS = $(CFLAGS_DEFAULT) $(CPU_CFLAGS) $(XCXXFLAGS) |
---|
82 | ASFLAGS = $(CPU_ASFLAGS) $(CPU_CFLAGS) $(XASFLAGS) |
---|
83 | |
---|
84 | LINK_LIBS = $(LINK_LIBS_GCC272) $(LD_LIBS) |
---|
85 | |
---|
86 | ## FIXME: This doesn't seem to be correct |
---|
87 | # when debugging, optimize flag: typically empty |
---|
88 | # some compilers do allow optimization with their "-g" |
---|
89 | CFLAGS_DEBUG_OPTIMIZE_V=-g |
---|
90 | CXXFLAGS_DEBUG_OPTIMIZE_V=-g |
---|
91 | LDFLAGS_DEBUG_V = |
---|
92 | |
---|
93 | # profile flag; use gprof(1) |
---|
94 | CFLAGS_PROFILE_V=-pg |
---|
95 | CXXFLAGS_PROFILE_V=-pg |
---|
96 | LDFLAGS_PROFILE_V = |
---|
97 | |
---|
98 | # List of library paths without -L |
---|
99 | LD_PATHS= $(PROJECT_RELEASE)/lib |
---|
100 | |
---|
101 | # ld flag for incomplete link |
---|
102 | LDFLAGS_INCOMPLETE = -r |
---|
103 | |
---|
104 | # ld flags for profiling, debugging |
---|
105 | LDFLAGS=$(LDFLAGS_PROFILE) $(LDFLAGS_DEBUG) $(LD_PATHS:%=-L %) |
---|
106 | |
---|
107 | # |
---|
108 | # Client compiler and support tools |
---|
109 | # |
---|
110 | |
---|
111 | # |
---|
112 | # How to compile stuff into ${ARCH} subdirectory |
---|
113 | # |
---|
114 | |
---|
115 | COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ |
---|
116 | $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) |
---|
117 | CCLD = $(CC) |
---|
118 | LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ |
---|
119 | $(AM_LDFLAGS) $(LDFLAGS) -o $@ |
---|
120 | |
---|
121 | CXXLD = $(CXX) |
---|
122 | CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ |
---|
123 | $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) |
---|
124 | CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) \ |
---|
125 | $(AM_LDFLAGS) $(LDFLAGS) -o $@ |
---|
126 | |
---|
127 | AS = $(CC) |
---|
128 | ASCOMPILE = $(AS) $(AM_ASFLAGS) $(ASFLAGS) -o $@ |
---|
129 | |
---|
130 | ${ARCH}/%.o: %.c |
---|
131 | ${COMPILE} -o $@ -c $< |
---|
132 | |
---|
133 | ${ARCH}/%.o: %.cc |
---|
134 | ${CXXCOMPILE} -o $@ -c $< |
---|
135 | |
---|
136 | ${ARCH}/%.o: %.cpp |
---|
137 | ${CXXCOMPILE} -o $@ -c $< |
---|
138 | |
---|
139 | ${ARCH}/%.o: %.cxx |
---|
140 | ${CXXCOMPILE} -o $@ -c $< |
---|
141 | |
---|
142 | ${ARCH}/%.o: %.C |
---|
143 | ${CXXCOMPILE} -o $@ -c $< |
---|
144 | |
---|
145 | ${ARCH}/%.o: %.S |
---|
146 | ${ASCOMPILE} -DASM -c $< |
---|
147 | |
---|
148 | # Make foo.rel from foo.o |
---|
149 | ${ARCH}/%.rel: ${ARCH}/%.o |
---|
150 | ${make-rel} |
---|
151 | |
---|
152 | # create $(ARCH)/pgm from pgm.sh |
---|
153 | ${ARCH}/%: %.sh |
---|
154 | $(RM) $@ |
---|
155 | $(CP) $< $@ |
---|
156 | $(CHMOD) +x $@ |
---|
157 | |
---|
158 | # Dependency files for use by gmake |
---|
159 | # NOTE: we don't put them into $(ARCH) |
---|
160 | # so that 'make clean' doesn't blow it away |
---|
161 | |
---|
162 | DEPEND=Depends-${ARCH} |
---|
163 | |
---|
164 | CLEAN_DEPEND=$(DEPEND).tmp |
---|
165 | CLOBBER_DEPEND=$(DEPEND) |
---|
166 | |
---|
167 | # We deliberately don't have anything depend on the |
---|
168 | # $(DEPEND) file; otherwise it will get rebuilt even |
---|
169 | # on 'make clean' |
---|
170 | # |
---|
171 | |
---|
172 | ## HACK: Specific to gcc |
---|
173 | ## FIXME: The approach below is known to be conceptionally broken. |
---|
174 | depend-am: $(C_FILES) $(CC_FILES) $(S_FILES) |
---|
175 | ## Use gcc -M to generate dependencies |
---|
176 | ## Replace foo.o with $(ARCH)/foo.o |
---|
177 | ## Replace $(ARCH) value with string $(ARCH) |
---|
178 | ## so that it will for debug and profile cases |
---|
179 | $(COMPILE) $(AM_CPPFLAGS) $(AM_CFLAGS) -M $^ | \ |
---|
180 | sed -e 's?^\(.*\)\.o[ ]*:?$$(ARCH)/\1.o:?' \ |
---|
181 | -e 's?$(ARCH)/?$$(ARCH)/?' >$(DEPEND).tmp |
---|
182 | mv $(DEPEND).tmp $(DEPEND) |
---|
183 | depend: depend-am |
---|
184 | |
---|
185 | # pull in dependencies if they exist |
---|
186 | ifeq (${DEPEND},$(wildcard ${DEPEND})) |
---|
187 | include ${DEPEND} |
---|
188 | @ENDIF@ |
---|
189 | |
---|
190 | |
---|
191 | # spell out all the LINK_FILE's, rather than using -lbsp, so |
---|
192 | # that $(LINK_FILES) can be a dependency |
---|
193 | |
---|
194 | LINK_OBJS = \ |
---|
195 | $(OBJS) \ |
---|
196 | $(MANAGERS_NOT_WANTED:%=$(PROJECT_RELEASE)/lib/no-%$(LIB_VARIANT).rel) |
---|
197 | |
---|
198 | LINK_FILES =\ |
---|
199 | $(START_FILE) \ |
---|
200 | $(OBJS) \ |
---|
201 | $(MANAGERS_NOT_WANTED:%=$(PROJECT_RELEASE)/lib/no-%$(LIB_VARIANT).rel) \ |
---|
202 | $(PROJECT_RELEASE)/lib/librtemsall$(LIBSUFFIX_VA) |
---|
203 | |
---|
204 | if RTEMS_USE_GCC |
---|
205 | if RTEMS_USE_GCC272 |
---|
206 | define make-rel |
---|
207 | $(LINK) -nostdlib -Wl,-r $(XLDFLAGS) -o $@ $^ |
---|
208 | endef |
---|
209 | else |
---|
210 | ## gcc >= 2.8 |
---|
211 | define make-rel |
---|
212 | $(LINK) -qnolinkcmds -nostdlib -Wl,-r $(XLDFLAGS) $^ |
---|
213 | endef |
---|
214 | endif |
---|
215 | else |
---|
216 | ## non-gcc |
---|
217 | define make-rel |
---|
218 | $(LINK) $(XLDFLAGS) $^ |
---|
219 | endef |
---|
220 | endif |
---|
221 | |
---|
222 | ## ------------------------------------------------------------------------- |
---|
223 | |
---|
224 | ## translate VARIANT into VARIANT_V |
---|
225 | VARIANT = OPTIMIZE |
---|
226 | |
---|
227 | VARIANT_OPTIMIZE_V = OPTIMIZE |
---|
228 | VARIANT_DEBUG_V = DEBUG |
---|
229 | VARIANT_PROFILE_V = PROFILE |
---|
230 | VARIANT_optimize_V = OPTIMIZE |
---|
231 | VARIANT_debug_V = DEBUG |
---|
232 | VARIANT_profile_V = PROFILE |
---|
233 | |
---|
234 | VARIANT_V = $(VARIANT_$(VARIANT)_V) |
---|
235 | |
---|
236 | ## Setup the variant build subdirectory |
---|
237 | ARCH_OPTIMIZE_V = o-optimize |
---|
238 | ARCH_DEBUG_V = o-debug |
---|
239 | ARCH_PROFILE_V = o-profile |
---|
240 | |
---|
241 | ARCH__V = $(ARCH_OPTIMIZE_V) |
---|
242 | ARCH = $(ARCH_$(VARIANT_V)_V) |
---|
243 | |
---|
244 | ## Setup the library suffix |
---|
245 | LIBSUFFIX_OPTIMIZE_V = |
---|
246 | LIBSUFFIX_DEBUG_V = _g |
---|
247 | LIBSUFFIX_PROFILE_V = _p |
---|
248 | LIBSUFFIX__V = $(LIBSUFFIX_OPTIMIZE_V) |
---|
249 | |
---|
250 | LIB_VARIANT = $(LIBSUFFIX_$(VARIANT_V)_V) |
---|
251 | LIBSUFFIX_VA = $(LIB_VARIANT).a |
---|
252 | |
---|
253 | ## These are supposed to be set in make/custom/<bsp>.cfg |
---|
254 | ## CFLAGS_OPTIMIZE_V = |
---|
255 | ## CFLAGS_DEBUG_V = |
---|
256 | ## CFLAGS_PROFILE_V = |
---|
257 | CFLAGS__V = $(CFLAGS_OPTIMIZE_V) |
---|
258 | |
---|
259 | ## ------------------------------------------------------------------------ |
---|
260 | ## Setup hard-coded flags |
---|
261 | if RTEMS_USE_GCC |
---|
262 | if RTEMS_USE_GCC272 |
---|
263 | ## gcc < gcc-2.8 |
---|
264 | RTEMS_CFLAGS_OPTIMIZE_V = |
---|
265 | RTEMS_CFLAGS_DEBUG_V = -Wno-unused |
---|
266 | RTEMS_CFLAGS_PROFILE_V = |
---|
267 | else |
---|
268 | ## gcc >= gcc-2.8 |
---|
269 | RTEMS_CFLAGS_OPTIMIZE_V = |
---|
270 | RTEMS_CFLAGS_DEBUG_V = -qrtems_debug -Wno-unused |
---|
271 | RTEMS_CFLAGS_PROFILE_V = |
---|
272 | endif |
---|
273 | ## non-gcc |
---|
274 | ## We can't guess what flags might be required here. |
---|
275 | ## Pass the values from the environment if you want to apply them. |
---|
276 | endif |
---|
277 | RTEMS_CFLAGS__V = $(RTEMS_CFLAGS_OPTIMIZE_V) |
---|
278 | |
---|
279 | ## ------------------------------------------------------------------------- |
---|
280 | |
---|
281 | CC = @CC@ $(GCCSPECS) |
---|
282 | CXX = @CXX@ $(GCCSPECS) |
---|
283 | CPP = @CPP@ $(GCCSPECS) |
---|
284 | |
---|
285 | LD = @LD@ |
---|
286 | OBJCOPY = @OBJCOPY@ |
---|
287 | NM = @NM@ |
---|
288 | SIZE = @SIZE@ |
---|
289 | STRIP = @STRIP@ |
---|
290 | |
---|
291 | |
---|
292 | ## |
---|
293 | AM_CPPFLAGS = $(RTEMS_CPPFLAGS) |
---|
294 | |
---|
295 | AM_CFLAGS = $(RTEMS_CFLAGS_$(VARIANT_V)_V) $(CFLAGS_$(VARIANT_V)_V) |
---|
296 | AM_CXXFLAGS = $(RTEMS_CFLAGS_$(VARIANT_V)_V) $(CFLAGS_$(VARIANT_V)_V) |
---|