source: rtems/cpukit/automake/compile.am @ f22ebf0

4.104.114.84.95
Last change on this file since f22ebf0 was 9ea3832c, checked in by Ralf Corsepius <ralf.corsepius@…>, on 06/15/02 at 05:29:18

Copied over from the automake/

  • Property mode set to 100644
File size: 6.5 KB
Line 
1##
2## $Id$
3##
4
5## -------------------------------------------------------------------------
6## NOTE: This file is rather immature and has to be considered to be
7## almost experimental.
8##
9## Expect frequent changes -- It deserves to be cleaned up :(
10## -------------------------------------------------------------------------
11
12## The section below is based on make/compilers/gcc-target-default.cfg
13## used in former versions of RTEMS.
14
15##
16## Set up the flags for the toolchains:
17##
18## We are considering 3 different building schemes here:
19## * Using gcc's being able to accept -specs (aka gcc-2.8 building scheme)
20## * Using gcc's not being able to accept -specs (aka gcc-2.7.2 building
21##   scheme)
22## * Using third party toolchains (aka non-gcc building scheme)
23##
24## Automake conditionals in use:
25## RTEMS_USE_GCC     .. if we are using GCC
26
27## NOTES:
28## * The gcc-2.8 building scheme is the nominal building scheme and
29##   is actively supported.
30## * The non-gcc building scheme requires manually setting up environment
31##   variables and is hardly tested at all
32
33## CFLAGS_OPTIMIZE_V, CFLAGS_DEBUG_V, CFLAGS_PROFILE_V are the values we
34## would want the corresponding macros to be set to.
35##
36## CFLAGS_OPTIMIZE, CFLAGS_DEBUG, CFLAGS_PROFILE are set by the
37## 'VARIANT=<OPTIMIZE|DEBUG|PROFILE>' targets to their _V values.
38
39## XCPPFLAGS, XCFLAGS, XCXXFLAGS, XASFLAGS
40## are used to add flags from the shell
41## cf. make.info ("Implicit rules/variables" for details)
42
43if RTEMS_USE_GCC
44## All the stuff below is specific to gcc
45
46CFLAGS_DEFAULT=-g -Wall
47## gcc >= 2.8.x
48GCCSPECS = $(GCC_SPECS) $(RTEMS_BSP_SPECS)
49else
50## fall back to the old style compilers/*.cfg
51## CONFIG.CC is supposed to be provided by <BSP>.cfg
52include $(CONFIG.CC)
53endif # RTEMS_USE_GCC
54
55DEFS = @DEFS@
56
57CPPFLAGS = @CPPFLAGS@ $(CPU_DEFINES) \
58   $(DEFINES) $(XCPPFLAGS) $(CPPFLAGS_GCC)
59CFLAGS   = $(CFLAGS_DEFAULT) $(CPU_CFLAGS) $(XCFLAGS)
60CXXFLAGS = $(CFLAGS_DEFAULT) $(CPU_CFLAGS) $(XCXXFLAGS)
61ASFLAGS  = $(CPU_ASFLAGS) $(CPU_CFLAGS) $(XASFLAGS)
62
63LINK_LIBS = $(LD_LIBS)
64
65## FIXME: This doesn't seem to be correct
66# when debugging, optimize flag: typically empty
67# some compilers do allow optimization with their "-g"
68CFLAGS_DEBUG_OPTIMIZE_V=-g
69CXXFLAGS_DEBUG_OPTIMIZE_V=-g
70LDFLAGS_DEBUG_V =
71
72# profile flag; use gprof(1)
73CFLAGS_PROFILE_V=-pg
74CXXFLAGS_PROFILE_V=-pg
75LDFLAGS_PROFILE_V =
76
77# List of library paths without -L
78LD_PATHS= $(PROJECT_RELEASE)/lib
79
80# ld flag for incomplete link
81LDFLAGS_INCOMPLETE = -r
82
83# ld flags for profiling, debugging
84LDFLAGS=$(LDFLAGS_PROFILE) $(LDFLAGS_DEBUG) $(LD_PATHS:%=-L %)
85
86#
87# Client compiler and support tools
88#
89
90#
91# How to compile stuff into ${ARCH} subdirectory
92#
93
94COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
95        $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
96CCLD = $(CC)
97LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
98        $(AM_LDFLAGS) $(LDFLAGS) -o $@
99
100CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
101        $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
102CXXLD = $(CXX)
103CXXLINK = $(CXXLD) $(AM_CXXFLAGS) $(CXXFLAGS) \
104        $(AM_LDFLAGS) $(LDFLAGS) -o $@
105
106AS = $(CC)
107ASCOMPILE = $(AS) $(AM_ASFLAGS) $(ASFLAGS)
108
109${ARCH}/%.o: %.c
110        ${COMPILE} -o $@ -c $<
111
112${ARCH}/%.o: %.cc
113        ${CXXCOMPILE} -o $@ -c $<
114
115${ARCH}/%.o: %.cpp
116        ${CXXCOMPILE} -o $@ -c $<
117
118${ARCH}/%.o: %.cxx
119        ${CXXCOMPILE} -o $@ -c $<
120
121${ARCH}/%.o: %.C
122        ${CXXCOMPILE} -o $@ -c $<
123
124${ARCH}/%.o: %.S
125        ${ASCOMPILE} -DASM -o $@ -c $<
126
127# Make foo.rel from foo.o
128${ARCH}/%.rel: ${ARCH}/%.o
129        ${make-rel}
130
131# Dependency files for use by gmake
132# NOTE: we don't put them into $(ARCH)
133#       so that 'make clean' doesn't blow it away
134
135DEPEND=Depends-${ARCH}
136
137CLEAN_DEPEND=$(DEPEND).tmp
138CLOBBER_DEPEND=$(DEPEND)
139
140# We deliberately don't have anything depend on the
141# $(DEPEND) file; otherwise it will get rebuilt even
142# on 'make clean'
143#
144
145## HACK: Specific to gcc
146## FIXME: The approach below is known to be conceptionally broken.
147depend-am: $(C_FILES) $(CC_FILES) $(S_FILES)
148##       Use gcc -M to generate dependencies
149##       Replace foo.o with $(ARCH)/foo.o
150##       Replace $(ARCH) value with string $(ARCH)
151##           so that it will for debug and profile cases
152        $(COMPILE) -M   $^    |  \
153        sed -e 's?^\(.*\)\.o[ ]*:?$$(ARCH)/\1.o:?' \
154            -e 's?$(ARCH)/?$$(ARCH)/?'   >$(DEPEND).tmp
155        mv $(DEPEND).tmp $(DEPEND)
156depend: depend-am
157
158# pull in dependencies if they exist 
159ifeq (${DEPEND},$(wildcard ${DEPEND}))
160include ${DEPEND}
161@ENDIF@
162
163
164# spell out all the LINK_FILE's, rather than using -lbsp, so
165#  that $(LINK_FILES) can be a dependency
166
167LINK_OBJS = \
168    $(OBJS) \
169    $(MANAGERS_NOT_WANTED:%=$(PROJECT_RELEASE)/lib/no-%$(LIB_VARIANT).rel)
170
171LINK_FILES =\
172    $(START_FILE) \
173    $(OBJS) \
174    $(MANAGERS_NOT_WANTED:%=$(PROJECT_RELEASE)/lib/no-%$(LIB_VARIANT).rel)
175
176if RTEMS_USE_GCC
177## gcc >= 2.8
178define make-rel
179        $(LINK) -qnolinkcmds -nostdlib -Wl,-r $(XLDFLAGS) $^
180endef
181else
182## non-gcc
183define make-rel
184        $(LINK) $(XLDFLAGS) $^
185endef
186endif
187
188## -------------------------------------------------------------------------
189
190## translate VARIANT into VARIANT_V
191VARIANT = OPTIMIZE
192
193VARIANT_OPTIMIZE_V = OPTIMIZE
194VARIANT_DEBUG_V = DEBUG
195VARIANT_PROFILE_V = PROFILE
196VARIANT_optimize_V = OPTIMIZE
197VARIANT_debug_V = DEBUG
198VARIANT_profile_V = PROFILE
199
200VARIANT_V = $(VARIANT_$(VARIANT)_V)
201
202## Setup the variant build subdirectory
203ARCH_OPTIMIZE_V = o-optimize
204ARCH_DEBUG_V = o-debug
205ARCH_PROFILE_V = o-profile
206
207ARCH__V = $(ARCH_OPTIMIZE_V)
208ARCH = $(ARCH_$(VARIANT_V)_V)
209
210## Setup the library suffix
211LIBSUFFIX_OPTIMIZE_V =
212LIBSUFFIX_DEBUG_V = _g
213LIBSUFFIX_PROFILE_V = _p
214LIBSUFFIX__V = $(LIBSUFFIX_OPTIMIZE_V)
215
216LIB_VARIANT = $(LIBSUFFIX_$(VARIANT_V)_V)
217LIBSUFFIX_VA = $(LIB_VARIANT).a
218
219## These are supposed to be set in make/custom/<bsp>.cfg
220## CFLAGS_OPTIMIZE_V =
221## CFLAGS_DEBUG_V =
222## CFLAGS_PROFILE_V =
223CFLAGS__V = $(CFLAGS_OPTIMIZE_V)
224
225## ------------------------------------------------------------------------
226## Setup hard-coded flags
227if RTEMS_USE_GCC
228## gcc >= gcc-2.8
229RTEMS_CFLAGS_OPTIMIZE_V =
230RTEMS_CFLAGS_DEBUG_V = -qrtems_debug -Wno-unused
231RTEMS_CFLAGS_PROFILE_V =
232
233## non-gcc
234## We can't guess what flags might be required here.
235## Pass the values from the environment if you want to apply them.
236endif
237RTEMS_CFLAGS__V = $(RTEMS_CFLAGS_OPTIMIZE_V)
238
239## -------------------------------------------------------------------------
240
241CC = @CC@ $(GCCSPECS)
242CXX = @CXX@ $(GCCSPECS)
243CPP = @CPP@ $(GCCSPECS)
244
245LD = @LD@
246OBJCOPY = @OBJCOPY@
247NM = @NM@
248SIZE = @SIZE@
249STRIP = @STRIP@
250
251
252##
253AM_CPPFLAGS = $(RTEMS_CPPFLAGS)
254
255AM_CFLAGS = $(RTEMS_CFLAGS_$(VARIANT_V)_V) $(CFLAGS_$(VARIANT_V)_V)
256AM_CXXFLAGS = $(RTEMS_CFLAGS_$(VARIANT_V)_V) $(CFLAGS_$(VARIANT_V)_V)
Note: See TracBrowser for help on using the repository browser.