source: rtems/automake/compile.am @ c274328b

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

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.8 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
204# FIXME: Do we want this? Only useful below tests/.
205#    $(PROJECT_RELEASE)/lib$(MULTISUBDIR)/librtemcpu$(LIBSUFFIX_VA)
206#    $(PROJECT_RELEASE)/lib/librtembsp$(LIBSUFFIX_VA)
207
208if RTEMS_USE_GCC
209if RTEMS_USE_GCC272
210define make-rel
211        $(LINK) -nostdlib -Wl,-r $(XLDFLAGS) $^
212endef
213else
214## gcc >= 2.8
215define make-rel
216        $(LINK) -qnolinkcmds -nostdlib -Wl,-r $(XLDFLAGS) $^
217endef
218endif
219else
220## non-gcc
221define make-rel
222        $(LINK) $(XLDFLAGS) $^
223endef
224endif
225
226## -------------------------------------------------------------------------
227
228## translate VARIANT into VARIANT_V
229VARIANT = OPTIMIZE
230
231VARIANT_OPTIMIZE_V = OPTIMIZE
232VARIANT_DEBUG_V = DEBUG
233VARIANT_PROFILE_V = PROFILE
234VARIANT_optimize_V = OPTIMIZE
235VARIANT_debug_V = DEBUG
236VARIANT_profile_V = PROFILE
237
238VARIANT_V = $(VARIANT_$(VARIANT)_V)
239
240## Setup the variant build subdirectory
241ARCH_OPTIMIZE_V = o-optimize
242ARCH_DEBUG_V = o-debug
243ARCH_PROFILE_V = o-profile
244
245ARCH__V = $(ARCH_OPTIMIZE_V)
246ARCH = $(ARCH_$(VARIANT_V)_V)
247
248## Setup the library suffix
249LIBSUFFIX_OPTIMIZE_V =
250LIBSUFFIX_DEBUG_V = _g
251LIBSUFFIX_PROFILE_V = _p
252LIBSUFFIX__V = $(LIBSUFFIX_OPTIMIZE_V)
253
254LIB_VARIANT = $(LIBSUFFIX_$(VARIANT_V)_V)
255LIBSUFFIX_VA = $(LIB_VARIANT).a
256
257## These are supposed to be set in make/custom/<bsp>.cfg
258## CFLAGS_OPTIMIZE_V =
259## CFLAGS_DEBUG_V =
260## CFLAGS_PROFILE_V =
261CFLAGS__V = $(CFLAGS_OPTIMIZE_V)
262
263## ------------------------------------------------------------------------
264## Setup hard-coded flags
265if RTEMS_USE_GCC
266if RTEMS_USE_GCC272
267## gcc < gcc-2.8
268RTEMS_CFLAGS_OPTIMIZE_V =
269RTEMS_CFLAGS_DEBUG_V = -Wno-unused
270RTEMS_CFLAGS_PROFILE_V =
271else
272## gcc >= gcc-2.8
273RTEMS_CFLAGS_OPTIMIZE_V =
274RTEMS_CFLAGS_DEBUG_V = -qrtems_debug -Wno-unused
275RTEMS_CFLAGS_PROFILE_V =
276endif
277## non-gcc
278## We can't guess what flags might be required here.
279## Pass the values from the environment if you want to apply them.
280endif
281RTEMS_CFLAGS__V = $(RTEMS_CFLAGS_OPTIMIZE_V)
282
283## -------------------------------------------------------------------------
284
285CC = @CC@ $(GCCSPECS)
286CXX = @CXX@ $(GCCSPECS)
287CPP = @CPP@ $(GCCSPECS)
288
289LD = @LD@
290OBJCOPY = @OBJCOPY@
291NM = @NM@
292SIZE = @SIZE@
293STRIP = @STRIP@
294
295
296##
297AM_CPPFLAGS = $(RTEMS_CPPFLAGS)
298
299AM_CFLAGS = $(RTEMS_CFLAGS_$(VARIANT_V)_V) $(CFLAGS_$(VARIANT_V)_V)
300AM_CXXFLAGS = $(RTEMS_CFLAGS_$(VARIANT_V)_V) $(CFLAGS_$(VARIANT_V)_V)
Note: See TracBrowser for help on using the repository browser.