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

4.115
Last change on this file since 8fbe2e6 was 98db96e, checked in by Sebastian Huber <sebastian.huber@…>, on 06/29/13 at 12:00:39

make: Use C flags for C++ as default

In case a BSP selects special CFLAGS_OPTIMIZE_V flags then they will be
also used for CXXFLAGS_OPTIMIZE_V automatically for example.

  • Property mode set to 100644
File size: 4.7 KB
RevLine 
[bffb938]1#
[c2c9c7e]2#  Shared compiler for all GNU tools configurations
[bffb938]3#
4
5##
[0707bd20]6# CFLAGS_OPTIMIZE_V, CFLAGS_DEBUG_V are the values we
[bffb938]7# would want the corresponding macros to be set to.
8#
[0707bd20]9# CFLAGS_OPTIMIZE, CFLAGS_DEBUG are set in the leaf
10# Makefiles by the 'debug:' targets to their _V values.
[bffb938]11#
12
13# default flags
[a110b68]14# XCPPFLAGS, XCFLAGS, XCXXFLAGS, XASFLAGS
15# are used to add flags from the shell
16# cf. make.info ("Implicit rules/variables" for details)
17
[4d20133]18# NOTE: Should these go to CPPFLAGS ?
[3e132a8]19CFLAGS_DEFAULT=-Wall
[4d20133]20
21# NOTE: CPU_CFLAGS should probably be renamed to CPU_CPPFLAGS
22# NOTE: CPU_DEFINES should probably be merged with CPU_CFLAGS
[9608320]23CPPFLAGS += $(CPU_DEFINES) $(CPU_CFLAGS) $(DEFINES) $(XCPPFLAGS)
[4d20133]24CFLAGS   = $(CFLAGS_DEFAULT) $(XCFLAGS)
25CXXFLAGS = $(CFLAGS_DEFAULT) $(XCXXFLAGS)
[a110b68]26ASFLAGS  = $(CPU_ASFLAGS) $(XASFLAGS)
[bffb938]27
[4cc89bd]28# NOTE: GCCSPECS probably belongs to CPPFLAGS
[df413e9]29GCCSPECS_OPTIMIZE_V =
[baa60b5e]30GCCSPECS_DEBUG_V =
[df413e9]31
32GCCSPECS = -B$(PROJECT_RELEASE)/lib/ -specs bsp_specs -qrtems
33GCCSPECS += $(GCCSPECS_$(VARIANT_V)_V)
34
[4cc89bd]35CC  += $(GCCSPECS)
36CXX += $(GCCSPECS)
37
[72f9937b]38CPPFLAGS +=
[bffb938]39
40# Define this to yes if C++ is included in the development environment.
41# This requires that at least the GNU C++ compiler and libg++ be installed.
[d6c83529]42ifeq ($(HAS_CPLUSPLUS),yes)
[bffb938]43CPLUS_LD_LIBS += $(PROJECT_RELEASE)/lib/librtems++$(LIBSUFFIX_VA)
44endif
45
[98100d2]46# debug flag;
[83a2fad]47CFLAGS_DEBUG_V ?= -O0 -g
[98db96e]48CXXFLAGS_DEBUG_V ?= $(CFLAGS_DEBUG_V)
[a858910]49
[8ef3818]50# when debugging, optimize flag: typically empty
51# some compilers do allow optimization with their "-g"
[83a2fad]52CFLAGS_OPTIMIZE_V ?= -O2 -g
[98db96e]53CXXFLAGS_OPTIMIZE_V ?= $(CFLAGS_OPTIMIZE_V)
[8ef3818]54
[df49c60]55ifndef AUTOMAKE
[f67eee1]56CPPFLAGS_$(VARIANT)=$(CPPFLAGS_$(VARIANT)_V)
[db28d621]57CFLAGS_$(VARIANT)  =$(CFLAGS_$(VARIANT)_V)
58CXXFLAGS_$(VARIANT)=$(CXXFLAGS_$(VARIANT)_V)
[df49c60]59endif
[bffb938]60
[df49c60]61ifndef AUTOMAKE
[f67eee1]62CPPFLAGS += $(CPPFLAGS_OPTIMIZE) $(CPPFLAGS_DEBUG)
[0707bd20]63CFLAGS   += $(CFLAGS_OPTIMIZE) $(CFLAGS_DEBUG)
64CXXFLAGS += $(CXXFLAGS_OPTIMIZE) $(CXXFLAGS_DEBUG)
[df49c60]65endif
[bffb938]66
67# List of library paths without -L
68LD_PATHS= $(PROJECT_RELEASE)/lib
69
70# ld flag for incomplete link
71LDFLAGS_INCOMPLETE = -r
72
[0707bd20]73# LDFLAGS=$(LDFLAGS_DEBUG) $(LD_PATHS:%=-L%)
[e59d23ad]74LDFLAGS += $(LDFLAGS_DEBUG)
[bffb938]75
76#
77# Stuff to clean and clobber for the compiler and its tools
78#
79
80CLEAN_CC = a.out *.o *.BAK
81CLOBBER_CC =
82
83#
84# Client compiler and support tools
85#
86
[53a27c2]87# CPP command to write file to standard output with warnings suppressed
88CPP=$(CC) -E -w
[bffb938]89
90# egrep regexp to ignore symbol table entries in ar archives.
91# Only used to make sure we skip them when coalescing libraries.
92# skip __.SYMDEF and empty names (maybe bug in ranlib??).
93AR_SYMBOL_TABLE="HIGHLY-UNLIKELY-TO-CONFLICT"
94ARFLAGS=ruv
95
96#
97# How to compile stuff into ${ARCH} subdirectory
98#
99
100${ARCH}/%.o: %.c
[9608320]101        ${COMPILE.c} $(AM_CPPFLAGS) $(AM_CFLAGS) -o $@ $<
[bffb938]102
103${ARCH}/%.o: %.cc
[9608320]104        ${COMPILE.cc} $(AM_CPPFLAGS) $(AM_CXXFLAGS) -o $@ $<
[bffb938]105
[07001360]106${ARCH}/%.o: %.cpp
[9608320]107        ${COMPILE.cc} $(AM_CPPFLAGS) $(AM_CXXFLAGS) -o $@ $<
[07001360]108
109${ARCH}/%.o: %.cxx
[9608320]110        ${COMPILE.cc} $(AM_CPPFLAGS) $(AM_CXXFLAGS) -o $@ $<
[07001360]111
112${ARCH}/%.o: %.C
[9608320]113        ${COMPILE.cc} $(AM_CPPFLAGS) $(AM_CXXFLAGS) -o $@ $<
[07001360]114
[0162910]115${ARCH}/%.o: %.S
[9608320]116        ${COMPILE.S} $(AM_CPPFLAGS) -DASM -o $@ $<
[4d20133]117
[bffb938]118# Make foo.rel from foo.o
119${ARCH}/%.rel: ${ARCH}/%.o
[df49c60]120        ${make-rel}
[bffb938]121
122# create $(ARCH)/pgm from pgm.sh
[5b8c1b7]123${ARCH}/%: %.sh
[bffb938]124        $(RM) $@
125        $(CP) $< $@
126        $(CHMOD) +x $@
127
128# Dependency files for use by gmake
[d6c83529]129# NOTE: we don't put them into $(ARCH)
[bffb938]130#       so that 'make clean' doesn't blow it away
131
[d6c83529]132DEPEND=Depends-${ARCH}
[bffb938]133
134CLEAN_DEPEND=$(DEPEND).tmp
135CLOBBER_DEPEND=$(DEPEND)
136
137# We deliberately don't have anything depend on the
138# $(DEPEND) file; otherwise it will get rebuilt even
139# on 'make clean'
140#
141
[9f4868c]142depend-am: $(C_FILES) $(CC_FILES) $(S_FILES)
[bffb938]143ifneq ($(words $(C_FILES) $(CC_FILES) $(S_FILES)), 0)
144#       Use gcc -M to generate dependencies
145#       Replace foo.o with $(ARCH)/foo.o
146#       Replace $(ARCH) value with string $(ARCH)
[0707bd20]147#           so that it will for debug cases
[df49c60]148        $(COMPILE.c) $(AM_CPPFLAGS) $(AM_CFLAGS) -M   $^    |  \
[bffb938]149        $(SED) -e 's?^\(.*\)\.o[ ]*:?$$(ARCH)/\1.o:?' \
150            -e 's?$(ARCH)/?$$(ARCH)/?'   >$(DEPEND).tmp
151        $(MV) $(DEPEND).tmp $(DEPEND)
152endif
[9f4868c]153depend: depend-am
[bffb938]154
155# spell out all the LINK_FILE's, rather than using -lbsp, so
156#  that $(LINK_FILES) can be a dependency
157
[98100d2]158#
159# NOTE: a rule to link an rtems' application should look similar to this
160#       (cf. "make-exe" in make/custom/*.cfg):
161#
162# gcc28:
163# $(PGM): $(LINK_FILES)
[30cde042]164#       $(CC) $(CFLAGS) -o $@ $(LINK_OBJS) $(LINK_LIBS)
[98100d2]165#
166
167LINK_OBJS =\
[bffb938]168    $(CONSTRUCTOR) \
[5fa9b70]169    $(OBJS)
[bffb938]170
[98100d2]171LINK_FILES =\
172    $(CONSTRUCTOR) \
173    $(OBJS) \
[6703f877]174    $(PROJECT_RELEASE)/lib/librtemsbsp$(LIBSUFFIX_VA) \
[88f60e26]175    $(PROJECT_RELEASE)/lib/librtemscpu$(LIBSUFFIX_VA)
[98100d2]176
177LINK_LIBS += $(LD_LIBS)   
[bffb938]178
179#
180# Allow user to override link commands (to build a prom image, perhaps)
181#
182ifndef LINKCMDS
183LINKCMDS=$(PROJECT_RELEASE)/lib/linkcmds
184endif
185
186define make-rel
[ccf2cfd]187        $(LINK.c) $(CFLAGS) $(AM_CFLAGS) $(AM_LDFLAGS) \
[df49c60]188          -qnolinkcmds -nostdlib -Wl,-r $(XLDFLAGS) -o $@ $^
189endef
Note: See TracBrowser for help on using the repository browser.