X-Git-Url: https://git.sur5r.net/?p=groeck-it87;a=blobdiff_plain;f=Makefile;h=bb631830f420dd9c21906b3aae023fb26dff553d;hp=1b88e2a01ce096f7a5e697b9cc51f297ac5c0150;hb=HEAD;hpb=8293dc9f82fc461953e5bc8d9cb5f528aeb16058 diff --git a/Makefile b/Makefile index 1b88e2a..bb63183 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,10 @@ # For building for the current running version of Linux +ifndef TARGET TARGET := $(shell uname -r) +endif # Or specific version #TARGET := 2.6.33.5 + KERNEL_MODULES := /lib/modules/$(TARGET) ifneq ("","$(wildcard /usr/src/linux-headers-$(TARGET)/*)") @@ -17,9 +20,27 @@ endif endif #SYSTEM_MAP := $(KERNEL_BUILD)/System.map +ifneq ("","$(wildcard /boot/System.map-$(TARGET))") SYSTEM_MAP := /boot/System.map-$(TARGET) +else +# Arch +SYSTEM_MAP := /proc/kallsyms +endif 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 # the module: @@ -38,17 +59,13 @@ ifneq ("","$(wildcard $(MODDESTDIR)/*.ko.xz)") COMPRESS_XZ := y endif -.PHONY: all install modules modules_install clean +.PHONY: all install modules modules_install clean dkms dkms_clean all: modules # Targets for running make directly in the external module directory: -ifneq ("","$(wildcard .git/*)") -IT87_CFLAGS=-DIT87_DRIVER_VERSION='\"$(shell git describe --long)\"' -else -IT87_CFLAGS=-DIT87_DRIVER_VERSION='\"\"' -endif +IT87_CFLAGS=-DIT87_DRIVER_VERSION='\"$(DRIVER_VERSION)\"' modules: @$(MAKE) EXTRA_CFLAGS="$(IT87_CFLAGS)" -C $(KERNEL_BUILD) M=$(CURDIR) $@ @@ -68,3 +85,24 @@ ifeq ($(COMPRESS_XZ), y) @xz -f $(MODDESTDIR)/$(DRIVER).ko endif 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)