From ed3a3bdb0d59772ae4b8719cb6ffa690627bf112 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Luis=20Salvador=20Rufo?= Date: Fri, 1 Oct 2021 19:44:34 +0200 Subject: [PATCH] Proper support for DESTDIR and INSTALL_MOD_PATH MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The environment variables DESTDIR and INSTALL_MOD_PATH must be mutually exclusive. https://www.gnu.org/prep/standards/html_node/DESTDIR.html https://www.kernel.org/doc/Documentation/kbuild/modules.txt This issue was discussed in this Buildroot thread: https://lists.buildroot.org/pipermail/buildroot/2021-August/621350.html I saw this behavior in other different projects, as: - Yocto Project: https://www.yoctoproject.org/pipermail/meta-freescale/2013-August/004307.html - Google IA Coral: https://coral.googlesource.com/linux-imx-debian/+/refs/heads/master/debian/rules For the above reasons, INSTALL_MOD_PATH will be set as DESTDIR by default. Reviewed-by: Tony Hutter Reviewed-by: Brian Behlendorf Signed-off-by: José Luis Salvador Rufo Signed-off-by: Romain Naour Closes #12577 --- module/Makefile.in | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/module/Makefile.in b/module/Makefile.in index 089b3ff88..8538dd9d6 100644 --- a/module/Makefile.in +++ b/module/Makefile.in @@ -1,6 +1,7 @@ include Kbuild INSTALL_MOD_DIR ?= extra +INSTALL_MOD_PATH ?= $(DESTDIR) SUBDIR_TARGETS = icp lua zstd @@ -81,15 +82,15 @@ clean: clean-@ac_system@ modules_install-Linux: @# Install the kernel modules $(MAKE) -C @LINUX_OBJ@ M=`pwd` modules_install \ - INSTALL_MOD_PATH=$(DESTDIR)$(INSTALL_MOD_PATH) \ + INSTALL_MOD_PATH=$(INSTALL_MOD_PATH) \ INSTALL_MOD_DIR=$(INSTALL_MOD_DIR) \ KERNELRELEASE=@LINUX_VERSION@ @# Remove extraneous build products when packaging - kmoddir=$(DESTDIR)$(INSTALL_MOD_PATH)/lib/modules/@LINUX_VERSION@; \ + kmoddir=$(INSTALL_MOD_PATH)/lib/modules/@LINUX_VERSION@; \ if [ -n "$(DESTDIR)" ]; then \ find $$kmoddir -name 'modules.*' | xargs $(RM); \ fi - sysmap=$(DESTDIR)$(INSTALL_MOD_PATH)/boot/System.map-@LINUX_VERSION@; \ + sysmap=$(INSTALL_MOD_PATH)/boot/System.map-@LINUX_VERSION@; \ if [ -f $$sysmap ]; then \ depmod -ae -F $$sysmap @LINUX_VERSION@; \ fi @@ -102,7 +103,7 @@ modules_install: modules_install-@ac_system@ modules_uninstall-Linux: @# Uninstall the kernel modules - kmoddir=$(DESTDIR)$(INSTALL_MOD_PATH)/lib/modules/@LINUX_VERSION@; \ + kmoddir=$(INSTALL_MOD_PATH)/lib/modules/@LINUX_VERSION@; \ for objdir in $(ZFS_MODULES); do \ $(RM) -R $$kmoddir/$(INSTALL_MOD_DIR)/$$objdir; \ done