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

4.104.114.84.95
Last change on this file since a110b68 was a110b68, checked in by Joel Sherrill <joel.sherrill@…>, on 02/18/99 at 17:55:49

Part of automake VI patch from Ralf Corsepius <corsepiu@…>:

2) rtems-rc-19990131-1.diff

Rework of compilers/*.cfg files (esp. gcc-target-default.cfg) to adapt
the flags/makefile variables to automake and make standards (cf.
make.info - implicit rules/variables).

This patch is rather risky and may probably break things, but is an
essential step towards automake.

FWIW: It also reverts the i386-ASMFLAGS/ASFLAGS-patch, which was wrong,
as I had to experience ;-.

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