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

4.104.114.84.95
Last change on this file since 07001360 was 07001360, checked in by Joel Sherrill <joel.sherrill@…>, on 05/07/99 at 16:31:08

Added rules to handle alternate suffixes for C++ files.

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