forked from gschorcht/i2c-ch341-usb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
55 lines (41 loc) · 1.19 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
MODULE_NAME=i2c-ch341-usb
MODULE_VERSION=1.0.0
DKMS := $(shell which dkms)
PWD := $(shell pwd)
KVERSION := $(shell uname -r)
KERNEL_DIR = /lib/modules/$(KVERSION)/build
MODULE_DIR = /lib/modules/$(KVERSION)
ifneq ($(DKMS),)
MODULE_INSTALLED := $(shell dkms status $(MODULE_NAME))
else
MODULE_INSTALLED =
endif
MODULE_NAME = i2c-ch341-usb
obj-m := $(MODULE_NAME).o
$(MODULE_NAME).ko: $(MODULE_NAME).c
make -C $(KERNEL_DIR) M=$(PWD) modules
all:
make -C $(KERNEL_DIR) M=$(PWD) modules
clean:
make -C $(KERNEL_DIR) M=$(PWD) clean
rm -f examples/gpio_input examples/gpio_output
ifeq ($(DKMS),) # if DKMS is not installed
install: $(MODULE_NAME).ko
cp $(MODULE_NAME).ko $(MODULE_DIR)/kernel/drivers/i2c/busses
depmod
uninstall:
rm -f $(MODULE_DIR)/kernel/drivers/i2c/busses/$(MODULE_NAME).ko
depmod
else # if DKMS is installed
install: $(MODULE_NAME).ko
ifneq ($(MODULE_INSTALLED),)
@echo Module $(MODULE_NAME) is installed ... uninstall it first
@make uninstall
endif
@dkms install .
uninstall:
ifneq ($(MODULE_INSTALLED),)
dkms remove -m $(MODULE_NAME) -v $(MODULE_VERSION) --all
rm -rf /usr/src/$(MODULE_NAME)-$(MODULE_VERSION)
endif
endif # ifeq ($(DKMS),)