# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=hwinfo
pkgver=21.52
pkgrel=0
pkgdesc="Hardware information tool"
url="https://github.com/openSUSE/hwinfo"
arch="all"
license="GPL-2.0-or-later"
makedepends="$depends_dev flex perl libx86emu-dev linux-headers"
subpackages="$pkgname-dev $pkgname-doc $pkgname-libs"
source="$pkgname-$pkgver.tar.gz::https://github.com/openSUSE/$pkgname/archive/$pkgver.tar.gz
	respect-flags.patch"
builddir="$srcdir/$pkgname-$pkgver"
options="!check"  # no tests provided

export HWINFO_VERSION=$pkgver

build() {
	cd "$builddir"

	# Build full and tiny static libraries.
	make tinystatic
	make static
	cp src/libhd*.a .
	make clean

	# Build full shared library.
	make shared LIBDIR=/usr/lib
}

package() {
	cd "$builddir"

	make install \
		LIBDIR=/usr/lib \
		DESTDIR="$pkgdir"

	rmdir "$pkgdir"/sbin "$pkgdir"/usr/lib || true

	install -m 644 -t "$pkgdir"/usr/lib/ libhd.a libhd_tiny.a

	mkdir -p "$pkgdir"/usr/share/man/man1
	cp doc/*.1 "$pkgdir"/usr/share/man/man1/

	mkdir -p "$pkgdir"/usr/share/man/man8
	cp doc/*.8 "$pkgdir"/usr/share/man/man8/
}

sha512sums="a0d15d548fdbb02a1d0250e0a125b1d53e65b58e5325cff6f1c8a84b9b67a3da5f7575701c065214650523ef6ec59ed6c26f531a0878ea528099c6c06b6f48ae  hwinfo-21.52.tar.gz
1a78d21c97bb2b699804c20622b7309573ba3d8dcfdaa8c2c31be42cba42a342e4a4fb451551ee4d1af9384ba455363727cc37839a26550871cca139b5a0ba20  respect-flags.patch"
