1 # $NetBSD: Makefile.inc,v 1.5 2011/06/29 08:05:52 mrg Exp $ 2 3 .if ${MKGCC} != "no" 4 .if exists(${.CURDIR}/../arch/${MACHINE_ARCH}.mk) 5 .include "${.CURDIR}/../arch/${MACHINE_ARCH}.mk" 6 .endif 7 .endif 8 9 UNSUPPORTED_COMPILER.clang= # defined 10 11 DIST= ${NETBSDSRCDIR}/external/gpl3/gcc/dist 12 GNUHOSTDIST= ${DIST} 13 GCCARCH= ${NETBSDSRCDIR}/external/gpl3/gcc/usr.bin/gcc/arch/${MACHINE_ARCH} 14 GCCARCHLIBGCC= ${NETBSDSRCDIR}/external/gpl3/gcc/lib/libgcc/arch/${MACHINE_ARCH} 15 GCCARCHXX= ${NETBSDSRCDIR}/external/gpl3/gcc/lib/libstdc++-v3/arch/${MACHINE_ARCH} 16 17 GCPPFLAGS= ${G_LIBGCC2_CFLAGS} ${G_USE_COLLECT2} ${G_INCLUDES} 18 CPPFLAGS+= -I${.CURDIR} -I${GCCARCHLIBGCC} 19 CPPFLAGS+= -I${GCCARCH} ${GCPPFLAGS:M-D*} ${GCPPFLAGS:M-I*:N-I.*} 20 CPPFLAGS+= ${G_EXTRA_HEADERS:M/*:H:u:S/^/-I/g} 21 CPPFLAGS+= -I${DIST} -I${DIST}/gcc/cp -I${DIST}/gcc/config -I${GCCARCHXX} -I. 22 23 .if ${MACHINE_ARCH} == "powerpc" || \ 24 ${MACHINE_ARCH} == "sh3el" || \ 25 ${MACHINE_ARCH} == "sh3eb" || \ 26 ${MACHINE_ARCH} == "m68000" 27 _TRADITIONAL_CPP= 28 COMPILE.S= ${CC} ${AFLAGS} ${CPPFLAGS} -c 29 .endif 30 31 .if !defined(MKNATIVE_LIBGCC_NEW) 32 33 # 34 # Old style libgcc build procedure. 35 # 36 37 # This is copied from gcc/mklibgcc.in:$lib2funcs 38 LIB2FUNCS_ALL= \ 39 _muldi3 _negdi2 _lshrdi3 _ashldi3 _ashrdi3 _cmpdi2 _ucmpdi2 \ 40 _clear_cache _enable_execute_stack _trampoline __main _absvsi2 \ 41 _absvdi2 _addvsi3 _addvdi3 _subvsi3 _subvdi3 _mulvsi3 _mulvdi3 \ 42 _negvsi2 _negvdi2 _ctors _ffssi2 _ffsdi2 _clz _clzsi2 _clzdi2 \ 43 _ctzsi2 _ctzdi2 _popcount_tab _popcountsi2 _popcountdi2 \ 44 _paritysi2 _paritydi2 _powisf2 _powidf2 _powixf2 _powitf2 \ 45 _mulsc3 _muldc3 _mulxc3 _multc3 _divsc3 _divdc3 _divxc3 \ 46 _divtc3 _bswapsi2 _bswapdi2 47 48 # non swfloat versions 49 .for _p in _fix _fixuns 50 . for _s in sf df xf tf 51 LIB2FUNCS_ALL+= ${_p}${_s}di 52 . endfor 53 .endfor 54 .for _p in _float _floatun 55 . for _s in sf df xf tf 56 LIB2FUNCS_ALL+= ${_p}di${_s} 57 . endfor 58 .endfor 59 60 .for _m in sf df xf 61 LIB2FUNCS_ALL+= fixuns${_p}si 62 .endfor 63 64 LIB2FUNCS_SHORT:=${LIB2FUNCS_ALL} 65 LIB2_DIVMOD_FUNCS:=${G_LIB2_DIVMOD_FUNCS} 66 .for f in ${G_LIB1ASMFUNCS}; do 67 LIB2FUNCS_SHORT:=${LIB2FUNCS_SHORT:N${f}} 68 LIB2_DIVMOD_FUNCS:=${LIB2_DIVMOD_FUNCS:N${f}} 69 .endfor 70 71 LIB2FUNCS= ${LIB2FUNCS_SHORT:=.c} 72 LIB2FUNCS_ST= ${G_LIB2FUNCS_ST:=.c} 73 LIB2DIVMOD= ${LIB2_DIVMOD_FUNCS:=.c} 74 LIB2_EH= ${G_LIB2ADDEH:M*.c:T} 75 .if !empty(G_LIB1ASMFUNCS) 76 LIB1ASMFUNCS= ${G_LIB1ASMFUNCS:=.S} 77 .endif 78 79 DPSRCS+= ${.CURDIR}/../arch/${MACHINE_ARCH}.mk 80 CLEANFILES+= ${LIB2FUNCS} ${LIB2FUNCS_ST} ${LIB2DIVMOD} cs-tconfig.h 81 .if !empty(G_LIB1ASMFUNCS) 82 CLEANFILES+= ${LIB1ASMFUNCS} 83 .endif 84 85 .for file in ${G_LIB2ADD:M${GNUHOSTDIST}*} 86 BUILDSYMLINKS+= ${file} ${file:T:S/.asm$/.S/} 87 .endfor 88 89 # XXX 90 .if ${MACHINE_ARCH} == "m68000" 91 CPICFLAGS:= 92 BUILDSYMLINKS+= ${DIST}/gcc/config/m68k/fpgnulib.c fpgnulib.c 93 BUILDSYMLINKS+= ${DIST}/gcc/config/m68k/fpgnulib.c xfgnulib.c 94 CPPFLAGS.xfgnulib.c+=-DEXTFLOAT=1 95 .endif 96 97 .if ${MACHINE_ARCH} == "powerpc64" 98 COPTS+= -mlong-double-128 99 .endif 100 101 ${LIB2FUNCS} ${LIB2FUNCS_ST}: ${.CURDIR}/Makefile 102 ${_MKTARGET_CREATE} 103 printf '#define L${.PREFIX}\n#include <libgcc2.c>\n' >${.TARGET} 104 105 ${LIB2DIVMOD}: ${.CURDIR}/Makefile 106 ${_MKTARGET_CREATE} 107 printf '#define L${.PREFIX}\n#include <libgcc2.c>\n' >${.TARGET} 108 109 .if !empty(G_LIB1ASMFUNCS) 110 ${LIB1ASMFUNCS}: ${.CURDIR}/Makefile 111 ${_MKTARGET_CREATE} 112 printf '#define L${.PREFIX}\n#include <${G_LIB1ASMSRC}>\n' >${.TARGET} 113 .endif 114 115 ${LIB2_EH:.c=.o}: 116 ${_MKTARGET_COMPILE} 117 ${COMPILE.c} -fexceptions ${COPTS.${.IMPSRC:T}} -o ${.TARGET} ${.IMPSRC} 118 119 ${LIB2_EH:.c=.pico}: 120 ${_MKTARGET_COMPILE} 121 ${COMPILE.c} ${CPICFLAGS} -fexceptions ${COPTS.${.IMPSRC:T}} -o ${.TARGET} ${.IMPSRC} 122 123 ${G_LIB2_DIVMOD_FUNCS:=.o}: 124 ${_MKTARGET_COMPILE} 125 ${COMPILE.c} -fexceptions -fnon-call-exceptions ${COPTS.${.IMPSRC:T}} -o ${.TARGET} ${.IMPSRC} 126 127 ${G_LIB2_DIVMOD_FUNCS:=.pico}: 128 ${_MKTARGET_COMPILE} 129 ${COMPILE.c} ${CPICFLAGS} -fexceptions -fnon-call-exceptions ${COPTS.${.IMPSRC:T}} -o ${.TARGET} ${.IMPSRC} 130 131 dp-bit.c: ${.CURDIR}/Makefile 132 ${_MKTARGET_CREATE} 133 printf '#define FLOAT\n#include <fp-bit.c>\n' >${.TARGET} 134 135 .else # defined(MKNATIVE_LIBGCC_NEW) 136 137 # 138 # New style libgcc build procedure. 139 # 140 141 .endif # defined(MKNATIVE_LIBGCC_NEW) 142 143 # 144 # Common rules. 145 # 146 147 .PATH: ${DIST}/gcc ${DIST}/gcc/cp ${DIST}/gcc/cp/inc ${DIST}/gcc/config \ 148 ${G_CONFIGDIR} 149 150 .include "../Makefile.tconfigh" 151 DPSRCS+= tconfig.h 152 153 BUILDSYMLINKS+= ${G_UNWIND_H} unwind.h 154 DPSRCS+= unwind.h 155 156 # these aren't necessary but are #include'd 157 FAKEHEADERS=options.h insn-flags.h insn-constants.h 158 ${FAKEHEADERS}: 159 ${_MKTARGET_CREATE} 160 touch ${.TARGET} 161 DPSRCS+= ${FAKEHEADERS} 162 CLEANFILES+= ${FAKEHEADERS} 163