if ab_match_arch "armv4" || \
   ab_match_arch "armv6hf" || \
   ab_match_arch "armv7hf" || \
   ab_match_arch "arm64"; then
    abinfo "Telling build system to use OpenGL ES due to hardware compatibility issue ..."
    GLES="USE_GLES=1"
fi

if ab_match_arch "armv7hf" || \
   ab_match_arch "arm64"; then
    abinfo "Telling build system to use NEON SIMD ..."
    NEON="NEON=1 VFP_HARD=1"
fi

if ab_match_arch "ppc64el"; then
    export CFLAGS="$CFLAGS -DNO_WARN_X86_INTRINSICS"
    export CXXFLAGS="$CXXFLAGS -DNO_WARN_X86_INTRINSICS"
fi

abinfo "Bulding Mupen64Plus ..."
"$SRCDIR"/m64p_build.sh \
    NEW_DYNAREC=1 \
    "$GLES" "$NEON" \
    PREFIX=/usr

abinfo "Installing Mupen64Plus ..."
"$SRCDIR"/m64p_install.sh \
    DEBUG=1 \
    NEW_DYNAREC=1 \
    "$GLES" "$NEON" \
    DESTDIR="$PKGDIR" \
    PREFIX=/usr \
    MANDIR=/usr/share/man

abinfo "Setting executable bits on shared objects ..."
chmod -v +x "$PKGDIR"/usr/lib/*.so.*
chmod -v +x "$PKGDIR"/usr/lib/mupen64plus/*.so
