%define svntag 4100

%define build_kmod 0
%define kversion %(uname -r)
%define kver    %(uname -r | sed -e 's/-/_/g')
%define kflavor %(uname -r | sed -e 's/.*vl.//')
%if "%kflavor" == ""
%undefine kflavor
%endif
%define kmod	kernel-module%{?kflavor:-%{kflavor}}

%define name	madwifi
%define ver	0.10.5.6
%define rel	5.%{svntag}%{?_dist_release}

Summary:        MADWIFI - Multimode Atheros Driver for WiFi on Linux
Name:		%{name}
Version:	%{ver}
Release: 	%{rel}
# svn co http://svn.madwifi-project.org/madwifi/branches/madwifi-hal-0.10.5.6
Source0:	madwifi-hal-%{version}.%{svntag}.tar.bz2

Source10:	madwifi-kmp.spec

License:	BSD or GPLv2
Group:		System Environment/Base
URL:            http://madwifi-project.org/
Vendor:         Project Vine
Distribution:   Vine Linux

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


%description
This package contains a Utilities for MADWIFI Atheros-based Wireless
LAN device driver.

%description -l ja
このパッケージは Atheros ベースの無線LANのデバイスドライバ MADWIFI
用のツール群が含まれています。


%package -n dkms-%{name}
Summary:         MADWIFI - Multimode Atheros Driver for WiFi on Linux
License:	 BSD or GPLv2
Group:		 System Environment/Kernel
Requires:	 %{name} = %{version}-%{release}
Requires(pre):   kernel, kernel-devel
Requires(post):  dkms
Requires(preun): dkms
Obsoletes:       kernel-module-madwifi

%description -n dkms-%{name}
This package contains a Linux kernel driver for Atheros-based Wireless
LAN devices.

%description -l ja -n dkms-%{name}
このパッケージは Athros ベースの無線LANのデバイスドライバ MADWIFI
が含まれています。


%prep
%setup -q -n madwifi-hal-%{ver}.%{svntag}


%build
%__make -C tools


%install
%__rm -rf %{buildroot}

%__make -C tools \
        DESTDIR=%{buildroot} \
        MANDIR=%{_mandir} \
	BINDIR=%{_bindir} \
	install

mkdir -p %{buildroot}/usr/src/%{name}-%{version}-%{release}
cp -r * %{buildroot}/usr/src/%{name}-%{version}-%{release}

## DKMS.CONF ##
cat > %{buildroot}/usr/src/%{name}-%{version}-%{release}/dkms.conf <<EOF

PACKAGE_NAME="%{name}"
PACKAGE_VERSION="%{version}-%{release}"

BUILT_MODULE_NAME[0]="ath_hal"
BUILT_MODULE_LOCATION[0]="ath_hal"
DEST_MODULE_LOCATION[0]="/updates/net/wireless"

BUILT_MODULE_NAME[1]="ath_pci"
BUILT_MODULE_LOCATION[1]="ath"
DEST_MODULE_LOCATION[1]="/updates/net/wireless"

BUILT_MODULE_NAME[2]="ath_rate_amrr"
BUILT_MODULE_LOCATION[2]="ath_rate/amrr"
DEST_MODULE_LOCATION[2]="/updates/net/wireless"

BUILT_MODULE_NAME[3]="ath_rate_minstrel"
BUILT_MODULE_LOCATION[3]="ath_rate/minstrel"
DEST_MODULE_LOCATION[3]="/updates/net/wireless"

BUILT_MODULE_NAME[4]="ath_rate_onoe"
BUILT_MODULE_LOCATION[4]="ath_rate/onoe"
DEST_MODULE_LOCATION[4]="/updates/net/wireless"

BUILT_MODULE_NAME[5]="ath_rate_sample"
BUILT_MODULE_LOCATION[5]="ath_rate/sample"
DEST_MODULE_LOCATION[5]="/updates/net/wireless"

BUILT_MODULE_NAME[6]="wlan"
BUILT_MODULE_LOCATION[6]="net80211"
DEST_MODULE_LOCATION[6]="/updates/net/wireless"

BUILT_MODULE_NAME[7]="wlan_acl"
BUILT_MODULE_LOCATION[7]="net80211"
DEST_MODULE_LOCATION[7]="/updates/net/wireless"

BUILT_MODULE_NAME[8]="wlan_ccmp"
BUILT_MODULE_LOCATION[8]="net80211"
DEST_MODULE_LOCATION[8]="/updates/net/wireless"

BUILT_MODULE_NAME[9]="wlan_scan_ap"
BUILT_MODULE_LOCATION[9]="net80211"
DEST_MODULE_LOCATION[9]="/updates/net/wireless"

BUILT_MODULE_NAME[10]="wlan_scan_sta"
BUILT_MODULE_LOCATION[10]="net80211"
DEST_MODULE_LOCATION[10]="/updates/net/wireless"

BUILT_MODULE_NAME[11]="wlan_tkip"
BUILT_MODULE_LOCATION[11]="net80211"
DEST_MODULE_LOCATION[11]="/updates/net/wireless"

BUILT_MODULE_NAME[12]="wlan_wep"
BUILT_MODULE_LOCATION[12]="net80211"
DEST_MODULE_LOCATION[12]="/updates/net/wireless"

BUILT_MODULE_NAME[13]="wlan_xauth"
BUILT_MODULE_LOCATION[13]="net80211"
DEST_MODULE_LOCATION[13]="/updates/net/wireless"

MAKE[0]="make KERNELPATH=\${kernel_source_dir} TARGET=%{_arch}-elf modules"

AUTOINSTALL="yes"
EOF

## KMP.SPEC ##
sed -e 's|##KMOD_NAME##|%{name}|g' \
    -e 's|##KMOD_VER##|%{version}-%{release}|g' \
    -e 's|##LICENSE##|%{license}|g' \
    %{SOURCE10} > \
    %{buildroot}/usr/src/%{name}-%{version}-%{release}/%{name}-kmp.spec


%clean
%__rm -rf %{buildroot}


%post -n dkms-%{name}
/usr/sbin/dkms add     -m %{name} -v %{version}-%{release} --rpm_safe_upgrade
/usr/sbin/dkms mkkmp   -m %{name} -v %{version}-%{release}
/usr/sbin/dkms build   -m %{name} -v %{version}-%{release} --rpm_safe_upgrade
/usr/sbin/dkms install -m %{name} -v %{version}-%{release} --rpm_safe_upgrade --force
exit 0


%preun -n dkms-%{name}
/usr/sbin/dkms remove  -m %{name} -v %{version}-%{release} --rpm_safe_upgrade --all
exit 0


%files
%defattr(-,root,root)
%doc COPYRIGHT INSTALL README* THANKS
%{_bindir}/*
%{_mandir}/man8/*.8*


%files -n dkms-%{name}
%defattr(-,root,root)
%dir /usr/src/%{name}-%{version}-%{release}
/usr/src/%{name}-%{version}-%{release}/*


%changelog
* Mon Dec 28 2009 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 0.10.5.6-5.4100
- updated to new svn snapshot (r4100)

* Wed Sep 23 2009 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 0.10.5.6-4.4098
- updated to new svn snapshot (r4098)

* Sat May 16 2009 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 0.10.5.6-3.4022
- updated to new svn snapshot (r4022)

* Sun Apr 26 2009 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 0.10.5.6-2.3992
- add Source10 for mkkmp feature

* Thu Apr  9 2009 MATSUBAYASHI Kohji <shaolin@vinelinux.org> - 0.10.5.6-1.3992
- switch to madwifi-hal branch (0.10.5.6)
- updated to new svn snapshot (r3992)
- drop kernel-module-madwifi subpackage; make DKMS-compatible

* Tue Jan 28 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 0.9.4-2.3813
- add kflavor(pae,smp..) to package name

* Sun Jul 20 2008 Daisuke SUZUKI <daisuke@linux.or.jp> 0.9.4-1.3813
- update to new svn snapshot (r3813)

* Wed Mar 26 2008 Daisuke SUZUKI <daisuke@linux.or.jp> 0.9.4-1
- new upstream release

* Mon Oct 22 2007 Daisuke SUZUKI <daisuke@linux.or.jp> 0.9.3.3-0vl1
- new upstream release

* Sat Oct 06 2007 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp> 0.9.3.1-0vl3
- rebuild

* Fri Sep 28 2007 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp> 0.9.3.1-0vl2
- rebuild

* Sun Jun 03 2007 Daisuke SUZUKI <daisuke@linux.or.jp> 0.9.3.1-0vl1
- update to 0.9.3.1

* Thu May 24 2007 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp> 
- 0.9.3-0vl4.r1770
- add patch120, 130, 140 for fix security issue

* Tue Apr 03 2007 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp> 
- 0.9.3-0vl3.r1770
- add patch110 for fix CVE-2006-7178

* Thu Dec 21 2006 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp> 
- 0.9.3-0vl2.r1770
- add Vender/Distribution Tag

* Sun Dec 10 2006 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp> 
- 0.9.3-0vl1.r1770
- add patch for fix CVE-2006-6332

* Thu Oct 26 2006 Daisuke SUZUKI <daisuke@linux.or.jp> 0.9.3-0vl0.r1770
- update to svn 0.9.3.r1770
- fix typo in Changelog

* Wed Oct 25 2006 Daisuke SUZUKI <daisuke@linux.or.jp> 0.9.3-0vl0.r1763
- update to svn 0.9.3.r1763

* Wed Sep 06 2006 Kazutaka HARADA <kazutaka@dc4.so-net.ne.jp> 0.9.2-0vl2
- fix typo of Group <BTS:VineLinux:148>.

* Tue Aug 01 2006 Daisuke SUZUKI <daisuke@linux.or.jp> 0.9.2-0vl1
- initial build for Vine Linux

