1 | # |
---|
2 | # $Id$ |
---|
3 | # |
---|
4 | # gcc 2.6.x compiler for a "native" nocpu/nobsp system |
---|
5 | # Compiler (and tools) configuration |
---|
6 | # |
---|
7 | |
---|
8 | # Prefix on the installed GNU tools |
---|
9 | # Just use the native tools |
---|
10 | GNU_TOOLS_PREFIX= |
---|
11 | |
---|
12 | # Additional target names (other than debug, profile) |
---|
13 | TARGET_VARIANTS += |
---|
14 | |
---|
15 | # |
---|
16 | # Pre-processor defines using the target options header file. |
---|
17 | # |
---|
18 | # Local tailoring (on the command line) can be done by setting XCFLAGS |
---|
19 | # or XCPPFLAGS -- neither of which are never set in the Makefile's |
---|
20 | # |
---|
21 | |
---|
22 | CPPFLAGS=$(CFLAGS) $(XCPPFLAGS) $(DEFINES) |
---|
23 | |
---|
24 | CPLUS_CPPFLAGS=$(CFLAGS) $(XCPPFLAGS) $(DEFINES) |
---|
25 | |
---|
26 | # This section makes the target dependent options file. |
---|
27 | |
---|
28 | # NDEBUG (C library) |
---|
29 | # if defined asserts do not generate code. This is commonly used |
---|
30 | # as a command line option. |
---|
31 | # |
---|
32 | # RTEMS_TEST_NO_PAUSE (RTEMS tests) |
---|
33 | # do not pause between screens of output in the rtems tests |
---|
34 | # |
---|
35 | # NO_TABLE_MOVE (SPARC PORT) |
---|
36 | # do not have a second trap table -- use the BSP's |
---|
37 | # |
---|
38 | # STACK_CHECKER_ON (RTEMS support code) |
---|
39 | # If defined, stack bounds checking is enabled. |
---|
40 | # |
---|
41 | # RTEMS_DEBUG (RTEMS) |
---|
42 | # If defined, debug checks in RTEMS and support library code are enabled. |
---|
43 | |
---|
44 | define make-target-options |
---|
45 | echo "/* #define NDEBUG 1 */ " >>$@ |
---|
46 | echo "#define RTEMS_TEST_NO_PAUSE 1" >>$@ |
---|
47 | echo "/* #define STACK_CHECKER_ON 1 */" >>$@ |
---|
48 | echo "/* #define RTEMS_DEBUG 1 */" >>$@ |
---|
49 | endef |
---|
50 | |
---|
51 | # |
---|
52 | # Local tailoring (on the command line) can be done by setting XCFLAGS |
---|
53 | # which is never set in the Makefile's |
---|
54 | # |
---|
55 | |
---|
56 | # |
---|
57 | # CFLAGS_OPTIMIZE_V, CFLAGS_DEBUG_V, CFLAGS_PROFILE_V are the values we |
---|
58 | # would want the corresponding macros to be set to. |
---|
59 | # |
---|
60 | # CFLAGS_OPTIMIZE, CFLAGS_DEBUG, CFLAGS_PROFILE are set in the leaf |
---|
61 | # Makefiles by the 'debug:' and 'profile:' targets to their _V values. |
---|
62 | # |
---|
63 | |
---|
64 | # default flags |
---|
65 | |
---|
66 | # |
---|
67 | # This contains the compiler options necessary to select the CPU model |
---|
68 | # and (hopefully) optimize for it. |
---|
69 | # |
---|
70 | CPU_CFLAGS = |
---|
71 | |
---|
72 | CFLAGS_DEFAULT = $(CPU_CFLAGS) -Wall -ansi -fasm |
---|
73 | |
---|
74 | # optimize flag: typically -0, could use -O4 or -fast |
---|
75 | # -O4 is ok for RTEMS |
---|
76 | CFLAGS_OPTIMIZE_V=-O4 -fomit-frame-pointer |
---|
77 | |
---|
78 | # debug flag; typically -g |
---|
79 | CFLAGS_DEBUG_V=-g -Wno-unused |
---|
80 | |
---|
81 | # profile flag; use gprof(1) |
---|
82 | CFLAGS_PROFILE_V=-pg |
---|
83 | |
---|
84 | # default is to optimize |
---|
85 | CFLAGS_OPTIMIZE=$(CFLAGS_OPTIMIZE_V) |
---|
86 | |
---|
87 | # dynamic libraries |
---|
88 | CFLAGS_DYNAMIC_V=-fpic |
---|
89 | # ASFLAGS_DYNAMIC_V= |
---|
90 | |
---|
91 | CFLAGS=$(CFLAGS_DEFAULT) $(CFLAGS_OPTIMIZE) $(CFLAGS_DEBUG) $(CFLAGS_PROFILE) \ |
---|
92 | -I $(PROJECT_INCLUDE) |
---|
93 | |
---|
94 | # List of library paths without -L |
---|
95 | LD_PATHS= $(PROJECT_RELEASE)/lib |
---|
96 | |
---|
97 | # libraries you want EVERYONE to link with |
---|
98 | LD_LIBS= |
---|
99 | |
---|
100 | # ld flag to ensure pure-text |
---|
101 | LDFLAGS_MUST_BE_PURE_V = |
---|
102 | |
---|
103 | # ld flag for [un]shared objects |
---|
104 | LDFLAGS_STATIC_LIBRARIES_V = |
---|
105 | LDFLAGS_SHARED_LIBRARIES_V = |
---|
106 | |
---|
107 | # ld flag for incomplete link |
---|
108 | LDFLAGS_INCOMPLETE = -r |
---|
109 | |
---|
110 | # Special linker options when building lib.so |
---|
111 | LDFLAGS_DYNAMIC_V = ?? |
---|
112 | |
---|
113 | # Some dynamic linking systems want the preferred name recorded in the binary |
---|
114 | # ref: src/libxil/Makefile |
---|
115 | LDFLAGS_DYNAMIC_LIBNAME_V = -h $(DYNAMIC_VERSION_LIBNAME) |
---|
116 | |
---|
117 | # ld flags for profiling, debugging |
---|
118 | LDFLAGS_PROFILE_V = |
---|
119 | LDFLAGS_DEBUG_V = |
---|
120 | |
---|
121 | LDFLAGS=$(LDFLAGS_PROFILE) $(LDFLAGS_DEBUG) $(LD_PATHS:%=-L %) |
---|
122 | |
---|
123 | # |
---|
124 | # Stuff to clean and clobber for the compiler and its tools |
---|
125 | # |
---|
126 | |
---|
127 | CLEAN_CC = a.out *.o *.BAK |
---|
128 | CLOBBER_CC = |
---|
129 | |
---|
130 | # |
---|
131 | # Client compiler and support tools |
---|
132 | # |
---|
133 | |
---|
134 | CC=gcc |
---|
135 | CXX=$(CC) |
---|
136 | CCC=$(CXX) |
---|
137 | |
---|
138 | # CPP command to write file to standard output |
---|
139 | CPP=$(CC) -E |
---|
140 | |
---|
141 | # flags set by cc when running cpp |
---|
142 | CPP_CC_FLAGS=-D__STDC__ |
---|
143 | |
---|
144 | AS=as |
---|
145 | ASPP=ERROR_NO_ASPP |
---|
146 | |
---|
147 | ASFLAGS= |
---|
148 | |
---|
149 | |
---|
150 | # NOTE: should never use full path .. but there is no guarantee ld, etc |
---|
151 | # will be in the same directory as gcc.. so hope they are in the path |
---|
152 | # Don't do this on a real target!!! |
---|
153 | LD=ld |
---|
154 | NM=nm |
---|
155 | AR=ar |
---|
156 | # egrep regexp to ignore symbol table entries in ar archives. |
---|
157 | # Only used to make sure we skip them when coalescing libraries. |
---|
158 | # skip __.SYMDEF and empty names (maybe bug in ranlib??). |
---|
159 | AR_SYMBOL_TABLE="HIGHLY-UNLIKELY-TO-CONFLICT" |
---|
160 | ARFLAGS=ruv |
---|
161 | |
---|
162 | # NOTE: see comment on ld, nm, ar |
---|
163 | SIZE=size |
---|
164 | |
---|
165 | # |
---|
166 | # Command to convert a normal archive to one searchable by $(LD) |
---|
167 | # Not needed on SVR4 |
---|
168 | # |
---|
169 | |
---|
170 | MKLIB=echo library is complete: |
---|
171 | |
---|
172 | # |
---|
173 | # How to compile stuff into ${ARCH} subdirectory |
---|
174 | # |
---|
175 | # NOTE: we override COMPILE.c |
---|
176 | # |
---|
177 | |
---|
178 | COMPILE.c=$(CC) $(CFLAGS) $(CPPFLAGS) $(XCFLAGS) -c |
---|
179 | |
---|
180 | ${ARCH}/%.o: %.c |
---|
181 | ${COMPILE.c} -o $@ $< |
---|
182 | |
---|
183 | ${ARCH}/%.o: %.cc |
---|
184 | ${COMPILE.c} -o $@ $< |
---|
185 | |
---|
186 | ${ARCH}/%.o: %.S |
---|
187 | ${COMPILE.c} -DASM -o $@ $< |
---|
188 | |
---|
189 | ${ARCH}/%.o: %.s |
---|
190 | $(CPP) $(CPPFLAGS) - <$*.s >$(ARCH)/$*.i |
---|
191 | $(AS) $(ASFLAGS) -o $@ $(ARCH)/$*.i |
---|
192 | # $(RM) $(ARCH)/$*.i |
---|
193 | |
---|
194 | # Specify our own default rule for this to prevent having CFLAGS and |
---|
195 | # CPPFLAGS being passed to linker |
---|
196 | ${ARCH}/%: ${ARCH}/%.o |
---|
197 | ${CC} ${LDFLAGS} -o $@ $@.o ${LD_LIBS} |
---|
198 | |
---|
199 | # Make foo.rel from foo.o |
---|
200 | ${ARCH}/%.rel: ${ARCH}/%.o |
---|
201 | ${LD} $(LDFLAGS_INCOMPLETE) -o $@ $^ |
---|
202 | |
---|
203 | # create $(ARCH)/pgm from pgm.sh |
---|
204 | ${ARCH}/%: %.sh |
---|
205 | $(RM) $@ |
---|
206 | $(CP) $< $@ |
---|
207 | $(CHMOD) +x $@ |
---|
208 | |
---|
209 | # Dependency files for use by gmake |
---|
210 | # NOTE: we don't put them into $(ARCH) |
---|
211 | # so that 'make clean' doesn't blow it away |
---|
212 | |
---|
213 | DEPEND=Depends-${ARCH} |
---|
214 | |
---|
215 | CLEAN_DEPEND=$(DEPEND).tmp |
---|
216 | CLOBBER_DEPEND=$(DEPEND) |
---|
217 | |
---|
218 | # We deliberately don't have anything depend on the |
---|
219 | # $(DEPEND) file; otherwise it will get rebuilt even |
---|
220 | # on 'make clean' |
---|
221 | # |
---|
222 | |
---|
223 | depend: $(C_FILES) $(CC_FILES) $(S_FILES) |
---|
224 | ifneq ($(words $(C_FILES) $(CC_FILES) $(S_FILES)), 0) |
---|
225 | # Use gcc -M to generate dependencies |
---|
226 | # Replace foo.o with $(ARCH)/foo.o |
---|
227 | # Replace $(ARCH) value with string $(ARCH) |
---|
228 | # so that it will for debug and profile cases |
---|
229 | $(COMPILE.c) -M $^ | \ |
---|
230 | $(SED) -e 's?^\(.*\)\.o[ ]*:?$$(ARCH)/\1.o:?' \ |
---|
231 | -e 's?$(ARCH)/?$$(ARCH)/?' >$(DEPEND).tmp |
---|
232 | $(MV) $(DEPEND).tmp $(DEPEND) |
---|
233 | endif |
---|
234 | |
---|
235 | |
---|
236 | # List (possibly empty) of required managers |
---|
237 | # We require: |
---|
238 | # region -- used by lib/libcsupport for malloc() |
---|
239 | # ext -- used by libc for libc reentrancy hooks |
---|
240 | |
---|
241 | MANAGERS_REQUIRED=region ext sem |
---|
242 | |
---|
243 | # Create a RTEMS executable based on MANAGERS which was set in |
---|
244 | # app's Makefile |
---|
245 | |
---|
246 | MANAGERS_NOT_WANTED=$(filter-out $(MANAGERS), $(MANAGER_LIST)) |
---|
247 | MANAGERS_NOT_WANTED:=$(filter-out $(MANAGERS_REQUIRED), $(MANAGERS_NOT_WANTED)) |
---|
248 | |
---|
249 | # spell out all the LINK_FILE's, rather than using -lbsp, so |
---|
250 | # that $(LINK_FILES) can be a dependency |
---|
251 | |
---|
252 | # Start file must be one of |
---|
253 | # $(PROJECT_RELEASE)/lib/start$(LIB_VARIANT).o |
---|
254 | # $(PROJECT_RELEASE)/lib/asmiface$(LIB_VARIANT).o |
---|
255 | # It defaults to start.o, but an app can override it. |
---|
256 | |
---|
257 | # Note: Normally RTEMS provides a start file... |
---|
258 | START_FILE= |
---|
259 | |
---|
260 | CONSTRUCTOR= |
---|
261 | |
---|
262 | LIBGCC = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name $(GCCSED)) |
---|
263 | |
---|
264 | LINK_FILES= $(START_FILE) \ |
---|
265 | $(CONSTRUCTOR) \ |
---|
266 | $(OBJS) \ |
---|
267 | $(MANAGERS_NOT_WANTED:%=$(PROJECT_RELEASE)/lib/no-%$(LIB_VARIANT).rel) \ |
---|
268 | $(LD_LIBS) \ |
---|
269 | $(LIBC_EXTRA_LIBS) \ |
---|
270 | $(PROJECT_RELEASE)/lib/libtest$(LIBSUFFIX_VA) \ |
---|
271 | $(PROJECT_RELEASE)/lib/librtemsall$(LIBSUFFIX_VA) \ |
---|
272 | $(LIBC_LIBM) $(LIBC_LIBC) $(LIBGCC) |
---|
273 | |
---|
274 | # Here is the rule to actually build a $(ARCH)/foo.exe |
---|
275 | # It also builds $(ARCH)/foo.sr and $(ARCH)/foo.nm |
---|
276 | # Usage ref: src/tests/sptest/sp1/Makefile |
---|
277 | |
---|
278 | # On Solaris at least you need to had /usr/ucblib/libucb.a |
---|
279 | |
---|
280 | define make-exe |
---|
281 | $(CC) -o $(basename $@).exe $(LINK_FILES) -lc -lm |
---|
282 | $(NM) -n $(basename $@).exe > $(basename $@).num |
---|
283 | $(SIZE) $(basename $@).exe |
---|
284 | endef |
---|
285 | |
---|
286 | define make-rel |
---|
287 | $(LD) $(LDFLAGS_INCOMPLETE) $(XLDFLAGS) -o $@ $(OBJS) |
---|
288 | endef |
---|