# Comment/uncomment the following line to enable/disable debugging

KERNEL_VERSION=2.4.18-14

###############################################################################

install:
	/bin/mkdir -p /lib/modules/$(KERNEL_VERSION)/rcdog
	/bin/cp grandusb.o /lib/modules/$(KERNEL_VERSION)/rcdog/grandusb.o
	/bin/chmod 700 /lib/modules/$(KERNEL_VERSION)/rcdog/grandusb.o
	if [ -e /lib/modules/$(KERNEL_VERSION)/modules.dep ]; then \
		indep=`/bin/grep 'rcdog/grandusb.o:' /lib/modules/$(KERNEL_VERSION)/modules.dep`; \
		if [ -z "$$indep" ]; then \
			/bin/echo "/lib/modules/$(KERNEL_VERSION)/rcdog/grandusb.o:" >> /lib/modules/$(KERNEL_VERSION)/modules.dep; \
			/bin/echo "" >> /lib/modules/$(KERNEL_VERSION)/modules.dep; \
		fi; \
	fi; \
	inlocal=`/bin/grep 'grandusb' /etc/rc.d/rc.local`;\
	if [ -z "$$inlocal" ]; then \
        /bin/cat "$$PWD/grandusb_load" >> /etc/rc.d/rc.local;\
	fi; \
	/bin/echo " The usb dog's driver has been installed successfully!";\
	/bin/echo "Please restart the system to active the dog driver";\
	
	
uninstall:


	rm -rf /lib/modules/$(KERNEL_VERSION)/rcdog/grandusb.o;\
	/usr/bin/diff -n $$PWD/grandusb_load /etc/rc.d/rc.local>>/etc/temp.0;\
	/bin/sed -e '/[a-z][0-9]/d' /etc/temp.0>>/etc/temp.1;\
	rm -f /etc/rc.d/rc.local;\
	cp /etc/temp.1 /etc/rc.d/rc.local;\
	/bin/chmod 700 /etc/rc.d/rc.local;\
	rm -f /etc/temp.0;\
	rm -f /etc/temp.1;\
	/sbin/rmmod grandusb;\
	rm -f /dev/grandusb;\
	
	/bin/echo "The USB dog driver will be uninstalled !";\
	/bin/echo "Please reboot the system to validate the uninstall!";\



clean:
	/bin/rm -f grandusb.o;\
	/bin/rm -f grandusb1.o;
