# Contributor: Stuart Cardall <developer@it-offshore.co.uk>
# Maintainer: Stuart Cardall <developer@it-offshore.co.uk>
pkgname=libqmi
pkgver=1.34.0
pkgrel=1
pkgdesc="QMI modem protocol helper library"
url="https://www.freedesktop.org/wiki/Software/libqmi"
arch="all"
license="GPL-2.0-or-later AND LGPL-2.1-or-later"
makedepends="
	bash-completion-dev
	glib-dev
	gobject-introspection-dev
	help2man
	libgudev-dev
	libmbim-dev
	libqrtr-glib-dev
	linux-headers
	meson
	python3
	"
subpackages="
	$pkgname-dev
	$pkgname-doc
	$pkgname-bash-completion
	qmi-utils
	"
source="https://gitlab.freedesktop.org/mobile-broadband/libqmi/-/archive/$pkgver/libqmi-$pkgver.tar.gz
	0001-qmi-common-turn-qmi_helpers_str_hex-into-qmi_common_.patch
	0002-uim-Add-Open-Logical-Channel-command.patch
	0003-uim-Add-Send-APDU-command.patch
	0004-uim-Add-Logical-Channel-command.patch
	0005-uim-Add-File-Control-Information-to-Open-Logical-Cha.patch
	"

build() {
	abuild-meson \
		-Db_lto=true \
		. output
	meson compile -C output
}

check() {
	local tests=$(meson test --list -C output)
	case "$CARCH" in
		s390x) tests=${tests//test-message} ;;
	esac
	meson test --no-rebuild --print-errorlogs -C output $tests
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C output
}

utils() {
	pkgdesc="$pkgdesc (CLI utilities)"

	amove usr/bin
}

sha512sums="
4be50814c846e986d2f792af1d488e76f9e3d5457741c1e49187232150b4e14fd26538d0850f2c014be0144b61781827787ca466cd94f1032019ec69e3ab3f3b  libqmi-1.34.0.tar.gz
9fd2e5a4b3b5b148c01e9b713385623b1c9c20b491b8d99760cb42fcf0a1d7d1f3bcb35044119bb57c8577bc19dd3d7a20098dc2447b397612aee01bc52d9974  0001-qmi-common-turn-qmi_helpers_str_hex-into-qmi_common_.patch
503c0f8ac3869b5fc0486708d10ec9095148d900914187a00e3c0a90d47657672e6dffddbf1cf59a66601272e9b598f710ea14c2eacf7dc49b05838506878d58  0002-uim-Add-Open-Logical-Channel-command.patch
c66418eaba0ce6d6a878685a2e80a86cd8cf5c47ecb2842fbf15439f5335e6b19e69e9838579eee156e53938e05570327b82e2e22349eb30e3a92c10e82b7ec9  0003-uim-Add-Send-APDU-command.patch
0bc0568f5bde4bd12f7a73875a9c178af3d2fb2151dd119084501e33156e21062964e7bdbd6137d0b66011048150fb12c8194ffa2d50b1e114e9361836456478  0004-uim-Add-Logical-Channel-command.patch
548b795681ed8bafad2e34a3c7f8857fa8c09e6814afd94569b9254d3865fffb21c28d9056552866defee7af43ea735c9f767895a61cf158da99bc416c0f0079  0005-uim-Add-File-Control-Information-to-Open-Logical-Cha.patch
"
