# Contributor: Diaz Devera Victor <vitronic2@gmail.com>
# Maintainer: Bart Ribbers <bribbers@disroot.org>
pkgname=qt5-qtgamepad
pkgver=5.15.10_git20230414
pkgrel=0
_module="${pkgname#qt5-}"
_pkgver=f90bd729eb70d4a0770efed3f9bb1b6dbe67d37c
_fullname=$_module-$_pkgver
pkgdesc="Adds support for getting events from gamepad devices"
url="https://doc.qt.io/qt-5/qtgamepad-index.html"
license="LGPL-2.1-only AND LGPL-3.0-only AND GPL-3.0-only AND Qt-GPL-exception-1.0"
arch="all !armhf" # armhf blocked by qt5-qtdeclarative
depends_dev="
	eudev-dev
	qt5-qtdeclarative-dev
	sdl2-dev
	"
makedepends="$depends_dev
	qt5-qtbase-dev
	"
subpackages="$pkgname-dev"
source="https://dev.alpinelinux.org/archive/qt/$_fullname.tar.xz"
builddir="$srcdir/$_fullname"

_disturl="dev.alpinelinux.org:/archive/qt/"
snapshot() {
	clean
	makedepends="git xz rsync tar" deps
	mkdir -p "$srcdir" && cd "$srcdir"
	git clone --filter=tree:0 https://invent.kde.org/qt/qt/$_module.git .
	git archive --format tar --prefix=$_fullname/ $_pkgver > "$SRCDEST"/$_fullname.tar
	xz -vv -T0 -9 -e "$SRCDEST"/$_fullname.tar
	rsync --progress -La "$SRCDEST"/$_fullname.tar.xz $_disturl
}

prepare() {
	default_prepare

	# We need to make the build system think we're running in a git repository
	# so it correctly symlinks during the build
	mkdir .git
}

build() {
	qmake-qt5
	make -j1
}

check() {
	make check
}

package() {
	make INSTALL_ROOT="$pkgdir" install

	# Drop QMAKE_PRL_BUILD_DIR because reference the build dir
	find "$pkgdir/usr/lib" -type f -name '*.prl' \
		-exec sed -i -e '/^QMAKE_PRL_BUILD_DIR/d' {} \;

	install -d "$pkgdir"/usr/share/licenses
	ln -s /usr/share/licenses/qt5-base "$pkgdir"/usr/share/licenses/$pkgname
}

sha512sums="
1de5d52390e1bd2d4135a99ccd69fb02aee1af5567d032c584f3f05d024c44828ade7a036b9116f3ca9000dadf719f99a55330fac09ea294b3c0df9245d9ca17  qtgamepad-f90bd729eb70d4a0770efed3f9bb1b6dbe67d37c.tar.xz
"
