2023-08-12 19:41:48 -04:00
|
|
|
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
|
|
|
|
|
2023-08-19 17:56:49 -04:00
|
|
|
targets += $(dtbo-y)
|
2023-08-12 19:41:48 -04:00
|
|
|
always := $(dtbo-y)
|
2018-05-17 12:45:14 -04:00
|
|
|
|
2023-08-04 21:22:30 -04:00
|
|
|
.PHONY: all clean install uninstall
|
2018-05-17 12:45:14 -04:00
|
|
|
|
2023-08-04 21:22:30 -04:00
|
|
|
# LINUX_DIR is set by Buildroot, but not if running manually
|
|
|
|
ifeq ($(LINUX_DIR),)
|
|
|
|
LINUX_DIR := /lib/modules/$(shell uname -r)/build
|
|
|
|
endif
|
|
|
|
|
2023-08-12 19:41:48 -04:00
|
|
|
# BUILD_DIR is set by DKMS, but not if running manually
|
|
|
|
ifeq ($(BUILD_DIR),)
|
|
|
|
BUILD_DIR := .
|
|
|
|
endif
|
2023-08-04 21:22:30 -04:00
|
|
|
|
2023-08-12 19:41:48 -04:00
|
|
|
BOOT_CONFIG_LINE := dtoverlay=sharp-drm
|
2023-08-19 17:56:49 -04:00
|
|
|
BOOT_CMDLINE_ADD := console=tty2 fbcon=font:VGA8x8 fbcon=map:10
|
2023-08-04 21:22:30 -04:00
|
|
|
|
2023-08-12 19:41:48 -04:00
|
|
|
all:
|
|
|
|
$(MAKE) -C '$(LINUX_DIR)' M='$(shell pwd)'
|
2023-08-04 21:22:30 -04:00
|
|
|
|
2023-08-12 19:41:48 -04:00
|
|
|
install_modules:
|
2023-08-04 21:22:30 -04:00
|
|
|
$(MAKE) -C '$(LINUX_DIR)' M='$(shell pwd)' modules_install
|
2023-08-12 19:41:48 -04:00
|
|
|
# Rebuild dependencies
|
|
|
|
depmod -A
|
|
|
|
|
|
|
|
install: install_modules install_aux
|
|
|
|
|
|
|
|
# Separate rule to be called from DKMS
|
|
|
|
install_aux:
|
2023-08-04 21:22:30 -04:00
|
|
|
# Install device tree overlay
|
2023-08-12 19:41:48 -04:00
|
|
|
install -D -m 0644 $(BUILD_DIR)/sharp-drm.dtbo /boot/overlays/
|
2023-08-04 21:22:30 -04:00
|
|
|
# Add configuration line if it wasn't already there
|
|
|
|
grep -qxF '$(BOOT_CONFIG_LINE)' /boot/config.txt \
|
2023-08-19 17:56:49 -04:00
|
|
|
|| printf '[all]\ndtparam=spi=on\n$(BOOT_CONFIG_LINE)\n' >> /boot/config.txt
|
2023-08-04 21:22:30 -04:00
|
|
|
# Add auto-load module line if it wasn't already there
|
2023-08-12 19:41:48 -04:00
|
|
|
grep -qxF 'sharp-drm' /etc/modules \
|
|
|
|
|| echo 'sharp-drm' >> /etc/modules
|
2023-08-19 17:56:49 -04:00
|
|
|
# Configure fbcon for display
|
|
|
|
grep -qxF '$(BOOT_CMDLINE_ADD)' /boot/cmdline.txt \
|
|
|
|
|| sed -i.save 's/$$/ $(BOOT_CMDLINE_ADD)/' /boot/cmdline.txt
|
2023-08-04 21:22:30 -04:00
|
|
|
# Rebuild dependencies
|
|
|
|
depmod -A
|
|
|
|
|
|
|
|
uninstall:
|
2023-08-19 17:56:49 -04:00
|
|
|
# Remove fbcon configuration and create a backup file
|
|
|
|
sed -i.save 's/ $(BOOT_CMDLINE_ADD)//' /boot/cmdline.txt
|
2023-08-04 21:22:30 -04:00
|
|
|
# Remove auto-load module line and create a backup file
|
2023-08-12 19:41:48 -04:00
|
|
|
sed -i.save '/sharp-drm/d' /etc/modules
|
2023-08-04 21:22:30 -04:00
|
|
|
# Remove configuration line and create a backup file
|
|
|
|
sed -i.save '/$(BOOT_CONFIG_LINE)/d' /boot/config.txt
|
|
|
|
# Remove device tree overlay
|
2023-08-12 19:41:48 -04:00
|
|
|
rm -f /boot/overlays/sharp-drm.dtbo
|
2018-05-17 12:45:14 -04:00
|
|
|
|
2023-08-04 20:22:22 -04:00
|
|
|
clean:
|
2023-08-04 21:22:30 -04:00
|
|
|
$(MAKE) -C '$(LINUX_DIR)' M='$(shell pwd)' clean
|