# Template file for 'cross-${_triplet}-gcc'
_triplet=bpf
_pkgname=gcc
pkgname=cross-${_triplet}-gcc
version=14.2.1+20250405
revision=1
_patchver="${version%+*}"
_minorver="${version%.*}"
_majorver="${_minorver%.*}"
build_wrksrc=build
build_style=gnu-configure
make_build_args="INHIBIT_LIBC_CFLAGS='-DUSE_TM_CLONE_REGISTRY=0'"
hostmakedepends="autoconf automake cross-bpf-binutils bison flex
 perl tar texinfo"
makedepends="gmp-devel isl-devel libmpc-devel mpfr-devel zlib-devel"
short_desc="GNU Compiler Collection"
maintainer="Leah Neukirchen <leah@vuxu.org>"
license="GFDL-1.2-or-later, GPL-3.0-or-later, LGPL-2.1-or-later"
homepage="https://gcc.gnu.org"
distfiles="https://gcc.gnu.org/pub/gcc/snapshots/${_majorver}-${version#*+}/gcc-${_majorver}-${version#*+}.tar.xz"
checksum=9a84b0947d8fb18197eef3fce8e255e30a61f7f382cebb961b1705c1d99214a3
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-fixincludes\
		--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 \
		--disable-gcov \
		--enable-__cxa_atexit \
		--enable-c99 \
		--enable-interwork \
		--enable-languages=c \
		--enable-long-long \
		--enable-plugins \
		--host=${XBPS_CROSS_TRIPLET} \
		--libdir=/usr/lib \
		--libexecdir=/usr/lib \
		--prefix=/usr \
		--target=${_triplet} \
		--with-gnu-as \
		--with-gnu-ld \
		--with-headers=/usr/${_triplet}/include \
		--with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' \
		--with-libelf \
		--with-native-system-header-dir=/include \
		--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.*
}
