-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
73 lines (59 loc) · 1.71 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
SHELL := /bin/bash
KVER ?= $(shell uname -r)
KSRC := /lib/modules/$(KVER)/build
PWD := $(shell pwd)
CLR_MODULE_FILES := *.mod.c *.mod *.o .*.cmd *.ko *~ .tmp_versions* modules.order Module.symvers
SYMBOL_FILE := Module.symvers
MODDESTDIR := /lib/modules/$(KVER)/kernel/drivers/bluetooth
ifeq ("","$(wildcard MOK.der)")
NO_SKIP_SIGN := y
endif
#Handle the compression option for modules in 3.18+
ifneq ("","$(wildcard $(MODDESTDIR)/*.ko.gz)")
COMPRESS_GZIP := y
endif
ifneq ("","$(wildcard $(MODDESTDIR)/*.ko.xz)")
COMPRESS_XZ := y
endif
EXTRA_CFLAGS += -O2
KEY_FILE ?= MOK.der
obj-m += btusb.o
obj-m += btrtl.o
obj-m += btmtk.o
obj-m += btintel.o
ccflags-y += -D__CHECK_ENDIAN__
.PHONY: all install clean sign sign-install
all:
$(MAKE) -C $(KSRC) M=$(PWD) modules
uninstall:
@rm $(MODDESTDIR)/btusb.ko* $(MODDESTDIR)/btrtl.ko*
install: all
@mkdir -p $(MODDESTDIR)
@install -p -D -m 644 *.ko $(MODDESTDIR)
ifeq ($(COMPRESS_GZIP), y)
@gzip -f $(MODDESTDIR)/btusb.ko
@gzip -f $(MODDESTDIR)/btrtl.ko
endif
ifeq ($(COMPRESS_XZ), y)
@xz -f $(MODDESTDIR)/btusb.ko
@xz -f $(MODDESTDIR)/btrtl.ko
endif
@depmod -a $(KVER)
@echo "Install btusb/btrtl SUCCESS"
clean:
@rm -fr *.mod.c *.mod *.o .*.cmd .*.o.cmd *.ko *~ .*.o.d .cache.mk
@rm -fr .tmp_versions
@rm -fr Modules.symvers
@rm -fr Module.symvers
@rm -fr Module.markers
@rm -fr modules.order
sign:
ifeq ($(NO_SKIP_SIGN), y)
@openssl req -new -x509 -newkey rsa:2048 -keyout MOK.priv -outform DER -out MOK.der -nodes -days 36500 -subj "/CN=Custom MOK/"
@mokutil --import MOK.der
else
echo "Skipping key creation"
endif
@$(KSRC)/scripts/sign-file sha256 MOK.priv MOK.der btusb.ko
@$(KSRC)/scripts/sign-file sha256 MOK.priv MOK.der btrtl.ko
sign-install: all sign install