%define version  @CONFIG_SND_VERSION@
%define kversion @kversion@.@kpatchlevel@.@ksublevel@

Summary:   ALSA driver
Name:      alsa-driver
Version:   %{version}
Release:   1
Source:    alsa-driver-%{version}.tar.gz
URL:       http://www.alsa-project.org
Copyright: GPL
Group:     Base/Kernel
Requires:  kernel kernel-headers
BuildRoot: /tmp/alsa-driver-%{version}-root

%description
Advanced Linux Sound Architecture driver. Driver is fully compatible
with OSS/Lite, but contains many enhanced features.

%prep
%setup

%build
./configure --prefix=/usr ${EXTRA_ALSA_DRIVER_CONFIG_FLAGS}
make

%install
rm -rf $RPM_BUILD_ROOT

for I in etc/rc.d/init.d usr/include/linux lib/modules/%{kversion}/misc; do
  mkdir -p $RPM_BUILD_ROOT/$I
done

make prefix=$RPM_BUILD_ROOT/usr \
     moddir=$RPM_BUILD_ROOT/lib/modules/%{kversion}/misc \
     install

install -m755 utils/alsasound $RPM_BUILD_ROOT/etc/rc.d/init.d/alsasound

%post
if [ -x /sbin/chkconfig ]; then
  chkconfig --add alsasound
fi
depmod -a

%postun
if [ "$1" = 0 ] ; then
  if [ -x /sbin/chkconfig ]; then
    chkconfig --del alsasound
  fi
fi

%clean
rm -rf $RPM_BUILD_ROOT

%files
%attr(-,root,root) %doc ChangeLog FAQ INSTALL README TODO snddevices doc/
%attr(-,root,root) %config /etc/rc.d/init.d/*
%attr(-,root,root) /usr/include/linux/*.h
%attr(-,root,root) /lib/modules/%{kversion}/misc/*.o
