]> git.sur5r.net Git - groeck-it87/blob - Makefile
Revert "Add optional DKMS target to Makefile"
[groeck-it87] / Makefile
1 # For building for the current running version of Linux
2 TARGET          := $(shell uname -r)
3 # Or specific version
4 #TARGET         := 2.6.33.5
5 KERNEL_MODULES  := /lib/modules/$(TARGET)
6
7 ifneq ("","$(wildcard /usr/src/linux-headers-$(TARGET)/*)")
8 # Ubuntu
9 KERNEL_BUILD    := /usr/src/linux-headers-$(TARGET)
10 else
11 ifneq ("","$(wildcard /usr/src/kernels/$(TARGET)/*)")
12 # Fedora
13 KERNEL_BUILD    := /usr/src/kernels/$(TARGET)
14 else
15 KERNEL_BUILD    := $(KERNEL_MODULES)/build
16 endif
17 endif
18
19 #SYSTEM_MAP     := $(KERNEL_BUILD)/System.map
20 SYSTEM_MAP      := /boot/System.map-$(TARGET)
21
22 DRIVER := it87
23
24 # Directory below /lib/modules/$(TARGET)/kernel into which to install
25 # the module:
26 MOD_SUBDIR = drivers/hwmon
27 MODDESTDIR=$(KERNEL_MODULES)/kernel/$(MOD_SUBDIR)
28
29 obj-m   := $(patsubst %,%.o,$(DRIVER))
30 obj-ko  := $(patsubst %,%.ko,$(DRIVER))
31
32 MAKEFLAGS += --no-print-directory
33
34 ifneq ("","$(wildcard $(MODDESTDIR)/*.ko.gz)")
35 COMPRESS_GZIP := y
36 endif
37 ifneq ("","$(wildcard $(MODDESTDIR)/*.ko.xz)")
38 COMPRESS_XZ := y
39 endif
40
41 .PHONY: all install modules modules_install clean
42
43 all: modules
44
45 # Targets for running make directly in the external module directory:
46
47 ifneq ("","$(wildcard .git/*)")
48 IT87_CFLAGS=-DIT87_DRIVER_VERSION='\"$(shell git describe --long)\"'
49 else
50 IT87_CFLAGS=-DIT87_DRIVER_VERSION='\"<unknown>\"'
51 endif
52
53 modules:
54         @$(MAKE) EXTRA_CFLAGS="$(IT87_CFLAGS)" -C $(KERNEL_BUILD) M=$(CURDIR) $@
55
56 clean:
57         @$(MAKE) -C $(KERNEL_BUILD) M=$(CURDIR) $@
58
59 install: modules_install
60
61 modules_install:
62         mkdir -p $(MODDESTDIR)
63         cp $(DRIVER).ko $(MODDESTDIR)/
64 ifeq ($(COMPRESS_GZIP), y)
65         @gzip -f $(MODDESTDIR)/$(DRIVER).ko
66 endif
67 ifeq ($(COMPRESS_XZ), y)
68         @xz -f $(MODDESTDIR)/$(DRIVER).ko
69 endif
70         depmod -a -F $(SYSTEM_MAP) $(TARGET)