]> git.sur5r.net Git - groeck-k10temp/blob - Makefile
Makefile: Add support for arch distribution
[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 ifneq ("","$(wildcard /boot/System.map-$(TARGET))")
18 SYSTEM_MAP      := /boot/System.map-$(TARGET)
19 else
20 # Arch
21 SYSTEM_MAP      := /proc/kallsyms
22 endif
23
24 DRIVER := k10temp
25
26 # Directory below /lib/modules/$(TARGET)/kernel into which to install
27 # the module:
28 MOD_SUBDIR = drivers/hwmon
29 MODDESTDIR=$(KERNEL_MODULES)/kernel/$(MOD_SUBDIR)
30
31 obj-m   := $(patsubst %,%.o,$(DRIVER))
32 obj-ko  := $(patsubst %,%.ko,$(DRIVER))
33
34 MAKEFLAGS += --no-print-directory
35
36 ifneq ("","$(wildcard $(MODDESTDIR)/*.ko.gz)")
37 COMPRESS_GZIP := y
38 endif
39 ifneq ("","$(wildcard $(MODDESTDIR)/*.ko.xz)")
40 COMPRESS_XZ := y
41 endif
42
43 .PHONY: all install modules modules_install clean
44
45 all: modules
46
47 # Targets for running make directly in the external module directory:
48
49 modules clean:
50         @$(MAKE) -C $(KERNEL_BUILD) M=$(CURDIR) $@
51
52 install: modules_install
53
54 modules_install:
55         mkdir -p $(MODDESTDIR)
56         cp $(DRIVER).ko $(MODDESTDIR)/
57 ifeq ($(COMPRESS_GZIP), y)
58         @gzip -f $(MODDESTDIR)/$(DRIVER).ko
59 endif
60 ifeq ($(COMPRESS_XZ), y)
61         @xz -f $(MODDESTDIR)/$(DRIVER).ko
62 endif
63         depmod -a -F $(SYSTEM_MAP) $(TARGET)