[PATCH 1/2] kbuild: add target to install gzipped modules

From: Lucas De Marchi
Date: Thu Dec 29 2011 - 10:49:00 EST


Add target in Makefile to compress the module after it's installed.
Module-init-tools and libkmod can handle gzipped modules.

This is not much useful for distributions because the package will gzip
the modules and call depmod in a install rule. However for those
compiling the kernel on their own and debugging module loading, it's
useful so depmod doesn't have to be called twice and we don't have to
manually compress the modules.

Signed-off-by: Lucas De Marchi <lucas.demarchi@xxxxxxxxxxxxxx>
---
Makefile | 10 ++++++++--
scripts/Makefile.modinst | 8 ++++++++
2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index ea51081..baddcfe 100644
--- a/Makefile
+++ b/Makefile
@@ -1104,8 +1104,9 @@ PHONY += modules_prepare
modules_prepare: prepare scripts

# Target to install modules
-PHONY += modules_install
-modules_install: _modinst_ _modinst_post
+PHONY += modules_install modules_install_gz
+modules_install: _modinst_bare _modinst_post
+modules_install_gz: _modinst_gz _modinst_post

PHONY += _modinst_
_modinst_:
@@ -1119,8 +1120,13 @@ _modinst_:
fi
@cp -f $(objtree)/modules.order $(MODLIB)/
@cp -f $(objtree)/modules.builtin $(MODLIB)/
+
+_modinst_bare: _modinst_
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst

+_modinst_gz: _modinst_
+ $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst compression=gz
+
# This depmod is only for convenience to give the initial
# boot a modules.dep even before / is mounted read-write. However the
# boot script depmod is the master version.
diff --git a/scripts/Makefile.modinst b/scripts/Makefile.modinst
index efa5d94..442f953 100644
--- a/scripts/Makefile.modinst
+++ b/scripts/Makefile.modinst
@@ -12,6 +12,8 @@ include scripts/Kbuild.include
__modules := $(sort $(shell grep -h '\.ko' /dev/null $(wildcard $(MODVERDIR)/*.mod)))
modules := $(patsubst %.o,%.ko,$(wildcard $(__modules:.ko=.o)))

+compression ?= none
+
PHONY += $(modules)
__modinst: $(modules)
@:
@@ -19,6 +21,9 @@ __modinst: $(modules)
quiet_cmd_modules_install = INSTALL $@
cmd_modules_install = mkdir -p $(2); cp $@ $(2) ; $(mod_strip_cmd) $(2)/$(notdir $@)

+quiet_cmd_modules_compress_gz = GZ $@.gz
+ cmd_modules_compress_gz = gzip $(2)/$(notdir $@)
+
# Modules built outside the kernel source tree go into extra by default
INSTALL_MOD_DIR ?= extra
ext-mod-dir = $(INSTALL_MOD_DIR)$(subst $(patsubst %/,%,$(KBUILD_EXTMOD)),,$(@D))
@@ -27,6 +32,9 @@ modinst_dir = $(if $(KBUILD_EXTMOD),$(ext-mod-dir),kernel/$(@D))

$(modules):
$(call cmd,modules_install,$(MODLIB)/$(modinst_dir))
+ifeq ($(compression),gz)
+ $(call cmd,modules_compress_gz,$(MODLIB)/$(modinst_dir))
+endif


# Declare the contents of the .PHONY variable as phony. We keep that
--
1.7.8.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/