obj-m += memstick.o mspro_block.o
obj-m += xd_card.o
obj-m += flash_bd.o
obj-m += jmb38x_ms.o
obj-m += jmb38x_xd.o

xd_card-objs := xd_card_blk.o xd_card_ecc.o

KERNELDIR ?= /lib/modules/$(KVER)/build

PWD       := $(shell pwd)
MODULE_INSTALLDIR = /lib/modules/$(KVER)/kernel/drivers/jmb38x
EXTRA_CFLAGS = -fno-inline #-DDEBUG

all:
	echo $(PWD)
	$(MAKE) -C $(KERNELDIR) M=$(PWD)

clean:
	rm -rf *.o *.o.d *.ko.d .depend .*.cmd *.ko *.mod.c .tmp_versions *.symvers Module.markers modules.order

install: all
	mkdir -p $(MODULE_INSTALLDIR)
	rm -f $(MODULE_INSTALLDIR)/*.ko
	rm -rf $(MODULE_INSTALLDIR)/../memstick

	install -c -m 644 *.ko $(MODULE_INSTALLDIR)
	/sbin/depmod -ae

	echo "# remove modules in initramfs " >> /etc/rc.local  
	echo "rmmod jmb38x_ms" >> /etc/rc.local
	echo "rmmod mspro_block" >> /etc/rc.local
	echo "rmmod flash_bd" >> /etc/rc.local
	echo "rmmod xd_card" >> /etc/rc.local
	echo "rmmod jmb38x_xd" >> /etc/rc.local
	echo "modprobe jmb38x_ms" >> /etc/rc.local
	echo "modprobe mspro_block" >> /etc/rc.local
	echo "modprobe flash_bd" >> /etc/rc.local
	echo "modprobe xd_card" >> /etc/rc.local
	echo "modprobe jmb38x_xd" >> /etc/rc.local

