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