#########################################################
#             Makefile for MOS7840   LINUX 2.6          #      
#########################################################

KDIR:=/lib/modules/$(shell uname -r)/build
MDIR:=/lib/modules/$(shell uname -r)/kernel/drivers/usb/serial

EXTRA_CFLAGS += -I$(KDIR)/drivers/usb/serial


obj-m:=mos7840.o

default:
	$(MAKE) -C $(KDIR) $(EXTRA_CFLAGS) SUBDIRS=$(PWD) modules

clean:
	rm -rf .tmp_versions Module.symvers *.mod.c *.o *.ko .*.cmd

load:
	-modprobe usbserial
	insmod mos7840.ko

unload:
	rmmod mos7840

install:
	install -m 744 mos7840.ko $(MDIR)/mos7840.ko
	depmod -a
	cp -f /etc/modprobe.conf /etc/modprobe.conf~
	grep 'install mos7840' /etc/modprobe.conf || echo "install mos7840 /sbin/modprobe --ignore-install mos7840" >>/etc/modprobe.conf

uninstall:
	$(RM) $(MDIR)/mos7840.ko
	depmod -a
	cp -f /etc/modprobe.conf /etc/modprobe.conf~
	grep -v 'install mos7840' /etc/modprobe.conf~ >/etc/modprobe.conf


