# Template file for 'cross-${_triplet}-gcc'
_triplet=or1k-none-elf
_pkgname=gcc
pkgname=cross-${_triplet}-gcc
version=10.2.0
revision=1
build_wrksrc=build
build_style=gnu-configure
make_build_args="INHIBIT_LIBC_CFLAGS='-DUSE_TM_CLONE_REGISTRY=0'"
hostmakedepends="autoconf automake cross-or1k-none-elf-binutils bison flex
 perl tar texinfo"
makedepends="gmp-devel isl15-devel libmpc-devel mpfr-devel zlib-devel"
depends="cross-or1k-none-elf-binutils"
short_desc="GNU Compiler Collection"
maintainer="John Sullivan <jsullivan@csumb.edu>"
license="GFDL-1.2-or-later, GPL-3.0-or-later, LGPL-2.1-or-later"
homepage="https://gcc.gnu.org"
distfiles="${GNU_SITE}/gcc/gcc-${version}/gcc-${version}.tar.xz"
checksum=b8dd4368bb9c7f0b98188317ee0254dd8cc99d1e3a18d0ff146c855fe16c1d8c
alternatives="or1k-none-elf:/usr/bin/or1k-none-elf-cc:/usr/bin/or1k-none-elf-gcc"
nocross=yes
nopie=yes
nostrip_files="libgcc.a libgcov.a"

if [ "$XBPS_TARGET_WORDSIZE" != 64 ]; then
	broken="https://api.travis-ci.org/v3/job/717355887/log.txt"
fi

export CFLAGS_FOR_TARGET="-g -Os -ffunction-sections -fdata-sections"
export CXXFLAGS_FOR_TARGET="-g -Os -ffunction-sections -fdata-sections"

post_extract() {
	mkdir -p build
}

do_configure() {
	../configure \
		--disable-decimal-float \
		--disable-libffi \
		--disable-libgomp \
		--disable-libmudflap \
		--disable-libquadmath \
		--disable-libssp \
		--disable-libstdcxx-pch \
		--disable-libstdc__-v3 \
		--disable-nls \
		--disable-shared \
		--disable-threads \
		--disable-tls \
		--disable-werror \
		--enable-__cxa_atexit \
		--enable-c99 \
		--enable-gnu-indirect-function \
		--enable-interwork \
		--enable-languages=c,c++ \
		--enable-long-long \
		--enable-multilib \
		--enable-plugins \
		--host=${XBPS_CROSS_TRIPLET} \
		--libdir=/usr/lib \
		--libexecdir=/usr/lib \
		--prefix=/usr \
		--target=${_triplet} \
		--with-gmp \
		--with-gnu-as \
		--with-gnu-ld \
		--with-headers=/usr/${_triplet}/include \
		--with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' \
		--with-isl \
		--with-libelf \
		--with-mpc \
		--with-mpfr \
		--with-native-system-header-dir=/include \
		--with-newlib \
		--with-python-dir=share/gcc-${_triplet} \
		--with-sysroot=/usr/${_triplet} \
		--with-system-zlib
}

post_install() {
	rm -fr ${DESTDIR}/usr/share/{info,man/man7}
	rm -fr ${DESTDIR}/usr/lib/libcc1.*
}
