source: rtems/make/compilers/gcc-target-default.cfg @ 28e7d7fa

4.104.114.84.95
Last change on this file since 28e7d7fa was 28e7d7fa, checked in by Joel Sherrill <joel.sherrill@…>, on Aug 20, 1998 at 10:04:22 PM

Patches from Eric Norum

  • Property mode set to 100644
File size: 8.3 KB
Line 
1#
2#  Shared compiler for all GNU tools configurations
3#
4#  $Id$
5#
6
7CPPFLAGS=$(CFLAGS) $(XCPPFLAGS)
8
9CPLUS_CPPFLAGS=$(CFLAGS) $(XCPPFLAGS)
10
11##
12# CFLAGS_OPTIMIZE_V, CFLAGS_DEBUG_V, CFLAGS_PROFILE_V are the values we
13# would want the corresponding macros to be set to.
14#
15# CFLAGS_OPTIMIZE, CFLAGS_DEBUG, CFLAGS_PROFILE are set in the leaf
16# Makefiles by the 'debug:' and 'profile:' targets to their _V values.
17#
18
19# default flags
20
21# We only include the header files for networking if it is enabled.
22INCLUDE_NETWORKING_yes_V = -I$(PROJECT_INCLUDE)/networking
23INCLUDE_NETWORKING = $(INCLUDE_NETWORKING_$(HAS_NETWORKING)_V)
24
25ifeq ($(RTEMS_USE_GCC272),yes)
26ifeq ($(RTEMS_CROSS_TARGET),no)
27
28ifdef RTEMS_LIBC_DIR
29RTEMS_LIBC_INCLUDES := -I$(RTEMS_LIBC_DIR)/include
30endif
31
32# Used for posix bsps
33CFLAGS_DEFAULT = $(CPU_DEFINES) $(CPU_CFLAGS) -Wall -ansi -fasm -g \
34  -I$(PROJECT_INCLUDE) \
35  $(INCLUDE_NETWORKING) \
36  $(RTEMS_LIBC_INCLUDES) $(DEFINES)
37
38ASMFLAGS=$(CPU_DEFINES) $(CPU_CFLAGS) -g \
39  -I$(PROJECT_INCLUDE) \
40  $(RTEMS_LIBC_INCLUDES) $(DEFINES)
41else
42# Used for embedded bsps
43# Ask gcc where it finds its own include files
44GCC_INCLUDE=$(shell $(CC) $(CPU_CFLAGS) -print-file-name=include $(GCCSED))
45
46CFLAGS_DEFAULT = $(CPU_DEFINES) $(CPU_CFLAGS) -Wall -ansi -fasm -g \
47  -nostdinc -I$(PROJECT_INCLUDE) \
48  $(INCLUDE_NETWORKING) \
49  -I$(RTEMS_LIBC_DIR)/include -I$(GCC_INCLUDE) $(DEFINES)
50
51ASMFLAGS=$(CPU_DEFINES) $(CPU_CFLAGS) -g \
52  -nostdinc -I$(PROJECT_INCLUDE) \
53  -I$(RTEMS_LIBC_DIR)/include -I$(GCC_INCLUDE) $(DEFINES)
54endif
55
56# default location of Standard C Library
57ifndef LIBC_LIBC
58LIBC_LIBC=$(RTEMS_LIBC_DIR)/lib/libc.a
59endif
60
61ifndef LIBC_LIBM
62LIBC_LIBM=$(RTEMS_LIBC_DIR)/lib/libm.a
63endif
64
65else
66CFLAGS_DEFAULT = $(CPU_DEFINES) $(CPU_CFLAGS) -Wall -ansi -fasm -g \
67        -B$(PROJECT_RELEASE)/lib/ -specs bsp_specs -qrtems \
68        $(INCLUDE_NETWORKING) $(DEFINES)
69
70ASMFLAGS=$(CPU_DEFINES) $(CPU_CFLAGS) -g -I$(srcdir) \
71        -B$(PROJECT_RELEASE)/lib/ -specs bsp_specs -qrtems $(DEFINES)
72
73# default location of Standard C Library
74ifndef LIBC_LIBC
75LIBC_LIBC=$(shell $(CC) $(CPU_CFLAGS) -print-file-name=libc.a $(GCCSED))
76endif
77
78ifndef LIBC_LIBM
79LIBC_LIBM=$(shell $(CC) $(CPU_CFLAGS) -print-file-name=libm.a $(GCCSED))
80endif
81endif
82
83# Define this to yes if C++ is included in the development environment.
84# This requires that at least the GNU C++ compiler and libg++ be installed.
85ifeq ($(RTEMS_HAS_CPLUSPLUS),yes)
86HAS_CPLUSPLUS=yes
87CPLUS_LD_LIBS += $(PROJECT_RELEASE)/lib/librtems++$(LIBSUFFIX_VA)
88else
89HAS_CPLUSPLUS=no
90endif
91
92# debug flag;
93CFLAGS_DEBUG_V+=-Wno-unused
94
95ifeq ($(RTEMS_USE_GCC272),no)
96CFLAGS_DEBUG_V+=-qrtems_debug
97endif
98
99# when debugging, optimize flag: typically empty
100# some compilers do allow optimization with their "-g"
101#CFLAGS_DEBUG_OPTIMIZE_V=
102
103# profile flag; use gprof(1)
104CFLAGS_PROFILE_V=-pg
105
106# default is to optimize
107CFLAGS_OPTIMIZE=$(CFLAGS_OPTIMIZE_V)
108
109# dynamic libraries
110CFLAGS_DYNAMIC_V=-fpic
111#ASFLAGS_DYNAMIC_V=
112
113CFLAGS=$(CFLAGS_DEFAULT) $(CFLAGS_OPTIMIZE) $(CFLAGS_DEBUG) $(CFLAGS_PROFILE)
114
115# List of library paths without -L
116LD_PATHS= $(PROJECT_RELEASE)/lib
117
118# libraries you want EVERYONE to link with
119#LD_LIBS=
120
121# ld flag to ensure pure-text
122#LDFLAGS_MUST_BE_PURE_V =
123
124# ld flag for [un]shared objects
125#LDFLAGS_STATIC_LIBRARIES_V =
126#LDFLAGS_SHARED_LIBRARIES_V =
127
128# ld flag for incomplete link
129LDFLAGS_INCOMPLETE = -r
130
131# Special linker options when building lib.so
132LDFLAGS_DYNAMIC_V = ??
133
134# Some dynamic linking systems want the preferred name recorded in the binary
135# ref: src/libxil/Makefile
136LDFLAGS_DYNAMIC_LIBNAME_V = -h $(DYNAMIC_VERSION_LIBNAME)
137
138# ld flags for profiling, debugging
139LDFLAGS_PROFILE_V =
140LDFLAGS_DEBUG_V =
141
142LDFLAGS=$(LDFLAGS_PROFILE) $(LDFLAGS_DEBUG) $(LD_PATHS:%=-L %)
143
144#
145# Stuff to clean and clobber for the compiler and its tools
146#
147
148CLEAN_CC = a.out *.o *.BAK
149CLOBBER_CC =
150
151#
152# Client compiler and support tools
153#
154
155# CPP command to write file to standard output
156CPP=$(CC) -E -ansi -w -Wp,-$$
157
158# flags set by cc when running cpp
159CPP_CC_FLAGS=-D__STDC__
160
161ASFLAGS= $(CPU_ASFLAGS)
162ASM4FLAGS := -I $(PROJECT_INCLUDE)
163
164# egrep regexp to ignore symbol table entries in ar archives.
165# Only used to make sure we skip them when coalescing libraries.
166# skip __.SYMDEF and empty names (maybe bug in ranlib??).
167AR_SYMBOL_TABLE="HIGHLY-UNLIKELY-TO-CONFLICT"
168ARFLAGS=ruv
169
170#
171# Command to convert a normal archive to one searchable by $(LD)
172#
173# NOTE: Obsolete, use $(RANLIB) instead, MKLIB may disappear soon
174MKLIB=$(RANLIB)
175
176#
177# How to compile stuff into ${ARCH} subdirectory
178#
179# NOTE: we override COMPILE.c
180#
181
182COMPILE.c=$(CC) $(CFLAGS) $(XCFLAGS) -c
183COMPILE.cc=$(CXX) $(CFLAGS) $(CXXFLAGS) -fno-rtti $(XCFLAGS) -c
184
185${ARCH}/%.o: %.c
186        ${COMPILE.c} -o $@ $<
187
188${ARCH}/%.o: %.cc
189        ${COMPILE.cc} -o $@ $<
190
191${ARCH}/%.o: %.S
192        ${COMPILE.c} -DASM -o $@ $<
193
194# strip out C++ style comments.
195${ARCH}/%.o: %.s
196        sed -e 's/\/\/.*$$//' < $< | \
197            $(CPP) $(ASMFLAGS) -I. -I$(srcdir) -DASM - >$(ARCH)/$*.i
198        $(AS) $(ASFLAGS) -o $@ $(ARCH)/$*.i
199
200#       $(CPP) $(CPPFLAGS) -DASM - < $<  >$(ARCH)/$*.i
201#       $(AS) $(ASFLAGS) -o $@ $(ARCH)/$*.i
202#       $(RM) $(ARCH)/$*.i
203
204# Specify our own default rule for this to prevent having CFLAGS and
205#  CPPFLAGS being passed to linker
206#
207#
208# NOTE (Ralf): Having this rule is a bug, IMO.
209# I have only kept it for the moment because some (broken) Makefiles
210# might need it.
211#
212# ${ARCH}/%: ${ARCH}/%.o
213#       ${CC} ${LDFLAGS} -o $@ $@.o ${LD_LIBS}
214#
215# Anyway, the rule above is wrong. The one below should be correct
216# (But this one should also not be necessary. If something breaks now,
217# have a look at the Makefile or custom/*.cfg :-)
218# $(ARCH)/%.exe: $(ARCH)/%.o
219#       $(make-exe)
220
221# Make foo.rel from foo.o
222${ARCH}/%.rel: ${ARCH}/%.o
223        ${LD} $(LDFLAGS_INCOMPLETE) -o $@ $^
224
225# create $(ARCH)/pgm from pgm.sh
226${ARCH}/%: %.sh
227        $(RM) $@
228        $(CP) $< $@
229        $(CHMOD) +x $@
230
231# Dependency files for use by gmake
232# NOTE: we don't put in $(TARGET_ARCH)
233#       so that 'make clean' doesn't blow it away
234
235DEPEND=Depends-$(TARGET_ARCH:o-%=%)
236
237CLEAN_DEPEND=$(DEPEND).tmp
238CLOBBER_DEPEND=$(DEPEND)
239
240# We deliberately don't have anything depend on the
241# $(DEPEND) file; otherwise it will get rebuilt even
242# on 'make clean'
243#
244
245depend: $(C_FILES) $(CC_FILES) $(S_FILES)
246ifneq ($(words $(C_FILES) $(CC_FILES) $(S_FILES)), 0)
247#       Use gcc -M to generate dependencies
248#       Replace foo.o with $(ARCH)/foo.o
249#       Replace $(ARCH) value with string $(ARCH)
250#           so that it will for debug and profile cases
251        $(COMPILE.c) -M   $^    |  \
252        $(SED) -e 's?^\(.*\)\.o[ ]*:?$$(ARCH)/\1.o:?' \
253            -e 's?$(ARCH)/?$$(ARCH)/?'   >$(DEPEND).tmp
254        $(MV) $(DEPEND).tmp $(DEPEND)
255endif
256
257# spell out all the LINK_FILE's, rather than using -lbsp, so
258#  that $(LINK_FILES) can be a dependency
259
260# Start file must be one of
261#    $(PROJECT_RELEASE)/lib/start$(LIB_VARIANT).o
262#    $(PROJECT_RELEASE)/lib/asmiface$(LIB_VARIANT).o
263# It defaults to start.o, but an app can override it.
264
265ifeq ($(START_BASE),)
266  START_FILE=
267else
268  START_FILE=$(PROJECT_RELEASE)/lib/$(START_BASE)$(LIB_VARIANT).o
269endif
270
271CONSTRUCTOR=
272
273LIBC_LOW=
274
275ifndef LIBGCC
276LIBGCC = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name $(GCCSED))
277endif
278
279#
280# NOTE: a rule to link an rtems' application should look similar to this
281#       (cf. "make-exe" in make/custom/*.cfg):
282#
283# gcc27:
284# $(PGM): $(LINK_FILES)
285#       $(LD) $(LDFLAGS) -o $@ $(LINK_OBJS) \
286#       --start-group $(LINK_LIBS) --end-group
287#
288# gcc28:
289# $(PGM): $(LINK_FILES)
290#       $(CC) $(CFLAGS) -o $@ $(LINK_OBJS) $(LINK_LIBS)
291#
292
293LINK_OBJS =\
294    $(CONSTRUCTOR) \
295    $(OBJS) \
296    $(MANAGERS_NOT_WANTED:%=$(PROJECT_RELEASE)/lib/no-%$(LIB_VARIANT).rel) \
297    $(PROJECT_RELEASE)/lib/libtest$(LIBSUFFIX_VA)
298
299LINK_FILES =\
300    $(START_FILE) \
301    $(CONSTRUCTOR) \
302    $(OBJS) \
303    $(MANAGERS_NOT_WANTED:%=$(PROJECT_RELEASE)/lib/no-%$(LIB_VARIANT).rel) \
304    $(PROJECT_RELEASE)/lib/libtest$(LIBSUFFIX_VA) \
305    $(PROJECT_RELEASE)/lib/librtemsall$(LIBSUFFIX_VA)
306
307ifeq ($(RTEMS_USE_GCC272),yes)
308LINK_LIBS = $(PROJECT_RELEASE)/lib/librtemsall$(LIBSUFFIX_VA)
309ifeq ($(RTEMS_CROSS_TARGET),yes)
310# NOTE: add libc and libgcc only for embedded targets
311#       LIBC_LIBM should not be needed by rtems itself.
312# FIXME: If a BSP requires libm, its make/custom/*.cfg file should add
313#        LIBC_LIBM to LINK_LIBS (untested)
314LINK_LIBS += $(LIBC_LIBC) $(LIBGCC)
315endif
316endif
317
318LINK_LIBS += $(LD_LIBS)   
319
320#
321# Allow user to override link commands (to build a prom image, perhaps)
322#
323ifndef LINKCMDS
324LINKCMDS=$(PROJECT_RELEASE)/lib/linkcmds
325endif
326
327
328define make-rel
329        $(LD) $(LDFLAGS_INCOMPLETE) $(XLDFLAGS) -o $@ $(OBJS)
330endef
Note: See TracBrowser for help on using the repository browser.