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
|
|
|
|
|
|
|
|
targets += $(dtbo-y)
|
|
|
|
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-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-12 19:41:48 -04:00
|
|
|
|| echo '[all]\ndtparam=spi=on\n$(BOOT_CONFIG_LINE)' >> /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-04 21:22:30 -04:00
|
|
|
# Rebuild dependencies
|
|
|
|
depmod -A
|
|
|
|
|
|
|
|
uninstall:
|
|
|
|
# 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
|