1 # $NetBSD: Makefile.inc,v 1.30 2015/04/15 19:13:46 mrg Exp $
3 LIBGCC_MACHINE_ARCH?=${MACHINE_ARCH:S/earmv5/earm/}
6 .if exists(${.CURDIR}/../arch/${LIBGCC_MACHINE_ARCH}/defs.mk)
7 .include "${.CURDIR}/../arch/${LIBGCC_MACHINE_ARCH}/defs.mk"
11 UNSUPPORTED_COMPILER.clang= # defined
15 GCCARCH= ${GCC_SUBDIR}/usr.bin/gcc/arch/${LIBGCC_MACHINE_ARCH}
16 GCCARCHLIBGCC= ${GCC_SUBDIR}/lib/libgcc/arch/${LIBGCC_MACHINE_ARCH}
17 GCCARCHXX= ${GCC_SUBDIR}/lib/libstdc++-v3/arch/${LIBGCC_MACHINE_ARCH}
19 GCPPFLAGS= ${G_LIBGCC2_CFLAGS} ${G_USE_COLLECT2} ${G_INCLUDES}
20 CPPFLAGS+= -I${.CURDIR} -I${GCCARCHLIBGCC}
21 CPPFLAGS+= -I${GCCARCH} ${GCPPFLAGS:M-D*} ${GCPPFLAGS:M-I*:N-I.*}
22 CPPFLAGS+= ${GCPPFLAGS:M-m*} ${GCPPFLAGS:M-f*}
23 CPPFLAGS+= ${G_EXTRA_HEADERS:M/*:H:u:S/^/-I/g}
24 CPPFLAGS+= -I${DIST}/libgcc -I${DIST}/libgcc/config
25 CPPFLAGS+= -I${DIST}/gcc -I${DIST}/include -I.
27 .if ${LIBGCC_MACHINE_ARCH} == "powerpc" || \
28 ${LIBGCC_MACHINE_ARCH} == "sh3el" || \
29 ${LIBGCC_MACHINE_ARCH} == "sh3eb" || \
30 ${LIBGCC_MACHINE_ARCH} == "m68000"
32 COMPILE.S= ${CC} ${AFLAGS} ${CPPFLAGS} -c
35 .if ${LIBGCC_MACHINE_ARCH} == "powerpc"
36 CPPFLAGS+= -I${DIST}/gcc/config/rs6000
40 # Old style libgcc build procedure.
43 # This is copied from dist/libgcc/Makefile.in:$lib2funcs
45 _muldi3 _negdi2 _lshrdi3 _ashldi3 _ashrdi3 _cmpdi2 _ucmpdi2 \
46 _clear_cache _trampoline __main \
47 _absvsi2 _absvdi2 _addvsi3 _addvdi3 \
48 _subvsi3 _subvdi3 _mulvsi3 _mulvdi3 \
51 _ffssi2 _ffsdi2 _clz _clzsi2 _clzdi2 _ctzsi2 _ctzdi2 \
52 _popcount_tab _popcountsi2 _popcountdi2 _paritysi2 _paritydi2 \
53 _powisf2 _powidf2 _powixf2 _powitf2 \
54 _mulsc3 _muldc3 _mulxc3 _multc3 _divsc3 _divdc3 _divxc3 _divtc3 \
55 _bswapsi2 _bswapdi2 _clrsbsi2 _clrsbdi2
57 .if ${LIBGCC_MACHINE_ARCH} != "coldfire" && empty(LIBGCC_MACHINE_ARCH:Mearm*)
60 _muldi3 _negdi2 _lshrdi3 _ashldi3 _ashrdi3
64 .if ${LIBGCC_MACHINE_ARCH} != "coldfire" && empty(LIBGCC_MACHINE_ARCH:Mearm*)
66 # non swfloat versions
67 .for _p in _fix _fixuns
68 . for _m in sf df xf tf
69 LIB2FUNCS_ALL+= ${_p}${_m}di
73 .for _p in _float _floatun
74 . for _m in sf df xf tf
75 LIB2FUNCS_ALL+= ${_p}di${_m}
80 LIB2FUNCS_ALL+= _fixuns${_m}si
84 LIB2FUNCS_SHORT:=${LIB2FUNCS_ALL}
85 LIB2_DIVMOD_FUNCS:=${G_LIB2_DIVMOD_FUNCS}
86 .for f in ${G_LIB1ASMFUNCS}; do
87 LIB2FUNCS_SHORT:=${LIB2FUNCS_SHORT:N${f}}
88 LIB2_DIVMOD_FUNCS:=${LIB2_DIVMOD_FUNCS:N${f}}
91 LIB2FUNCS= ${LIB2FUNCS_SHORT:=.c}
92 LIB2FUNCS_ST= ${G_LIB2FUNCS_ST:=.c}
93 LIB2DIVMOD= ${LIB2_DIVMOD_FUNCS:=.c}
94 .if ${HAVE_LIBGCC_EH} == "no"
95 LIB2_EH= ${G_LIB2ADDEH:M*.c:T:Nunwind-dw2.c:Nunwind-dw2-fde-dip.c:Nunwind-sjlj.c:Nunwind-c.c:Nunwind-arm.c:Npr-support.c}
96 LIB2_EHASM= ${G_LIB2ADDEH:M*.S:T:Nlibunwind.S}
97 G_CONFIGLINKS:= ${G_CONFIGLINKS:S,libgcc/config/arm/unwind-arm.h,libgcc/unwind-generic.h,}
99 LIB2_EH= ${G_LIB2ADDEH:M*.c:T}
100 LIB2_EHASM= ${G_LIB2ADDEH:M*.S:T}
103 # We have to weed out any existing func.S file that may exist
104 # from the list of files we create.
105 .if !empty(G_LIB1ASMFUNCS)
106 . for f in ${G_LIB1ASMFUNCS:=.S}
107 . if !exists(${DIST}/libgcc/config/${MACHINE_GNU_ARCH}/${f})
113 .if exists(${.CURDIR}/../arch/${LIBGCC_MACHINE_ARCH}/defs.mk)
114 DPSRCS+= ${.CURDIR}/../arch/${LIBGCC_MACHINE_ARCH}/defs.mk
116 CLEANFILES+= ${LIB2FUNCS} ${LIB2FUNCS_ST} ${LIB2DIVMOD} cs-tconfig.h
117 .if !empty(G_LIB1ASMFUNCS)
118 CLEANFILES+= ${LIB1ASMFUNCS}
121 .for file in ${G_LIB2ADD:M${GNUHOSTDIST}*:N*.c}
122 BUILDSYMLINKS+= ${file} ${file:T:S/.asm$/.S/}
126 .if (${LIBGCC_MACHINE_ARCH} == "m68000" || ${LIBGCC_MACHINE_ARCH} == "m68k" || \
127 ${LIBGCC_MACHINE_ARCH} == "coldfire")
129 BUILDSYMLINKS+= ${DIST}/libgcc/config/m68k/fpgnulib.c fpgnulib.c
130 BUILDSYMLINKS+= ${DIST}/libgcc/config/m68k/fpgnulib.c xfgnulib.c
131 CPPFLAGS.xfgnulib.c+= -DEXTFLOAT=1
134 .if ${LIBGCC_MACHINE_ARCH} == "powerpc64"
135 COPTS+= -mlong-double-128
138 ${LIB2FUNCS} ${LIB2FUNCS_ST}: ${.CURDIR}/Makefile
140 printf '#define L${.PREFIX}\n#include <libgcc2.c>\n' >${.TARGET}
142 ${LIB2DIVMOD}: ${.CURDIR}/Makefile
144 printf '#define L${.PREFIX}\n#include <libgcc2.c>\n' >${.TARGET}
146 .if !empty(G_LIB1ASMFUNCS)
147 ${LIB1ASMFUNCS}: ${.CURDIR}/Makefile
149 printf '#define L${.PREFIX}\n#include <${G_LIB1ASMSRC}>\n' >${.TARGET}
152 # Use dynamic sources to arrange for the C file to be the first dependency
153 # so ${.IMPSRC} will work.
155 ${LIB2_EH:.c=.o}: $(.PREFIX).c
157 ${COMPILE.c} -fexceptions ${COPTS.${.IMPSRC:T}} -o ${.TARGET} ${.IMPSRC}
159 ${LIB2_EH:.c=.pico}: $(.PREFIX).c
161 ${COMPILE.c} ${CPICFLAGS} -fexceptions ${COPTS.${.IMPSRC:T}} -o ${.TARGET} ${.IMPSRC}
163 ${G_LIB2_DIVMOD_FUNCS:=.o}: $(.PREFIX).c
165 ${COMPILE.c} -fexceptions -fnon-call-exceptions ${COPTS.${.IMPSRC:T}} -o ${.TARGET} ${.IMPSRC}
167 ${G_LIB2_DIVMOD_FUNCS:=.pico}: $(.PREFIX).c
169 ${COMPILE.c} ${CPICFLAGS} -fexceptions -fnon-call-exceptions ${COPTS.${.IMPSRC:T}} -o ${.TARGET} ${.IMPSRC}
171 dp-bit.c: ${.CURDIR}/Makefile
173 printf '#define FLOAT\n#include <fp-bit.c>\n' >${.TARGET}
179 .PATH: ${DIST}/gcc ${DIST}/gcc/cp ${DIST}/gcc/cp/inc ${DIST}/gcc/config \
180 ${G_LIB2ADD:H:O:u} ${G_LIB2ADDEH:H:O:u} ${GCCARCHLIBGCC}
182 .include "../Makefile.tconfigh"
186 .if defined(G_CONFIGLINKS) && !empty(G_CONFIGLINKS)
187 BUILDSYMLINKS+= ${G_CONFIGLINKS}
188 .for _src _dst in ${G_CONFIGLINKS}
194 EXTRA_FAKEHEADERS= options.h libgcc_tm.h
195 .include "../../Makefile.hacks"