### this file is sourced not run
PKGVER=2.5
PKGBUILD=1
PKGARCH=x86_64

# source: james
TARBALL=hostapd-$PKGVER.tar.gz
MD5SUM=69f9cec3f76d74f402864a43e4f8624f
SRC_URL=http://w1.fi/releases/$TARBALL
BUNDLE=

SLACKREQ='libnl openssl'
SLACKDESC="hostapd-rtl: hostapd-rtl $PKGVER (hostapd for realtek wifi)
hostapd-rtl: 
hostapd-rtl: This is a special patched version of hostapd built to work with 
hostapd-rtl: certain realtek wifi chips. 8188eu/8188ee/8192 is known to work. 
hostapd-rtl: For this to work, you need to use realtek original driver; 
hostapd-rtl: not the one included in the Linux kernel.
hostapd-rtl: This also contains drivers for others chips, but it is not known
hostapd-rtl: how well they behave with this version of hostapd.
hostapd-rtl: 
hostapd-rtl: https://github.com/pritambaral/hostapd-rtl871xdrv
hostapd-rtl: http://w1.fi/hostapd/  
"

### default pkg_download
### default pkg_prepare
### default pkg_package
### build
pkg_build() {
	# apply patch
	cd /tmp/hostapd* &&
	patch -Np1 -i /tmp/pkg/hostapd-rtl*/rtlxdrv.patch &&
	cp -v /tmp/pkg/hostapd-rtl*/driver_* src/drivers &&
	
	# build
	cd /tmp/hostapd*/hostapd &&
	
	# our config is defconfig + wired, LIBNL32, radius server, 80211n, and fully dynamic vlan
	cp defconfig .config &&
	sed -i -e '
		s/#CONFIG_DRIVER_WIRED/CONFIG_DRIVER_WIRED/;
		s/#CONFIG_LIBNL32/CONFIG_LIBNL32/;
		s/#CONFIG_RADIUS_SERVER/CONFIG_RADIUS_SERVER/;
		s/#CONFIG_IEEE80211N/CONFIG_IEEE80211N/;
		s/#CONFIG_FULL_DYNAMIC_VLAN/CONFIG_FULL_DYNAMIC_VLAN/;
		' .config &&
	echo "CONFIG_DRIVER_RTW=y" >> .config && # add support for rtl871xdrv
	
	make $MAKEFLAGS &&
	install -m755 hostapd /usr/sbin/hostapd-rtl &&
	install -m755 hostapd_cli /usr/bin/hostapd-rtl_cli &&
	install -m644 hostapd.8 /usr/share/man/man8/hostapd-rtl.8 &&
	install -m644 hostapd_cli.1 /usr/share/man/man1/hostapd-rtl_cli.1 &&
	
	mkdir -p /usr/share/hostapd-rtl/samples &&
	cp README /usr/share/hostapd-rtl &&
	cp hostapd.accept hostapd.conf hostapd.deny hostapd.eap_user \
	   hostapd.radius_clients hostapd.vlan hostapd.wpa_psk wired.conf \
	   /usr/share/hostapd-rtl/samples &&
	 
	install -m644 /tmp/pkg/hostapd-rtl871xdrv.conf /usr/share/hostapd-rtl/samples/ &&
	pkg_build_slackdesc
}


