# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Contributor: Sergej Pupykin <pupykin.s+arch@gmail.com>

pkgname=ipguard
pkgver=1.04
pkgrel=8
pkgdesc="ipguard - arp<->ip relation checking tool"
arch=(x86_64)
url="http://ipguard.deep.perm.ru/"
license=("GPL")
depends=(libpcap libnet)
source=(http://ipguard.deep.perm.ru/files/$pkgname-$pkgver.tar.gz
	build-fix-le.patch pass-ldflags.patch)
md5sums=('7f44f7c31876f0d68792f02047e25409'
         'b27cfc9e8ad4ef9459d7274a2e624831'
         '4866f88e44fd806d545ec5191a41636b')
sha256sums=('95bf97ae2c58827e34d40daa7065c5107d39a67eb92e2164f7758846f43c41fe'
            '0e79d40a0af92171796c1e36c650c402e27ee69cdf518792fc2fd1d963f842c9'
            '5c2818b8318143c7f4443aaf136f9bfb1a26795b85845139ea8f862cf8a210ff')

prepare() {
  cd "$srcdir"/$pkgname-$pkgver
  patch -Np1 <../build-fix-le.patch
  patch -Np1 <../pass-ldflags.patch
  sed -i 's|$(PREFIX)/sbin|$(PREFIX)/bin|g' Makefile
}

build() {
  cd "$srcdir"/$pkgname-$pkgver
  CFLAGS+=' -fcommon' # https://wiki.gentoo.org/wiki/Gcc_10_porting_notes/fno_common
  LDFLAGS=${LDFLAGS} CFLAGS="${CFLAGS} -DLIBNET_LIL_ENDIAN" make
}

package() {
  cd "$srcdir"/$pkgname-$pkgver
  make PREFIX="$pkgdir"/usr install
  mkdir -p "$pkgdir"/usr/share
  mv "$pkgdir"/usr/man "$pkgdir"/usr/share/
}
