%define pkg_version 0.5.11
%define pkg_release 2%{?_dist_release}

Summary:     IEEE 802.11 AP, IEEE 802.1X/WPA/WPA2/EAP/RADIUS Authenticator
Name:        hostapd
Version:     %{pkg_version}
Release:     %{pkg_release}
Source0:     %{name}-%{version}.tar.gz
Patch0:      %{name}-%{version}.patch
License:     GPL2
Group:       System Environment/Daemons
URL:         http://hostap.epitest.fi/hostapd/

BuildRequires: openssl-devel
BuildRoot:   %{_tmppath}/%{name}-%{version}-root

%description
hostapd  is a user space daemon for access point and authentication servers.  It implements IEEE 802.11 access point management,
IEEE 802.1X/WPA/WPA2/EAP Authenticators and RADIUS authentication server.  The current version supports Linux (Host AP, madwifi,
Prism54 drivers) and FreeBSD (net80211).

%prep
%setup -q -n %{name}-%{version}
%patch0 -p1

%build
%{__make}

%install
%{__rm} -rf ${RPM_BUILD_ROOT}
%{__make} install DESTDIR="${RPM_BUILD_ROOT}"

%post
if [ $1 = 1 ] ; then
    /sbin/chkconfig --add hostapd
fi

%preun
if [ $1 = 0 ] ; then
    /etc/rc.d/init.d/hostapd stop
    /sbin/chkconfig --del hostapd
fi

%clean
%__rm -rf ${RPM_BUILD_ROOT}

%files
%defattr(-, root, root)
%doc ChangeLog COPYING README
%dir %{_sysconfdir}/hostapd/
%{_sbindir}/hostapd
%{_bindir}/hostapd_cli
%{_mandir}/man8/hostapd.8.gz
%{_mandir}/man1/hostapd_cli.1.gz
%attr(0644, root, root) %config %{_sysconfdir}/hostapd/hostapd.conf
%attr(0755, root, root) %{_sysconfdir}/rc.d/init.d/hostapd

%changelog
* Sun Feb 06 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 0.5.11-2
- rebuild with openssl-1.0.0c

* Mon Jan 05 2009 Masahiro INOUE <miyabi.-.inoue@nifty.com> 0.5.11-1
- new upstream release

* Wed Apr 16 2008 Masahiro INOUE <miyabi.-.inoue@nifty.com> 0.5.10-1
- initial build for Vine Linux
