4 .if exists(${.CURDIR}/../arch/${MACHINE_ARCH}.mk)
5 .include "${.CURDIR}/../arch/${MACHINE_ARCH}.mk"
9 DIST= ${NETBSDSRCDIR}/gnu/dist/gcc4
11 GCCARCH= ${NETBSDSRCDIR}/gnu/usr.bin/gcc4/arch/${MACHINE_ARCH}
12 GCCARCHLIBGCC= ${NETBSDSRCDIR}/gnu/lib/libgcc4/arch/${MACHINE_ARCH}
13 GCCARCHXX= ${NETBSDSRCDIR}/gnu/lib/libstdc++-v3_4/arch/${MACHINE_ARCH}
15 GCPPFLAGS= ${G_LIBGCC2_CFLAGS} ${G_USE_COLLECT2} ${G_INCLUDES}
16 CPPFLAGS+= -I${.CURDIR} -I${GCCARCHLIBGCC}
17 CPPFLAGS+= -I${GCCARCH} ${GCPPFLAGS:M-D*} ${GCPPFLAGS:M-I*:N-I.*}
18 CPPFLAGS+= -I${G_EXTRA_HEADERS:M/*:H:u}
19 CPPFLAGS+= -I${DIST} -I${DIST}/gcc/cp -I${DIST}/gcc/config -I${GCCARCHXX} -I.
21 .if ${MACHINE_ARCH} == "powerpc" || \
22 ${MACHINE_ARCH} == "sh3el" || \
23 ${MACHINE_ARCH} == "sh3eb" || \
24 ${MACHINE_ARCH} == "m68000"
26 COMPILE.S= ${CC} ${AFLAGS} ${CPPFLAGS} -c
29 .if !defined(MKNATIVE_LIBGCC_NEW)
32 # Old style libgcc build procedure.
35 # This is copied from gcc/mklibgcc.in:$lib2funcs
36 LIB2FUNCS_ALL= _muldi3 _negdi2 _lshrdi3 _ashldi3 _ashrdi3 \
37 _cmpdi2 _ucmpdi2 _floatdidf _floatdisf _fixunsdfsi _fixunssfsi \
38 _fixunsdfdi _fixdfdi _fixunssfdi _fixsfdi _fixxfdi _fixunsxfdi \
39 _floatdixf _fixunsxfsi _fixtfdi _fixunstfdi _floatditf _clear_cache \
40 _enable_execute_stack _trampoline __main _absvsi2 _absvdi2 _addvsi3 \
41 _addvdi3 _subvsi3 _subvdi3 _mulvsi3 _mulvdi3 _negvsi2 _negvdi2 _ctors \
42 _ffssi2 _ffsdi2 _clz _clzsi2 _clzdi2 _ctzsi2 _ctzdi2 _popcount_tab \
43 _popcountsi2 _popcountdi2 _paritysi2 _paritydi2 _powisf2 _powidf2 \
47 _mulsc3 _muldc3 _mulxc3 _multc3 _divsc3 _divdc3 _divxc3 _divtc3
49 LIB2FUNCS_SHORT:=${LIB2FUNCS_ALL}
50 LIB2_DIVMOD_FUNCS:=${G_LIB2_DIVMOD_FUNCS}
51 .for f in ${G_LIB1ASMFUNCS}; do
52 LIB2FUNCS_SHORT:=${LIB2FUNCS_SHORT:N${f}}
53 LIB2_DIVMOD_FUNCS:=${LIB2_DIVMOD_FUNCS:N${f}}
56 LIB2FUNCS= ${LIB2FUNCS_SHORT:=.c}
57 LIB2FUNCS_ST= ${G_LIB2FUNCS_ST:=.c}
58 LIB2DIVMOD= ${LIB2_DIVMOD_FUNCS:=.c}
59 LIB2_EH= ${G_LIB2ADDEH:M*.c:T}
60 .if !empty(G_LIB1ASMFUNCS)
61 LIB1ASMFUNCS= ${G_LIB1ASMFUNCS:=.S}
64 DPSRCS+= ${.CURDIR}/../arch/${MACHINE_ARCH}.mk
65 CLEANFILES+= ${LIB2FUNCS} ${LIB2FUNCS_ST} ${LIB2DIVMOD} cs-tconfig.h
66 .if !empty(G_LIB1ASMFUNCS)
67 CLEANFILES+= ${LIB1ASMFUNCS}
70 .for file in ${G_LIB2ADD:M${GNUHOSTDIST}*}
71 BUILDSYMLINKS+= ${file} ${file:T:S/.asm$/.S/}
75 .if ${MACHINE_ARCH} == "m68000"
77 BUILDSYMLINKS+= ${DIST}/gcc/config/m68k/fpgnulib.c fpgnulib.c
78 BUILDSYMLINKS+= ${DIST}/gcc/config/m68k/fpgnulib.c xfgnulib.c
79 CPPFLAGS.xfgnulib.c+=-DEXTFLOAT=1
82 .if ${MACHINE_ARCH} == "powerpc64"
83 COPTS+= -mlong-double-128
86 ${LIB2FUNCS} ${LIB2FUNCS_ST}: ${.CURDIR}/Makefile
88 printf '#define L${.PREFIX}\n#include <libgcc2.c>\n' >${.TARGET}
90 ${LIB2DIVMOD}: ${.CURDIR}/Makefile
92 printf '#define L${.PREFIX}\n#include <libgcc2.c>\n' >${.TARGET}
94 .if !empty(G_LIB1ASMFUNCS)
95 ${LIB1ASMFUNCS}: ${.CURDIR}/Makefile
97 printf '#define L${.PREFIX}\n#include <${G_LIB1ASMSRC}>\n' >${.TARGET}
102 ${COMPILE.c} -fexceptions ${COPTS.${.IMPSRC:T}} -o ${.TARGET} ${.IMPSRC}
106 ${COMPILE.c} ${CPICFLAGS} -fexceptions ${COPTS.${.IMPSRC:T}} -o ${.TARGET} ${.IMPSRC}
108 ${G_LIB2_DIVMOD_FUNCS:=.o}:
110 ${COMPILE.c} -fexceptions -fnon-call-exceptions ${COPTS.${.IMPSRC:T}} -o ${.TARGET} ${.IMPSRC}
112 ${G_LIB2_DIVMOD_FUNCS:=.so}:
114 ${COMPILE.c} ${CPICFLAGS} -fexceptions -fnon-call-exceptions ${COPTS.${.IMPSRC:T}} -o ${.TARGET} ${.IMPSRC}
116 dp-bit.c: ${.CURDIR}/Makefile
118 printf '#define FLOAT\n#include <fp-bit.c>\n' >${.TARGET}
120 .else # defined(MKNATIVE_LIBGCC_NEW)
123 # New style libgcc build procedure.
126 .endif # defined(MKNATIVE_LIBGCC_NEW)
132 .PATH: ${DIST}/gcc ${DIST}/gcc/cp ${DIST}/gcc/cp/inc ${DIST}/gcc/config \
137 TARGET_CPU_DEFAULT="" \
138 HEADERS="$(G_xm_include_list)" DEFINES="USED_FOR_TARGET $(G_xm_defines)" \
139 ${HOST_SH} $(GNUHOSTDIST)/gcc/mkconfig.sh tconfig.h
141 CLEANFILES+= tconfig.h
143 BUILDSYMLINKS+= ${G_UNWIND_H} unwind.h
146 # these aren't necessary but are #include'd
147 FAKEHEADERS=options.h insn-flags.h insn-constants.h
151 DPSRCS+= ${FAKEHEADERS}
152 CLEANFILES+= ${FAKEHEADERS}