Makefile revision 96779
11573Srgrimes# $FreeBSD: head/gnu/lib/libgcc/Makefile 96779 2002-05-17 03:08:15Z obrien $
21573Srgrimes
31573Srgrimes.include "${.CURDIR}/../../usr.bin/cc/Makefile.tgt"
41573Srgrimes
51573SrgrimesGCCDIR=	${.CURDIR}/../../../contrib/gcc
61573Srgrimes.PATH: ${GCCDIR}/config/${GCC_CPU} ${GCCDIR}
71573Srgrimes
81573Srgrimes# allow to be overridden for the a.out case
91573Srgrimes.if !defined(LIB) || ${LIB} != "gcc_r"
101573SrgrimesLIB=	gcc
111573Srgrimes.endif
121573Srgrimes
131573Srgrimes#SHLIB_MAJOR=	1
141573Srgrimes#SHLIB_MINOR=	0
151573Srgrimes
16148834Sstefanf.if ${OBJFORMAT} == aout
171573Srgrimes# Install libgcc_pic.a, since ld.so uses it.
181573SrgrimesINSTALL_PIC_ARCHIVE=  yes
191573Srgrimes.endif
201573Srgrimes
211573Srgrimes#
221573Srgrimes# XXX This is a hack, but it seems to work.
231573Srgrimes# libgcc2.a is meant to be compiled by *this* version of gcc.
241573Srgrimes#
251573Srgrimes# Normally, this does not make any difference, since we only have gcc, but
261573Srgrimes# when bootstrapping from gcc-2.6.3, we have to use the freshly built 2.7.2
271573Srgrimes# compiler for some of the libgcc2.c __attribute__ stuff.
281573Srgrimes#
291573Srgrimes# We now depend on a bootstrap pass (normally in `make world') to build
301573Srgrimes# and install the new version of gcc before we get here.  This makes
3184260Sobrien# finding the new version (XCC) easy but may break finding the old version
32167457Sstefanf# (CC).
331573Srgrimes#
341573SrgrimesXCC=	${CC}
351573SrgrimesXCXX=	${CXX}
361573Srgrimes
371573SrgrimesCFLAGS+=	-fexceptions
3884260SobrienCFLAGS+=	-DIN_GCC -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED \
3984260Sobrien		-DFINE_GRAINED_LIBRARIES
401573Srgrimes.if ${OBJFORMAT} != aout
411573SrgrimesCFLAGS+=	-D_PTHREADS -DGTHREAD_USE_WEAK
428870Srgrimes.endif
431573SrgrimesCFLAGS+=	-I${.CURDIR}/../../usr.bin/cc/cc_tools \
441573Srgrimes		-I${GCCDIR}/config -I${GCCDIR} -I.
451573SrgrimesLDFLAGS=	-nostdlib
461573Srgrimes
471573Srgrimes#---------------------------------------------------------------------------
4884260Sobrien#
491573Srgrimes# When upgrading GCC, get the following defintions straight from Makefile.in
50148834Sstefanf#
5184260Sobrien
5284260Sobrien# Library members defined in libgcc2.c.
5384260Sobrien# Variable length limited to 255 charactes when passed to a shell script.
5484260SobrienLIB2FUNCS_1 = _muldi3 _negdi2 _lshrdi3 _ashldi3 _ashrdi3 _ffsdi2 _clz \
551573Srgrimes    _cmpdi2 _ucmpdi2 _floatdidf _floatdisf _fixunsdfsi _fixunssfsi \
561573Srgrimes    _fixunsdfdi _fixdfdi _fixunssfdi _fixsfdi _fixxfdi _fixunsxfdi
571573Srgrimes
5884260SobrienLIB2FUNCS_2 = _floatdixf _fixunsxfsi _fixtfdi _fixunstfdi _floatditf \
5984260Sobrien    _clear_cache _trampoline __main _exit _absvsi2 _absvdi2 _addvsi3 \
6084260Sobrien    _addvdi3 _subvsi3 _subvdi3 _mulvsi3 _mulvdi3 _negvsi2 _negvdi2 _ctors
6184260Sobrien
6284260Sobrien# Defined in libgcc2.c, included only in the static library.
6384260SobrienLIB2FUNCS_ST = _eprintf _bb __gcc_bcmp
6484260Sobrien
6584260SobrienFPBIT_FUNCS = _pack_sf _unpack_sf _addsub_sf _mul_sf _div_sf \
6684260Sobrien    _fpcmp_parts_sf _compare_sf _eq_sf _ne_sf _gt_sf _ge_sf \
6784260Sobrien    _lt_sf _le_sf _unord_sf _si_to_sf _sf_to_si _negate_sf _make_sf \
68148834Sstefanf    _sf_to_df _thenan_sf _sf_to_usi _usi_to_sf
6984260Sobrien
7084260SobrienDPBIT_FUNCS = _pack_df _unpack_df _addsub_df _mul_df _div_df \
7184260Sobrien    _fpcmp_parts_df _compare_df _eq_df _ne_df _gt_df _ge_df \
7284260Sobrien    _lt_df _le_df _unord_df _si_to_df _df_to_si _negate_df _make_df \
7384260Sobrien    _df_to_sf _thenan_df _df_to_usi _usi_to_df
7484260Sobrien
7584260Sobrien# These might cause a divide overflow trap and so are compiled with
7684260Sobrien# unwinder info.
7784260SobrienLIB2_DIVMOD_FUNCS = _divdi3 _moddi3 _udivdi3 _umoddi3 _udiv_w_sdiv _udivmoddi4
7884260Sobrien
7984260SobrienMACHMODE_H = machmode.h machmode.def
8084260Sobrien
8184260SobrienLIB2ADD = $(LIB2FUNCS_EXTRA)
8284260SobrienLIB2ADD_ST = $(LIB2FUNCS_STATIC_EXTRA)
8384260Sobrien
8484260Sobrien# Additional sources to handle exceptions; overridden on ia64.
8584260SobrienLIB2ADDEH = unwind-dw2.c unwind-dw2-fde.c unwind-sjlj.c
8684260Sobrien
8784260Sobrien#-----------------------------------------------------------------------
8884260Sobrien#
8984260Sobrien#	Platform specific bits.
9084260Sobrien#	When upgrading GCC, get the following defintions from config/<cpu>/t-*
9184260Sobrien#
9284260Sobrien
9384260Sobrien.if ${TARGET_ARCH} == "alpha"
9484260Sobrien#	from config/alpha/t-alpha
9584260SobrienLIB2FUNCS_EXTRA = qrnnd.asm
9684260Sobrien.endif
9784260Sobrien
9884260Sobrien.if ${TARGET_ARCH} == "arm"
9984260Sobrien#	from config/arm/t-strongarm-elf
10084260SobrienLIB1ASMSRC = arm/lib1funcs.asm
10184260SobrienLIB1ASMFUNCS = _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_tls _bb_init_func
10284260Sobrien# We want fine grained libraries, so use the new code to build the
10384260Sobrien# floating point emulation libraries.
10484260SobrienXXX fix this: NEED_FP_EMULATION set to "yes" with different rules per platform
10584260Sobrien.endif
10684260Sobrien
10784260Sobrien.if ${TARGET_ARCH} == "ia64"
10884260Sobrien#	from config/ia64/t-ia64
10984260SobrienLIB1ASMSRC    = ia64/lib1funcs.asm
11084260SobrienLIB1ASMFUNCS  = __divtf3 __divdf3 __divsf3 \
11184260Sobrien	__divdi3 __moddi3 __udivdi3 __umoddi3 \
11284260Sobrien	__divsi3 __modsi3 __udivsi3 __umodsi3 __save_stack_nonlocal \
11384260Sobrien	__nonlocal_goto __restore_stack_nonlocal __trampoline
11484260SobrienLIB2ADDEH = unwind-ia64.c unwind-sjlj.c
11584260Sobrien.endif
11684260Sobrien
11784260Sobrien.if ${TARGET_ARCH} == "powerpc"
11884260Sobrien#	from config/rs6000/t-ppccomm
11984260SobrienLIB2FUNCS_EXTRA = tramp.asm
12084260Sobrien# This one can't end up in shared libgcc
12184260SobrienLIB2FUNCS_STATIC_EXTRA = eabi.asm
12284260Sobrien# We want fine grained libraries, so use the new code to build the
12384260Sobrien# floating point emulation libraries.
12484260SobrienOBJS+=	dp-bit.o fp-bit.o
12584260Sobrien.endif
12684260Sobrien
12784260Sobrien.if ${TARGET_ARCH} == "sparc64"
12884260Sobrien#	from config/sparc/t-elf
12984260Sobrien# We want fine grained libraries, so use the new code to build the
13084260Sobrien# floating point emulation libraries.
13184260SobrienLIB1ASMSRC = lb1spc.asm
13284260SobrienLIB1ASMFUNCS = _mulsi3 _divsi3 _modsi3
13384260SobrienOBJS+=	dp-bit.o fp-bit.o
13484260Sobrien.endif
13584260Sobrien
13684260Sobriendp-bit.o: config/fp-bit.c
13784260Sobrien	${XCC} -c ${CFLAGS} -o ${.TARGET} ${.ALLSRC:M*fp-bit*}
13884260Sobrien
13984260Sobriendp-bit.So: config/fp-bit.c
14084260Sobrien	${XCC} ${PICFLAG} -c ${CFLAGS} -o ${.TARGET} ${.ALLSRC:M*fp-bit*}
14184260Sobrien
14284260Sobriendp-bit.po: config/fp-bit.c
14384260Sobrien	${XCC} -p -c ${CFLAGS} -o ${.TARGET} ${.ALLSRC:M*fp-bit*}
14484260Sobrien
14584260Sobrienfp-bit.o: config/fp-bit.c
14684260Sobrien	${XCC} -DFLOAT=1 -c ${CFLAGS} -o ${.TARGET} ${.ALLSRC:M*fp-bit*}
14784260Sobrien
14884260Sobrienfp-bit.So: config/fp-bit.c
14984260Sobrien	${XCC} ${PICFLAG} -DFLOAT=1 -c ${CFLAGS} -o ${.TARGET} ${.ALLSRC:M*fp-bit*}
15084260Sobrien
15184260Sobrienfp-bit.po: config/fp-bit.c
15284260Sobrien	${XCC} -p -DFLOAT=1 -c ${CFLAGS} -o ${.TARGET} ${.ALLSRC:M*fp-bit*}
15384260Sobrien
15484260Sobrien#-----------------------------------------------------------------------
15584260Sobrien
15684260Sobrien# Remove any objects from LIB2FUNCS and LIB2_DIVMOD_FUNCS that are
15784260Sobrien# defined as optimized assembly code in LIB1ASMFUNCS.
15884260Sobrien.if defined(LIB1ASMFUNCS)
15984260Sobrien.for sym in ${LIB1ASMFUNCS}
16084260SobrienLIB2FUNCS_1:=	${LIB2FUNCS_1:S/${sym}//g}
16184260SobrienLIB2FUNCS_2:=	${LIB2FUNCS_2:S/${sym}//g}
16284260SobrienLIB2_DIVMOD_FUNCS:= ${LIB2_DIVMOD_FUNCS:S/${sym}//g}
16384260Sobrien.endfor
16484260Sobrien.endif
16584260Sobrien
16684260SobrienASM_T=		${LIB1ASMFUNCS:S/$/.o/}
16784260SobrienASM_P=		${LIB1ASMFUNCS:S/$/.po/}
16884260SobrienASM_S=		${LIB1ASMFUNCS:S/$/.So/}
16984260Sobrien
17084260SobrienSYMS=		${LIB1ASMFUNCS}		\
17184260Sobrien		${LIB2FUNCS_1}		\
17284260Sobrien		${LIB2FUNCS_2}		\
17384260Sobrien		${LIB2_DIVMOD_FUNCS}
17484260Sobrien.if ${TARGET_ARCH} == "arm" || ${TARGET_ARCH} == "powerpc" || ${TARGET_ARCH} == "sparc64"
17584260SobrienSYMS+=		${FPBIT_FUNCS} ${DPBIT_FUNCS}
17684260Sobrien.endif
17784260SobrienSYMS_ST=	${LIB2FUNCS_ST}		\
17884260Sobrien		${LIB2ADD_ST}
17984260SobrienOBJS_T=		${SYMS:S/$/.o/}  ${SYMS_ST:S/$/.o/}
18084260SobrienOBJS_P=		${SYMS:S/$/.po/} ${SYMS_ST:S/$/.po/}
18184260SobrienOBJS_S=		${SYMS:S/$/.So/}
18284260SobrienOBJS=		${SYMS:S/$/.o/}
18384260SobrienSTATICOBJS=	${SYMS_ST:S/$/.o/}
18484260SobrienSRCS=		${LIB2ADD} ${LIB2ADDEH}
18584260Sobrien
18684260SobrienCOMMONHDRS=	tconfig.h
187148834SstefanfSRCS+=		${COMMONHDRS}
18884260SobrienCLEANFILES+=	${COMMONHDRS}
18984260Sobrien
19084260Sobrientconfig.h: ${.CURDIR}/../../usr.bin/cc/cc_tools/Makefile
19184260Sobrien	${MAKE} -f ${.ALLSRC} MFILE=${.ALLSRC} GCCDIR=${GCCDIR} ${.TARGET}
19284260Sobrien
19384260Sobrien${OBJS} beforedepend: ${COMMONHDRS}
19484260Sobrien
19584260Sobrien${OBJS_T}: libgcc2.c
19684260Sobrien	${XCC} -c ${CFLAGS} -DL${.PREFIX} -o ${.TARGET} ${.ALLSRC:M*.c}
19784260Sobrien	@${LD} -o ${.TARGET}.tmp -x -r ${.TARGET}
19884260Sobrien	@mv ${.TARGET}.tmp ${.TARGET}
19984260Sobrien
20084260Sobrien.if !defined(NOPIC)
20184260Sobrien${OBJS_S}: libgcc2.c
20284260Sobrien	${XCC} -c ${PICFLAG} ${CFLAGS} -DL${.PREFIX} -o ${.TARGET} ${.ALLSRC:M*.c}
20384260Sobrien	@${LD} -o ${.TARGET}.tmp -x -r ${.TARGET}
20484260Sobrien	@mv ${.TARGET}.tmp ${.TARGET}
20584260Sobrien.endif
20684260Sobrien
20784260Sobrien.if !defined(NOPROFILE)
20884260Sobrien${OBJS_P}: libgcc2.c
20984260Sobrien	${XCC} -c -p ${CFLAGS} -DL${.PREFIX} -o ${.TARGET} ${.ALLSRC:M*.c}
21084260Sobrien	@${LD} -o ${.TARGET}.tmp -X -r ${.TARGET}
21184260Sobrien	@mv ${.TARGET}.tmp ${.TARGET}
21284260Sobrien.endif
21384260Sobrien
21484260Sobrien.if defined(LIB1ASMSRC)
21584260Sobrien${ASM_T}: ${LIB1ASMSRC}
21684260Sobrien	${XCC} -x assembler-with-cpp -c ${CFLAGS} -DL${.PREFIX} -o ${.TARGET} ${GCCDIR}/config/${LIB1ASMSRC}
21784260Sobrien	@${LD} -o ${.TARGET}.tmp -x -r ${.TARGET}
21884260Sobrien	@mv ${.TARGET}.tmp ${.TARGET}
21984260Sobrien
22084260Sobrien.if !defined(NOPIC)
22184260Sobrien${ASM_S}: ${LIB1ASMSRC}
22284260Sobrien	${XCC} -x assembler-with-cpp -c ${PICFLAG} ${CFLAGS} -DL${.PREFIX} -o ${.TARGET} ${GCCDIR}/config/${LIB1ASMSRC}
22384260Sobrien	@${LD} -o ${.TARGET}.tmp -x -r ${.TARGET}
22484260Sobrien	@mv ${.TARGET}.tmp ${.TARGET}
22584260Sobrien.endif
22684260Sobrien
22784260Sobrien.if !defined(NOPROFILE)
22884260Sobrien${ASM_P}: ${LIB1ASMSRC}
22984260Sobrien	${XCC} -x assembler-with-cpp -c -p ${CFLAGS} -DL${.PREFIX} -o ${.TARGET} ${GCCDIR}/config/${TARGET_ARCH}/${LIB1ASMSRC}
23084260Sobrien	@${LD} -o ${.TARGET}.tmp -X -r ${.TARGET}
23184260Sobrien	@mv ${.TARGET}.tmp ${.TARGET}
23284260Sobrien.endif
23384260Sobrien.endif
23484260Sobrien
23584260Sobrien.include <bsd.lib.mk>
23684260Sobrien