source: rtems/automake/compile.am @ f92cc34

4.104.114.84.95
Last change on this file since f92cc34 was a34b245, checked in by Joel Sherrill <joel.sherrill@…>, on 10/29/01 at 14:39:50

2001-10-29 Ralf Corsepius <corsepiu@…>

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