# Contributor: Francesco Zanini <francesco@zanini.me>
# Contributor: Katie Holly <holly@fuslvz.ws>
# Maintainer: Francesco Zanini <francesco@zanini.me>
setvar pkgname = 'bird'
setvar pkgver = '1.6.3'
setvar pkgrel = '0'
setvar pkgdesc = ""BIRD Internet Routing Daemon""
setvar url = ""http://bird.network.cz/""
setvar arch = ""all""
setvar license = ""GPLv2+""
setvar depends = """"
setvar makedepends = ""bison flex ncurses-dev readline-dev linux-headers""
setvar install = """"
setvar subpackages = ""bird6""
setvar source = ""
	ftp://bird.network.cz/pub/bird/bird-$pkgver.tar.gz
	bird.initd
	""
setvar builddir = ""$srcdir"/bird-$pkgver"

proc prepare {
	cd $builddir
	default_prepare
	update_config_guess
	# generate bird6.initd
	cd $srcdir
	sed -e 's/^name=.*/name=bird6/' bird.initd > bird6.initd
}

proc _build {
	../configure --prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		@ARGV
	make
}

proc build {
	cd $builddir
	mkdir -p ipv6 ipv4
	cd "$builddir"/ipv6
	_build --enable-ipv6
	cd "$builddir"/ipv4
	_build
}

proc package {
	cd "$builddir"/ipv4
	make DESTDIR="$pkgdir" install
	cd "$builddir"/ipv6
	make DESTDIR="$pkgdir" install
	for i in bird bird6 {
		install -Dm755 "$srcdir"/$i.initd "$pkgdir"/etc/init.d/$i
	}
}

proc bird6 {
	setvar pkgdesc = ""BIRD Internet Routing Daemon for IPv6""
	mkdir -p "$subpkgdir"/etc \
		"$subpkgdir"/etc/init.d \
		"$subpkgdir"/usr/sbin
	mv "$pkgdir"/etc/*6.conf "$subpkgdir"/etc/
	for i in etc/init.d usr/sbin {
		mv "$pkgdir"/$i/*6 "$subpkgdir"/$i/
	}
}

setvar sha512sums = ""d0f044cbbb3e5fe0624ad8ae58f5fa352ff41a9cd73f37d803431d9d148927bce52d8f2b82e31dd65c753c55b1034aaf8e15739a511e42cd2dd122b5cd1e15df  bird-1.6.3.tar.gz
59245af3fd514421d0babcefed556597022a36d14615d596bb5c08c7dd0a6ed4519928e35a0b7ff14fe27ecfa50fa8011283c92bfc9b8355b15b3263df189d5d  bird.initd""