Deleted Added
sdiff udiff text old ( 216804 ) new ( 217123 )
full compact
1# $FreeBSD: head/gnu/lib/libgcc/Makefile 216804 2010-12-29 17:12:05Z kan $
2
3GCCDIR= ${.CURDIR}/../../../contrib/gcc
4GCCLIB= ${.CURDIR}/../../../contrib/gcclibs
5
6SHLIB_NAME= libgcc_s.so.1
7SHLIBDIR?= /lib
8
9.include <bsd.own.mk>
10#
11# libgcc is linked in last and thus cannot depend on ssp symbols coming
12# from earlier libraries. Disable stack protection for this library.
13#
14MK_SSP= no
15
16.include "${.CURDIR}/../../usr.bin/cc/Makefile.tgt"
17
18.if ${TARGET_CPUARCH} == "sparc64" || ${TARGET_CPUARCH} == "mips"
19LIB= gcc
20.endif
21
22.PATH: ${GCCDIR}/config/${GCC_CPU} ${GCCDIR}/config ${GCCDIR}
23
24CFLAGS+= -DIN_GCC -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED \
25 -DHAVE_GTHR_DEFAULT \
26 -I${GCCLIB}/include \
27 -I${GCCDIR}/config -I${GCCDIR} -I. \
28 -I${.CURDIR}/../../usr.bin/cc/cc_tools
29
30LDFLAGS+= -nodefaultlibs
31LDADD+= -lc
32
33OBJS= # added to below in various ways depending on TARGET_CPUARCH
34
35#---------------------------------------------------------------------------
36#
37# When upgrading GCC, get the following defintions straight from Makefile.in
38#
39# Library members defined in libgcc2.c.
40LIB2FUNCS= _muldi3 _negdi2 _lshrdi3 _ashldi3 _ashrdi3 \
41 _cmpdi2 _ucmpdi2 _clear_cache \
42 _enable_execute_stack _trampoline __main _absvsi2 _absvdi2 _addvsi3 \
43 _addvdi3 _subvsi3 _subvdi3 _mulvsi3 _mulvdi3 _negvsi2 _negvdi2 _ctors \
44 _ffssi2 _ffsdi2 _clz _clzsi2 _clzdi2 _ctzsi2 _ctzdi2 _popcount_tab \
45 _popcountsi2 _popcountdi2 _paritysi2 _paritydi2 _powisf2 _powidf2 \
46 _powixf2 _powitf2 _mulsc3 _muldc3 _mulxc3 _multc3 _divsc3 _divdc3 \
47 _divxc3 _divtc3
48
49# The floating-point conversion routines that involve a single-word integer.
50.for mode in sf df xf
51LIB2FUNCS+= _fixuns${mode}si
52.endfor
53
54# Likewise double-word routines.
55.for mode in sf df xf tf
56LIB2FUNCS+= _fix${mode}di _fixuns${mode}di
57LIB2FUNCS+= _floatdi${mode} _floatundi${mode}
58.endfor
59
60LIB2ADD = $(LIB2FUNCS_EXTRA)
61LIB2ADD_ST = $(LIB2FUNCS_STATIC_EXTRA)
62
63# Additional sources to handle exceptions; overridden by targets as needed.
64LIB2ADDEH = unwind-dw2.c unwind-dw2-fde-glibc.c unwind-sjlj.c gthr-gnat.c \
65 unwind-c.c
66LIB2ADDEHSTATIC = $(LIB2ADDEH)
67LIB2ADDEHSHARED = $(LIB2ADDEH)
68
69# List of extra C and assembler files to add to static and shared libgcc2.
70# Assembler files should have names ending in `.asm'.
71LIB2FUNCS_EXTRA =
72
73# List of extra C and assembler files to add to static libgcc2.
74# Assembler files should have names ending in `.asm'.
75LIB2FUNCS_STATIC_EXTRA =
76
77# Defined in libgcc2.c, included only in the static library.
78# KAN: Excluded _sf_to_tf and _df_to_tf as TPBIT_FUNCS are not
79# built on any of our platforms.
80LIB2FUNCS_ST = _eprintf __gcc_bcmp
81
82FPBIT_FUNCS = _pack_sf _unpack_sf _addsub_sf _mul_sf _div_sf \
83 _fpcmp_parts_sf _compare_sf _eq_sf _ne_sf _gt_sf _ge_sf \
84 _lt_sf _le_sf _unord_sf _si_to_sf _sf_to_si _negate_sf _make_sf \
85 _sf_to_df _thenan_sf _sf_to_usi _usi_to_sf
86
87DPBIT_FUNCS = _pack_df _unpack_df _addsub_df _mul_df _div_df \
88 _fpcmp_parts_df _compare_df _eq_df _ne_df _gt_df _ge_df \
89 _lt_df _le_df _unord_df _si_to_df _df_to_si _negate_df _make_df \
90 _df_to_sf _thenan_df _df_to_usi _usi_to_df
91
92TPBIT_FUNCS = _pack_tf _unpack_tf _addsub_tf _mul_tf _div_tf \
93 _fpcmp_parts_tf _compare_tf _eq_tf _ne_tf _gt_tf _ge_tf \
94 _lt_tf _le_tf _unord_tf _si_to_tf _tf_to_si _negate_tf _make_tf \
95 _tf_to_df _tf_to_sf _thenan_tf _tf_to_usi _usi_to_tf
96
97# These might cause a divide overflow trap and so are compiled with
98# unwinder info.
99LIB2_DIVMOD_FUNCS = _divdi3 _moddi3 _udivdi3 _umoddi3 _udiv_w_sdiv _udivmoddi4
100
101#-----------------------------------------------------------------------
102#
103# Platform specific bits.
104# When upgrading GCC, get the following definitions from config/<cpu>/t-*
105#
106.if ${TARGET_CPUARCH} == "arm"
107# from config/arm/t-strongarm-elf
108CFLAGS+= -Dinhibit_libc -fno-inline
109LIB1ASMSRC = lib1funcs.asm
110LIB1ASMFUNCS = _dvmd_tls _bb_init_func
111LIB2FUNCS_EXTRA = floatunsidf.c floatunsisf.c
112
113# Not now
114#LIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_tls _bb_init_func
115#LIB1ASMFUNCS+= _call_via_rX _interwork_call_via_rX \
116# _lshrdi3 _ashrdi3 _ashldi3 \
117# _negdf2 _addsubdf3 _muldivdf3 _cmpdf2 _unorddf2 _fixdfsi _fixunsdfsi \
118# _truncdfsf2 _negsf2 _addsubsf3 _muldivsf3 _cmpsf2 _unordsf2 \
119# _fixsfsi _fixunssfsi _floatdidf _floatdisf
120.endif
121
122.if ${TARGET_CPUARCH} == "mips"
123LIB2FUNCS_EXTRA = floatunsidf.c floatunsisf.c
124.if defined(TARGET_ABI) && ${TARGET_ABI} != "o32"
125LIB2FUNCS_EXTRA+= floatdidf.c fixunsdfsi.c
126LIB2FUNCS_EXTRA+= floatdisf.c floatundidf.c
127LIB2FUNCS_EXTRA+= fixsfdi.c floatundisf.c
128LIB2FUNCS_EXTRA+= fixdfdi.c fixunssfsi.c
129.endif
130.endif
131
132.if ${TARGET_CPUARCH} == "ia64"
133# from config/ia64/t-ia64
134LIB1ASMSRC = lib1funcs.asm
135LIB1ASMFUNCS = __divxf3 __divdf3 __divsf3 \
136 __divdi3 __moddi3 __udivdi3 __umoddi3 \
137 __divsi3 __modsi3 __udivsi3 __umodsi3 __save_stack_nonlocal \
138 __nonlocal_goto __restore_stack_nonlocal __trampoline \
139 _fixtfdi _fixunstfdi _floatditf
140LIB2ADDEH = unwind-ia64.c unwind-sjlj.c unwind-c.c
141.endif
142
143.if ${TARGET_ARCH} == "powerpc"
144# from config/rs6000/t-ppccomm
145LIB2FUNCS_EXTRA = tramp.asm
146LIB2FUNCS_STATIC_EXTRA = eabi.asm
147.endif
148
149.if ${TARGET_ARCH} == "powerpc64"
150# from config/rs6000/t-ppccomm
151LIB2FUNCS_EXTRA = tramp.asm
152.endif
153
154.if ${TARGET_CPUARCH} == "sparc64"
155# from config/sparc/t-elf
156LIB1ASMSRC = lb1spc.asm
157LIB1ASMFUNCS = _mulsi3 _divsi3 _modsi3
158.endif
159
160#-----------------------------------------------------------------------
161
162# Remove any objects from LIB2FUNCS and LIB2_DIVMOD_FUNCS that are
163# defined as optimized assembly code in LIB1ASMFUNCS.
164.if defined(LIB1ASMFUNCS)
165.for sym in ${LIB1ASMFUNCS}
166LIB2FUNCS:= ${LIB2FUNCS:S/${sym}//g}
167LIB2_DIVMOD_FUNCS:= ${LIB2_DIVMOD_FUNCS:S/${sym}//g}
168.endfor
169.endif
170
171COMMONHDRS= tm.h tconfig.h options.h unwind.h gthr-default.h
172
173#-----------------------------------------------------------------------
174#
175# Helpful shortcuts for compiler invocations.
176#
177HIDE = -fvisibility=hidden -DHIDE_EXPORTS
178CC_T = ${CC} -c ${CFLAGS} ${HIDE} -fPIC
179CC_P = ${CC} -c ${CFLAGS} ${HIDE} -p -fPIC
180CC_S = ${CC} -c ${CFLAGS} ${PICFLAG} -DSHARED
181
182#-----------------------------------------------------------------------
183#
184# Functions from libgcc2.c
185#
186STD_CFLAGS =
187DIV_CFLAGS = -fexceptions -fnon-call-exceptions
188
189STD_FUNCS = ${LIB2FUNCS}
190DIV_FUNCS = ${LIB2_DIVMOD_FUNCS}
191
192STD_CFILE = libgcc2.c
193DIV_CFILE = libgcc2.c
194
195OBJ_GRPS = STD DIV
196
197#-----------------------------------------------------------------------
198#
199# Floating point emulation functions
200#
201.if ${TARGET_CPUARCH} == "armNOT_YET" || \
202 ${TARGET_CPUARCH} == "powerpc" || ${TARGET_CPUARCH} == "sparc64"
203
204FPBIT_CFLAGS = -DFINE_GRAINED_LIBRARIES -DFLOAT
205DPBIT_CFLAGS = -DFINE_GRAINED_LIBRARIES
206
207FPBIT_CFILE = config/fp-bit.c
208DPBIT_CFILE = config/fp-bit.c
209
210OBJ_GRPS += FPBIT DPBIT
211.endif
212
213#-----------------------------------------------------------------------
214#
215# Generic build rules for object groups defined above
216#
217.for T in ${OBJ_GRPS}
218${T}_OBJS_T = ${${T}_FUNCS:S/$/.o/}
219${T}_OBJS_P = ${${T}_FUNCS:S/$/.po/}
220${T}_OBJS_S = ${${T}_FUNCS:S/$/.So/}
221OBJS += ${${T}_FUNCS:S/$/.o/}
222
223${${T}_OBJS_T}: ${${T}_CFILE} ${COMMONHDRS}
224 ${CC_T} ${${T}_CFLAGS} -DL${.PREFIX} -o ${.TARGET} ${.ALLSRC:M*.c}
225${${T}_OBJS_P}: ${${T}_CFILE} ${COMMONHDRS}
226 ${CC_P} ${${T}_CFLAGS} -DL${.PREFIX} -o ${.TARGET} ${.ALLSRC:M*.c}
227${${T}_OBJS_S}: ${${T}_CFILE} ${COMMONHDRS}
228 ${CC_S} ${${T}_CFLAGS} -DL${.PREFIX} -o ${.TARGET} ${.ALLSRC:M*.c}
229.endfor
230
231#-----------------------------------------------------------------------
232#
233# Extra objects coming from separate files
234#
235.if !empty(LIB2ADD)
236OBJS += ${LIB2ADD:R:S/$/.o/}
237SOBJS += ${LIB2ADD:R:S/$/.So/}
238POBJS += ${LIB2ADD:R:S/$/.po/}
239.endif
240
241#-----------------------------------------------------------------------
242#
243# Objects that should be in static library only.
244#
245SYMS_ST = ${LIB2FUNCS_ST} ${LIB2ADD_ST}
246STAT_OBJS_T = ${SYMS_ST:S/$/.o/}
247STAT_OBJS_P = ${SYMS_ST:S/$/.po/}
248STATICOBJS = ${SYMS_ST:S/$/.o/}
249
250${STAT_OBJS_T}: ${STD_CFILE} ${COMMONHDRS}
251 ${CC_T} -DL${.PREFIX} -o ${.TARGET} ${.ALLSRC:M*.c}
252${STAT_OBJS_P}: ${STD_CFILE} ${COMMONHDRS}
253 ${CC_P} -DL${.PREFIX} -o ${.TARGET} ${.ALLSRC:M*.c}
254
255#-----------------------------------------------------------------------
256#
257# Assembler files.
258#
259.if defined(LIB1ASMSRC)
260ASM_T = ${LIB1ASMFUNCS:S/$/.o/}
261ASM_P = ${LIB1ASMFUNCS:S/$/.po/}
262ASM_S = ${LIB1ASMFUNCS:S/$/.So/}
263ASM_V = ${LIB1ASMFUNCS:S/$/.vis/}
264OBJS += ${LIB1ASMFUNCS:S/$/.o/}
265
266${ASM_T}: ${LIB1ASMSRC} ${.PREFIX}.vis
267 ${CC} -x assembler-with-cpp -c ${CFLAGS} -DL${.PREFIX} \
268 -o ${.TARGET} -include ${.PREFIX}.vis ${.ALLSRC:N*.h:N*.vis}
269${ASM_P}: ${LIB1ASMSRC} ${.PREFIX}.vis
270 ${CC} -x assembler-with-cpp -p -c ${CFLAGS} -DL${.PREFIX} \
271 -o ${.TARGET} -include ${.PREFIX}.vis ${.ALLSRC:N*.h:N*.vis}
272${ASM_S}: ${LIB1ASMSRC}
273 ${CC} -x assembler-with-cpp -c ${PICFLAG} ${CFLAGS} -DL${.PREFIX} \
274 -o ${.TARGET} ${.ALLSRC:N*.h}
275${ASM_V}: ${LIB1ASMSRC}
276 ${CC} -x assembler-with-cpp -c ${CFLAGS} -DL${.PREFIX} \
277 -o ${.PREFIX}.vo ${.ALLSRC:N*.h}
278 ( nm -pg ${.PREFIX}.vo | \
279 awk 'NF == 3 && $$2 !~ /^[UN]$$/ { print "\t.hidden ", $$3 }'\
280 ) > ${.TARGET}
281
282CLEANFILES += ${ASM_V} ${ASM_V:R:S/$/.vo/}
283.endif
284
285#-----------------------------------------------------------------------
286#
287# Exception handling / unwinding support.
288#
289EH_OBJS_T = ${LIB2ADDEHSTATIC:R:S/$/.o/}
290EH_OBJS_P = ${LIB2ADDEHSTATIC:R:S/$/.po/}
291EH_OBJS_S = ${LIB2ADDEHSHARED:R:S/$/.So/}
292EH_CFLAGS = -fexceptions -D__GLIBC__=3 -DElfW=__ElfN
293SOBJS += ${EH_OBJS_S}
294
295.for _src in ${LIB2ADDEHSTATIC}
296${_src:R:S/$/.o/}: ${_src} ${COMMONHDRS}
297 ${CC_T} ${EH_CFLAGS} -o ${.TARGET} ${.IMPSRC}
298${_src:R:S/$/.po/}: ${_src} ${COMMONHDRS}
299 ${CC_P} ${EH_CFLAGS} -o ${.TARGET} ${.IMPSRC}
300.endfor
301.for _src in ${LIB2ADDEHSHARED}
302${_src:R:S/$/.So/}: ${_src} ${COMMONHDRS}
303 ${CC_S} ${EH_CFLAGS} -o ${.TARGET} ${.IMPSRC}
304.endfor
305
306
307#-----------------------------------------------------------------------
308#
309# Generated headers
310#
311${COMMONHDRS}: ${.CURDIR}/../../usr.bin/cc/cc_tools/Makefile
312 ${MAKE} -f ${.ALLSRC} MFILE=${.ALLSRC} GCCDIR=${GCCDIR} ${.TARGET}
313
314CLEANFILES += ${COMMONHDRS}
315CLEANFILES += cs-*.h option*
316
317#-----------------------------------------------------------------------
318#
319# Build symbol version map
320#
321SHLIB_MKMAP = ${GCCDIR}/mkmap-symver.awk
322SHLIB_MKMAP_OPTS =
323SHLIB_MAPFILES = ${GCCDIR}/libgcc-std.ver
324VERSION_MAP = libgcc.map
325
326libgcc.map: ${SHLIB_MKMAP} ${SHLIB_MAPFILES} ${SOBJS} ${OBJS:R:S/$/.So/}
327 ( nm -pg ${SOBJS};echo %% ; \
328 cat ${SHLIB_MAPFILES} \
329 | sed -e '/^[ ]*#/d' \
330 -e 's/^%\(if\|else\|elif\|endif\|define\)/#\1/' \
331 | ${CC} ${CFLAGS} -E -xassembler-with-cpp -; \
332 ) | awk -f ${SHLIB_MKMAP} ${SHLIB_MKMAP_OPTS} > ${.TARGET}
333
334CLEANFILES += libgcc.map
335
336#-----------------------------------------------------------------------
337#
338# Build additional static libgcc_eh[_p].a libraries.
339#
340libgcc_eh.a: ${EH_OBJS_T}
341 @${ECHO} building static gcc_eh library
342 @rm -f ${.TARGET}
343 @${AR} cq ${.TARGET} `lorder ${EH_OBJS_T} | tsort -q`
344 ${RANLIB} ${.TARGET}
345
346all: libgcc_eh.a
347
348.if ${MK_PROFILE} != "no"
349libgcc_eh_p.a: ${EH_OBJS_P}
350 @${ECHO} building profiled gcc_eh library
351 @rm -f ${.TARGET}
352 @${AR} cq ${.TARGET} `lorder ${EH_OBJS_P} | tsort -q`
353 ${RANLIB} ${.TARGET}
354all: libgcc_eh_p.a
355.endif
356
357_libinstall: _lib-eh-install
358
359_lib-eh-install:
360.if ${MK_INSTALLLIB} != "no"
361 ${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
362 ${_INSTALLFLAGS} libgcc_eh.a ${DESTDIR}${LIBDIR}
363.endif
364.if ${MK_PROFILE} != "no"
365 ${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
366 ${_INSTALLFLAGS} libgcc_eh_p.a ${DESTDIR}${LIBDIR}
367.endif
368
369CLEANFILES+= libgcc_eh.a libgcc_eh_p.a ${EH_OBJS_T} ${EH_OBJS_P}
370
371.include <bsd.lib.mk>
372
373.SUFFIXES: .vis .vo