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 -ansi -fasm |
---|
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 = $(shell $(CC) $(CPU_CFLAGS) -print-file-name=libc.a $(GCCSED)) |
---|
58 | LIBC_LIBM = $(shell $(CC) $(CPU_CFLAGS) -print-file-name=libm.a $(GCCSED)) |
---|
59 | LIBC_LIBGCC = $(shell $(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 | else |
---|
66 | ## gcc >= 2.8.x |
---|
67 | if RTEMS_CONFIG_PER_BSP |
---|
68 | BSP_SPECS = -specs bsp_specs -qrtems |
---|
69 | endif |
---|
70 | |
---|
71 | GCCSPECS = -B$(PROJECT_RELEASE)/lib/ $(BSP_SPECS) |
---|
72 | endif |
---|
73 | else |
---|
74 | ## fall back to the old style compilers/*.cfg |
---|
75 | ## CONFIG.CC is supposed to be provided by <BSP>.cfg |
---|
76 | include $(CONFIG.CC) |
---|
77 | endif # RTEMS_USE_GCC |
---|
78 | |
---|
79 | DEFS = @DEFS@ |
---|
80 | |
---|
81 | CPPFLAGS += $(CPU_DEFINES) $(CPU_CFLAGS) \ |
---|
82 | $(DEFINES) $(XCPPFLAGS) $(CPPFLAGS_GCC) |
---|
83 | CFLAGS = $(CFLAGS_DEFAULT) $(XCFLAGS) |
---|
84 | CXXFLAGS = $(CFLAGS_DEFAULT) $(XCXXFLAGS) |
---|
85 | ASFLAGS = $(CPU_ASFLAGS) $(XASFLAGS) |
---|
86 | |
---|
87 | LINK_LIBS = $(LINK_LIBS_GCC272) $(LD_LIBS) |
---|
88 | |
---|
89 | ## FIXME: This doesn't seem to be correct |
---|
90 | # when debugging, optimize flag: typically empty |
---|
91 | # some compilers do allow optimization with their "-g" |
---|
92 | CFLAGS_DEBUG_OPTIMIZE_V=-g |
---|
93 | CXXFLAGS_DEBUG_OPTIMIZE_V=-g |
---|
94 | LDFLAGS_DEBUG_V = |
---|
95 | |
---|
96 | # profile flag; use gprof(1) |
---|
97 | CFLAGS_PROFILE_V=-pg |
---|
98 | CXXFLAGS_PROFILE_V=-pg |
---|
99 | LDFLAGS_PROFILE_V = |
---|
100 | |
---|
101 | # List of library paths without -L |
---|
102 | LD_PATHS= $(PROJECT_RELEASE)/lib |
---|
103 | |
---|
104 | # ld flag for incomplete link |
---|
105 | LDFLAGS_INCOMPLETE = -r |
---|
106 | |
---|
107 | # ld flags for profiling, debugging |
---|
108 | LDFLAGS=$(LDFLAGS_PROFILE) $(LDFLAGS_DEBUG) $(LD_PATHS:%=-L %) |
---|
109 | |
---|
110 | # |
---|
111 | # Client compiler and support tools |
---|
112 | # |
---|
113 | |
---|
114 | ## HACK: specific to gcc |
---|
115 | ## FIXME: Do we call the correct CPP, why aren't |
---|
116 | ## CPPFLAGS and CFLAGS part of this call? |
---|
117 | # CPP command to write file to standard output |
---|
118 | CPP=$(CC) -E -ansi -w -Wp,-$$ |
---|
119 | |
---|
120 | ARFLAGS=ruv |
---|
121 | |
---|
122 | # |
---|
123 | # How to compile stuff into ${ARCH} subdirectory |
---|
124 | # |
---|
125 | |
---|
126 | ${ARCH}/%.o: %.c |
---|
127 | ${COMPILE.c} $(AM_CPPFLAGS) $(AM_CFLAGS) -o $@ $< |
---|
128 | |
---|
129 | ${ARCH}/%.o: %.cc |
---|
130 | ${COMPILE.cc} $(AM_CPPFLAGS) $(AM_CXXFLAGS) -o $@ $< |
---|
131 | |
---|
132 | ${ARCH}/%.o: %.cpp |
---|
133 | ${COMPILE.cc} $(AM_CPPFLAGS) $(AM_CXXFLAGS) -o $@ $< |
---|
134 | |
---|
135 | ${ARCH}/%.o: %.cxx |
---|
136 | ${COMPILE.cc} $(AM_CPPFLAGS) $(AM_CXXFLAGS) -o $@ $< |
---|
137 | |
---|
138 | ${ARCH}/%.o: %.C |
---|
139 | ${COMPILE.cc} $(AM_CPPFLAGS) $(AM_CXXFLAGS) -o $@ $< |
---|
140 | |
---|
141 | ${ARCH}/%.o: %.S |
---|
142 | ${COMPILE.S} $(AM_CPPFLAGS) -DASM -o $@ $< |
---|
143 | |
---|
144 | # Make foo.rel from foo.o |
---|
145 | ${ARCH}/%.rel: ${ARCH}/%.o |
---|
146 | ${make-rel} |
---|
147 | |
---|
148 | # create $(ARCH)/pgm from pgm.sh |
---|
149 | ${ARCH}/%: %.sh |
---|
150 | $(RM) $@ |
---|
151 | $(CP) $< $@ |
---|
152 | $(CHMOD) +x $@ |
---|
153 | |
---|
154 | # Dependency files for use by gmake |
---|
155 | # NOTE: we don't put them into $(ARCH) |
---|
156 | # so that 'make clean' doesn't blow it away |
---|
157 | |
---|
158 | DEPEND=Depends-${ARCH} |
---|
159 | |
---|
160 | CLEAN_DEPEND=$(DEPEND).tmp |
---|
161 | CLOBBER_DEPEND=$(DEPEND) |
---|
162 | |
---|
163 | # We deliberately don't have anything depend on the |
---|
164 | # $(DEPEND) file; otherwise it will get rebuilt even |
---|
165 | # on 'make clean' |
---|
166 | # |
---|
167 | |
---|
168 | ## HACK: Specific to gcc |
---|
169 | ## FIXME: The approach below is known to be conceptionally broken. |
---|
170 | depend-am: $(C_FILES) $(CC_FILES) $(S_FILES) |
---|
171 | ## Use gcc -M to generate dependencies |
---|
172 | ## Replace foo.o with $(ARCH)/foo.o |
---|
173 | ## Replace $(ARCH) value with string $(ARCH) |
---|
174 | ## so that it will for debug and profile cases |
---|
175 | $(COMPILE.c) $(AM_CPPFLAGS) $(AM_CFLAGS) -M $^ | \ |
---|
176 | sed -e 's?^\(.*\)\.o[ ]*:?$$(ARCH)/\1.o:?' \ |
---|
177 | -e 's?$(ARCH)/?$$(ARCH)/?' >$(DEPEND).tmp |
---|
178 | mv $(DEPEND).tmp $(DEPEND) |
---|
179 | depend: depend-am |
---|
180 | |
---|
181 | # pull in dependencies if they exist |
---|
182 | ifeq (${DEPEND},$(wildcard ${DEPEND})) |
---|
183 | include ${DEPEND} |
---|
184 | @ENDIF@ |
---|
185 | |
---|
186 | |
---|
187 | # spell out all the LINK_FILE's, rather than using -lbsp, so |
---|
188 | # that $(LINK_FILES) can be a dependency |
---|
189 | |
---|
190 | LINK_OBJS = \ |
---|
191 | $(OBJS) \ |
---|
192 | $(MANAGERS_NOT_WANTED:%=$(PROJECT_RELEASE)/lib/no-%$(LIB_VARIANT).rel) |
---|
193 | |
---|
194 | LINK_FILES =\ |
---|
195 | $(START_FILE) \ |
---|
196 | $(OBJS) \ |
---|
197 | $(MANAGERS_NOT_WANTED:%=$(PROJECT_RELEASE)/lib/no-%$(LIB_VARIANT).rel) \ |
---|
198 | $(PROJECT_RELEASE)/lib/librtemsall$(LIBSUFFIX_VA) |
---|
199 | |
---|
200 | if RTEMS_USE_GCC |
---|
201 | if RTEMS_USE_GCC272 |
---|
202 | define make-rel |
---|
203 | $(LD) $(LDFLAGS_INCOMPLETE) $(XLDFLAGS) -o $@ $^ |
---|
204 | endef |
---|
205 | else |
---|
206 | ## gcc >= 2.8 |
---|
207 | define make-rel |
---|
208 | $(LINK.c) $(AM_CFLAGS) $(AM_LDFLAGS) \ |
---|
209 | -qnolinkcmds -nostdlib -Wl,-r $(XLDFLAGS) -o $@ $^ |
---|
210 | endef |
---|
211 | endif |
---|
212 | else |
---|
213 | ## non-gcc |
---|
214 | define make-rel |
---|
215 | $(LINK.c) $(AM_CFLAGS) $(AM_LDFLAGS) \ |
---|
216 | $(XLDFLAGS) -o $@ $^ |
---|
217 | endef |
---|
218 | endif |
---|
219 | |
---|
220 | ## ------------------------------------------------------------------------- |
---|
221 | |
---|
222 | ## translate VARIANT into VARIANT_V |
---|
223 | VARIANT = OPTIMIZE |
---|
224 | |
---|
225 | VARIANT_OPTIMIZE_V = OPTIMIZE |
---|
226 | VARIANT_DEBUG_V = DEBUG |
---|
227 | VARIANT_PROFILE_V = PROFILE |
---|
228 | VARIANT_optimize_V = OPTIMIZE |
---|
229 | VARIANT_debug_V = DEBUG |
---|
230 | VARIANT_profile_V = PROFILE |
---|
231 | |
---|
232 | VARIANT_V = $(VARIANT_$(VARIANT)_V) |
---|
233 | |
---|
234 | ## Setup the variant build subdirectory |
---|
235 | ARCH_OPTIMIZE_V = o-optimize |
---|
236 | ARCH_DEBUG_V = o-debug |
---|
237 | ARCH_PROFILE_V = o-profile |
---|
238 | |
---|
239 | ARCH__V = $(ARCH_OPTIMIZE_V) |
---|
240 | ARCH = $(ARCH_$(VARIANT_V)_V) |
---|
241 | |
---|
242 | ## Setup the library suffix |
---|
243 | LIBSUFFIX_OPTIMIZE_V = |
---|
244 | LIBSUFFIX_DEBUG_V = _g |
---|
245 | LIBSUFFIX_PROFILE_V = _p |
---|
246 | LIBSUFFIX__V = $(LIBSUFFIX_OPTIMIZE_V) |
---|
247 | |
---|
248 | LIB_VARIANT = $(LIBSUFFIX_$(VARIANT_V)_V) |
---|
249 | LIBSUFFIX_VA = $(LIB_VARIANT).a |
---|
250 | |
---|
251 | ## These are supposed to be set in make/custom/<bsp>.cfg |
---|
252 | ## CFLAGS_OPTIMIZE_V = |
---|
253 | ## CFLAGS_DEBUG_V = |
---|
254 | ## CFLAGS_PROFILE_V = |
---|
255 | CFLAGS__V = $(CFLAGS_OPTIMIZE_V) |
---|
256 | |
---|
257 | ## ------------------------------------------------------------------------ |
---|
258 | ## Setup hard-coded flags |
---|
259 | if RTEMS_USE_GCC |
---|
260 | if RTEMS_USE_GCC272 |
---|
261 | ## gcc < gcc-2.8 |
---|
262 | RTEMS_CFLAGS_OPTIMIZE_V = |
---|
263 | RTEMS_CFLAGS_DEBUG_V = -Wno-unused |
---|
264 | RTEMS_CFLAGS_PROFILE_V = |
---|
265 | else |
---|
266 | ## gcc >= gcc-2.8 |
---|
267 | RTEMS_CFLAGS_OPTIMIZE_V = |
---|
268 | RTEMS_CFLAGS_DEBUG_V = -qrtems_debug -Wno-unused |
---|
269 | RTEMS_CFLAGS_PROFILE_V = |
---|
270 | endif |
---|
271 | ## non-gcc |
---|
272 | ## We can't guess what flags might be required here. |
---|
273 | ## Pass the values from the environment if you want to apply them. |
---|
274 | endif |
---|
275 | RTEMS_CFLAGS__V = $(RTEMS_CFLAGS_OPTIMIZE_V) |
---|
276 | |
---|
277 | ## ------------------------------------------------------------------------- |
---|
278 | |
---|
279 | CC = @CC@ $(GCCSPECS) |
---|
280 | CXX = @CXX@ $(GCCSPECS) |
---|
281 | OBJCOPY = @OBJCOPY@ |
---|
282 | NM = @NM@ |
---|
283 | SIZE = @SIZE@ |
---|
284 | STRIP = @STRIP@ |
---|
285 | |
---|
286 | ## |
---|
287 | ## FIXME: DEFS and INCLUDES should not be passed as AM_CPPFLAGS |
---|
288 | AM_CPPFLAGS += $(DEFS) $(INCLUDES) $(RTEMS_CPPFLAGS) |
---|
289 | |
---|
290 | AM_CFLAGS += $(RTEMS_CFLAGS_$(VARIANT_V)_V) $(CFLAGS_$(VARIANT_V)_V) |
---|
291 | AM_CXXFLAGS += $(RTEMS_CFLAGS_$(VARIANT_V)_V) $(CFLAGS_$(VARIANT_V)_V) |
---|