source: rtems/automake/compile.am @ a0ea6f1

4.104.114.84.95
Last change on this file since a0ea6f1 was a0ea6f1, checked in by Joel Sherrill <joel.sherrill@…>, on 01/06/02 at 20:12:13

2002-02-05 Ralf Corsepius <corsepiu@…>

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