############################ 2.6 usbhid kernel compile ###############################

CURRENT = $(shell uname -r)
ifneq ($(KERNELRELEASE),)
# We were called by kbuild
# Do NOT indent stuff in this part! It has to be like this to make the
# $(error ... ) stuff work

# only compile those modules which are enabled by global configure
ifeq ($(CV_OPTION_HID),yes)

# check if kernel was configured to have hid as an module
ifeq ($(CONFIG_USB_HID),m)

ubt780-objs := hid-ubt780.o

# behave exactly as kernel config wants us to behave

obj-$(CONFIG_USB_HID) += ubt780.o

else
ifeq ($(CONFIG_USB_HID),y)
$(error You requested to build hid with configure, but hid is configured as built-in in your kernel config)
endif

$(error You requested to build hid with configure, but hid is not configured in your kernel config)
endif # CONFIG_USB_HID
endif # CV_OPTION_HID not

else  # We were called from command line
PWD  := $(shell pwd)

KDIR = /lib/modules/$(CURRENT)/build
MDIR = drivers/misc
DEST = /lib/modules/$(CURRENT)/kernel/$(MDIR)
RULS = /etc/udev/rules.d

CV_OPTION_HID := yes

export CV_OPTION_HID



all:
	@echo $(CFLAGS)
	@echo '    Building drivers for 2.6 kernel.'
	@echo '***Note: Drivers not enabled as modules in your kernel config but requested through configure are NOT built'
	$(MAKE) -C $(KDIR) M=$(PWD) modules

endif  # End kbuild check

######################### Version independent targets ##########################

clean:
	rm -rf *.o *.ko *.mod.* .ubt780* .tmp*  core *.i *.symvers *.order *.*~ 

install:
	su -c "cp -v ubt780.ko $(DEST) && /sbin/depmod -a && cp -v ubt780.rules $(RULS)"

EMPTY_AUTOMAKE_TARGETS = distdir install install-data install-exec uninstall install-info
EMPTY_AUTOMAKE_TARGETS += installdirs check dvi pdf ps info html tags ctags mostlyclean distclean maintainer-clean
.PHONY: $(EMPTY_AUTOMAKE_TARGETS)
	$(EMPTY_AUTOMAKE_TARGETS):