Fix 1600X model, and don't report negative temperatures
[groeck-k10temp] / Makefile
1 # For building for the current running version of Linux
2 TARGET          := $(shell uname -r)
3 KERNEL_MODULES  := /lib/modules/$(TARGET)
4
5 ifneq ("","$(wildcard /usr/src/linux-headers-$(TARGET)/*)")
6 # Ubuntu
7 KERNEL_BUILD    := /usr/src/linux-headers-$(TARGET)
8 else
9 ifneq ("","$(wildcard /usr/src/kernels/$(TARGET)/*)")
10 # Fedora
11 KERNEL_BUILD    := /usr/src/kernels/$(TARGET)
12 else
13 KERNEL_BUILD    := $(KERNEL_MODULES)/build
14 endif
15 endif
16
17 SYSTEM_MAP      := /boot/System.map-$(TARGET)
18
19 DRIVER := k10temp
20
21 # Directory below /lib/modules/$(TARGET)/kernel into which to install
22 # the module:
23 MOD_SUBDIR = drivers/hwmon
24 MODDESTDIR=$(KERNEL_MODULES)/kernel/$(MOD_SUBDIR)
25
26 obj-m   := $(patsubst %,%.o,$(DRIVER))
27 obj-ko  := $(patsubst %,%.ko,$(DRIVER))
28
29 MAKEFLAGS += --no-print-directory
30
31 ifneq ("","$(wildcard $(MODDESTDIR)/*.ko.gz)")
32 COMPRESS_GZIP := y
33 endif
34 ifneq ("","$(wildcard $(MODDESTDIR)/*.ko.xz)")
35 COMPRESS_XZ := y
36 endif
37
38 .PHONY: all install modules modules_install clean
39
40 all: modules
41
42 # Targets for running make directly in the external module directory:
43
44 modules clean:
45         @$(MAKE) -C $(KERNEL_BUILD) M=$(CURDIR) $@
46
47 install: modules_install
48
49 modules_install:
50         mkdir -p $(MODDESTDIR)
51         cp $(DRIVER).ko $(MODDESTDIR)/
52 ifeq ($(COMPRESS_GZIP), y)
53         @gzip -f $(MODDESTDIR)/$(DRIVER).ko
54 endif
55 ifeq ($(COMPRESS_XZ), y)
56         @xz -f $(MODDESTDIR)/$(DRIVER).ko
57 endif
58         depmod -a -F $(SYSTEM_MAP) $(TARGET)