-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
73 lines (52 loc) · 1.59 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# this is used for packaging, to distinguish from the original
PACKAGE := hid-wiimote-plus
# this is used to name the module file, so it must match the original to override it
MODULE := hid-wiimote
VERSION := 0.9.2
DISTDIR := $(PACKAGE)-$(VERSION)
DISTFILES := \
99-wiimote.rules \
COPYING \
dkms.conf.in \
gamepad.rst \
hid-wiimote-core.c \
hid-wiimote-debug.c \
hid-wiimote-modules.c \
hid-wiimote.h \
Kbuild \
Makefile \
README.md
KDIR ?= /lib/modules/$(shell uname -r)/build
SRCTREE ?= /usr/src
SRCDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
.PHONY: all clean dist install uninstall
all:
make --directory=$(KDIR) M=$(SRCDIR) WIIMOTE_MODULE_VERSION=$(VERSION)
clean:
$(info cleaning up)
make --directory=$(KDIR) M=$(SRCDIR) clean
$(RM) --recursive $(DISTDIR)
$(RM) dkms.conf
dist:
mkdir $(DISTDIR)
cp --target-directory=$(DISTDIR) $(DISTFILES)
tar -c -z -f $(DISTDIR).tar.gz $(DISTDIR)
$(RM) --recursive $(DISTDIR)
install:
-cp --target-directory=/etc/udev/rules.d 99-wiimote.rules
$(RM) --recursive $(SRCTREE)/$(DISTDIR)
mkdir --parents $(SRCTREE)/$(DISTDIR)
cp --target-directory=$(SRCTREE)/$(DISTDIR) $(DISTFILES)
make --directory=$(SRCTREE)/$(DISTDIR) dkms.conf
dkms add -m $(PACKAGE) -v $(VERSION)
dkms build -m $(PACKAGE) -v $(VERSION)
dkms install -m $(PACKAGE) -v $(VERSION)
uninstall:
$(RM) /etc/udev/rules.d/99-wiimote.rules
-dkms remove -m $(PACKAGE) -v $(VERSION) --all
$(RM) --recursive $(SRCTREE)/$(DISTDIR)
dkms.conf: dkms.conf.in
sed -e "s/@PACKAGE@/$(PACKAGE)/g" \
-e "s/@VERSION@/$(VERSION)/g" \
-e "s/@MODULE@/$(MODULE)/g" \
$< > $@