#!/bin/sh
# 

system=`uname -s`
release=`uname -r`
#  machine=`uname -p`
#  arch=`uname -m`

state="unknown"

case $system in
  Linux)
    case $release in
      1*) state="ancient";;
      2.[0-3]*) state="ancient";;
      2.4*) state="known";;
      2.5*) state="late";;
    esac
esac

case $state in
  ancient)
    echo "This is a supported OS ($system) but an old release ($release)."
    echo "The ByteBlasterMV driver cannot be used as-is on this"
    echo "system, but you may be able to port it.  Good luck!"
    exit;;
  late)
    echo "This is a newer release of $system than is supported by"
    echo "this software.  It may or may not work.";;
  unknown) 
    echo "The ByteBlasterMV driver has not been ported to this"
    echo "version of this OS.  Sorry."
    exit;;
esac

baserel=`echo $release | sed 's/-.*//'`

# Try to find modversions.h in all the usual locations.  If your distribution
# has installed it somewhere else then you may have to add a new test here.

if   [ -f /lib/modules/$release/build/include/linux/modversions.h ]; then
  INCLUDE=/lib/modules/$release/build/include/

elif [ -f /usr/src/kernel-headers/$release/include/linux/modversions.h ]; then
  INCLUDE=/usr/src/kernel-headers/$release/include/

elif [ -f /lib/modules/$baserel/build/include/linux/modversions.h ]; then
  INCLUDE=/lib/modules/$baserel/build/include/

elif [ -f /usr/src/kernel-headers/$baserel/include/linux/modversions.h ]; then
  INCLUDE=/usr/src/kernel-headers/$baserel/include/

else
  INCLUDE=__unknown
fi

if [ -f .config.make ]; then
  rm -f .config.make
fi

if [ -d $INCLUDE ]; then
  echo INCLUDEDIR = $INCLUDE >> .config.make
  echo "Using kernel headers from $INCLUDE"
  echo VER = $release >> .config.make
  echo "Installing ByteBlasterMV module into /lib/modules/$release/"
else
  echo "Unable to find modversions.h for this kernel.  Please install the"
  echo "kernel-headers package for your kernel and try again."
  exit
fi

