source: rtems/automake/compile.am @ 4dc2e9a

4.104.114.84.9
Last change on this file since 4dc2e9a was 4dc2e9a, checked in by Joel Sherrill <joel.sherrill@…>, on Jan 3, 2001 at 6:47:07 PM

2001-01-03 Emmanuel Raguet <raguet@…>

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