#!/bin/bash

NAME="dvbsky_v4l"
VERSION="14.6.19"

make distclean
make all

cat <<EOF > dkms.conf
PACKAGE_NAME=$NAME
PACKAGE_VERSION=$VERSION
CHECK_MODULE_VERSION=n

MAKE="'make' all VER=\$kernelver"
CLEAN="'make' distclean"
AUTOINSTALL="yes"

EOF

# determine module names and paths from temporary build
i=0
for f in `find -name *.ko`; do
    M=`basename $f .ko`
    echo "BUILT_MODULE_NAME[$i]=$M" >> dkms.conf
    echo "BUILT_MODULE_LOCATION[$i]=`dirname $f`" >> dkms.conf
    echo "DEST_MODULE_LOCATION[$i]=/updates/dkms" >> dkms.conf
    ((i=i+1))
done

ln -s `pwd` /usr/src/$NAME-$VERSION

dkms add -m $NAME -v $VERSION
dkms build -m $NAME -v $VERSION
dkms install -m $NAME -v $VERSION

