aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: 9b0ba3184b7417ac9fe85b9d6a2355d53045d7f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
TARGET	        := $(shell uname -r)
DKMS_ROOT_PATH  := /usr/src/zenpower-0.1.1

ifneq ("","$(wildcard /usr/src/linux-headers-$(TARGET)/*)")
# Ubuntu
KERNEL_BUILD	:= /usr/src/linux-headers-$(TARGET)
else
ifneq ("","$(wildcard /usr/src/kernels/$(TARGET)/*)")
# Fedora
KERNEL_BUILD	:= /usr/src/kernels/$(TARGET)
else
KERNEL_BUILD	:= $(KERNEL_MODULES)/build
endif
endif

obj-m	:= $(patsubst %,%.o,zenpower)
obj-ko	:= $(patsubst %,%.ko,zenpower)

.PHONY: all modules clean dkms-install dkms-uninstall

all: modules

modules:
	@$(MAKE) -C $(KERNEL_BUILD) M=$(CURDIR) modules

clean:
	@$(MAKE) -C $(KERNEL_BUILD) M=$(CURDIR) clean

dkms-install:
	mkdir $(DKMS_ROOT_PATH)
	cp $(CURDIR)/dkms.conf $(DKMS_ROOT_PATH)
	cp $(CURDIR)/Makefile $(DKMS_ROOT_PATH)
	cp $(CURDIR)/zenpower.c $(DKMS_ROOT_PATH)
	dkms add zenpower/0.1.1
	dkms build zenpower/0.1.1
	dkms install zenpower/0.1.1

dkms-uninstall:
	dkms remove zenpower/0.1.1 --all
	rm -rf $(DKMS_ROOT_PATH)