# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=libnl
pkgver=1.1.4
pkgrel=0
pkgdesc="Library for applications dealing with netlink sockets"
url="https://www.infradead.org/~tgr/libnl/"
arch="all"
license="LGPL-2.1"
makedepends="linux-headers"
subpackages="$pkgname-dev"
source="https://www.infradead.org/~tgr/libnl/files/$pkgname-$pkgver.tar.gz
	libnl-1.1-flags.patch
	libnl-1.1-vlan-header.patch
	fix-strerror_r.patch
	fix-includes.patch"
builddir="$srcdir"/$pkgname-$pkgver

# tests does not work on s390x builder
case "$CARCH" in
s390x) options="$options !check";;
esac

build() {
	cd "$builddir"
	export CFLAGS="$CFLAGS -D_GNU_SOURCE"
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr
	make
}

check() {
	cd "$builddir"/tests
	LD_LIBRARY_PATH=$(pwd)/../lib ./test-genl
}

package() {
	cd "$builddir"
	make DESTDIR="$pkgdir" install
}

sha512sums="25e26ddcc16540346ea34815ab6ac094177e5cee2eb3d843c4f8b30cd9d83390a3e87cb46046dc3bd9ae4d21f77e57bb3827c2cfc588eb18afe049921f2030b4  libnl-1.1.4.tar.gz
7ef2b3a7fb79227644c897a8cd59d6fc1e94a37211ea59684fe11ec4e34fe95cdc8c3df72134128326c2db10cbada9641290994253a4a80875971d95a73a74c0  libnl-1.1-flags.patch
ea45d780b16e6045735aaf2e3febf19ddccab4ca0e03710aebfe51655adc50177aefa3bd4d06e0ccce0160f4c6db73cfa4eb7cebe53b3e15c1807c3b00dc1c9c  libnl-1.1-vlan-header.patch
0464db6611234e3ece7191d88da12d241d0a1cf03e8fa1a8ec1757c0ae971fde1ae727e39358a49ac74f2fee8465b02f6fe21ae0ccc58851299c325b9475d58b  fix-strerror_r.patch
3d7281137f95e2dcdbc17e1e1676f2a220a735161527cef80d4608e0c16d985d4d14df1d040b6d18b24c407577b6bf0cfb0d7f3520657e9c16b2d487eb1d445a  fix-includes.patch"
