source: rtems/automake/compile.am @ 560aae24

4.104.114.84.95
Last change on this file since 560aae24 was 560aae24, checked in by Joel Sherrill <joel.sherrill@…>, on 01/29/01 at 15:27:25

2001-01-26 Ralf Corsepius <corsepiu@…>

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