# Template file for 'fs-uae'
pkgname=fs-uae
version=3.1.66
revision=1
build_style=gnu-configure
hostmakedepends="pkg-config gettext zip"
makedepends="libmpeg2-devel SDL2-devel libglib-devel libpng-devel libopenal-devel"
short_desc="FS-UAE Amiga Emulator"
maintainer="Orphaned <orphan@voidlinux.org>"
license="GPL-2.0-only"
homepage="https://fs-uae.net"
distfiles="https://fs-uae.net/files/FS-UAE/Stable/${version}/${pkgname}-${version}.tar.xz"
checksum=606e1868b500413d69bd33bb469f8fd08d6c08988801f17b7dd022f3fbe23832

case "$XBPS_TARGET_MACHINE" in
	x86_64*|i686*) nopie=yes ;;
	*) configure_args+=" --disable-jit" ;;
esac

if [ "$CROSS_BUILD" ]; then
	post_configure() {
		make $makejobs \
		 CC=$CC_FOR_BUILD CFLAGS=$CFLAGS_FOR_BUILD \
		 CXX=$CXX_FOR_BUILD CXXFLAGS=$CXXFLAGS_FOR_BUILD \
		 LIBS= GLIB_LIBS= LIBMPEG2_LIBS= OPENAL_LIBS= \
		 OPENGL_LIBS= PNG_LIBS= SDL2_LIBS= X11_LIBS= ZLIB_LIBS= \
		 gen/blit.h gen/blitfunc.cpp gen/blitfunc.h gen/blittable.cpp \
		 gen/compemu.cpp gen/cpudefs.cpp gen/cpuemu_0.cpp \
		 gen/linetoscr.cpp

		rm src/readcpu.o gen/cpudefs.o
		make $makejobs src/readcpu.o gen/cpudefs.o
		touch gen/*
	}
fi

post_extract() {
	case "$XBPS_TARGET_MACHINE" in
		*-musl) sed -i -e 's/| RTLD_DEEPBIND//' src/dlopen.cpp ;;
	esac
	sed -i -e '/^NoDisplay/d' share/applications/fs-uae.desktop
}
