KVER ?= $(shell uname -r)
KERNEL_DIR ?= /lib/modules/$(KVER)/build
INSTALL_DIR ?= /lib/modules/$(KVER)/ttyPos

obj-m := ttyPos.o

all:
	$(MAKE) modules -C $(KERNEL_DIR) M=$(CURDIR)

clean:
	$(RM) *.o *.ko *.mod *.mod.* .*.cmd *.order *.symvers *~
	$(RM) -r .tmp_versions

install: all
	install -D -m 644 ttyPos.ko $(INSTALL_DIR)/ttyPos.ko
	/sbin/depmod -a

uninstall:
	modprobe -r ttyPos || true
	$(RM) $(INSTALL_DIR)/ttyPos.ko
	/sbin/depmod -a
