# Contributor: Leonardo Arena <rnalrd@alpinelinux.org>
# Maintainer: Leonardo Arena <rnalrd@alpinelinux.org>
pkgname=open-lldp
_realname=lldpad
pkgver=0.9.46
pkgrel=3
pkgdesc="Open Source implementation of the IEEE standard 802.1AB Link Layer Discovery Protocol (LLDP)"
url="http://www.open-lldp.org"
arch="all"
license="GPL"
depends=
makedepends="autoconf automake bash flex libtool libconfig-dev libnl-dev
	readline-dev linux-headers bsd-compat-headers"
install=
subpackages="$pkgname-dev $pkgname-doc"
source="http://ftp-osl.osuosl.org/pub/${pkgname}/${pkgname}-${pkgver}.tar.gz
        clif.h.patch
	$pkgname.initd
	$pkgname.confd"

_builddir="$srcdir/${pkgname}-${pkgver}"

prepare() {
        local i
        cd "$_builddir"
        for i in $source; do
                case $i in
                *.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
                esac
        done
	sed -i 's/ln -T -s/ln -s/' Makefile.am || return 1
	sed -i -e 's/-Werror//' Makefile.am configure.ac || return 1
	libtoolize --force && aclocal && autoconf --force && automake --add-missing
}

build() {
	cd "$_builddir"
	./bootstrap.sh || return 1
        export CFLAGS="${CFLAGS} -fgnu89-inline"
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		|| return 1
	make || return 1
}

package() {
	cd "$_builddir"
	make DESTDIR="$pkgdir" install
	mkdir -p "$pkgdir"/usr/include/dcbd
	# ln -s /usr/include/lldpad "$pkgdir"/usr/include/dcbd
	ln -s /usr/include/lldpad/lldp_dcbx_cmds.h "$pkgdir"/usr/include/dcbd/clif_cmds.h
	install -m755 -D ../../$pkgname.initd "$pkgdir"/etc/init.d/$_realname
	install -m644 -D ../../$pkgname.confd "$pkgdir"/etc/conf.d/$_realname
}

md5sums="15ca4c1f6ce3023f7134ab7d784986c3  open-lldp-0.9.46.tar.gz
709186cd0d59b59d43958e5eadf0b97d  clif.h.patch
1d6cdac5614860629fd2a5bbe02d9263  open-lldp.initd
a1d2e351028d39193fc0a3466ba4db33  open-lldp.confd"
sha256sums="c7b4abc970bf4cc12617b8124de0b440e69fc2a9f680973d2c313301802def14  open-lldp-0.9.46.tar.gz
bff3746fe5d576d4239664a6966d6fd3e8defac208f8cb538dd24fbd9613fc47  clif.h.patch
5f7a6f265afc16051066c1890c49f330f1fb79cce4fc9a0880aec161eb00d27c  open-lldp.initd
f914e08fb444ee398727fabdf6bd84df2f66087ba5ce35872452859ed06e9890  open-lldp.confd"
sha512sums="45982ba69c159ca386970d49de8cee70b654e762b60d95c96a4794ee696e6c889694bb12eb1454e6c176152c949e67af38974a431838c3788d9bc42751c60878  open-lldp-0.9.46.tar.gz
fd9eca241564e76df2b97d8048b788fc35c3d791a1784386e68bf92dfd39076b356546adee42028007483f0cdb579b0da519d0376791d0f902f7e83df60d9306  clif.h.patch
cfd618d2414ec1624e66105b5357de93414b0320badf63b78cbab9b5bb493bd8ef7cac9a22ba4d60418037d2d6636469a20dc288906348c2332beb786f67f808  open-lldp.initd
8f8a68b9764e3b2be0cc01a37debb099e3d9021c354eb8d584a5123c470002f1f61ecc5688e5d958c8c576fd36df7a65233192221849a8fc51e999a7c5ea5678  open-lldp.confd"