# Template file for 'iproute2'
pkgname=iproute2
version=4.5.0
revision=1
hostmakedepends="pkg-config perl flex"
makedepends="libfl-devel libmnl-devel db-devel iptables-devel"
conf_files="
	/etc/iproute2/ematch_map
	/etc/iproute2/rt_dsfield
	/etc/iproute2/rt_protos
	/etc/iproute2/rt_realms
	/etc/iproute2/rt_scopes
	/etc/iproute2/rt_tables"
short_desc="IP Routing Utilities"
maintainer="Juan RP <xtraeme@voidlinux.eu>"
homepage="http://www.linux-foundation.org/en/Net:Iproute2"
license="GPL-2"
distfiles="${KERNEL_SITE}/utils/net/$pkgname/$pkgname-$version.tar.xz"
checksum=3f15292f53e465cb5bd6652961343ca64eb6936309ae75be5d5a541435bc494a

do_configure() {
	./configure
	sed -i 's,CCOPTS,HOSTCCOPTS,g' netem/Makefile
	sed -i 's/^LDFLAGS +=/override &/' */Makefile
}
do_build() {
	make HOSTCC=cc CC="$CC" RANLIB="$RANLIB" AR="$AR" LD="$LD" \
		CCOPTS="$CFLAGS" HOSTCCOPTS="$XBPS_CFLAGS" LDFLAGS="$LDFLAGS" \
		DBM_INCLUDE="$XBPS_CROSS_BASE/usr/include" ${makejobs}
}
do_install() {
	make DESTDIR=${DESTDIR} SBINDIR=/usr/bin install

	rm -r ${DESTDIR}/usr/share/doc
	rm -r ${DESTDIR}/usr/share/man/man3
}

iproute2-tc-ipt_package() {
	short_desc+=" - tc(8) IPtables support"
	pkg_install() {
		vmove usr/lib/tc/m_xt.so
	}
}
