-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
75 lines (64 loc) · 2.2 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
74
75
DEPENDENCIES := nothing
default: i915
.PHONY: install
.SILENT: clean uninstall patch download install i915
ifeq ($(KVER),)
KVER := "$(shell uname -r)"
endif
#CKERNEL := "/usr/lib/modules/$(shell uname -r)"
CKERNEL := "/usr/lib/modules/$(KVER)"
#CKERNELVERSION := $(shell uname -r | cut -d- -f1)
CKERNELVERSION := $(shell echo $(KVER) | cut -d- -f1)
# 4.14.8
LOCALKERNEL := $(shell pwd)/linux-$(CKERNELVERSION)
# ./linux-4.14.8
LOCALI915 := $(LOCALKERNEL)/drivers/gpu/drm/i915
clean:
cd $(LOCALKERNEL); \
find ./ -name "*.o" -delete; \
find ./ -name "*.ko" -delete; \
find ./ -name "*.ko.gz" -delete; \
find ./ -name "*.rej" -delete
make -C $(CKERNEL)/build M="$(LOCALI915)" clean
rm -rf ./linux-*/
echo "$(LOCALKERNEL) cleaned!"
uninstall:
if [ -f $(CKERNEL)/updates/i915.ko.xz ]; then \
rm $(CKERNEL)/updates/i915.ko.xz; \
echo "$(CKERNEL)/updates/i915.ko.xz deleted."; \
fi
rmdir $(CKERNEL)/updates || \
echo "$(CKERNEL) not empty!"; \
ls -lah $(CKERNEL)/updates/ || \
echo "Nothing to uninstall!"
download:
if [ ! -d $(LOCALKERNEL)/ ]; then \
echo "Downloading Linux kernel source for v$(CKERNELVERSION)"; \
git clone --depth=1 --branch v$(CKERNELVERSION) \
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git $(LOCALKERNEL); \
fi
patch: download
# Patch to allow building "out-of-tree"
patch --forward -p1 --directory=$(LOCALKERNEL) \
< patches/i915-out-of-tree.patch || \
echo "Already patched."
# Patch to disable ghost LVDS display in i915 for x220/x230
patch --forward -p1 --directory=$(LOCALKERNEL) \
< patches/i915-no-lvds-multi.patch || \
echo "Already patched"
# default target
i915: patch
echo Building $(LOCAL) using $(CKERNEL)/build
make -C $(CKERNEL)/build M="$(LOCALI915)"
cp $(LOCALI915)/i915.ko \
./i915.ko
xz -z $(LOCALI915)/i915.ko
install: uninstall
# too easy, drop modded .ko.gz in /usr/lib/modules/`uname -r`/updates , depmod, build initram and reboot...
if [ ! -d $(CKERNEL)/updates/ ]; then \
mkdir $(CKERNEL)/updates; fi
cp $(LOCALI915)/i915.ko.xz \
$(CKERNEL)/updates/i915.ko.xz && \
echo "Installed modded i915.ko to $(CKERNEL)/updates/i915.ko.xz"
depmod
echo "Done! Reboot to load the new i915 module."