================================
Signed-off-by: Steve Brokenshire <sbrokenshire@xestia.co.uk>
@@ -5,6 +5,7 @@
PHONY := __modinst
__modinst:
+include include/config/auto.conf
include scripts/Kbuild.include
#
@@ -16,8 +17,15 @@
__modinst: $(modules)
@:
-quiet_cmd_modules_install = INSTALL $@
- cmd_modules_install = mkdir -p $(2); cp $@ $(2) ; $(mod_strip_cmd) $(2)/$(notdir $@)
+quiet_cmd_modules_install = INSTALL $@
+ cmd_modules_install = mkdir -p $(2); \
+ cp $@ $(2) ; \
+ $(mod_strip_cmd) $(2)/$(notdir $@)
+
+quiet_cmd_modules_compress_gzip = COMPRESS $@
+ cmd_modules_compress_gzip = gzip --best -c $(2)/`basename $@` \
+ > $(2)/`basename $@`.gz; \
+ rm $(2)/`basename $@`
# Modules built outside the kernel source tree go into extra by default
INSTALL_MOD_DIR ?= extra
@@ -26,8 +34,11 @@
modinst_dir = $(if $(KBUILD_EXTMOD),$(ext-mod-dir),kernel/$(@D))
$(modules):
+
$(call cmd,modules_install,$(MODLIB)/$(modinst_dir))
+ $(if $(CONFIG_MODULE_COMPRESS_GZIP), \
+ $(call cmd,modules_compress_gzip,$(MODLIB)/$(modinst_dir)))
# Declare the contents of the .PHONY variable as phony. We keep that
# information in a variable se we can use it in if_changed and friends.
@@ -716,6 +716,45 @@
rmmod). This is mainly for kernel developers and desperate users.
If unsure, say N.
+config MODULE_COMPRESS
+ bool "Compress kernel modules on installation"
+ depends on MODULES
+ help
+ This option compresses the kernel modules when 'make
+ modules_install' is run.
+
+ The modules will be compressed into the selected compression
+ format with Gzip being the default compression format.
+
+ When a kernel module is installed from outside of the main kernel
+ source and uses the Kbuild system for installing modules then that
+ kernel module will also be compressed when it is installed.
+
+ When running mkinitrd you will find that an error message
+ appears saying that it cannot find a certain kernel module.
+ As a workaround, unset CONFIG_MODULE_COMPRESS, build the modules
+ and install them, run mkinitrd and create the initrd image, place
+ the initrd image in the correct place for booting, set
+ CONFIG_MODULE_COMPRESS and then install the modules again.
+
+ This options requires the module-init-tools package to be
+ configured with --enable-zlib (if using gzip which is the
+ default compression method).
+
+choice
+ depends on MODULE_COMPRESS
+ prompt "Kernel module compression method"
+ default MODULE_COMPRESS_GZIP
+
+config MODULE_COMPRESS_GZIP
+ bool "Gzip compression"
+ help
+ Compresses the kernel modules using the Gzip (GNU zip)
+ compression format.
+
+ This option requires gzip to be installed.
+
+endchoice
config MODVERSIONS
bool "Module versioning support"
depends on MODULES
@@ -96,6 +96,11 @@
Installation default is in /lib/modules/<kernel-version>/extra,
but may be prefixed with INSTALL_MOD_PATH - see separate
chapter.
+ If MODULES_COMPRESS is set when the modules_install target is
+ run then the module is compressed after it has been
+ copied to /lib/modules/<kernel-version>. Compressed modules
+ using the default Gzip compression format will require
+ module-init-tools installed with --zlib-enabled.
make -C $KDIR M=`pwd` clean
Remove all generated files for the module - the kernel