From 4f73396ba78dc9012280ea7e800e76d59656f91b Mon Sep 17 00:00:00 2001 From: Lekensteyn Date: Sat, 21 Jan 2012 15:02:11 +0100 Subject: [PATCH] Add easier way to use DKMS --- Makefile.dkms | 24 ++++++++++++++++++++++++ README.md | 14 ++++++++++---- 2 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 Makefile.dkms diff --git a/Makefile.dkms b/Makefile.dkms new file mode 100644 index 0000000..48ec687 --- /dev/null +++ b/Makefile.dkms @@ -0,0 +1,24 @@ +modname := bbswitch +DKMS := dkms +modver := $(shell awk -F'"' '/MODULE_VERSION/{print $$2}' < bbswitch.c) + +# directory in which generated files are stored +DKMS_DEST := /usr/src/$(modname)-$(modver) + +all: install + +src_install: + mkdir -p '$(DKMS_DEST)' + cp Makefile bbswitch.c '$(DKMS_DEST)' + sed 's/#MODULE_VERSION#/$(modver)/' dkms/dkms.conf > '$(DKMS_DEST)/dkms.conf' + +build: src_install + $(DKMS) build 'bbswitch/$(modver)' + +install: build + $(DKMS) install 'bbswitch/$(modver)' + +uninstall: + $(DKMS) remove bbswitch/$(modver) --all + +.PHONY: all src_install build install uninstall diff --git a/README.md b/README.md index 5376608..72e3d20 100644 --- a/README.md +++ b/README.md @@ -38,10 +38,16 @@ information. DKMS support ------------ -Change `#MODULE_VERSION#` to the current version of bbswitch. Copy the -Makefile, C source and dkms.conf file to `/usr/src/bbswitch-VERSION/` (replace -VERSION with the current version of bbswitch which has been inserted for -`#MODULE_VERSION#`. +If you have DKMS installed, you can install bbswitch in such a way that it +survives kernel upgrades. It is recommended to remove older versions of bbswitch +by running `dkms remove bbswitch/OLDVERSION --all` as root. To install the new +version, simply run: + + # make -f Makefile.dkms + +To uninstall it, run: + + # make -f Makefile.dkms uninstall Usage -----