[PATCH v5 11/14] module: update timestamp of modules.order after modules are built

From: Thomas Weißschuh

Date: Tue May 05 2026 - 05:14:53 EST


Make sure that modules.order is always newer than the module .ko files.
Other rules can then use modules.order as a prerequisite and rerun if
any module is (re-)built.

Signed-off-by: Thomas Weißschuh <linux@xxxxxxxxxxxxxx>
---
scripts/Makefile.modfinal | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/scripts/Makefile.modfinal b/scripts/Makefile.modfinal
index b09040ccddd2..44a382689a5a 100644
--- a/scripts/Makefile.modfinal
+++ b/scripts/Makefile.modfinal
@@ -66,6 +66,13 @@ endif

targets += $(modules:%.o=%.ko) $(modules:%.o=%.mod.o) .module-common.o

+# Update modules.order when a module is (re-)built.
+# Allow using it as target dependency.
+targets += modules.order
+__modfinal: modules.order
+modules.order: $(modules:%.o=%.ko)
+ @touch $@
+
# Add FORCE to the prerequisites of a target to force it to be always rebuilt.
# ---------------------------------------------------------------------------


--
2.54.0