1# $NetBSD: Makefile.inc,v 1.30 2015/04/15 19:13:46 mrg Exp $ 2 3LIBGCC_MACHINE_ARCH?=${MACHINE_ARCH:S/earmv5/earm/} 4 5.if ${MKGCC} != "no" 6.if exists(${.CURDIR}/../arch/${LIBGCC_MACHINE_ARCH}/defs.mk) 7.include "${.CURDIR}/../arch/${LIBGCC_MACHINE_ARCH}/defs.mk" 8.endif 9.endif 10 11UNSUPPORTED_COMPILER.clang= # defined 12 13DIST= ${GCCDIST} 14GNUHOSTDIST= ${DIST} 15GCCARCH= ${GCC_SUBDIR}/usr.bin/gcc/arch/${LIBGCC_MACHINE_ARCH} 16GCCARCHLIBGCC= ${GCC_SUBDIR}/lib/libgcc/arch/${LIBGCC_MACHINE_ARCH} 17GCCARCHXX= ${GCC_SUBDIR}/lib/libstdc++-v3/arch/${LIBGCC_MACHINE_ARCH} 18 19GCPPFLAGS= ${G_LIBGCC2_CFLAGS} ${G_USE_COLLECT2} ${G_INCLUDES} 20CPPFLAGS+= -I${.CURDIR} -I${GCCARCHLIBGCC} 21CPPFLAGS+= -I${GCCARCH} ${GCPPFLAGS:M-D*} ${GCPPFLAGS:M-I*:N-I.*} 22CPPFLAGS+= ${GCPPFLAGS:M-m*} ${GCPPFLAGS:M-f*} 23CPPFLAGS+= ${G_EXTRA_HEADERS:M/*:H:u:S/^/-I/g} 24CPPFLAGS+= -I${DIST}/libgcc -I${DIST}/libgcc/config 25CPPFLAGS+= -I${DIST}/gcc -I${DIST}/include -I. 26 27.if ${LIBGCC_MACHINE_ARCH} == "powerpc" || \ 28 ${LIBGCC_MACHINE_ARCH} == "sh3el" || \ 29 ${LIBGCC_MACHINE_ARCH} == "sh3eb" || \ 30 ${LIBGCC_MACHINE_ARCH} == "m68000" 31_TRADITIONAL_CPP= 32COMPILE.S= ${CC} ${AFLAGS} ${CPPFLAGS} -c 33.endif 34 35.if ${LIBGCC_MACHINE_ARCH} == "powerpc" 36CPPFLAGS+= -I${DIST}/gcc/config/rs6000 37.endif 38 39# 40# Old style libgcc build procedure. 41# 42 43# This is copied from dist/libgcc/Makefile.in:$lib2funcs 44LIB2FUNCS_ALL= \ 45 _muldi3 _negdi2 _lshrdi3 _ashldi3 _ashrdi3 _cmpdi2 _ucmpdi2 \ 46 _clear_cache _trampoline __main \ 47 _absvsi2 _absvdi2 _addvsi3 _addvdi3 \ 48 _subvsi3 _subvdi3 _mulvsi3 _mulvdi3 \ 49 _negvsi2 _negvdi2 \ 50 _ctors \ 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 56 57.if ${LIBGCC_MACHINE_ARCH} != "coldfire" && empty(LIBGCC_MACHINE_ARCH:Mearm*) 58 59LIB2FUNCS_ALL+= \ 60 _muldi3 _negdi2 _lshrdi3 _ashldi3 _ashrdi3 61 62.endif 63 64.if ${LIBGCC_MACHINE_ARCH} != "coldfire" && empty(LIBGCC_MACHINE_ARCH:Mearm*) 65 66# non swfloat versions 67.for _p in _fix _fixuns 68. for _m in sf df xf tf 69LIB2FUNCS_ALL+= ${_p}${_m}di 70. endfor 71.endfor 72 73.for _p in _float _floatun 74. for _m in sf df xf tf 75LIB2FUNCS_ALL+= ${_p}di${_m} 76. endfor 77.endfor 78 79.for _m in sf df xf 80LIB2FUNCS_ALL+= _fixuns${_m}si 81.endfor 82.endif 83 84LIB2FUNCS_SHORT:=${LIB2FUNCS_ALL} 85LIB2_DIVMOD_FUNCS:=${G_LIB2_DIVMOD_FUNCS} 86.for f in ${G_LIB1ASMFUNCS}; do 87LIB2FUNCS_SHORT:=${LIB2FUNCS_SHORT:N${f}} 88LIB2_DIVMOD_FUNCS:=${LIB2_DIVMOD_FUNCS:N${f}} 89.endfor 90 91LIB2FUNCS= ${LIB2FUNCS_SHORT:=.c} 92LIB2FUNCS_ST= ${G_LIB2FUNCS_ST:=.c} 93LIB2DIVMOD= ${LIB2_DIVMOD_FUNCS:=.c} 94.if ${HAVE_LIBGCC_EH} == "no" 95LIB2_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} 96LIB2_EHASM= ${G_LIB2ADDEH:M*.S:T:Nlibunwind.S} 97G_CONFIGLINKS:= ${G_CONFIGLINKS:S,libgcc/config/arm/unwind-arm.h,libgcc/unwind-generic.h,} 98.else 99LIB2_EH= ${G_LIB2ADDEH:M*.c:T} 100LIB2_EHASM= ${G_LIB2ADDEH:M*.S:T} 101.endif 102 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}) 108LIB1ASMFUNCS+= ${f} 109. endif 110. endfor 111.endif 112 113.if exists(${.CURDIR}/../arch/${LIBGCC_MACHINE_ARCH}/defs.mk) 114DPSRCS+= ${.CURDIR}/../arch/${LIBGCC_MACHINE_ARCH}/defs.mk 115.endif 116CLEANFILES+= ${LIB2FUNCS} ${LIB2FUNCS_ST} ${LIB2DIVMOD} cs-tconfig.h 117.if !empty(G_LIB1ASMFUNCS) 118CLEANFILES+= ${LIB1ASMFUNCS} 119.endif 120 121.for file in ${G_LIB2ADD:M${GNUHOSTDIST}*:N*.c} 122BUILDSYMLINKS+= ${file} ${file:T:S/.asm$/.S/} 123.endfor 124 125# XXX 126.if (${LIBGCC_MACHINE_ARCH} == "m68000" || ${LIBGCC_MACHINE_ARCH} == "m68k" || \ 127 ${LIBGCC_MACHINE_ARCH} == "coldfire") 128CPICFLAGS:= 129BUILDSYMLINKS+= ${DIST}/libgcc/config/m68k/fpgnulib.c fpgnulib.c 130BUILDSYMLINKS+= ${DIST}/libgcc/config/m68k/fpgnulib.c xfgnulib.c 131CPPFLAGS.xfgnulib.c+= -DEXTFLOAT=1 132.endif 133 134.if ${LIBGCC_MACHINE_ARCH} == "powerpc64" 135COPTS+= -mlong-double-128 136.endif 137 138${LIB2FUNCS} ${LIB2FUNCS_ST}: ${.CURDIR}/Makefile 139 ${_MKTARGET_CREATE} 140 printf '#define L${.PREFIX}\n#include <libgcc2.c>\n' >${.TARGET} 141 142${LIB2DIVMOD}: ${.CURDIR}/Makefile 143 ${_MKTARGET_CREATE} 144 printf '#define L${.PREFIX}\n#include <libgcc2.c>\n' >${.TARGET} 145 146.if !empty(G_LIB1ASMFUNCS) 147${LIB1ASMFUNCS}: ${.CURDIR}/Makefile 148 ${_MKTARGET_CREATE} 149 printf '#define L${.PREFIX}\n#include <${G_LIB1ASMSRC}>\n' >${.TARGET} 150.endif 151 152# Use dynamic sources to arrange for the C file to be the first dependency 153# so ${.IMPSRC} will work. 154 155${LIB2_EH:.c=.o}: $(.PREFIX).c 156 ${_MKTARGET_COMPILE} 157 ${COMPILE.c} -fexceptions ${COPTS.${.IMPSRC:T}} -o ${.TARGET} ${.IMPSRC} 158 159${LIB2_EH:.c=.pico}: $(.PREFIX).c 160 ${_MKTARGET_COMPILE} 161 ${COMPILE.c} ${CPICFLAGS} -fexceptions ${COPTS.${.IMPSRC:T}} -o ${.TARGET} ${.IMPSRC} 162 163${G_LIB2_DIVMOD_FUNCS:=.o}: $(.PREFIX).c 164 ${_MKTARGET_COMPILE} 165 ${COMPILE.c} -fexceptions -fnon-call-exceptions ${COPTS.${.IMPSRC:T}} -o ${.TARGET} ${.IMPSRC} 166 167${G_LIB2_DIVMOD_FUNCS:=.pico}: $(.PREFIX).c 168 ${_MKTARGET_COMPILE} 169 ${COMPILE.c} ${CPICFLAGS} -fexceptions -fnon-call-exceptions ${COPTS.${.IMPSRC:T}} -o ${.TARGET} ${.IMPSRC} 170 171dp-bit.c: ${.CURDIR}/Makefile 172 ${_MKTARGET_CREATE} 173 printf '#define FLOAT\n#include <fp-bit.c>\n' >${.TARGET} 174 175# 176# Common rules. 177# 178 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} 181 182.include "../Makefile.tconfigh" 183DPSRCS+= tconfig.h 184 185.if ${MKGCC} != "no" 186.if defined(G_CONFIGLINKS) && !empty(G_CONFIGLINKS) 187BUILDSYMLINKS+= ${G_CONFIGLINKS} 188.for _src _dst in ${G_CONFIGLINKS} 189DPSRCS+= ${_dst} 190.endfor 191.endif 192.endif 193 194EXTRA_FAKEHEADERS= options.h libgcc_tm.h 195.include "../../Makefile.hacks" 196