# Template file for 'hostapd'
pkgname=hostapd
version=2.0
revision=1
build_wrksrc=${pkgname}
makedepends="pkg-config libnl3-devel openssl-devel"
short_desc="IEEE 802.11 AP, IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authenticator"
maintainer="Juan RP <xtraeme@gmail.com>"
license="GPL-2"
homepage="http://w1.fi/hostapd/"
distfiles="http://w1.fi/releases/${pkgname}-${version}.tar.gz"
checksum=262ce394b930bccc3d65fb99ee380f28d36444978f524c845a98e8e29f4e9d35

do_build() {
	cp -f ${FILESDIR}/config .config
	sed -i 's#/etc/hostapd#/etc/hostapd/hostapd#' hostapd.conf
	export CFLAGS="${CFLAGS} $(pkg-config --cflags libnl-3.0)"
	make ${makejobs}
}

do_install() {
	vinstall ${FILESDIR}/hostapd.service 644 usr/lib/systemd/system

	vmkdir usr/bin
	install -t ${DESTDIR}/usr/bin hostapd hostapd_cli

	vmkdir etc/hostapd
	install -m644 -t ${DESTDIR}/etc/hostapd \
		hostapd.{accept,conf,deny,eap_user,radius_clients,sim_db,vlan,wpa_psk} \
		wired.conf hlr_auc_gw.milenage_db
  
	vinstall hostapd.8 644 usr/share/man/man8
	vinstall hostapd_cli.1 644 usr/share/man/man1
}

hostapd_package() {
	conf_files="
		/etc/hostapd/hostapd.conf
		/etc/hostapd/hlr_auc_gw.milenage_db
		/etc/hostapd/hostapd.accept
		/etc/hostapd/hostapd.deny
		/etc/hostapd/hostapd.eap_user
		/etc/hostapd/hostapd.radius_clients
		/etc/hostapd/hostapd.sim_db
		/etc/hostapd/hostapd.vlan
		/etc/hostapd/hostapd.wpa_psk
		/etc/hostapd/wired.conf"
	pkg_install() {
		vmove etc
		vmove usr
	}
}
