Add optional DKMS target to Makefile (v2)
Using DKMS, the driver will be automatically rebuilt when the kernel is updated. * `make dkms` to install via DKMS * `make dkms_clean` to remove from DKMS Signed-off-by: Burt P <pburt0@gmail.com>
This commit is contained in:
42
Makefile
42
Makefile
@@ -20,6 +20,19 @@ endif
|
|||||||
SYSTEM_MAP := /boot/System.map-$(TARGET)
|
SYSTEM_MAP := /boot/System.map-$(TARGET)
|
||||||
|
|
||||||
DRIVER := it87
|
DRIVER := it87
|
||||||
|
ifneq ("","$(wildcard .git/*)")
|
||||||
|
DRIVER_VERSION := $(shell git describe --long)
|
||||||
|
else
|
||||||
|
ifneq ("", "$(wildcard VERSION)")
|
||||||
|
DRIVER_VERSION := $(shell cat VERSION)
|
||||||
|
else
|
||||||
|
DRIVER_VERSION := unknown
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
# DKMS
|
||||||
|
DKMS_ROOT_PATH=/usr/src/$(DRIVER)-$(DRIVER_VERSION)
|
||||||
|
MODPROBE_OUTPUT=$(shell lsmod | grep it87)
|
||||||
|
|
||||||
# Directory below /lib/modules/$(TARGET)/kernel into which to install
|
# Directory below /lib/modules/$(TARGET)/kernel into which to install
|
||||||
# the module:
|
# the module:
|
||||||
@@ -38,17 +51,13 @@ ifneq ("","$(wildcard $(MODDESTDIR)/*.ko.xz)")
|
|||||||
COMPRESS_XZ := y
|
COMPRESS_XZ := y
|
||||||
endif
|
endif
|
||||||
|
|
||||||
.PHONY: all install modules modules_install clean
|
.PHONY: all install modules modules_install clean dkms dkms_clean
|
||||||
|
|
||||||
all: modules
|
all: modules
|
||||||
|
|
||||||
# Targets for running make directly in the external module directory:
|
# Targets for running make directly in the external module directory:
|
||||||
|
|
||||||
ifneq ("","$(wildcard .git/*)")
|
IT87_CFLAGS=-DIT87_DRIVER_VERSION='\"$(DRIVER_VERSION)\"'
|
||||||
IT87_CFLAGS=-DIT87_DRIVER_VERSION='\"$(shell git describe --long)\"'
|
|
||||||
else
|
|
||||||
IT87_CFLAGS=-DIT87_DRIVER_VERSION='\"<unknown>\"'
|
|
||||||
endif
|
|
||||||
|
|
||||||
modules:
|
modules:
|
||||||
@$(MAKE) EXTRA_CFLAGS="$(IT87_CFLAGS)" -C $(KERNEL_BUILD) M=$(CURDIR) $@
|
@$(MAKE) EXTRA_CFLAGS="$(IT87_CFLAGS)" -C $(KERNEL_BUILD) M=$(CURDIR) $@
|
||||||
@@ -68,3 +77,24 @@ ifeq ($(COMPRESS_XZ), y)
|
|||||||
@xz -f $(MODDESTDIR)/$(DRIVER).ko
|
@xz -f $(MODDESTDIR)/$(DRIVER).ko
|
||||||
endif
|
endif
|
||||||
depmod -a -F $(SYSTEM_MAP) $(TARGET)
|
depmod -a -F $(SYSTEM_MAP) $(TARGET)
|
||||||
|
|
||||||
|
dkms:
|
||||||
|
@sed -i -e '/^PACKAGE_VERSION=/ s/=.*/=\"$(DRIVER_VERSION)\"/' dkms.conf
|
||||||
|
@echo "$(DRIVER_VERSION)" >VERSION
|
||||||
|
@mkdir $(DKMS_ROOT_PATH)
|
||||||
|
@cp `pwd`/dkms.conf $(DKMS_ROOT_PATH)
|
||||||
|
@cp `pwd`/VERSION $(DKMS_ROOT_PATH)
|
||||||
|
@cp `pwd`/Makefile $(DKMS_ROOT_PATH)
|
||||||
|
@cp `pwd`/compat.h $(DKMS_ROOT_PATH)
|
||||||
|
@cp `pwd`/it87.c $(DKMS_ROOT_PATH)
|
||||||
|
@dkms add -m $(DRIVER) -v $(DRIVER_VERSION)
|
||||||
|
@dkms build -m $(DRIVER) -v $(DRIVER_VERSION)
|
||||||
|
@dkms install --force -m $(DRIVER) -v $(DRIVER_VERSION)
|
||||||
|
@modprobe $(DRIVER)
|
||||||
|
|
||||||
|
dkms_clean:
|
||||||
|
@if [ ! -z "$(MODPROBE_OUTPUT)" ]; then \
|
||||||
|
rmmod $(DRIVER);\
|
||||||
|
fi
|
||||||
|
@dkms remove -m $(DRIVER) -v $(DRIVER_VERSION) --all
|
||||||
|
@rm -rf $(DKMS_ROOT_PATH)
|
||||||
|
7
dkms.conf
Normal file
7
dkms.conf
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
MAKE="make"
|
||||||
|
CLEAN="make clean"
|
||||||
|
PACKAGE_NAME="it87"
|
||||||
|
PACKAGE_VERSION="to be filled by make dkms"
|
||||||
|
BUILT_MODULE_NAME[0]="it87"
|
||||||
|
DEST_MODULE_LOCATION[0]="/kernel/drivers/hwmon/it87"
|
||||||
|
AUTOINSTALL="yes"
|
1
it87.c
1
it87.c
@@ -4263,6 +4263,7 @@ module_param(fix_pwm_polarity, bool, 0000);
|
|||||||
MODULE_PARM_DESC(fix_pwm_polarity,
|
MODULE_PARM_DESC(fix_pwm_polarity,
|
||||||
"Force PWM polarity to active high (DANGEROUS)");
|
"Force PWM polarity to active high (DANGEROUS)");
|
||||||
MODULE_LICENSE("GPL");
|
MODULE_LICENSE("GPL");
|
||||||
|
MODULE_VERSION(IT87_DRIVER_VERSION);
|
||||||
|
|
||||||
module_init(sm_it87_init);
|
module_init(sm_it87_init);
|
||||||
module_exit(sm_it87_exit);
|
module_exit(sm_it87_exit);
|
||||||
|
Reference in New Issue
Block a user