source: rtems/automake/compile.am @ 372e4e2

4.104.114.84.95
Last change on this file since 372e4e2 was 372e4e2, checked in by Joel Sherrill <joel.sherrill@…>, on 09/13/00 at 13:08:11

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

  • aclocal/rtems-top.m4: Add ENDIF-hack.
  • automake/compile.am: Add include $(DEPENDS) + ENDIF-hack.
  • Property mode set to 100644
File size: 8.3 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
[372e4e2]178# pull in dependencies if they exist 
179ifeq (${DEPEND},$(wildcard ${DEPEND}))
180include ${DEPEND}
181@ENDIF@
182
183
[1ea70d78]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
276## FIXME: This will probably vanish, when GNU canonicalization will be
277## introduced
278
279CC = $(CC_FOR_TARGET) $(GCCSPECS)
280CXX = $(CXX_FOR_TARGET) $(GCCSPECS)
281AR_FOR_TARGET = @AR_FOR_TARGET@
282AR = $(AR_FOR_TARGET)
283AS_FOR_TARGET = @AS_FOR_TARGET@
284AS = $(AS_FOR_TARGET)
285RANLIB_FOR_TARGET = @RANLIB_FOR_TARGET@
286RANLIB = $(RANLIB_FOR_TARGET)
287LD_FOR_TARGET = @LD_FOR_TARGET@
288LD = $(LD_FOR_TARGET)
289NM_FOR_TARGET = @NM_FOR_TARGET@
290NM = $(NM_FOR_TARGET)
291OBJCOPY_FOR_TARGET = @OBJCOPY_FOR_TARGET@
292OBJCOPY = $(OBJCOPY_FOR_TARGET)
293SIZE_FOR_TARGET = @SIZE_FOR_TARGET@
294SIZE = $(SIZE_FOR_TARGET)
295STRIP_FOR_TARGET = @STRIP_FOR_TARGET@
296STRIP = $(STRIP_FOR_TARGET)
297
[03d5706]298##
299## FIXME: DEFS and INCLUDES should not be passed as AM_CPPFLAGS
300AM_CPPFLAGS += $(DEFS) $(INCLUDES) $(RTEMS_CPPFLAGS)
[1ea70d78]301
302AM_CFLAGS += $(RTEMS_CFLAGS_$(VARIANT_V)_V) $(CFLAGS_$(VARIANT_V)_V)
303AM_CXXFLAGS += $(RTEMS_CFLAGS_$(VARIANT_V)_V) $(CFLAGS_$(VARIANT_V)_V)
Note: See TracBrowser for help on using the repository browser.