]> git.sur5r.net Git - groeck-it87/blob - Makefile
Checkpatch cleanup: Use octal permissions for module parameters
[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 EXTRA_CFLAGS=-DIT87_DRIVER_VERSION='\"$(shell git describe --long)\"'
48
49 modules:
50         @$(MAKE) EXTRA_CFLAGS=$(EXTRA_CFLAGS) -C $(KERNEL_BUILD) M=$(CURDIR) $@
51
52 clean:
53         @$(MAKE) -C $(KERNEL_BUILD) M=$(CURDIR) $@
54
55 install: modules_install
56
57 modules_install:
58         mkdir -p $(MODDESTDIR)
59         cp $(DRIVER).ko $(MODDESTDIR)/
60 ifeq ($(COMPRESS_GZIP), y)
61         @gzip -f $(MODDESTDIR)/$(DRIVER).ko
62 endif
63 ifeq ($(COMPRESS_XZ), y)
64         @xz -f $(MODDESTDIR)/$(DRIVER).ko
65 endif
66         depmod -a -F $(SYSTEM_MAP) $(TARGET)