Makefile revision 139106
1# $FreeBSD: head/gnu/lib/libgcc/Makefile 139106 2004-12-21 09:33:47Z ru $
2
3.include "${.CURDIR}/../../usr.bin/cc/Makefile.tgt"
4
5GCCDIR=	${.CURDIR}/../../../contrib/gcc
6.PATH: ${GCCDIR}/config/${GCC_CPU} ${GCCDIR}
7
8# allow to be overridden for the a.out case
9.if !defined(LIB) || ${LIB} != "gcc_r"
10LIB=	gcc
11.endif
12
13#SHLIB_MAJOR=	1
14
15# We need to install libgcc_pic.a as well, for use by shared libs.
16INSTALL_PIC_ARCHIVE=
17
18#
19# XXX This is a hack, but it seems to work.
20# libgcc2.a is meant to be compiled by *this* version of gcc.
21#
22# Normally, this does not make any difference, since we only have gcc, but
23# when bootstrapping from gcc-2.6.3, we have to use the freshly built 2.7.2
24# compiler for some of the libgcc2.c __attribute__ stuff.
25#
26# We now depend on a bootstrap pass (normally in `make world') to build
27# and install the new version of gcc before we get here.  This makes
28# finding the new version (XCC) easy but may break finding the old version
29# (CC).
30#
31XCC=	${CC}
32XCXX=	${CXX}
33
34CFLAGS+=	-fexceptions
35CFLAGS+=	-DIN_GCC -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED \
36		-DFINE_GRAINED_LIBRARIES
37CFLAGS+=	-D_PTHREADS -DGTHREAD_USE_WEAK
38CFLAGS+=	-I${.CURDIR}/../../usr.bin/cc/cc_tools \
39		-I${GCCDIR}/config -I${GCCDIR} -I.
40
41OBJS=		# added to below in various ways depending on TARGET_ARCH
42
43#---------------------------------------------------------------------------
44#
45# When upgrading GCC, get the following defintions straight from Makefile.in
46#
47# Library members defined in libgcc2.c.
48LIB2FUNCS = _muldi3 _negdi2 _lshrdi3 _ashldi3 _ashrdi3 \
49	_cmpdi2 _ucmpdi2 _floatdidf _floatdisf _fixunsdfsi _fixunssfsi \
50	_fixunsdfdi _fixdfdi _fixunssfdi _fixsfdi _fixxfdi _fixunsxfdi \
51	_floatdixf _fixunsxfsi _fixtfdi _fixunstfdi _floatditf _clear_cache \
52	_enable_execute_stack _trampoline __main _absvsi2 _absvdi2 _addvsi3 \
53	_addvdi3 _subvsi3 _subvdi3 _mulvsi3 _mulvdi3 _negvsi2 _negvdi2 _ctors \
54	_ffssi2 _ffsdi2 _clz _clzsi2 _clzdi2 _ctzsi2 _ctzdi2 _popcount_tab \
55	_popcountsi2 _popcountdi2 _paritysi2 _paritydi2 
56
57# Defined in libgcc2.c, included only in the static library.
58LIB2FUNCS_ST = _eprintf __gcc_bcmp
59
60FPBIT_FUNCS = _pack_sf _unpack_sf _addsub_sf _mul_sf _div_sf \
61    _fpcmp_parts_sf _compare_sf _eq_sf _ne_sf _gt_sf _ge_sf \
62    _lt_sf _le_sf _unord_sf _si_to_sf _sf_to_si _negate_sf _make_sf \
63    _sf_to_df _sf_to_tf _thenan_sf _sf_to_usi _usi_to_sf
64
65DPBIT_FUNCS = _pack_df _unpack_df _addsub_df _mul_df _div_df \
66    _fpcmp_parts_df _compare_df _eq_df _ne_df _gt_df _ge_df \
67    _lt_df _le_df _unord_df _si_to_df _df_to_si _negate_df _make_df \
68    _df_to_sf _df_to_tf _thenan_df _df_to_usi _usi_to_df
69
70TPBIT_FUNCS = _pack_tf _unpack_tf _addsub_tf _mul_tf _div_tf \
71    _fpcmp_parts_tf _compare_tf _eq_tf _ne_tf _gt_tf _ge_tf \
72    _lt_tf _le_tf _unord_tf _si_to_tf _tf_to_si _negate_tf _make_tf \
73    _tf_to_df _tf_to_sf _thenan_tf _tf_to_usi _usi_to_tf
74
75# These might cause a divide overflow trap and so are compiled with
76# unwinder info.
77LIB2_DIVMOD_FUNCS = _divdi3 _moddi3 _udivdi3 _umoddi3 _udiv_w_sdiv _udivmoddi4
78
79LIB2ADD = $(LIB2FUNCS_EXTRA)
80LIB2ADD_ST = $(LIB2FUNCS_STATIC_EXTRA)
81
82# Additional sources to handle exceptions; overridden by targets as needed.
83LIB2ADDEH = unwind-dw2.c unwind-dw2-fde.c unwind-sjlj.c gthr-gnat.c unwind-c.c
84
85#-----------------------------------------------------------------------
86#
87#	Platform specific bits.
88#	When upgrading GCC, get the following defintions from config/<cpu>/t-*
89#
90
91.if ${TARGET_ARCH} == "alpha"
92#	from config/alpha/t-alpha
93LIB2FUNCS_EXTRA = qrnnd.asm
94.endif
95
96.if ${TARGET_ARCH} == "arm"
97#	from config/arm/t-strongarm-elf
98CFLAGS+=	-Dinhibit_libc -fno-inline
99LIB1ASMSRC =	lib1funcs.asm
100LIB1ASMFUNCS =	_udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_tls _bb_init_func
101OBJS+=	dp-bit.o fp-bit.o
102# We want fine grained libraries, so use the new code to build the
103# floating point emulation libraries.
104XXX fix this: NEED_FP_EMULATION set to "yes" with different rules per platform
105.endif
106
107.if ${TARGET_ARCH} == "ia64"
108#	from config/ia64/t-ia64
109LIB1ASMSRC    = lib1funcs.asm
110LIB1ASMFUNCS  = __divxf3 __divdf3 __divsf3 \
111        __divdi3 __moddi3 __udivdi3 __umoddi3 \
112        __divsi3 __modsi3 __udivsi3 __umodsi3 __save_stack_nonlocal \
113        __nonlocal_goto __restore_stack_nonlocal __trampoline __compat
114LIB2ADDEH = unwind-ia64.c unwind-sjlj.c unwind-c.c gthr-gnat.c
115.endif
116
117.if ${TARGET_ARCH} == "powerpc"
118#	from config/rs6000/t-ppccomm
119LIB2FUNCS_EXTRA = tramp.asm
120# This one can't end up in shared libgcc
121LIB2FUNCS_STATIC_EXTRA = eabi.asm
122# We want fine grained libraries, so use the new code to build the
123# floating point emulation libraries.
124OBJS+=	dp-bit.o fp-bit.o
125.endif
126
127.if ${TARGET_ARCH} == "sparc64"
128#	from config/sparc/t-elf
129# We want fine grained libraries, so use the new code to build the
130# floating point emulation libraries.
131LIB1ASMSRC = lb1spc.asm
132LIB1ASMFUNCS = _mulsi3 _divsi3 _modsi3
133OBJS+=	dp-bit.o fp-bit.o
134.endif
135
136dp-bit.o: config/fp-bit.c
137	${XCC} -c ${CFLAGS} -o ${.TARGET} ${.ALLSRC:M*fp-bit*}
138
139dp-bit.So: config/fp-bit.c
140	${XCC} ${PICFLAG} -c ${CFLAGS} -o ${.TARGET} ${.ALLSRC:M*fp-bit*}
141
142dp-bit.po: config/fp-bit.c
143	${XCC} -p -c ${CFLAGS} -o ${.TARGET} ${.ALLSRC:M*fp-bit*}
144
145fp-bit.o: config/fp-bit.c
146	${XCC} -DFLOAT=1 -c ${CFLAGS} -o ${.TARGET} ${.ALLSRC:M*fp-bit*}
147
148fp-bit.So: config/fp-bit.c
149	${XCC} ${PICFLAG} -DFLOAT=1 -c ${CFLAGS} -o ${.TARGET} ${.ALLSRC:M*fp-bit*}
150
151fp-bit.po: config/fp-bit.c
152	${XCC} -p -DFLOAT=1 -c ${CFLAGS} -o ${.TARGET} ${.ALLSRC:M*fp-bit*}
153
154#-----------------------------------------------------------------------
155
156# Remove any objects from LIB2FUNCS and LIB2_DIVMOD_FUNCS that are
157# defined as optimized assembly code in LIB1ASMFUNCS.
158.if defined(LIB1ASMFUNCS)
159.for sym in ${LIB1ASMFUNCS}
160LIB2FUNCS:=	${LIB2FUNCS:S/${sym}//g}
161LIB2_DIVMOD_FUNCS:= ${LIB2_DIVMOD_FUNCS:S/${sym}//g}
162.endfor
163.endif
164
165ASM_T=		${LIB1ASMFUNCS:S/$/.o/}
166ASM_P=		${LIB1ASMFUNCS:S/$/.po/}
167ASM_S=		${LIB1ASMFUNCS:S/$/.So/}
168
169SYMS=		${LIB2FUNCS}		\
170		${LIB2_DIVMOD_FUNCS}
171.if ${TARGET_ARCH} == "arm" || ${TARGET_ARCH} == "powerpc" || ${TARGET_ARCH} == "sparc64"
172SYMS+=		${FPBIT_FUNCS} ${DPBIT_FUNCS}
173.endif
174SYMS_ST=	${LIB2FUNCS_ST}		\
175		${LIB2ADD_ST}
176OBJS+=		${SYMS:S/$/.o/} ${LIB1ASMFUNCS:S/$/.o/}
177OBJS_T=		${SYMS:S/$/.o/}  ${SYMS_ST:S/$/.o/}
178OBJS_P=		${SYMS:S/$/.po/} ${SYMS_ST:S/$/.po/}
179OBJS_S=		${SYMS:S/$/.So/}
180STATICOBJS=	${SYMS_ST:S/$/.o/}
181SRCS=		${LIB2ADD} ${LIB2ADDEH}
182
183COMMONHDRS=	tm.h tconfig.h
184SRCS+=		${COMMONHDRS}
185CLEANFILES+=	${COMMONHDRS}
186
187${COMMONHDRS}: ${.CURDIR}/../../usr.bin/cc/cc_tools/Makefile
188	${MAKE} -f ${.ALLSRC} MFILE=${.ALLSRC} GCCDIR=${GCCDIR} ${.TARGET}
189
190${OBJS} beforedepend: ${COMMONHDRS}
191
192${OBJS_T}: libgcc2.c
193	${XCC} -c ${CFLAGS} -DL${.PREFIX} -o ${.TARGET} ${.ALLSRC:M*.c}
194
195.if !defined(NO_PIC)
196${OBJS_S}: libgcc2.c
197	${XCC} -c ${PICFLAG} ${CFLAGS} -DL${.PREFIX} -o ${.TARGET} ${.ALLSRC:M*.c}
198.endif
199
200.if !defined(NO_PROFILE)
201${OBJS_P}: libgcc2.c
202	${XCC} -c -p ${CFLAGS} -DL${.PREFIX} -o ${.TARGET} ${.ALLSRC:M*.c}
203.endif
204
205.if defined(LIB1ASMSRC)
206.for _lib1asmsrc in ${LIB1ASMSRC}
207${ASM_T}: ${_lib1asmsrc}
208	${XCC} -x assembler-with-cpp -c ${CFLAGS} -DL${.PREFIX} \
209	    -o ${.TARGET} ${.ALLSRC:N*.h}
210
211.if !defined(NO_PIC)
212${ASM_S}: ${_lib1asmsrc}
213	${XCC} -x assembler-with-cpp -c ${PICFLAG} ${CFLAGS} -DL${.PREFIX} \
214	    -o ${.TARGET} ${.ALLSRC:N*.h}
215.endif
216
217.if !defined(NO_PROFILE)
218${ASM_P}: ${_lib1asmsrc}
219	${XCC} -x assembler-with-cpp -p -c ${CFLAGS} -DL${.PREFIX} \
220	    -o ${.TARGET} ${.ALLSRC:N*.h}
221.endif
222.endfor
223.endif
224
225.include <bsd.lib.mk>
226