-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathMakefile
80 lines (65 loc) · 2.3 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
76
77
78
79
80
obj-m += sharp-drm.o
sharp-drm-objs += src/main.o src/drm_iface.o src/params_iface.o src/ioctl_iface.o
ccflags-y := -g -std=gnu99 -Wno-declaration-after-statement
dtb-y += sharp-drm.dtbo
targets += $(dtbo-y)
always := $(dtbo-y)
.PHONY: all clean install uninstall
# KERNELRELEASE is set by DKMS, can be different inside chroot
ifeq ($(KERNELRELEASE),)
KERNELRELEASE := $(shell uname -r)
endif
# LINUX_DIR is set by Buildroot
ifeq ($(LINUX_DIR),)
LINUX_DIR := /lib/modules/$(KERNELRELEASE)/build
endif
# BUILD_DIR is set by DKMS, but not if running manually
ifeq ($(BUILD_DIR),)
BUILD_DIR := .
endif
BOOT_CONFIG_LINE := dtoverlay=sharp-drm
BOOT_CMDLINE_ADD := console=tty2 fbcon=font:VGA8x8 fbcon=map:10
# Raspbian 12 moved config and cmdline to firmware
ifeq ($(wildcard /boot/firmware/config.txt),)
CONFIG=/boot/config.txt
else
CONFIG=/boot/firmware/config.txt
endif
ifeq ($(wildcard /boot/firmware/cmdline.txt),)
CMDLINE=/boot/cmdline.txt
else
CMDLINE=/boot/firmware/cmdline.txt
endif
all: sharp-drm.dtbo
$(MAKE) -C '$(LINUX_DIR)' M='$(shell pwd)'
sharp-drm.dtbo: sharp-drm.dts
dtc -@ -I dts -O dtb -W no-unit_address_vs_reg -o $@ $<
install_modules:
$(MAKE) -C '$(LINUX_DIR)' M='$(shell pwd)' modules_install
# Rebuild dependencies
depmod -A
install: install_modules install_aux
# Separate rule to be called from DKMS
install_aux: sharp-drm.dtbo
# Install device tree overlay
install -D -m 0644 $(BUILD_DIR)/sharp-drm.dtbo /boot/overlays/
# Add configuration line if it wasn't already there
@grep -qxF '$(BOOT_CONFIG_LINE)' $(CONFIG) \
|| printf '[all]\ndtparam=spi=on\n$(BOOT_CONFIG_LINE)\n' >> $(CONFIG)
# Add auto-load module line if it wasn't already there
@grep -qxF 'sharp-drm' /etc/modules \
|| echo 'sharp-drm' >> /etc/modules
# Configure fbcon for display
@grep -qF '$(BOOT_CMDLINE_ADD)' $(CMDLINE) \
|| sed -i.save 's/$$/ $(BOOT_CMDLINE_ADD)/' $(CMDLINE)
uninstall:
# Remove fbcon configuration and create a backup file
@sed -i.save 's/ $(BOOT_CMDLINE_ADD)//' $(CMDLINE)
# Remove auto-load module line and create a backup file
@sed -i.save '/sharp-drm/d' /etc/modules
# Remove configuration line and create a backup file
@sed -i.save '/$(BOOT_CONFIG_LINE)/d' $(CONFIG)
# Remove device tree overlay
@rm -f /boot/overlays/sharp-drm.dtbo
clean:
$(MAKE) -C '$(LINUX_DIR)' M='$(shell pwd)' clean