source: rtems/automake/compile.am @ 1ea70d78

4.104.114.84.95
Last change on this file since 1ea70d78 was 1ea70d78, checked in by Joel Sherrill <joel.sherrill@…>, on 09/12/00 at 20:54:13

2000-09-12 Ralf Corsepius <corsepiu@…>

  • aclocal/check-cxx.m4: Add AC_SUBST(CPLUS_LD_LIBS)
  • aclocal/prog-cc.m4: Cleanup comments, require RTEMS_ENABLE_GCC28, add automake conditionals RTEMS_USE_GCC, RTEMS_USE_GCC272.
  • automake/compile.am: Replaced.
  • automake/local.am: Remove building variant handling.
  • Property mode set to 100644
File size: 8.2 KB
RevLine 
[7294718f]1##
2## $Id$
3##
[03d5706]4
5## -------------------------------------------------------------------------
[1ea70d78]6## NOTE: This file is rather immature and has to be considered to be
7## almost experimental.
[03d5706]8##
[1ea70d78]9## Expect frequent changes -- It deserves to be cleaned up :(
[03d5706]10## -------------------------------------------------------------------------
11
[1ea70d78]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 = $(shell $(CC) $(CPU_CFLAGS) -print-file-name=libc.a $(GCCSED))
58LIBC_LIBM = $(shell $(CC) $(CPU_CFLAGS) -print-file-name=libm.a $(GCCSED))
59LIBC_LIBGCC = $(shell $(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)
65else
66## gcc >= 2.8.x
67## FIXME: This is BSP-specific and will fail for BSP-independent directories
68GCCSPECS = -B$(PROJECT_RELEASE)/lib/ -specs bsp_specs -qrtems
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
[03d5706]76DEFS = @DEFS@
77
[1ea70d78]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
111## HACK: specific to gcc
112## FIXME: Do we call the correct CPP, why aren't
113## CPPFLAGS and CFLAGS part of this call?
114# CPP command to write file to standard output
115CPP=$(CC) -E -ansi -w -Wp,-$$
116
117ARFLAGS=ruv
118
119#
120# How to compile stuff into ${ARCH} subdirectory
121#
122
123${ARCH}/%.o: %.c
124        ${COMPILE.c} $(AM_CPPFLAGS) $(AM_CFLAGS) -o $@ $<
125
126${ARCH}/%.o: %.cc
127        ${COMPILE.cc} $(AM_CPPFLAGS) $(AM_CXXFLAGS) -o $@ $<
128
129${ARCH}/%.o: %.cpp
130        ${COMPILE.cc} $(AM_CPPFLAGS) $(AM_CXXFLAGS) -o $@ $<
131
132${ARCH}/%.o: %.cxx
133        ${COMPILE.cc} $(AM_CPPFLAGS) $(AM_CXXFLAGS) -o $@ $<
134
135${ARCH}/%.o: %.C
136        ${COMPILE.cc} $(AM_CPPFLAGS) $(AM_CXXFLAGS) -o $@ $<
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.c) $(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# 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
270## FIXME: This will probably vanish, when GNU canonicalization will be
271## introduced
272
273CC = $(CC_FOR_TARGET) $(GCCSPECS)
274CXX = $(CXX_FOR_TARGET) $(GCCSPECS)
275AR_FOR_TARGET = @AR_FOR_TARGET@
276AR = $(AR_FOR_TARGET)
277AS_FOR_TARGET = @AS_FOR_TARGET@
278AS = $(AS_FOR_TARGET)
279RANLIB_FOR_TARGET = @RANLIB_FOR_TARGET@
280RANLIB = $(RANLIB_FOR_TARGET)
281LD_FOR_TARGET = @LD_FOR_TARGET@
282LD = $(LD_FOR_TARGET)
283NM_FOR_TARGET = @NM_FOR_TARGET@
284NM = $(NM_FOR_TARGET)
285OBJCOPY_FOR_TARGET = @OBJCOPY_FOR_TARGET@
286OBJCOPY = $(OBJCOPY_FOR_TARGET)
287SIZE_FOR_TARGET = @SIZE_FOR_TARGET@
288SIZE = $(SIZE_FOR_TARGET)
289STRIP_FOR_TARGET = @STRIP_FOR_TARGET@
290STRIP = $(STRIP_FOR_TARGET)
291
[03d5706]292##
293## FIXME: DEFS and INCLUDES should not be passed as AM_CPPFLAGS
294AM_CPPFLAGS += $(DEFS) $(INCLUDES) $(RTEMS_CPPFLAGS)
[1ea70d78]295
296AM_CFLAGS += $(RTEMS_CFLAGS_$(VARIANT_V)_V) $(CFLAGS_$(VARIANT_V)_V)
297AM_CXXFLAGS += $(RTEMS_CFLAGS_$(VARIANT_V)_V) $(CFLAGS_$(VARIANT_V)_V)
Note: See TracBrowser for help on using the repository browser.