# $Id: PKGBUILD 112859 2014-06-09 09:56:13Z spupykin $
# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>

pkgname=hostapd
pkgver=2.2
pkgrel=2
pkgdesc="IEEE 802.11 AP, IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authenticator"
arch=('i686' 'x86_64')
url="http://w1.fi/hostapd/"
license=('custom')
depends=('openssl' 'libnl')
install=hostapd.install
options=(emptydirs)
source=(http://w1.fi/releases/$pkgname-$pkgver.tar.gz
	config
	hostapd.service)
md5sums=('23c1f78a693c3288802d516adb7fd289'
         '72e8ecf8fadf8b06d87876ea8c3dfd07'
         'a0a16879eed5e4e41ae6b225a4809955')

build() {
  cd $pkgname-$pkgver/hostapd
  cp ../../config .config
  sed -i 's#/etc/hostapd#/etc/hostapd/hostapd#' hostapd.conf
  export CFLAGS="$CFLAGS $(pkg-config --cflags libnl-3.0)"
  make
}

package() {
  # Systemd unit
  install -Dm644 hostapd.service "$pkgdir/usr/lib/systemd/system/hostapd.service"

  cd $pkgname-$pkgver

  # License
  install -Dm644 COPYING "$pkgdir/usr/share/licenses/$pkgname/COPYING"

  cd hostapd

  # Binaries
  install -d "$pkgdir/usr/bin"
  install -t "$pkgdir/usr/bin" hostapd hostapd_cli

  # Configuration
  install -d "$pkgdir/etc/hostapd"
  install -d "$pkgdir/usr/share/doc/hostapd"
  install -m644 -t "$pkgdir/usr/share/doc/hostapd" \
    hostapd.{accept,conf,deny,eap_user,radius_clients,sim_db,vlan,wpa_psk} \
    wired.conf hlr_auc_gw.milenage_db

  # Man pages
  install -Dm644 hostapd.8 "$pkgdir/usr/share/man/man8/hostapd.8"
  install -Dm644 hostapd_cli.1 "$pkgdir/usr/share/man/man1/hostapd_cli.1"
}
