# Contributor: Denis Ryabyy <vv1r0x@gmail.com>
# Maintainer: Bart Ribbers <bribbers@disroot.org>
pkgname=qt5-qtserialport
pkgver=5.15.10_git20230424
pkgrel=1
_module="${pkgname#qt5-}"
_pkgver=af58a4c62415fbfd997c43422acf93e2e6ab5155
_fullname=$_module-$_pkgver
pkgdesc="Qt5 - QtSerialPort module"
url="https://wiki.qt.io/QtSerialPort"
arch="all"
license="( LGPL-2.0-or-later OR GPL-3.0-only OR GPL-2.0-or-later ) AND Qt-GPL-exception-1.0"
makedepends="
	eudev-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
}

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' {} \;
}

sha512sums="
2e4a239cd771ac1d77b6c07d97599b30c339475a36c2de15f2af543aa726444f96f087152b35c151e5b2035809a0daff5f0dc1c47d09e3b2579a8b86a8e45b68  qtserialport-af58a4c62415fbfd997c43422acf93e2e6ab5155.tar.xz
"
