#!/bin/sh
KVER=`uname -r`
VER=`uname -r | cut -d. -f1,2`

GCCVER=`cat /proc/version|awk '{print $7}' |cut -d. -f 1`
if [ $GCCVER != "2" ]; then
GCCVER=`cat /proc/version|awk '{print $7}' |cut -d. -f 1,2`
fi


if [ $VER == "2.4" ]; then
	cp Makefile.2.4 Makefile
	if [ -f precompiled/epass-$KVER.o ]; then
		cp precompiled/epass-$KVER.o epass.o
		echo compile finished!
	else
		if [ -d /lib/modules/`uname -r`/build/include/linux ]; then
			make clean
			make GCCVERSION=$GCCVER
			echo compile finished!
		else
			echo Please install kernel source!
		fi
	fi
fi

if [ $VER == "2.6" ]; then
	cp Makefile.2.6 Makefile
	if [ -f precompiled/epass-$KVER.ko ]; then
		cp precompiled/epass-$KVER.ko epass.ko
		echo compile finished!
	else
		if [ -d /lib/modules/`uname -r`/build/include/linux ]; then
			make clean
			make GCCVERSION=$GCCVER
			echo compile finished!
		else
			echo Please install kernel source!
		fi
	fi
fi
