abinfo "Setting kernel target for OpenBLAS ..."
if ab_match_arch amd64; then
    export TARGETCONF="DYNAMIC_OLDER=1 TARGET=PRESCOTT"
elif ab_match_arch arm64; then
    export TARGETCONF="TARGET=ARMV8"
elif ab_match_arch loongarch64 ||
     ab_match_arch loongarch64_nosimd; then
    export TARGETCONF="TARGET=GENERIC"
elif ab_match_arch loongson3; then
    export TARGETCONF="TARGET=LOONGSON3A"
elif ab_match_arch ppc64el; then
    export TARGETCONF="TARGET=POWER8"
elif ab_match_arch riscv64; then
    export TARGETCONF="TARGET=RISCV64_GENERIC"
else
    abdie "Unsupported or unoptimised target!"
fi

abinfo "Building OpenBLAS ..."
make \
    PREFIX="$PKGDIR/usr" \
    DYNAMIC_ARCH=1 \
    $TARGETCONF

abinfo "Installing OpenBLAS ..."
make install \
    PREFIX="$PKGDIR/usr"
