source: rtems/c/src/make/compilers/gcc-target-default.cfg @ 30cde042

4.104.114.84.95
Last change on this file since 30cde042 was 30cde042, checked in by Joel Sherrill <joel.sherrill@…>, on 07/28/98 at 16:50:14

Added missing parts of patch from Ralf Corsepius <corsepiu@…>.

  • Property mode set to 100644
File size: 8.2 KB
RevLine 
[bffb938]1#
[c2c9c7e]2#  Shared compiler for all GNU tools configurations
3#
4#  $Id$
[bffb938]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 KA9Q if it is enabled.
22INCLUDE_KA9Q_yes_V = -I$(PROJECT_INCLUDE)/ka9q
23INCLUDE_KA9Q = $(INCLUDE_KA9Q_$(HAS_KA9Q)_V)
24
25ifeq ($(RTEMS_USE_GCC272),yes)
[6ee6abb]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_KA9Q) \
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
[bffb938]43# Ask gcc where it finds its own include files
[98100d2]44GCC_INCLUDE=$(shell $(CC) $(CPU_CFLAGS) -print-file-name=include $(GCCSED))
[bffb938]45
46CFLAGS_DEFAULT = $(CPU_DEFINES) $(CPU_CFLAGS) -Wall -ansi -fasm -g \
47  -nostdinc -I$(PROJECT_INCLUDE) \
48  $(INCLUDE_KA9Q) \
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)
[6ee6abb]54endif
[bffb938]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_KA9Q) $(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
[98100d2]75LIBC_LIBC=$(shell $(CC) $(CPU_CFLAGS) -print-file-name=libc.a $(GCCSED))
[bffb938]76endif
77
78ifndef LIBC_LIBM
[98100d2]79LIBC_LIBM=$(shell $(CC) $(CPU_CFLAGS) -print-file-name=libm.a $(GCCSED))
[bffb938]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
[98100d2]92# debug flag;
[ac61209b]93CFLAGS_DEBUG_V+=-Wno-unused
[bffb938]94
[a858910]95ifeq ($(RTEMS_USE_GCC272),no)
96CFLAGS_DEBUG_V+=-qrtems_debug
97endif
98
[bffb938]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
[5dd4212]156CPP=$(CC) -E -ansi -w -Wp,-$$
[bffb938]157
158# flags set by cc when running cpp
159CPP_CC_FLAGS=-D__STDC__
160
161ASFLAGS=
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#
[98100d2]173# NOTE: Obsolete, use $(RANLIB) instead, MKLIB may disappear soon
174MKLIB=$(RANLIB)
[bffb938]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
[6ee6abb]183COMPILE.cc=$(CXX) $(CFLAGS) $(CXXFLAGS) -fno-rtti $(XCFLAGS) -c
[bffb938]184
185${ARCH}/%.o: %.c
[e81ef51]186        ${COMPILE.c} -o $@ $<
[bffb938]187
188${ARCH}/%.o: %.cc
[6ee6abb]189        ${COMPILE.cc} -o $@ $<
[bffb938]190
191${ARCH}/%.o: %.S
[e81ef51]192        ${COMPILE.c} -DASM -o $@ $<
[bffb938]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
[30cde042]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)
[bffb938]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
[5b8c1b7]226${ARCH}/%: %.sh
[bffb938]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
[6ee6abb]275ifndef LIBGCC
[98100d2]276LIBGCC = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name $(GCCSED))
[6ee6abb]277endif
[bffb938]278
[98100d2]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) \
[30cde042]286#       --start-group $(LINK_LIBS) --end-group
[98100d2]287#
288# gcc28:
289# $(PGM): $(LINK_FILES)
[30cde042]290#       $(CC) $(CFLAGS) -o $@ $(LINK_OBJS) $(LINK_LIBS)
[98100d2]291#
292
293LINK_OBJS =\
[bffb938]294    $(CONSTRUCTOR) \
295    $(OBJS) \
296    $(MANAGERS_NOT_WANTED:%=$(PROJECT_RELEASE)/lib/no-%$(LIB_VARIANT).rel) \
297    $(PROJECT_RELEASE)/lib/libtest$(LIBSUFFIX_VA)
298
[98100d2]299LINK_FILES =\
[bffb938]300    $(START_FILE) \
[98100d2]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)   
[bffb938]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.