Add KMODDIR to install target
authorBrian Behlendorf <behlendorf1@llnl.gov>
Sun, 17 Feb 2013 19:05:11 +0000 (11:05 -0800)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 6 Mar 2013 23:46:40 +0000 (15:46 -0800)
Provide a mechanism to control the directory name the modules
are installed in.  The kernel privdes INSTALL_MOD_DIR for
this but it was hardcoded to be 'addon/zfs'.

Add a KMODDIR variable which can be passed to 'make install'
to override the default directory name.  While we're here
change the default from 'addon/zfs' to 'extra' which is the
kernel.org default.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
module/Makefile.in

index c69b8a3..4c6d381 100644 (file)
@@ -5,6 +5,8 @@ subdir-m += zcommon
 subdir-m += zfs
 subdir-m += zpios
 
+INSTALL_MOD_DIR ?= extra
+
 ZFS_MODULE_CFLAGS += -include @SPL_OBJ@/spl_config.h
 ZFS_MODULE_CFLAGS += -include @abs_top_builddir@/zfs_config.h
 ZFS_MODULE_CFLAGS += -I@abs_top_srcdir@/include -I@SPL@/include -I@SPL@
@@ -39,22 +41,25 @@ clean:
 
 modules_install:
        @# Install the kernel modules
-       $(MAKE) -C @LINUX_OBJ@ SUBDIRS=`pwd` \
-               INSTALL_MOD_PATH=$(DESTDIR) \
-               INSTALL_MOD_DIR=addon/zfs $@
+       $(MAKE) -C @LINUX_OBJ@ SUBDIRS=`pwd` $@ \
+               INSTALL_MOD_PATH=$(DESTDIR)$(INSTALL_MOD_PATH) \
+               INSTALL_MOD_DIR=$(INSTALL_MOD_DIR)
        @# Remove extraneous build products when packaging
-       if [ -n "$(DESTDIR)" ]; then \
-               find $(DESTDIR)/lib/modules/@LINUX_VERSION@ \
-                       -name 'modules.*' | xargs $(RM); \
+       kmoddir=$(DESTDIR)$(INSTALL_MOD_PATH)/lib/modules/@LINUX_VERSION@; \
+       if [ -n $$kmoddir ]; then \
+               find $$kmoddir -name 'modules.*' | xargs $(RM); \
        fi
-       sysmap=$(DESTDIR)/boot/System.map-@LINUX_VERSION@; \
+       sysmap=$(DESTDIR)$(INSTALL_MOD_PATH)/boot/System.map-@LINUX_VERSION@; \
        if [ -f $$sysmap ]; then \
                depmod -ae -F $$sysmap @LINUX_VERSION@; \
        fi
 
 modules_uninstall:
        @# Uninstall the kernel modules
-       $(RM) -R $(DESTDIR)/lib/modules/@LINUX_VERSION@/addon/zfs
+       kmoddir=$(DESTDIR)$(INSTALL_MOD_PATH)/lib/modules/@LINUX_VERSION@
+       list='$(subdir-m)'; for subdir in $$list; do \
+               $(RM) -R $$kmoddir/$(INSTALL_MOD_DIR)/$$subdir; \
+       done
 
 distdir: