# Maintainer: A. Wilcox <awilfox@adelielinux.org>
pkgname=gcompat
pkgver=1.0.0
pkgrel=0
pkgdesc="The GNU C Library compatibility layer for musl"
url="https://git.adelielinux.org/adelie/gcompat"
arch="all"
options="!check"  # No test suite.
license="UoI-NCSA"
depends=""
makedepends="libucontext-dev utmps-dev"
replaces="libc6-compat"
source="https://distfiles.adelielinux.org/source/gcompat/$pkgname-$pkgver.tar.xz"

_link_arch=$CARCH
case "$CARCH" in
armel) _ld="ld-linux.so.3" ;;
armhf | armv7) _ld="ld-linux-armhf.so.3" ;;
aarch64) _ld="ld-linux-aarch64.so.1" ;;
x86) _ld="ld-linux.so.2" ;;
pmmx) _ld="ld-linux.so.2" _link_arch=i386;;
x86_64) _ld="ld-linux-x86-64.so.2" ;;
mips* | ppc | s390*) _ld="ld.so.1" ;;
ppc64*) _ld="ld64.so.2" ;;
esac

build() {
	make LINKER_PATH="/lib/ld-musl-${_link_arch}.so.1" LOADER_NAME="$_ld" WITH_LIBUCONTEXT=YesPlease
}

package() {
	make LINKER_PATH="/lib/ld-musl-${_link_arch}.so.1" LOADER_NAME="$_ld" WITH_LIBUCONTEXT=YesPlease DESTDIR="$pkgdir" install
}

sha512sums="61e355445571760b7cb8c8a828e7182544fefb403dca602f0b3756f39430974b5161517b0fdf4636a8a513be8e64d4dcb13553b28e9c7833f15c3b9871c94455  gcompat-1.0.0.tar.xz"