# $Id: PKGBUILD 221447 2014-09-12 17:58:47Z thomas $
# Maintainer: Thomas Bächler <thomas@archlinux.org>

pkgname=libpcap
pkgver=1.6.2
pkgrel=1
pkgdesc="A system-independent interface for user-level packet capture"
arch=('i686' 'x86_64')
url="http://www.tcpdump.org/"
license=('BSD')
depends=('glibc' 'libnl' 'sh' 'libusbx')
makedepends=('flex' 'bluez-libs')
source=(http://www.tcpdump.org/release/libpcap-${pkgver}.tar.gz{,.sig}
        mgmt.h)
sha256sums=('5db3e2998f1eeba2c76da55da5d474248fe19c44f49e15cac8a796a2c7e19690'
            'SKIP'
            '7c85da5330ce7ecb6934795c02c652b9e344461302cf74804a4692c3e2e1e7e2')

prepare() {
  mkdir -p ${srcdir}/include/bluetooth
  cp ${srcdir}/mgmt.h ${srcdir}/include/bluetooth/
}

build() {
  cd ${srcdir}/${pkgname}-${pkgver}
  CFLAGS="$CFLAGS -I${srcdir}/include" \
  ./configure --prefix=/usr \
    --enable-ipv6 \
    --enable-bluetooth \
    --with-libnl
  make
}

package() {
  cd ${srcdir}/${pkgname}-${pkgver}
  install -d -m755 ${pkgdir}/usr/bin
  make DESTDIR=${pkgdir} install
  
  # backwards compatibility, programs often look for net/bpf.h
  mkdir -p ${pkgdir}/usr/include/net
  cd ${pkgdir}/usr/include/net
  ln -s ../pcap-bpf.h bpf.h

  # install the license
  install -D -m644 ${srcdir}/$pkgname-$pkgver/LICENSE ${pkgdir}/usr/share/licenses/$pkgname/LICENSE
}
