2018-05-17 12:45:14 -04:00
|
|
|
obj-m += sharp.o
|
2023-08-04 20:22:22 -04:00
|
|
|
sharp-objs += src/main.o src/drm_iface.o src/params_iface.o src/ioctl_iface.o
|
|
|
|
ccflags-y := -DDEBUG -g -std=gnu99 -Wno-declaration-after-statement
|
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
|
|
|
|
|
|
|
|
BOOT_CONFIG_LINE := dtoverlay=sharp
|
|
|
|
|
|
|
|
all: sharp.ko sharp.dtbo
|
|
|
|
|
|
|
|
sharp.ko: src/*.c src/*.h
|
|
|
|
$(MAKE) -C '$(LINUX_DIR)' M='$(shell pwd)' modules
|
|
|
|
|
|
|
|
sharp.dtbo: sharp.dts
|
|
|
|
dtc -@ -I dts -O dtb -W no-unit_address_vs_reg -o $@ $<
|
|
|
|
|
|
|
|
install: sharp.ko sharp.dtbo
|
|
|
|
# Install kernel module
|
|
|
|
$(MAKE) -C '$(LINUX_DIR)' M='$(shell pwd)' modules_install
|
|
|
|
# Install device tree overlay
|
|
|
|
install -D -m 0644 sharp.dtbo /boot/overlays/
|
|
|
|
# Add configuration line if it wasn't already there
|
|
|
|
grep -qxF '$(BOOT_CONFIG_LINE)' /boot/config.txt \
|
2023-08-05 10:49:22 -04:00
|
|
|
|| echo '[all]\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
|
|
|
|
grep -qxF 'sharp' /etc/modules \
|
|
|
|
|| echo 'sharp' >> /etc/modules
|
|
|
|
# Rebuild dependencies
|
|
|
|
depmod -A
|
|
|
|
|
|
|
|
uninstall:
|
|
|
|
# Remove auto-load module line and create a backup file
|
|
|
|
sed -i.save '/sharp/d' /etc/modules
|
|
|
|
# Remove configuration line and create a backup file
|
|
|
|
sed -i.save '/$(BOOT_CONFIG_LINE)/d' /boot/config.txt
|
|
|
|
# Remove device tree overlay
|
|
|
|
rm -f /boot/overlays/sharp.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
|