source: rtems/automake/compile.am @ 35b2275

4.104.114.84.9
Last change on this file since 35b2275 was 35b2275, checked in by Ralf Corsepius <ralf.corsepius@…>, on Jul 22, 2002 at 9:17:40 AM

2002-07-22 Ralf Corsepius <corsepiu@…>

  • aclocal/bsp-configure.m4: Add RTEMS_CHECK_MULTIPROCESSING.
automake/compile.am: Add test -d $(ARCH)
mkdir $(ARCH) to all

compilation rules (Work-around to an automake bug).

automake/lib.am: Add test -d $(ARCH)
mkdir $(ARCH) to

make-library.

  • Property mode set to 100644
File size: 6.7 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        test -d $(ARCH) || mkdir $(ARCH)
111        ${COMPILE} -o $@ -c $<
112
113${ARCH}/%.o: %.cc
114        test -d $(ARCH) || mkdir $(ARCH)
115        ${CXXCOMPILE} -o $@ -c $<
116
117${ARCH}/%.o: %.cpp
118        test -d $(ARCH) || mkdir $(ARCH)
119        ${CXXCOMPILE} -o $@ -c $<
120
121${ARCH}/%.o: %.cxx
122        test -d $(ARCH) || mkdir $(ARCH)
123        ${CXXCOMPILE} -o $@ -c $<
124
125${ARCH}/%.o: %.C
126        test -d $(ARCH) || mkdir $(ARCH)
127        ${CXXCOMPILE} -o $@ -c $<
128
129${ARCH}/%.o: %.S
130        test -d $(ARCH) || mkdir $(ARCH)
131        ${ASCOMPILE} -DASM -o $@ -c $<
132
133# Make foo.rel from foo.o
134${ARCH}/%.rel: ${ARCH}/%.o
135        test -d $(ARCH) || mkdir $(ARCH)
136        ${make-rel}
137
138# Dependency files for use by gmake
139# NOTE: we don't put them into $(ARCH)
140#       so that 'make clean' doesn't blow it away
141
142DEPEND=Depends-${ARCH}
143
144CLEAN_DEPEND=$(DEPEND).tmp
145CLOBBER_DEPEND=$(DEPEND)
146
147# We deliberately don't have anything depend on the
148# $(DEPEND) file; otherwise it will get rebuilt even
149# on 'make clean'
150#
151
152## HACK: Specific to gcc
153## FIXME: The approach below is known to be conceptionally broken.
154depend-am: $(C_FILES) $(CC_FILES) $(S_FILES)
155##       Use gcc -M to generate dependencies
156##       Replace foo.o with $(ARCH)/foo.o
157##       Replace $(ARCH) value with string $(ARCH)
158##           so that it will for debug and profile cases
159        $(COMPILE) -M   $^    |  \
160        sed -e 's?^\(.*\)\.o[ ]*:?$$(ARCH)/\1.o:?' \
161            -e 's?$(ARCH)/?$$(ARCH)/?'   >$(DEPEND).tmp
162        mv $(DEPEND).tmp $(DEPEND)
163depend: depend-am
164
165# pull in dependencies if they exist 
166ifeq (${DEPEND},$(wildcard ${DEPEND}))
167include ${DEPEND}
168@ENDIF@
169
170
171# spell out all the LINK_FILE's, rather than using -lbsp, so
172#  that $(LINK_FILES) can be a dependency
173
174LINK_OBJS = \
175    $(OBJS) \
176    $(MANAGERS_NOT_WANTED:%=$(PROJECT_RELEASE)/lib/no-%$(LIB_VARIANT).rel)
177
178LINK_FILES =\
179    $(START_FILE) \
180    $(OBJS) \
181    $(MANAGERS_NOT_WANTED:%=$(PROJECT_RELEASE)/lib/no-%$(LIB_VARIANT).rel)
182
183if RTEMS_USE_GCC
184## gcc >= 2.8
185define make-rel
186        $(LINK) -qnolinkcmds -nostdlib -Wl,-r $(XLDFLAGS) $^
187endef
188else
189## non-gcc
190define make-rel
191        $(LINK) $(XLDFLAGS) $^
192endef
193endif
194
195## -------------------------------------------------------------------------
196
197## translate VARIANT into VARIANT_V
198VARIANT = OPTIMIZE
199
200VARIANT_OPTIMIZE_V = OPTIMIZE
201VARIANT_DEBUG_V = DEBUG
202VARIANT_PROFILE_V = PROFILE
203VARIANT_optimize_V = OPTIMIZE
204VARIANT_debug_V = DEBUG
205VARIANT_profile_V = PROFILE
206
207VARIANT_V = $(VARIANT_$(VARIANT)_V)
208
209## Setup the variant build subdirectory
210ARCH_OPTIMIZE_V = o-optimize
211ARCH_DEBUG_V = o-debug
212ARCH_PROFILE_V = o-profile
213
214ARCH__V = $(ARCH_OPTIMIZE_V)
215ARCH = $(ARCH_$(VARIANT_V)_V)
216
217## Setup the library suffix
218LIBSUFFIX_OPTIMIZE_V =
219LIBSUFFIX_DEBUG_V = _g
220LIBSUFFIX_PROFILE_V = _p
221LIBSUFFIX__V = $(LIBSUFFIX_OPTIMIZE_V)
222
223LIB_VARIANT = $(LIBSUFFIX_$(VARIANT_V)_V)
224LIBSUFFIX_VA = $(LIB_VARIANT).a
225
226## These are supposed to be set in make/custom/<bsp>.cfg
227## CFLAGS_OPTIMIZE_V =
228## CFLAGS_DEBUG_V =
229## CFLAGS_PROFILE_V =
230CFLAGS__V = $(CFLAGS_OPTIMIZE_V)
231
232## ------------------------------------------------------------------------
233## Setup hard-coded flags
234if RTEMS_USE_GCC
235## gcc >= gcc-2.8
236RTEMS_CFLAGS_OPTIMIZE_V =
237RTEMS_CFLAGS_DEBUG_V = -qrtems_debug -Wno-unused
238RTEMS_CFLAGS_PROFILE_V =
239
240## non-gcc
241## We can't guess what flags might be required here.
242## Pass the values from the environment if you want to apply them.
243endif
244RTEMS_CFLAGS__V = $(RTEMS_CFLAGS_OPTIMIZE_V)
245
246## -------------------------------------------------------------------------
247
248CC = @CC@ $(GCCSPECS)
249CXX = @CXX@ $(GCCSPECS)
250CPP = @CPP@ $(GCCSPECS)
251
252LD = @LD@
253OBJCOPY = @OBJCOPY@
254NM = @NM@
255SIZE = @SIZE@
256STRIP = @STRIP@
257
258
259##
260AM_CPPFLAGS = $(RTEMS_CPPFLAGS)
261
262AM_CFLAGS = $(RTEMS_CFLAGS_$(VARIANT_V)_V) $(CFLAGS_$(VARIANT_V)_V)
263AM_CXXFLAGS = $(RTEMS_CFLAGS_$(VARIANT_V)_V) $(CFLAGS_$(VARIANT_V)_V)
Note: See TracBrowser for help on using the repository browser.