-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdkms_Makefile
93 lines (75 loc) · 2.82 KB
/
dkms_Makefile
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
MODULES = vmmon vmnet
SUBDIRS = $(MODULES:%=%-only)
TARBALLS = $(MODULES:%=%.tar)
MODFILES = $(foreach mod,$(MODULES),$(mod)-only/$(mod).ko)
VM_UNAME = $(shell uname -r)
ALL_UNAME = $(shell ls /boot/config-*|sed 's/\/boot\/config\-//g')
DKMS_STA = $(shell dkms status|grep vmware\-host\-modules)
MODDIR = /lib/modules/$(VM_UNAME)/misc
MOD_SUBDIR = extra/drivers/net
MODINFO = /sbin/modinfo
DEPMOD = /sbin/depmod
DEST_MODULE_LOCATION = "/extra/driver/net/"
ifneq (,$(wildcard .git/*))
PACKAGE_VERSION := $(shell git describe --long --always)
else
ifneq ("", "$(wildcard VERSION)")
PACKAGE_VERSION := $(shell cat VERSION)
else
PACKAGE_VERSION := unknown
endif
endif
%.tar: FORCE gitcleancheck
git archive -o $@ --format=tar HEAD $(@:.tar=-only)
.PHONY: FORCE subdirs $(SUBDIRS) clean tarballs dkms dkms_clean dkms_configure
subdirs: retiredcheck $(SUBDIRS)
FORCE:
$(SUBDIRS):
$(MAKE) -C $@ $(MAKECMDGOALS) KVER=${kernelver} --file=dkms_Makefile
gitcheck:
@git status >/dev/null 2>&1 \
|| ( echo "This only works in a git repository."; exit 1 )
gitcleancheck: gitcheck
@git diff --exit-code HEAD >/dev/null 2>&1 \
|| echo "Warning: tarballs will reflect current HEAD (no uncommited changes)"
retiredcheck:
@test -f RETIRED && cat RETIRED || true
install: retiredcheck $(MODFILES)
@for f in $(MODFILES); do \
mver=$$($(MODINFO) -F vermagic $$f);\
mver=$${mver%% *};\
test "$${mver}" = "$(VM_UNAME)" \
|| ( echo "Version mismatch: module $$f $${mver}, kernel $(VM_UNAME)" ; exit 1 );\
done
install -D -t $(DESTDIR)$(MODDIR) $(MODFILES)
#strip --strip-debug $(MODULES:%=$(DESTDIR)$(MODDIR)/%.ko)
if test -z "$(DESTDIR)"; then $(DEPMOD) -a $(VM_UNAME); fi
clean: $(SUBDIRS)
rm -f *.ko *.o
tarballs: $(TARBALLS)
# DKMS
DRIVER_NAME = vmware-host-modules
PACKAGE_NAME = $(DRIVER_NAME)
dkms_configure:
@echo "PACKAGE_NAME="$(PACKAGE_NAME) > dkms.conf
@echo "PACKAGE_VERSION="$(PACKAGE_VERSION) >> dkms.conf
@echo 'MAKE="make --file=dkms_Makefile KVER=$${kernelver} DKMS_BUILD=1"' >> dkms.conf
@echo "BUILT_MODULE_NAME[0]=vmmon" >> dkms.conf
@echo "BUILT_MODULE_NAME[1]=vmnet" >> dkms.conf
@echo "DEST_MODULE_LOCATION[0]=/updates" >> dkms.conf
@echo "DEST_MODULE_LOCATION[1]=/updates" >> dkms.conf
@echo "AUTOINSTALL=\"yes\"" >> dkms.conf
@echo "$(PACKAGE_VERSION)" >VERSION
dkms: dkms_configure
if [ x$(DKMS_STA) = 'x' ]; then dkms add $(CURDIR); fi
## @dkms build -m $(DRIVER_NAME) -v $(PACKAGE_VERSION)
for kr in $(ALL_UNAME); do \
dkms build -m $(DRIVER_NAME) -v $(PACKAGE_VERSION) -k $$kr; \
dkms install --force -m $(DRIVER_NAME) -v $(PACKAGE_VERSION) -k $$kr; \
done
@modprobe $(MODULES)
dkms_clean:
-@rmmod $(MODULES);
##-@dkms remove -m $(PACKAGE_NAME) -v $(PACKAGE_VERSION)
for kr in $(ALL_UNAME); do dkms remove -m $(PACKAGE_NAME) -v $(PACKAGE_VERSION) -k $$kr; done
-@rm dkms.conf VERSION