TARGET = wrg526
# If KERNELRELEASE is defined, we've been invoked from the
# kernel build system and can use its language
obj-m := wrg526.o

KERNELDIR ?= /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)

default: wrg526.ko

wrg526.ko: wrg526.c wrg526ioctl.h
	$(MAKE) -I./ -C $(KERNELDIR) M=$(PWD) modules
#	strip "$(TARGET).ko"

install: wrg526.ko
	test -z "$(shell /sbin/lsmod | grep wrg526)" ||  /sbin/rmmod wrg526
	install -m 755 -d /lib/modules/$(shell uname -r)/kernel/drivers/WiNRADiO
	install -m 644 wrg526.ko /lib/modules/$(shell uname -r)/kernel/drivers/WiNRADiO/wrg526.ko
	/sbin/depmod -a
	/sbin/modprobe wrg526

uninstall:
	rm -f /lib/modules/$(shell uname -r)/kernel/drivers/WiNRADiO/wrg526.ko
	/sbin/depmod -a

clean:
	rm -f *.o
	rm -f *.ko
	rm -f .*.cmd
	rm -f *.mod.c
	rm -f *.mod.o
