#!/bin/bash

if [ $# -ne 0 ]; then
  args="$@"
elif [ -r /etc/asound/driver_args ]; then
  args="`cat /etc/asound/driver_args`"
else
  args="--with-debug=full --with-isapnp=yes --with-sequencer=yes"
fi

if [ -r /usr/share/aclocal/alsa-lib.m4 ]; then
  rm -f /usr/share/aclocal/alsa-lib.m4
fi
if [ -r /usr/local/share/aclocal/alsa-lib.m4 ]; then
  rm -f /usr/local/share/aclocal/alsa-lib.m4
fi
#if [ -d ../alsa-lib ]; then
#  echo "Building hard symlinks with alsa-lib sources..."
#  cd kernel
#  pwd
#  cd ..
#fi
make -C utils update-deps
aclocal $ACLOCAL_FLAGS
autoconf
echo "./configure $args"
./configure $args || exit 1
make dep
make
