[PATCH V1 3/3] kbuild: remove stale modules from install area

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



During install_modules, remove modules from the install/kernel area that are
not present in modules.order.  This can occur after changing config options.
Also remove any unrecognized files.

Signed-off-by: Steve Sistare <steven.sistare@xxxxxxxxxx>
---
 Makefile | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 8f58e27..7d64cab 100644
--- a/Makefile
+++ b/Makefile
@@ -1297,11 +1297,26 @@ _modinst_:
 	@cp -f $(objtree)/modules.builtin $(MODLIB)/
 	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst
 
+# Remove any files in the install area which are not listed in modules.order.
+# This can occur after changing config options.
+
+PHONY += _modinst_remove
+_modinst_remove: _modinst_
+	@declare -A mods; \
+	while read buf ; do \
+		mods[$$buf]=1; \
+	done < $(objtree)/modules.order; \
+	cd $(MODLIB); \
+	find kernel -not -type d | \
+	while read x ; do \
+		[[ -z "$${mods[$$x]}" ]] && rm $$x; \
+	done || true
+
 # 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.
 PHONY += _modinst_post
-_modinst_post: _modinst_
+_modinst_post: _modinst_remove
 	$(call cmd,depmod)
 
 ifeq ($(CONFIG_MODULE_SIG), y)
-- 
1.8.3.1




[Index of Archives]     [Linux&nblp;USB Development]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite Secrets]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux