# Template file for 'gcc'
# Revbump libtool when updating gcc, since it hardcodes some internal compiler paths
# which use the version number.

pkgname=gcc
version=13.2.0
revision=2
_minorver="${version%.*}"
_majorver="${_minorver%.*}"
_gmp_version=6.3.0
_mpfr_version=4.2.1
_mpc_version=1.3.1
_isl_version=0.26
create_wrksrc=yes
short_desc="GNU Compiler Collection"
maintainer="Enno Boland <gottox@voidlinux.org>"
homepage="http://gcc.gnu.org"
license="GFDL-1.2-or-later, GPL-3.0-or-later, LGPL-2.1-or-later"
# *-musl builders have issues fetching https://ftp.gnu.org/gnu/mpc/mpc-1.1.0.tar.gz
distfiles="
 ${GNU_SITE}/gcc/gcc-${version}/gcc-${version}.tar.xz
 ${GNU_SITE}/gmp/gmp-${_gmp_version}.tar.xz
 ${GNU_SITE}/mpfr/mpfr-${_mpfr_version}.tar.xz
 ${GNU_SITE}/mpc/mpc-${_mpc_version}.tar.gz
 ${SOURCEFORGE_SITE}/libisl/isl-${_isl_version}.tar.bz2"
checksum="e275e76442a6067341a27f04c5c6b83d8613144004c0413528863dc6b5c743da
 a3c2b80201b89e68616f4ad30bc66aee4927c3ce50e33929ca819d5c43538898
 277807353a6726978996945af13e52829e3abd7a9a5b7fb2793894e18f1fcbb2
 ab642492f5cf882b74aa0cb730cd410a81edcdbec895183ce930e706c1c759b8
 5eac8664e9d67be6bd0bee5085d6840b8baf738c06814df47eaf4166d9776436"

nopie=yes
lib32disabled=yes
bootstrap=yes
replaces="gcc-gcj<7.2.0 gcc-gcj-jdk-compat<7.2.0 libmpx>=0 libmpx-devel>=0
 libssp>=0 libssp-devel>=0"

_have_gccgo=yes
_have_libquadmath=no

# MIPS is untested and does not have go in crosstoolchains
# 32-bit PowerPC seems weirdly broken since the 10.x release
# 32-bit little endian PowerPC has no support at all (no GOARCH)
case "$XBPS_TARGET_MACHINE" in
	ppc64*) ;;
	mips*-musl|ppc*) _have_gccgo=no ;;
esac

case "$XBPS_TARGET_MACHINE" in
	i686*|x86_64*|ppc64le*) _have_libquadmath=yes ;;
esac

if [ "$CHROOT_READY" ]; then
	hostmakedepends="tar texinfo perl flex"
else
	_have_gccgo=no
	# libzstd fails to link in bootstrap with glibc 2.36
	# when zlib has been compiled with glibc 2.32.
	LDFLAGS="-lzstd -pthread"
fi
makedepends="zlib-devel libzstd-devel"
depends="binutils libgcc-devel-${version}_${revision}
 libstdc++-devel-${version}_${revision} libatomic-devel-${version}_${revision}"
checkdepends="dejagnu"

subpackages="libgcc libgomp libgomp-devel libatomic libatomic-devel"

build_options="ada gnatboot"
build_options_default="ada"
desc_option_ada="Enable Ada build"
desc_option_gnatboot="Enable Ada bootstrap using adacore.com binaries"

if [ "$build_option_gnatboot" ]; then
	case "$XBPS_TARGET_MACHINE" in
	x86_64)
		_gnat_tarball="gnat-gpl-2017-x86_64-linux-bin.tar.gz"
		distfiles+=" https://community.download.adacore.com/v1/9682e2e1f2f232ce03fe21d77b14c37a0de5649b?filename=$_gnat_tarball>$_gnat_tarball"
		checksum+=" b942bcac20dea39748b39f8b624d9619f60a8dee2e8195dbe3829c835b0956e6"
		build_options_default="gnatboot"
		;;
	i686)
		_gnat_tarball="gnat-gpl-2014-x86-linux-bin.tar.gz"
		distfiles+=" https://community.download.adacore.com/v1/c5e9e6fdff5cb77ed90cf8c62536653e27c0bed6?filename=$_gnat_tarball>$_gnat_tarball"
		checksum+=" 3b693510f5d22a240abb3034934c1adbd80ccd6e4f61a4f491cc408fdfd9c042"
		build_options_default="gnatboot"
		;;
	esac
fi

if [ "$CHROOT_READY" ]; then
	subpackages+=" gcc-fortran libgfortran-devel libgfortran"
	subpackages+=" gcc-objc gcc-objc++ libobjc-devel libobjc"

	if [ "$_have_libquadmath" = "yes" ]; then
		subpackages+=" libquadmath libquadmath-devel"
	fi
fi

if [ "$_have_gccgo" = "yes" ]; then
	subpackages+=" gcc-go gcc-go-tools libgo-devel libgo"
	# we need this for gcc-go on musl
	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
		makedepends+=" libucontext-devel"
	fi
fi

subpackages+=" libstdc++-devel libstdc++ libgcc-devel"
if [ "$build_option_gnatboot" -o "$build_option_ada" ]; then
	subpackages+=" gcc-ada libada-devel libada"
fi

case "$XBPS_TARGET_MACHINE" in
	i686) _triplet="i686-pc-linux-gnu";;
	i686-musl) _triplet="i686-linux-musl";;
	x86_64) _triplet="x86_64-unknown-linux-gnu";;
	x86_64-musl) _triplet="x86_64-linux-musl";;
	armv5tel) _triplet="arm-linux-gnueabi";;
	armv5tel-musl) _triplet="arm-linux-musleabi";;
	armv6l) _triplet="arm-linux-gnueabihf";;
	armv7l) _triplet="armv7l-linux-gnueabihf";;
	armv6l-musl) _triplet="arm-linux-musleabihf";;
	armv7l-musl) _triplet="armv7l-linux-musleabihf";;
	aarch64) _triplet="aarch64-linux-gnu";;
	aarch64-musl) _triplet="aarch64-linux-musl";;
	ppc) _triplet="powerpc-linux-gnu";;
	ppc-musl) _triplet="powerpc-linux-musl";;
	ppcle) _triplet="powerpcle-linux-gnu";;
	ppcle-musl) _triplet="powerpcle-linux-musl";;
	ppc64le) _triplet="powerpc64le-linux-gnu";;
	ppc64le-musl) _triplet="powerpc64le-linux-musl";;
	ppc64) _triplet="powerpc64-linux-gnu";;
	ppc64-musl) _triplet="powerpc64-linux-musl";;
	mips-musl) _triplet="mips-linux-musl";;
	mipshf-musl) _triplet="mips-linux-muslhf";;
	mipsel-musl) _triplet="mipsel-linux-musl";;
	mipselhf-musl) _triplet="mipsel-linux-muslhf";;
	riscv64) _triplet="riscv64-linux-gnu";;
	riscv64-musl) _triplet="riscv64-linux-musl";;
esac
case "$XBPS_TARGET_MACHINE" in
	*-musl)	 depends+=" musl-devel";;
	*) 	 depends+=" glibc-devel"
		 subpackages+=" libsanitizer libsanitizer-devel"
		 ;;
esac
case "$XBPS_TARGET_MACHINE" in
	i686*|x86_64*)
		subpackages+=" libvtv libvtv-devel"
		;;
esac
case "$XBPS_TARGET_MACHINE" in
	mips*) ;;
	riscv*) ;;
	x86_64*|i686) subpackages+=" libitm libitm-devel";;
	*) subpackages+=" libitm libitm-devel";;
esac
if [ "$CROSS_BUILD" ]; then
	hostmakedepends+=" cross-${_triplet}"
	if [ "$build_option_ada" ]; then
		hostmakedepends+=" gcc-ada"
	fi
fi

post_extract() {
	mv gcc-${version}/* gcc-${version}/.??* .
	rmdir gcc-${version}
	mv gmp-${_gmp_version} gmp
	mv mpfr-${_mpfr_version} mpfr
	mv mpc-${_mpc_version} mpc
	mv isl-${_isl_version} isl

	if [ "$build_option_gnatboot" ]; then
		local f="${XBPS_SRCDISTDIR}/${pkgname}-${version}/${_gnat_tarball}"
		msg_normal "Extracting ${_gnat_tarball} ...\n"
		mkdir -p ${wrksrc}/gnat-ins
		tar -x -f "$f" --strip-components=1 -C ${wrksrc}/gnat-ins
		cd ${wrksrc}/gnat-ins
		make ins-all prefix=${wrksrc}/gnat
		cd ${wrksrc}
		rm -rf ${wrksrc}/gnat-ins

		# Rename obsolete ld and as
		find ${wrksrc}/gnat -name ld -exec mv -v {} {}.old \;
		find ${wrksrc}/gnat -name as -exec mv -v {} {}.old \;
	fi
}

pre_configure() {
	# _FORTIFY_SOURCE needs an optimization level.
	sed -i "/ac_cpp=/s/\$CPPFLAGS/\$CPPFLAGS -O2/" {gcc,libiberty}/configure

	# Do not run fixincludes
	sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in

	# Do not enable C++17, gcc compiles with -std=c++11
	sed -i 's/HAVE_CXX17=1/HAVE_CXX17=0/' isl/configure

	if [ "$XBPS_TARGET_LIBC" = musl ]; then
		for p in ${FILESDIR}/*-musl.patch; do
			msg_normal "patching: $p\n"
			patch -p1 -i $p
		done
	fi
}
do_configure() {
	local _langs _args _hash

	_hash=gnu
	case "$XBPS_TARGET_MACHINE" in
		mipselhf-musl) _args+=" --with-arch=mips32r2 --with-float=hard --enable-autolink-libatomic"; _hash=sysv;;
		mipsel-musl) _args+=" --with-arch=mips32r2 --with-float=soft --enable-autolink-libatomic"; _hash=sysv;;
		mipshf-musl) _args+=" --with-arch=mips32r2 --with-float=hard --enable-autolink-libatomic";;
		mips-musl) _args+=" --with-arch=mips32r2 --with-float=soft --enable-autolink-libatomic";;
		armv5*) _args+=" --with-arch=armv5te --with-float=soft --enable-autolink-libatomic";;
		armv6l*) _args+=" --with-arch=armv6 --with-fpu=vfp --with-float=hard --enable-autolink-libatomic";;
		armv7l*) _args+=" --with-arch=armv7-a --with-fpu=vfpv3 --with-float=hard";;
		aarch64*) _args+=" --with-arch=armv8-a";;
		ppc64le*) _args+=" --with-abi=elfv2 --enable-secureplt --enable-targets=powerpcle-linux";;
		ppc64*) _args+=" --with-abi=elfv2 --enable-secureplt --enable-targets=powerpc-linux";;
		ppc*) _args+=" --enable-secureplt --enable-autolink-libatomic";;
	esac

	# on all big endian ppc64
	case "$XBPS_TARGET_MACHINE" in
		ppc64le*) ;;
		ppc64*) _args+=" --disable-libquadmath" ;;
	esac

	# fix: unknown long double size, cannot define BFP_FMT
	case "$XBPS_TARGET_MACHINE" in
		ppc*-musl) _args+=" --disable-decimal-float";;
	esac

	if [ -z "$CHROOT_READY" -o -n "$CROSS_BUILD" ]; then
		_langs="c,c++,lto"
	fi

	if [ "$CROSS_BUILD" ]; then
		export CC_FOR_TARGET="$CC"
		export GCC_FOR_TARGET="$CC"
		export CXX_FOR_TARGET="$CXX"
		export GOC_FOR_TARGET="${_triplet}-gccgo"
		export GFORTRAN_FOR_TARGET="${_triplet}-gfortran"

		_args+=" --host=$XBPS_CROSS_TRIPLET"
		_args+=" --with-build-sysroot=${XBPS_CROSS_BASE}"
		_langs+=",objc,obj-c++,fortran"
	elif [ -z "$CHROOT_READY" ]; then
		export LD_LIBRARY_PATH="${XBPS_MASTERDIR}/usr/lib${XBPS_TARGET_WORDSIZE}"
		_args+=" --build=${_triplet}"
	else
		_langs="c,c++,objc,obj-c++,fortran,lto"
		_args+=" --build=${_triplet}"
	fi

	if [ "$_have_gccgo" = "yes" ]; then
		_langs+=",go"
	fi

	if [ "$XBPS_TARGET_LIBC" = "musl" ]; then
		_args+=" --disable-gnu-unique-object"
		_args+=" --disable-libsanitizer"
		_args+=" --disable-symvers"
		_args+=" libat_cv_have_ifunc=no"
	else
		_args+=" --enable-gnu-unique-object"
	fi

	case "$XBPS_TARGET_MACHINE" in
		ppc*) _args+=" --disable-vtable-verify";;
		*) _args+=" --enable-vtable-verify";;
	esac

	export CFLAGS="${CFLAGS/-D_FORTIFY_SOURCE=2/}"
	export CXXFLAGS="${CXXFLAGS/-D_FORTIFY_SOURCE=2/}"

	# Disable explicit -fno-PIE, gcc will figure this out itself.
	export CFLAGS="${CFLAGS//-fno-PIE/}"
	export CXXFLAGS="${CXXFLAGS//-fno-PIE/}"
	export LDFLAGS="${LDFLAGS//-no-pie/}"

	_args+=" --prefix=/usr"
	_args+=" --mandir=/usr/share/man"
	_args+=" --infodir=/usr/share/info"
	_args+=" --libexecdir=/usr/lib${XBPS_TARGET_WORDSIZE}"
	_args+=" --libdir=/usr/lib${XBPS_TARGET_WORDSIZE}"
	_args+=" --enable-threads=posix"
	_args+=" --enable-__cxa_atexit"
	_args+=" --disable-multilib"
	_args+=" --with-system-zlib"
	_args+=" --enable-shared"
	_args+=" --enable-lto"
	_args+=" --enable-plugins"
	_args+=" --enable-linker-build-id"
	_args+=" --disable-werror"
	_args+=" --disable-nls"
	_args+=" --enable-default-pie"
	_args+=" --enable-default-ssp"
	_args+=" --enable-checking=release"
	_args+=" --disable-libstdcxx-pch"
	_args+=" --with-isl"
	_args+=" --with-linker-hash-style=$_hash"
	_args+=" --disable-sjlj-exceptions"
	_args+=" --disable-target-libiberty"
	_args+=" --disable-libssp"

	mkdir -p build
	cd build
	if [ "$build_option_gnatboot" ]; then
		_args+=" --enable-languages=${_langs},ada"
		_args+=" --enable-libada"
		CONFIG_SHELL=/bin/bash \
		CC="${wrksrc}/gnat/bin/gcc" \
		GNATBIND="${wrksrc}/gnat/bin/gnatbind" \
		GNATMAKE="${wrksrc}/gnat/bin/gnatmake" \
		PATH="${wrksrc}/gnat/bin:$PATH" \
			${wrksrc}/configure ${_args}
	elif [ "$build_option_ada" ]; then
		_args+=" --enable-languages=${_langs},ada"
		CONFIG_SHELL=/bin/bash \
			${wrksrc}/configure ${_args}
	else
		_args+=" --enable-languages=${_langs}"
		CONFIG_SHELL=/bin/bash \
			${wrksrc}/configure ${_args}
	fi
}
do_build() {
	if [ -z "$CHROOT_READY" ]; then
		export LD_LIBRARY_PATH="${XBPS_MASTERDIR}/usr/lib${XBPS_TARGET_WORDSIZE}"
	fi
	cd build
	if [ "$build_option_gnatboot" ]; then
		CC="${wrksrc}/gnat/bin/gcc" \
		GNATBIND="${wrksrc}/gnat/bin/gnatbind" \
		GNATMAKE="${wrksrc}/gnat/bin/gnatmake" \
		PATH="${wrksrc}/gnat/bin:$PATH" \
		make ${makejobs}
	else
		make ${makejobs}
	fi
}
pre_install() {
	if [ "$CROSS_BUILD" ]; then
		# XXX otherwise links to host libpthread
		for f in $(find ${wrksrc}/build/${XBPS_CROSS_TRIPLET} -type f -name libtool); do
			sed -e "s,add_dir=\"-L\$libdir\",add_dir=\"-L${XBPS_CROSS_BASE}\$libdir\",g" -i $f
		done
	fi
}
do_install() {
	cd build

	make DESTDIR=${DESTDIR} install

	# Make version a symlink of major version to make all versions
	# from the same series work automagically.
	mv ${DESTDIR}/usr/lib/gcc/${_triplet}/${version} \
		${DESTDIR}/usr/lib/gcc/${_triplet}/${_minorver}
	ln -sfr ${DESTDIR}/usr/lib/gcc/${_triplet}/${_minorver} \
		${DESTDIR}/usr/lib/gcc/${_triplet}/${version}

	# Ditto for c++ headers.
	mv ${DESTDIR}/usr/include/c++/${version} \
		${DESTDIR}/usr/include/c++/${_minorver}
	ln -sfr ${DESTDIR}/usr/include/c++/${_minorver} \
		${DESTDIR}/usr/include/c++/${version}

	# cc symlink
	ln -sfr ${DESTDIR}/usr/bin/gcc ${DESTDIR}/usr/bin/cc
	# rpcgen wants /lib/cpp, make a symlink
	ln -sfr ${DESTDIR}/usr/bin/cpp ${DESTDIR}/usr/lib/cpp

	# lto plugin symlink
	vmkdir usr/lib/bfd-plugins
	ln -sfr ${DESTDIR}/usr/lib/gcc/${_triplet}/${version}/liblto_plugin.so \
		${DESTDIR}/usr/lib/bfd-plugins

	# Remove "fixed" header
	# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91085
	rm -vf ${DESTDIR}/usr/lib/gcc/${_triplet}/${_minorver}/include-fixed/bits/statx.h

	# Remove libffi stuff.
	rm -f ${DESTDIR}/usr/lib/libffi*
	rm -f ${DESTDIR}/usr/share/man/man3/ffi*

	# Move libstdc++ gdb helpers to location where gdb can autoload them
	mkdir -p ${DESTDIR}/usr/share/gdb/auto-load/usr/lib
	mv ${DESTDIR}/usr/lib/*.py ${DESTDIR}/usr/share/gdb/auto-load/usr/lib

	# Install c89 and c99 wrappers and its manpages, from NetBSD.
	for f in c89 c99; do
		vbin ${FILESDIR}/${f}.sh ${f}
		vman ${FILESDIR}/${f}.1
	done

	if [ "$_have_libquadmath" != "yes"]; then
		rm -f ${DESTDIR}/usr/share/info/libquadmath.info*
	fi
}

gcc-ada_package() {
	lib32disabled=yes
	depends="gcc>=${_minorver} libada-devel>=${_minorver}"
	short_desc+=" - Ada compiler frontend"
	pkg_install() {
		for f in gnat{,bind,chop,clean,kr,link,ls,make,name,prep}; do
			vmove usr/bin/${f}
		done
	}
}

gcc-go_package() {
	lib32disabled=yes
	depends="gcc>=${_minorver} libgo-devel>=${_minorver}"
	short_desc+=" - Go compiler frontend"
	nostrip_files="buildid cgo test2json vet"
	pkg_install() {
		for f in gccgo ${_triplet}-gccgo; do
			vmove usr/bin/${f}
		done
		for f in buildid cgo go1 test2json vet; do
			vmove usr/lib/gcc/${_triplet}/${_minorver}/${f}
		done
		vmove usr/share/info/gccgo.info
		touch ${PKGDESTDIR}/usr/share/info/dir
		vmove usr/share/man/man1/gccgo.1
		vmove usr/lib/go
	}
}

gcc-go-tools_package() {
	lib32disabled=yes
	depends="gcc-go>=${_minorver}"
	short_desc+=" - Go tools"
	conflicts="go>=0"
	nostrip=yes
	pkg_install() {
		vmove usr/bin/go
		vmove usr/bin/gofmt
		vmove usr/share/man/man1/go.1
		vmove usr/share/man/man1/gofmt.1
	}
}

gcc-fortran_package() {
	lib32disabled=yes
	depends="gcc>=${_minorver} libgfortran-devel>=${_minorver}"
	short_desc+=" - Fortran compiler frontend"
	pkg_install() {
		for f in gfortran ${_triplet}-gfortran; do
			vmove usr/bin/${f}
		done
		vmove usr/lib/gcc/${_triplet}/${_minorver}/f951
		vmove usr/lib/gcc/${_triplet}/${_minorver}/libcaf_single.a
		vmove usr/lib/gcc/${_triplet}/${_minorver}/finclude
		if [ "$CROSS_BUILD" ]; then
			# A number of OMP modules are not built when cross
			# compiling gcc. Copy them from the cross compiler.
			local src="/usr/lib/gcc/${_triplet}/${version}/finclude"
			local dst="usr/lib/gcc/${_triplet}/${_minorver}/finclude"
			for f in omp_lib.f90 omp_lib.h omp_lib.mod omp_lib_kinds.mod \
				openacc.f90 openacc.mod openacc_kinds.mod openacc_lib.h; do
				vinstall ${src}/${f} 644 ${dst}/
			done
		fi
		vmove usr/share/info/gfortran.info
		touch ${PKGDESTDIR}/usr/share/info/dir
		vmove usr/share/man/man1/gfortran.1
	}
}

gcc-objc++_package() {
	lib32disabled=yes
	depends="gcc-objc>=${_minorver}"
	short_desc+=" - Objective-C++ support"
	pkg_install() {
		vmove usr/lib/gcc/${_triplet}/${_minorver}/cc1objplus
	}
}

gcc-objc_package() {
	lib32disabled=yes
	depends="gcc>=${_minorver} libobjc>=${_minorver}"
	short_desc+=" - Objective-C support"
	pkg_install() {
		vmove usr/lib/gcc/${_triplet}/${_minorver}/include/objc
		vmove usr/lib/gcc/${_triplet}/${_minorver}/cc1obj
	}
}

libada-devel_package() {
	depends="libada>=${_minorver}"
	short_desc+=" - Ada library - development files"
	pkg_install() {
		vmove usr/lib/gcc/${_triplet}/${_minorver}/adainclude
		vmove usr/lib/gcc/${_triplet}/${_minorver}/plugin/include/ada
	}
}

libada_package() {
	short_desc+=" - Ada library"
	pkg_install() {
		vmove usr/lib/gcc/${_triplet}/${_minorver}/adalib
		mv -v ${PKGDESTDIR}/usr/lib/gcc/${_triplet}/${_minorver}/adalib/libgna{rl,t}{,-${_majorver}}.so \
			${PKGDESTDIR}/usr/lib
	}
}

libgfortran-devel_package() {
	depends="libgfortran>=${_minorver}"
	short_desc+=" - Fortran library - development files"

	if [ "$_have_libquadmath" = "yes" ]; then
		depends+=" libquadmath-devel"
	fi

	pkg_install() {
		vmove usr/lib/libgfortran.spec
		vmove usr/lib/libgfortran.a
		# This does not seem to exist anymore?
		if [ -f usr/lib/gcc/${_triplet}/${_minorver}/libgfortranbegin.a ]; then
			vmove usr/lib/gcc/${_triplet}/${_minorver}/libgfortranbegin.a
		fi
	}
}

libgfortran_package() {
	short_desc+=" - Fortran library"
	pkg_install() {
		vmove "usr/lib/libgfortran.so*"
		vlicense COPYING.RUNTIME RUNTIME.LIBRARY.EXCEPTION
	}
}

libgo-devel_package() {
	depends="libgo>=${_minorver}"
	short_desc+=" - Go library - development files"
	nostrip=yes
	pkg_install() {
		vmove usr/lib/libgo.a
		vmove usr/lib/libgobegin.a
		vmove usr/lib/libgolibbegin.a
		vmove usr/lib/libgo.so
	}
}

libgo_package() {
	short_desc+=" - Go library"
	nostrip=yes
	pkg_install() {
		vmove "usr/lib/libgo.so*"
		vlicense COPYING.RUNTIME RUNTIME.LIBRARY.EXCEPTION
	}
}

libobjc-devel_package() {
	depends="libobjc>=${_minorver}"
	short_desc+=" - Objective-C library - development files"
	pkg_install() {
		vmove "usr/lib/libobjc.*a"
	}
}

libobjc_package() {
	short_desc+=" - Objective-C library"
	pkg_install() {
		vmove "usr/lib/libobjc.so*"
		vlicense COPYING.RUNTIME RUNTIME.LIBRARY.EXCEPTION
	}
}

libquadmath-devel_package() {
	depends="libquadmath>=${_minorver}"
	short_desc+=" - quadmath library - development files"
	pkg_install() {
		vmove "usr/lib/gcc/${_triplet}/${_minorver}/include/quadmath*"
		vmove "usr/lib/libquadmath*.a"
		vmove usr/share/info/libquadmath.info
		touch ${PKGDESTDIR}/usr/share/info/dir
	}
}

libquadmath_package() {
	short_desc+=" - quadmath library"
	pkg_install() {
		vmove "usr/lib/libquadmath.so*"
		vlicense COPYING.RUNTIME RUNTIME.LIBRARY.EXCEPTION
	}
}

libvtv-devel_package() {
	depends="libvtv>=${_minorver}"
	short_desc+=" - Vtable Verification Runtime Library - development files"
	pkg_install() {
		vmove usr/lib/libvtv.a
		vmove usr/lib/libvtv.so
	}
}

libvtv_package() {
	short_desc+=" - Vtable Verification Runtime Library"
	pkg_install() {
		vmove usr/lib/libvtv.so.*
	}
}

libatomic-devel_package() {
	depends="libatomic>=${_minorver}"
	short_desc+=" - Atomics library - development files"
	pkg_install() {
		vmove usr/lib/libatomic.a
		vmove usr/lib/libatomic.so
	}
}

libatomic_package() {
	short_desc+=" - Atomics library"
	pkg_install() {
		vmove usr/lib/libatomic.so.*
	}
}

libgcc_package() {
	short_desc+=" - GCC library"
	replaces="libcilkrts<8.2.0"
	noverifyrdeps=yes
	pkg_install() {
		vmove "usr/lib/libgcc_s.so*"
		vlicense COPYING.RUNTIME RUNTIME.LIBRARY.EXCEPTION
	}
}

libgcc-devel_package() {
	depends="libgcc-${version}_${revision}"
	short_desc+=" - GCC library - development files"
	replaces="libcilkrts-devel<8.2.0"
	pkg_install() {
		vmove "usr/lib/gcc/${_triplet}/${_minorver}/*.o"
		vmove "usr/lib/gcc/${_triplet}/${_minorver}/*.a"
	}
}

libgomp-devel_package() {
	depends="libgomp>=${_minorver}"
	short_desc+=" - OpenMP v4.0 library - development files"
	pkg_install() {
		vmove usr/lib/gcc/${_triplet}/${_minorver}/include/omp.h
		vmove usr/lib/libgomp.so
		vmove usr/lib/libgomp.a
		vmove usr/lib/libgomp.spec
		vmove usr/share/info/libgomp.info
		touch ${PKGDESTDIR}/usr/share/info/dir
	}
}

libgomp_package() {
	short_desc+=" - OpenMP v4.0 library"
	pkg_install() {
		vmove "usr/lib/libgomp*.so.*"
		vlicense COPYING.RUNTIME RUNTIME.LIBRARY.EXCEPTION
	}
}

libitm-devel_package() {
	depends="libitm>=${_minorver}"
	short_desc+=" - Transactional Memory library - development files"
	replaces="libitm<4.9.0_1"
	pkg_install() {
		vmove usr/lib/libitm.a
		vmove usr/lib/libitm.so
		vmove usr/lib/libitm.spec
		vmove usr/share/info/libitm.info
		touch ${PKGDESTDIR}/usr/share/info/dir
	}
}

libitm_package() {
	short_desc+=" - Transactional Memory library"
	pkg_install() {
		vmove "usr/lib/libitm.so.*"
	}
}

libsanitizer-devel_package() {
	depends="libsanitizer>=${_minorver}"
	short_desc+=" - Sanitizer libraries - development files"
	pkg_install() {
		vmove "usr/lib/lib*san*.so"
		vmove "usr/lib/lib*san*.a"
		vmove "usr/lib/lib*san_preinit.o"
		vmove usr/lib/libsanitizer.spec
	}
}

libsanitizer_package() {
	short_desc+=" - Sanitizer libraries"
	pkg_install() {
		vmove "usr/lib/lib*san*.so.*"
	}
}

libstdc++-devel_package() {
	depends="libstdc++>=${_minorver}"
	short_desc+=" - Standard C++ Library - development files"
	pkg_install() {
		vmove "usr/lib/libstdc++*.a"
		vmove "usr/lib/libsupc++.a"
		vmove usr/include/c++
	}
}

libstdc++_package() {
	short_desc+=" - Standard C++ Library"
	pkg_install() {
		vmove usr/share/gdb
		vmove usr/share/gcc-${version}/python
		vmove "usr/lib/libstdc++.so*"
		vlicense COPYING.RUNTIME RUNTIME.LIBRARY.EXCEPTION
	}
}
