Home | History | Annotate | Line # | Download | only in libgcc
Makefile.inc revision 1.41
      1 #	$NetBSD: Makefile.inc,v 1.41 2019/04/03 02:13:56 mrg Exp $
      2 
      3 LIBGCC_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 
     11 UNSUPPORTED_COMPILER.clang=	# defined
     12 
     13 DIST=		${GCCDIST}
     14 GNUHOSTDIST=	${DIST}
     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}
     18 
     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 .if ${LIBGCC_MACHINE_ARCH} == "x86_64"
     26 CPPFLAGS+=	-I${DIST}/libgcc/config/i386
     27 .else
     28 CPPFLAGS+=	-I${DIST}/libgcc/config/${LIBGCC_MACHINE_ARCH}
     29 .endif
     30 CPPFLAGS+=	-I${DIST}/gcc -I${DIST}/include -I.
     31 CPPFLAGS+=	${G_INTERNAL_CFLAGS:M-DHAVE_CC_TLS}
     32 
     33 .if ${LIBGCC_MACHINE_ARCH} == "powerpc" || \
     34     ${LIBGCC_MACHINE_ARCH} == "sh3el" || \
     35     ${LIBGCC_MACHINE_ARCH} == "sh3eb" || \
     36     ${LIBGCC_MACHINE_ARCH} == "m68000"
     37 _TRADITIONAL_CPP=
     38 COMPILE.S=	${CC} ${AFLAGS} ${CPPFLAGS} -c
     39 .endif
     40 
     41 .if ${LIBGCC_MACHINE_ARCH} == "powerpc"
     42 CPPFLAGS+=	-I${DIST}/gcc/config/rs6000
     43 .endif
     44 
     45 #
     46 # Old style libgcc build procedure.
     47 #
     48 
     49 # This is copied from dist/libgcc/Makefile.in:$lib2funcs
     50 LIB2FUNCS_ALL= \
     51 	_muldi3 _negdi2 _lshrdi3 _ashldi3 _ashrdi3 _cmpdi2 _ucmpdi2    \
     52 	_clear_cache _trampoline __main \
     53 	_absvsi2 _absvdi2 _addvsi3 _addvdi3 \
     54 	_subvsi3 _subvdi3 _mulvsi3 _mulvdi3 \
     55 	_negvsi2 _negvdi2 \
     56 	_ctors \
     57 	_ffssi2 _ffsdi2 _clz _clzsi2 _clzdi2  _ctzsi2 _ctzdi2 \
     58 	_popcount_tab _popcountsi2 _popcountdi2 _paritysi2 _paritydi2 \
     59 	_powisf2 _powidf2 _powixf2 _powitf2 \
     60 	_mulsc3 _muldc3 _mulxc3 _multc3 _divsc3 _divdc3 _divxc3 _divtc3 \
     61 	_bswapsi2 _bswapdi2 _clrsbsi2 _clrsbdi2
     62 
     63 .if ${LIBGCC_MACHINE_ARCH} != "coldfire" && empty(LIBGCC_MACHINE_ARCH:Mearm*)
     64 
     65 LIB2FUNCS_ALL+= \
     66 	_muldi3 _negdi2 _lshrdi3 _ashldi3 _ashrdi3
     67 
     68 .endif
     69 
     70 .if ${LIBGCC_MACHINE_ARCH} != "coldfire" && \
     71     empty(LIBGCC_MACHINE_ARCH:Mearm*) && \
     72     empty(LIBGCC_MACHINE_ARCH:Maarch64*) && \
     73     empty(LIBGCC_MACHINE_ARCH:Mmips64*)
     74 
     75 EXTRA_FUNC_SIZES=	sf df xf
     76 
     77 .if ${LIBGCC_MACHINE_ARCH} != "x86_64" && \
     78     ${LIBGCC_MACHINE_ARCH} != "i386" && \
     79     ${LIBGCC_MACHINE_ARCH} != "ia64"
     80 EXTRA_FUNC_SIZES+=	tf
     81 .endif
     82 
     83 # non swfloat versions
     84 .for _p in _fix _fixuns
     85 . for _m in ${EXTRA_FUNC_SIZES}
     86 LIB2FUNCS_ALL+=	${_p}${_m}di
     87 . endfor
     88 .endfor
     89 
     90 .for _p in _float _floatun
     91 . for _m in ${EXTRA_FUNC_SIZES}
     92 LIB2FUNCS_ALL+=	${_p}di${_m}
     93 . endfor
     94 .endfor
     95 
     96 .for _m in sf df xf
     97 LIB2FUNCS_ALL+=	_fixuns${_m}si
     98 .endfor
     99 .endif
    100 
    101 LIB2FUNCS_SHORT:=${LIB2FUNCS_ALL}
    102 LIB2_DIVMOD_FUNCS:=${G_LIB2_DIVMOD_FUNCS}
    103 .for f in ${G_LIB1ASMFUNCS}; do
    104 LIB2FUNCS_SHORT:=${LIB2FUNCS_SHORT:N${f}}
    105 LIB2_DIVMOD_FUNCS:=${LIB2_DIVMOD_FUNCS:N${f}}
    106 .endfor
    107 
    108 LIB2FUNCS=	${LIB2FUNCS_SHORT:=.c}
    109 LIB2FUNCS_ST=	${G_LIB2FUNCS_ST:=.c}
    110 LIB2DIVMOD=	${LIB2_DIVMOD_FUNCS:=.c}
    111 .if ${HAVE_LIBGCC_EH} == "no"
    112 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}
    113 LIB2_EHASM=	${G_LIB2ADDEH:M*.S:T:Nlibunwind.S}
    114 .else
    115 LIB2_EH=	${G_LIB2ADDEH:M*.c:T}
    116 LIB2_EHASM=	${G_LIB2ADDEH:M*.S:T}
    117 .endif
    118 
    119 # We have to weed out any existing func.S file that may exist
    120 # from the list of files we create.
    121 .if !empty(G_LIB1ASMFUNCS)
    122 . for f in ${G_LIB1ASMFUNCS:=.S}
    123 .  if !exists(${DIST}/libgcc/config/${MACHINE_CPU}/${f})
    124 LIB1ASMFUNCS+=	${f}
    125 .  endif
    126 . endfor
    127 .endif
    128 
    129 .if exists(${.CURDIR}/../arch/${LIBGCC_MACHINE_ARCH}/defs.mk)
    130 DPSRCS+=	${.CURDIR}/../arch/${LIBGCC_MACHINE_ARCH}/defs.mk
    131 .endif
    132 CLEANFILES+=	${LIB2FUNCS} ${LIB2FUNCS_ST} ${LIB2DIVMOD} cs-tconfig.h
    133 .if !empty(G_LIB1ASMFUNCS)
    134 CLEANFILES+=	${LIB1ASMFUNCS}
    135 .endif
    136 
    137 .for file in ${G_LIB2ADD:M${GNUHOSTDIST}*:N*.c}
    138 BUILDSYMLINKS+=	${file} ${file:T:S/.asm$/.S/}
    139 .endfor
    140 
    141 # XXX
    142 .if (${LIBGCC_MACHINE_ARCH} == "m68000" || ${LIBGCC_MACHINE_ARCH} == "m68k" || \
    143      ${LIBGCC_MACHINE_ARCH} == "coldfire")
    144 CPICFLAGS:=
    145 BUILDSYMLINKS+=	${DIST}/libgcc/config/m68k/fpgnulib.c fpgnulib.c
    146 BUILDSYMLINKS+=	${DIST}/libgcc/config/m68k/fpgnulib.c xfgnulib.c
    147 CPPFLAGS.xfgnulib.c+=	-DEXTFLOAT=1
    148 .endif
    149 
    150 .if ${LIBGCC_MACHINE_ARCH} == "powerpc64"
    151 COPTS+=	-mlong-double-128
    152 .endif
    153 
    154 ${LIB2FUNCS} ${LIB2FUNCS_ST}: ${.CURDIR}/Makefile
    155 	${_MKTARGET_CREATE}
    156 	printf '#define L${.PREFIX}\n#include <libgcc2.c>\n' >${.TARGET}
    157 
    158 ${LIB2DIVMOD}: ${.CURDIR}/Makefile
    159 	${_MKTARGET_CREATE}
    160 	printf '#define L${.PREFIX}\n#include <libgcc2.c>\n' >${.TARGET}
    161 
    162 .if !empty(G_LIB1ASMFUNCS)
    163 ${LIB1ASMFUNCS}: ${.CURDIR}/Makefile
    164 	${_MKTARGET_CREATE}
    165 	printf '#define L${.PREFIX}\n#include <${G_LIB1ASMSRC}>\n' >${.TARGET}
    166 .endif
    167 
    168 # Use dynamic sources to arrange for the C file to be the first dependency
    169 # so ${.IMPSRC} will work.
    170 
    171 ${LIB2_EH:.c=.o}: $(.PREFIX).c
    172 	${_MKTARGET_COMPILE}
    173 	${COMPILE.c} -fexceptions ${COPTS.${.IMPSRC:T}} -o ${.TARGET} ${.IMPSRC}
    174 
    175 ${LIB2_EH:.c=.pico}: $(.PREFIX).c
    176 	${_MKTARGET_COMPILE}
    177 	${COMPILE.c} ${CPICFLAGS} -fexceptions ${COPTS.${.IMPSRC:T}} -o ${.TARGET} ${.IMPSRC}
    178 
    179 ${G_LIB2_DIVMOD_FUNCS:=.o}: $(.PREFIX).c
    180 	${_MKTARGET_COMPILE}
    181 	${COMPILE.c} -fexceptions -fnon-call-exceptions ${COPTS.${.IMPSRC:T}} -o ${.TARGET} ${.IMPSRC}
    182 
    183 ${G_LIB2_DIVMOD_FUNCS:=.pico}: $(.PREFIX).c
    184 	${_MKTARGET_COMPILE}
    185 	${COMPILE.c} ${CPICFLAGS} -fexceptions -fnon-call-exceptions ${COPTS.${.IMPSRC:T}} -o ${.TARGET} ${.IMPSRC}
    186 
    187 dp-bit.c: ${.CURDIR}/Makefile
    188 	${_MKTARGET_CREATE}
    189 	printf '#define FLOAT\n#include <fp-bit.c>\n' >${.TARGET}
    190 
    191 #
    192 # Common rules.
    193 #
    194 
    195 .PATH: ${DIST}/gcc ${DIST}/gcc/cp ${DIST}/gcc/cp/inc ${DIST}/gcc/config \
    196 	${DIST}/libgcc/config ${DIST}/libgcc/config/${MACHINE_CPU} \
    197 	${G_LIB2ADD:H:O:u} ${G_LIB2ADDEH:H:O:u} ${GCCARCHLIBGCC}
    198 
    199 .include "../Makefile.tconfigh"
    200 DPSRCS+=	tconfig.h
    201 
    202 .include "../Makefile.gthr"
    203 
    204 EXTRA_FAKEHEADERS=	options.h libgcc_tm.h
    205 .include "../../Makefile.hacks"
    206 
    207 # XXX insn-modes.h
    208 BINBACKENDOBJ!=	cd ${.CURDIR}/../../../usr.bin/backend && ${PRINTOBJDIR}
    209 CPPFLAGS+=	-I${BINBACKENDOBJ}
    210