Skip to content

Commit

Permalink
Changed the dkms installing behaviour.
Browse files Browse the repository at this point in the history
Now the copy operation to /usr/src of the needed files is performed by dkms.
This way, the module is recompiled by dkms immediately, and installed for
the running kernel. Since the modules does not need to be already compiled,
a make clean operation is performed before dkms-install/dkms-uninstall.
Since dkms will install the compiled modules in its dir tree, a make uninstall
operation is invoked too, so that only the modules compiled by dkms will remain
installed in the system. This happens on both dkms-install and dkms-uninstall.

The missing 'all' dependency was added to the install target.

The PWD variable was not appropriate, since was read by make from the shell
and never changed upon recursive make -C invocations. CURDIR variable is an
internal make variable, which is updated to reflect the real current working
directory.
  • Loading branch information
Shub77 committed Jun 23, 2020
1 parent edec9bd commit 106e370
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions module/Makefile
Expand Up @@ -22,7 +22,7 @@ ifeq ($(KSRC),)
endif

ifeq ($(KVER),)
KVER := $(shell uname -r)
KVER := $(shell uname -r)
endif

MKDIR := mkdir -pv
Expand All @@ -34,9 +34,9 @@ obj-m += rapiddisk.o
obj-m += rapiddisk-cache.o

all:
$(MAKE) -C$(KSRC) M=$(PWD)
$(MAKE) -C $(KSRC) M=$(CURDIR)

install:
install: all
$(MKDIR) $(DESTDIR)/lib/modules/$(KVER)/kernel/drivers/block/
install -o root -g root -m 0755 rapiddisk.ko $(DESTDIR)/lib/modules/$(KVER)/kernel/drivers/block/
install -o root -g root -m 0755 rapiddisk-cache.ko $(DESTDIR)/lib/modules/$(KVER)/kernel/drivers/block/
Expand All @@ -51,18 +51,17 @@ clean:
rm -rf *.o *.ko *.symvers *.mod.c .*.cmd Module.markers modules.order *.o.* built-in*
rm -rf .tmp_versions .rapiddisk.o.d *.unsigned *.sdtinfo.c .ctf/ .cache.mk *.mod

dkms-install:
dkms-install: clean uninstall
ifeq ($(shell which dkms >/dev/null 2>/dev/null; echo $$?),1)
$(error No 'dkms' command found)
else ifeq ($(shell dkms status rapiddisk/$(VERSION) -k $(KVER) | grep '$(KVER)' >/dev/null 2>/dev/null; echo $$?),0)
$(error rapiddisk version $(VERSION) is already installed for kernel $(KVER). Use 'make dkms-uninstall' first)
else
[ ! -d $(DKMSDEST) ] && $(MKDIR) $(DKMSDEST) || true
$(CP) $(DKMSFILES) $(DKMSDEST)
dkms install rapiddisk/$(VERSION) -k $(KVER) .
dkms add . || true
dkms install rapiddisk/$(VERSION) -k $(KVER)
endif

dkms-uninstall:
dkms-uninstall: clean uninstall
ifeq ($(shell which dkms >/dev/null 2>/dev/null; echo $$?),1)
$(error No 'dkms' command found)
else ifeq ($(shell dkms status rapiddisk/$(VERSION) -k $(KVER) | grep '$(KVER)' >/dev/null 2>/dev/null; echo $$?),0)
Expand Down

0 comments on commit 106e370

Please sign in to comment.