linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Masahiro Yamada <masahiroy@kernel.org>
To: linux-kbuild@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org,
	Masahiro Yamada <masahiroy@kernel.org>
Subject: [PATCH v2 2/8] kbuild: rename modules.order in sub-directories to .modules.order
Date: Tue,  6 Sep 2022 15:13:07 +0900	[thread overview]
Message-ID: <20220906061313.1445810-3-masahiroy@kernel.org> (raw)
In-Reply-To: <20220906061313.1445810-1-masahiroy@kernel.org>

The next commit will move core-y from the top Makefile to ./Kbuild to
use obj-y to list sub-directories.

With that, both ./Makefile and ./Kbuild would create modules.order in
the top directory.

To avoid the conflict, rename the per-directory modules.order to
.modules.order.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

(no changes since v1)

 Makefile               | 27 +++++++++++++--------------
 scripts/Makefile.build | 18 +++++++++---------
 scripts/Makefile.lib   |  8 ++++----
 3 files changed, 26 insertions(+), 27 deletions(-)

diff --git a/Makefile b/Makefile
index 373cd2f0f49e..552ade93ca1d 100644
--- a/Makefile
+++ b/Makefile
@@ -1116,8 +1116,6 @@ vmlinux-alldirs	:= $(sort $(vmlinux-dirs) Documentation . \
 build-dirs	:= $(vmlinux-dirs)
 clean-dirs	:= $(vmlinux-alldirs)
 
-subdir-modorder := $(addsuffix /modules.order, $(build-dirs))
-
 # Externally visible symbols (used by link-vmlinux.sh)
 KBUILD_VMLINUX_OBJS := $(head-y) $(patsubst %/,%/built-in.a, $(core-y))
 KBUILD_VMLINUX_OBJS += $(addsuffix built-in.a, $(filter %/, $(libs-y)))
@@ -1172,7 +1170,7 @@ targets := vmlinux
 
 # The actual objects are generated when descending,
 # make sure no implicit rule kicks in
-$(sort $(vmlinux-deps) $(subdir-modorder)): descend ;
+$(sort $(vmlinux-deps)): descend ;
 
 filechk_kernel.release = \
 	echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))"
@@ -1444,13 +1442,6 @@ endif
 
 modules: $(if $(KBUILD_BUILTIN),vmlinux) modules_prepare
 
-cmd_modules_order = cat $(real-prereqs) > $@
-
-modules.order: $(subdir-modorder) FORCE
-	$(call if_changed,modules_order)
-
-targets += modules.order
-
 # Target to prepare building external modules
 modules_prepare: prepare
 	$(Q)$(MAKE) $(build)=scripts scripts/module.lds
@@ -1722,8 +1713,6 @@ KBUILD_BUILTIN :=
 KBUILD_MODULES := 1
 
 build-dirs := $(KBUILD_EXTMOD)
-$(MODORDER): descend
-	@:
 
 compile_commands.json: $(extmod_prefix)compile_commands.json
 PHONY += compile_commands.json
@@ -1755,12 +1744,22 @@ help:
 endif # KBUILD_EXTMOD
 
 # ---------------------------------------------------------------------------
-# Modules
+# Modules (common for in-tree modules and external modules)
 
 PHONY += modules modules_install modules_prepare
 
 ifdef CONFIG_MODULES
 
+subdir-modorder := $(addsuffix /.modules.order, $(build-dirs))
+
+$(sort $(subdir-modorder)): %/.modules.order: % ;
+
+cmd_modules_order = cat $(real-prereqs) > $@
+
+targets += $(MODORDER)
+$(MODORDER): $(subdir-modorder) FORCE
+	$(call if_changed,modules_order)
+
 modules: modules_check
 	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
 
@@ -1859,7 +1858,7 @@ clean: $(clean-dirs)
 		-o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
 		-o -name '*.lex.c' -o -name '*.tab.[ch]' \
 		-o -name '*.asn1.[ch]' \
-		-o -name '*.symtypes' -o -name 'modules.order' \
+		-o -name '*.symtypes' -o -name '*modules.order' \
 		-o -name '.tmp_*' \
 		-o -name '*.c.[012]*.*' \
 		-o -name '*.ll' \
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 91d2e5461a3e..da3dc4f5456e 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -73,7 +73,7 @@ endif
 
 # subdir-builtin and subdir-modorder may contain duplications. Use $(sort ...)
 subdir-builtin := $(sort $(filter %/built-in.a, $(real-obj-y)))
-subdir-modorder := $(sort $(filter %/modules.order, $(obj-m)))
+subdir-modorder := $(sort $(filter %/.modules.order, $(obj-m)))
 
 targets-for-builtin := $(extra-y)
 
@@ -89,7 +89,7 @@ targets-for-modules := $(foreach x, o mod $(if $(CONFIG_TRIM_UNUSED_KSYMS), usym
 				$(patsubst %.o, %.$x, $(filter %.o, $(obj-m))))
 
 ifdef need-modorder
-targets-for-modules += $(obj)/modules.order
+targets-for-modules += $(obj)/.modules.order
 endif
 
 targets += $(targets-for-builtin) $(targets-for-modules)
@@ -348,7 +348,7 @@ $(obj)/%.asn1.c $(obj)/%.asn1.h: $(src)/%.asn1 $(objtree)/scripts/asn1_compiler
 
 # To build objects in subdirs, we need to descend into the directories
 $(subdir-builtin): $(obj)/%/built-in.a: $(obj)/% ;
-$(subdir-modorder): $(obj)/%/modules.order: $(obj)/% ;
+$(subdir-modorder): $(obj)/%/.modules.order: $(obj)/% ;
 
 #
 # Rule to compile a set of .o files into one .a file (without symbol table)
@@ -365,18 +365,18 @@ $(obj)/built-in.a: $(real-obj-y) FORCE
 	$(call if_changed,ar_builtin)
 
 #
-# Rule to create modules.order file
+# Rule to create .modules.order file
 #
-# Create commands to either record .ko file or cat modules.order from
+# Create commands to either record .ko file or cat .modules.order from
 # a subdirectory
 # Add $(obj-m) as the prerequisite to avoid updating the timestamp of
-# modules.order unless contained modules are updated.
+# .modules.order unless contained modules are updated.
 
 cmd_modules_order = { $(foreach m, $(real-prereqs), \
-	$(if $(filter %/modules.order, $m), cat $m, echo $(patsubst %.o,%.ko,$m));) :; } \
+	$(if $(filter %/.modules.order, $m), cat $m, echo $(patsubst %.o,%.ko,$m));) :; } \
 	> $@
 
-$(obj)/modules.order: $(obj-m) FORCE
+$(obj)/.modules.order: $(obj-m) FORCE
 	$(call if_changed,modules_order)
 
 #
@@ -439,7 +439,7 @@ PHONY += $(subdir-ym)
 $(subdir-ym):
 	$(Q)$(MAKE) $(build)=$@ \
 	need-builtin=$(if $(filter $@/built-in.a, $(subdir-builtin)),1) \
-	need-modorder=$(if $(filter $@/modules.order, $(subdir-modorder)),1) \
+	need-modorder=$(if $(filter $@/.modules.order, $(subdir-modorder)),1) \
 	$(filter $@/%, $(single-subdir-goals))
 
 # Add FORCE to the prequisites of a target to force it to be always rebuilt.
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 3fb6a99e78c4..b594705d571a 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -26,14 +26,14 @@ subdir-ym := $(sort $(subdir-y) $(subdir-m) \
 
 # Handle objects in subdirs:
 # - If we encounter foo/ in $(obj-y), replace it by foo/built-in.a and
-#   foo/modules.order
-# - If we encounter foo/ in $(obj-m), replace it by foo/modules.order
+#   foo/.modules.order
+# - If we encounter foo/ in $(obj-m), replace it by foo/.modules.order
 #
-# Generate modules.order to determine modorder. Unfortunately, we don't have
+# Generate .modules.order to determine modorder. Unfortunately, we don't have
 # information about ordering between -y and -m subdirs. Just put -y's first.
 
 ifdef need-modorder
-obj-m := $(patsubst %/,%/modules.order, $(filter %/, $(obj-y)) $(obj-m))
+obj-m := $(patsubst %/,%/.modules.order, $(filter %/, $(obj-y)) $(obj-m))
 else
 obj-m := $(filter-out %/, $(obj-m))
 endif
-- 
2.34.1


  parent reply	other threads:[~2022-09-06  6:14 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-06  6:13 [PATCH v2 0/8] kbuild: various cleanups Masahiro Yamada
2022-09-06  6:13 ` [PATCH v2 1/8] kbuild: fix and refactor single target build Masahiro Yamada
2022-09-06  6:13 ` Masahiro Yamada [this message]
2022-09-06  6:13 ` [PATCH v2 3/8] kbuild: move core-y and drivers-y to ./Kbuild Masahiro Yamada
2022-09-21  4:39   ` Guenter Roeck
     [not found]     ` <CGME20220922121655eucas1p11822db5dbd1455bcbdba901f543b8e6b@eucas1p1.samsung.com>
2022-09-22 12:16       ` Marek Szyprowski
     [not found]         ` <CGME20220923113907eucas1p2b33fa5cf73646401089f96a69cf9b745@eucas1p2.samsung.com>
2022-09-23 11:39           ` Marek Szyprowski
2022-09-23 11:41             ` Masahiro Yamada
2022-09-23 12:09             ` Masahiro Yamada
2022-09-06  6:13 ` [PATCH v2 4/8] kbuild: move .vmlinux.objs rule to Makefile.modpost Masahiro Yamada
2022-09-06  6:13 ` [PATCH v2 5/8] kbuild: move vmlinux.o rule to the top Makefile Masahiro Yamada
2022-09-06  6:13 ` [PATCH v2 6/8] kbuild: unify two modpost invocations Masahiro Yamada
2022-09-06  6:13 ` [PATCH v2 7/8] kbuild: use obj-y instead extra-y for objects placed at the head Masahiro Yamada
2022-09-08  7:15   ` Masahiro Yamada
2022-09-19  8:10   ` Geert Uytterhoeven
2022-09-19 12:17     ` Masahiro Yamada
2022-09-19 12:28       ` Geert Uytterhoeven
2022-09-19 22:50   ` Guenter Roeck
2022-09-20  6:56     ` Geert Uytterhoeven
2022-09-20 13:33       ` Guenter Roeck
2022-09-06  6:13 ` [PATCH v2 8/8] kbuild: remove head-y syntax Masahiro Yamada
2022-09-06  7:59   ` Arnd Bergmann
2022-09-06  8:16     ` Ard Biesheuvel
2022-09-06  9:08     ` Masahiro Yamada
2022-09-07 20:15 ` [PATCH v2 0/8] kbuild: various cleanups Nicolas Schier
2022-09-07 20:18   ` Nicolas Schier
2022-09-08  2:00     ` Masahiro Yamada
2022-09-24 18:05 ` Masahiro Yamada

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220906061313.1445810-3-masahiroy@kernel.org \
    --to=masahiroy@kernel.org \
    --cc=linux-arch@vger.kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).