# Contributor: Díaz Urbaneja Diego <sodomon2@gmail.com>
# Maintainer: Díaz Urbaneja Diego <sodomon2@gmail.com>
pkgname=xemu
pkgver=0.7.131
pkgrel=1
pkgdesc="Original Xbox Emulator for Windows, macOS, and Linux."
url="https://xemu.app/"
#x86/armv7/armhf failed compilation because of lto (without lto it still doesn't work)
arch="all !x86 !armv7 !armhf"
license="GPL-2.0-only AND LGPL-2.1-only"
makedepends="
	bash
	gmp-dev
	gtk+3.0-dev
	glu-dev
	iasl
	keyutils-dev
	libslirp-dev
	libpcap-dev
	libsamplerate-dev
	nlohmann-json
	openssl-dev
	python3
	py3-setuptools
	py3-yaml
	samurai
	sdl2-dev
	tomlplusplus-dev
	"
options="!check" # checks fails with xbox parameter
source="$pkgname-$pkgver.tar.gz::https://github.com/xemu-project/xemu/releases/download/v$pkgver/src.tar.gz
	fix-missing-include.patch
	use-system-libs.patch
	basename.patch
	"
builddir="$srcdir/"

prepare() {
	default_prepare
	python scripts/gen-license.py > LICENSE
}

build() {
	./configure \
		--target-list="i386-softmmu" \
		--extra-cflags="-DXBOX=1" \
		--enable-lto \
		--disable-werror
	make qemu-system-i386
}

package() {
	install -Dm755 build/qemu-system-i386 "$pkgdir/usr/bin/$pkgname"
	install -Dm644 ui/xemu.desktop "$pkgdir/usr/share/applications/$pkgname.desktop"

	install -Dm644 ui/icons/xemu.svg "$pkgdir/usr/share/icons/hicolor/scalable/apps/$pkgname.svg"
	install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}

sha512sums="
0a5ea85652c61b673656aef9bbdda5e3de0b765ebbee9267c4cf71a95916d17038e69874ee3548b2e9453373af3306900e468643d6bc280fbf898e7bc06ebe0b  xemu-0.7.131.tar.gz
fc5e9c74c48496ccd1ea5227901b60d11af686641e5a724ad20f866c7ef7a4038ab00d06ba55fbb8e84c202b69a72304ed8a65855f53f6a0403f526dcd3928b8  fix-missing-include.patch
c5cfe0f593c0ae6408814ac5bfc19d4fe030f4e62fcc7665d5d6f52d21b48f42c7bf109c4d3b341afdcc68085bc29b1fad7110673dd157156b69bbfbf8e3c38f  use-system-libs.patch
fe7f53a1068af46469f20e3bab994a9f8c18bba7e4863f5a68bd263c5a44c76dd2f7d69db3f2041222db713a5291a8648318f4a7f0138fe16fb1c3657f5e2b9d  basename.patch
"
