modname := bbswitch DKMS := dkms modver := $(shell awk -F'"' '/define *BBSWITCH_VERSION/{print $$2}' < bbswitch.c) # directory in which generated files are stored DKMS_DEST := /usr/src/$(modname)-$(modver) all: install src_install: mkdir -p '$(DKMS_DEST)' cp Makefile bbswitch.c '$(DKMS_DEST)' sed 's/#MODULE_VERSION#/$(modver)/' dkms/dkms.conf > '$(DKMS_DEST)/dkms.conf' build: src_install $(DKMS) build -m bbswitch -v $(modver) install: build $(DKMS) install -m bbswitch -v $(modver) uninstall: $(DKMS) remove -m bbswitch -v $(modver) --all .PHONY: all src_install build install uninstall