167811Sobrien# $FreeBSD$
267811Sobrien
3188895Sru.include <bsd.own.mk>
4188895SruMK_SSP=		no
5188895Sru
696340SobrienGCCDIR=	${.CURDIR}/../../../contrib/gcc
7169718SkanGCCLIB=	${.CURDIR}/../../../contrib/gcclibs
896340SobrienCCDIR=	${.CURDIR}/../../usr.bin/cc
996340Sobrien.include "${CCDIR}/Makefile.tgt"
1096340Sobrien
1196796Speter.PATH: ${GCCDIR}/config/${GCC_CPU} ${GCCDIR}
1296796Speter
13169718SkanSRCS=		crtstuff.c tconfig.h tm.h options.h
14169718SkanOBJS=		crtbegin.o crtend.o crtbeginT.o
1567811SobrienSOBJS=		crtbegin.So crtend.So
16115663SobrienCSTD?=		gnu89
17169718SkanCFLAGS+=	-DIN_GCC -DHAVE_LD_EH_FRAME_HDR -DDT_CONFIG -D__GLIBC__=3
18260096SdimCFLAGS.gcc+=	-finhibit-size-directive -fno-toplevel-reorder
19259851SdimCFLAGS+=	-fno-inline-functions -fno-exceptions \
20259851Sdim		-fno-zero-initialized-in-bss -fno-asynchronous-unwind-tables \
21259851Sdim		-fno-omit-frame-pointer
22169718SkanCFLAGS+=	-I${GCCLIB}/include -I${GCCDIR}/config -I${GCCDIR} -I. \
2396340Sobrien		-I${CCDIR}/cc_tools
2496796SpeterCRTS_CFLAGS=	-DCRTSTUFFS_O -DSHARED ${PICFLAG}
25126688SruMKDEP=		-DCRT_BEGIN
2667811Sobrien
27211725Simp.if ${MACHINE_CPUARCH} == "ia64"
2896796SpeterBEGINSRC=	crtbegin.asm
2996796SpeterENDSRC=		crtend.asm
3096796SpeterCFLAGS+=	-x assembler-with-cpp	# Ugly hack
31183440SmarcelCFLAGS+=	-include osreldate.h
3296796Speter.undef SRCS				# hack for 'make depend'
3396796Speter.endif
34211725Simp.if ${MACHINE_CPUARCH} == "powerpc"
3596778SobrienTGTOBJS=	crtsavres.o
3696778SobrienSRCS+=		crtsavres.asm
3796778Sobrien.endif
38211725Simp.if ${MACHINE_CPUARCH} == "sparc64"
3996340SobrienTGTOBJS=	crtfastmath.o
4096340SobrienSRCS+=		crtfastmath.c
4196340Sobrien.endif
42172609SruBEGINSRC?=	crtstuff.c
43172609SruENDSRC?=	crtstuff.c
4467811Sobrien
4596340Sobrienall: ${OBJS} ${SOBJS} ${TGTOBJS}
46135029Sru${OBJS} ${SOBJS}: ${SRCS:M*.h}
4796340Sobrien
4896530SruCLEANFILES=	${OBJS} ${SOBJS} ${TGTOBJS}
4996530Sru
5096796Spetercrtbegin.o:	${BEGINSRC}
5167811Sobrien	${CC} ${CFLAGS} -g0 -DCRT_BEGIN \
5297314Sobrien		-c -o ${.TARGET} ${.ALLSRC:N*.h}
5367811Sobrien
54169718SkancrtbeginT.o:	${BEGINSRC}
55169718Skan	${CC} ${CFLAGS} -g0 -DCRT_BEGIN -DCRTSTUFFT_O \
56169718Skan		-c -o ${.TARGET} ${.ALLSRC:N*.h}
57169718Skan
5896796Spetercrtbegin.So:	${BEGINSRC}
5967811Sobrien	${CC} ${CFLAGS} -g0 -DCRT_BEGIN ${CRTS_CFLAGS} \
6097314Sobrien		-c -o ${.TARGET} ${.ALLSRC:N*.h}
6167811Sobrien
6296796Spetercrtend.o:	${ENDSRC}
6367811Sobrien	${CC} ${CFLAGS} -g0 -DCRT_END \
6497314Sobrien		-c -o ${.TARGET} ${.ALLSRC:N*.h}
6567811Sobrien
6696796Spetercrtend.So:	${ENDSRC}
6767811Sobrien	${CC} ${CFLAGS} -g0 -DCRT_END ${CRTS_CFLAGS} \
6897314Sobrien		-c -o ${.TARGET} ${.ALLSRC:N*.h}
6967811Sobrien
70169718SkanCLEANFILES+=	tm.h tconfig.h options.h optionlist cs-tconfig.h cs-tm.h
71169718Skantm.h tconfig.h options.h: ${CCDIR}/cc_tools/Makefile
7296340Sobrien	${MAKE} -f ${.ALLSRC} MFILE=${.ALLSRC} GCCDIR=${GCCDIR} ${.TARGET}
7367811Sobrien
7467811Sobrienrealinstall:
7596340Sobrien.for file in ${OBJS} ${SOBJS} ${TGTOBJS}
76100872Sru	${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
7767811Sobrien	    ${file} ${DESTDIR}${LIBDIR}/${file:S/.So$/S.o/}
7867811Sobrien.endfor
7967811Sobrien
8067811Sobrien.include <bsd.lib.mk>
81