misc: add top level makefile
Add a top level makefile to make common tasks easier. Supported targets: make - build modules make install - install modules (honors DESTDIR) make clean - clean up make tarballs - create source tarballs from current HEAD Note: "make tarballs" uses "git archive" so that it only works in a local copy of the git repository, not in a directory created by unpacking a tarball. Add *.tar to .gitignore to hide tarballs created by "make tarballs".
This commit is contained in:
1 parent
6fd497d954
commit
1d91cc5b6a
2 files changed
+46
No files matched your search
@@ -3,6 +3,7 @@
|
|||||||
*.ko
|
*.ko
|
||||||
*.ko.cmd
|
*.ko.cmd
|
||||||
*.mod.c
|
*.mod.c
|
||||||
|
*.tar
|
||||||
.tmp_versions
|
.tmp_versions
|
||||||
.cache.mk
|
.cache.mk
|
||||||
Module.symvers
|
Module.symvers
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
MODULES = vmmon vmnet
|
||||||
|
SUBDIRS = $(MODULES:%=%-only)
|
||||||
|
TARBALLS = $(MODULES:%=%.tar)
|
||||||
|
MODFILES = $(foreach mod,$(MODULES),$(mod)-only/$(mod).ko)
|
||||||
|
VM_UNAME = $(shell uname -r)
|
||||||
|
MODDIR = /lib/modules/$(VM_UNAME)/misc
|
||||||
|
|
||||||
|
MODINFO = /sbin/modinfo
|
||||||
|
DEPMOD = /sbin/depmod
|
||||||
|
|
||||||
|
%.tar: FORCE gitcleancheck
|
||||||
|
git archive -o $@ --format=tar HEAD $(@:.tar=-only)
|
||||||
|
|
||||||
|
.PHONY: FORCE subdirs $(SUBDIRS) clean tarballs
|
||||||
|
|
||||||
|
subdirs: $(SUBDIRS)
|
||||||
|
|
||||||
|
FORCE:
|
||||||
|
|
||||||
|
$(SUBDIRS):
|
||||||
|
$(MAKE) -C $@ $(MAKECMDGOALS)
|
||||||
|
|
||||||
|
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)"
|
||||||
|
|
||||||
|
install: $(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)
|
||||||
|
|
||||||
|
tarballs: $(TARBALLS)
|
||||||
|
|
||||||
Reference in new issue
Block a user