source: rtems/automake/compile.am @ bfba54e

4.104.114.84.9
Last change on this file since bfba54e was bfba54e, checked in by Joel Sherrill <joel.sherrill@…>, on Oct 10, 2001 at 12:22:21 AM

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

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