From e140a1cda38bf15f0c4e0bee7ce217970b0475d4 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Fri, 15 Sep 2017 08:15:05 -0700 Subject: [PATCH] Makefile: Add support for compressed modules Signed-off-by: Guenter Roeck --- Makefile | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index b975bc7..33f43df 100644 --- a/Makefile +++ b/Makefile @@ -14,12 +14,20 @@ DRIVER := it87 # Directory below /lib/modules/$(TARGET)/kernel into which to install # the module: MOD_SUBDIR = drivers/hwmon +MODDESTDIR=$(KERNEL_MODULES)/kernel/$(MOD_SUBDIR) obj-m := $(patsubst %,%.o,$(DRIVER)) obj-ko := $(patsubst %,%.ko,$(DRIVER)) MAKEFLAGS += --no-print-directory +ifneq ("","$(wildcard $(MODDESTDIR)/*.ko.gz)") +COMPRESS_GZIP := y +endif +ifneq ("","$(wildcard $(MODDESTDIR)/*.ko.xz)") +COMPRESS_XZ := y +endif + .PHONY: all install modules modules_install clean all: modules @@ -32,6 +40,12 @@ modules clean: install: modules_install modules_install: - mkdir -p $(KERNEL_MODULES)/kernel/$(MOD_SUBDIR) - cp $(DRIVER).ko $(KERNEL_MODULES)/kernel/$(MOD_SUBDIR)/ + mkdir -p $(MODDESTDIR) + cp $(DRIVER).ko $(MODDESTDIR)/ +ifeq ($(COMPRESS_GZIP), y) + @gzip -f $(MODDESTDIR)/$(DRIVER).ko +endif +ifeq ($(COMPRESS_XZ), y) + @xz -f $(MODDESTDIR)/$(DRIVER).ko +endif depmod -a -F $(SYSTEM_MAP) $(TARGET) -- 2.39.5