Commit 454753d9 authored by Masahiro Yamada's avatar Masahiro Yamada

kbuild: make modules.order rule consistent with built-in.a

built-in.a contains the built-in object paths from the current and sub
directories.

module.order collects the module paths from the current and sub
directories.

Make their build rules look more symmetrical.
Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
parent aaa385ba
...@@ -69,8 +69,9 @@ endif ...@@ -69,8 +69,9 @@ endif
# =========================================================================== # ===========================================================================
# subdir-builtin may contain duplications. Use $(sort ...) # subdir-builtin and subdir-modorder may contain duplications. Use $(sort ...)
subdir-builtin := $(sort $(filter %/built-in.a, $(real-obj-y))) subdir-builtin := $(sort $(filter %/built-in.a, $(real-obj-y)))
subdir-modorder := $(sort $(filter %/modules.order, $(modorder)))
ifneq ($(strip $(lib-y) $(lib-m) $(lib-)),) ifneq ($(strip $(lib-y) $(lib-m) $(lib-)),)
lib-target := $(obj)/lib.a lib-target := $(obj)/lib.a
...@@ -383,6 +384,7 @@ $(obj)/%.asn1.c $(obj)/%.asn1.h: $(src)/%.asn1 $(objtree)/scripts/asn1_compiler ...@@ -383,6 +384,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 # To build objects in subdirs, we need to descend into the directories
$(subdir-builtin): $(obj)/%/built-in.a: $(obj)/% ; $(subdir-builtin): $(obj)/%/built-in.a: $(obj)/% ;
$(subdir-modorder): $(obj)/%/modules.order: $(obj)/% ;
# #
# Rule to compile a set of .o files into one .a file (without symbol table) # Rule to compile a set of .o files into one .a file (without symbol table)
...@@ -401,9 +403,9 @@ targets += $(builtin-target) ...@@ -401,9 +403,9 @@ targets += $(builtin-target)
# #
# 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 # a subdirectory
$(modorder-target): $(subdir-ym) FORCE $(obj)/modules.order: $(subdir-modorder) FORCE
$(Q){ $(foreach m, $(modorder), \ $(Q){ $(foreach m, $(modorder), \
$(if $(filter %/modules.order, $m), cat $m, echo $m);) :; } \ $(if $(filter $^, $m), cat $m, echo $m);) :; } \
| $(AWK) '!x[$$0]++' - > $@ | $(AWK) '!x[$$0]++' - > $@
# #
...@@ -491,7 +493,7 @@ $(subdir-ym): ...@@ -491,7 +493,7 @@ $(subdir-ym):
$(Q)$(MAKE) $(build)=$@ \ $(Q)$(MAKE) $(build)=$@ \
$(if $(filter $@/, $(KBUILD_SINGLE_TARGETS)),single-build=) \ $(if $(filter $@/, $(KBUILD_SINGLE_TARGETS)),single-build=) \
need-builtin=$(if $(filter $@/built-in.a, $(subdir-builtin)),1) \ need-builtin=$(if $(filter $@/built-in.a, $(subdir-builtin)),1) \
need-modorder=$(if $(need-modorder),$(if $(filter $@/modules.order, $(modorder)),1)) need-modorder=$(if $(filter $@/modules.order, $(subdir-modorder)),1)
# Add FORCE to the prequisites of a target to force it to be always rebuilt. # Add FORCE to the prequisites of a target to force it to be always rebuilt.
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
......
...@@ -35,7 +35,9 @@ lib-y := $(filter-out $(obj-y), $(sort $(lib-y) $(lib-m))) ...@@ -35,7 +35,9 @@ lib-y := $(filter-out $(obj-y), $(sort $(lib-y) $(lib-m)))
# Determine modorder. # Determine modorder.
# Unfortunately, we don't have information about ordering between -y # Unfortunately, we don't have information about ordering between -y
# and -m subdirs. Just put -y's first. # and -m subdirs. Just put -y's first.
ifdef need-modorder
modorder := $(patsubst %/,%/modules.order, $(filter %/, $(obj-y)) $(obj-m:.o=.ko)) modorder := $(patsubst %/,%/modules.order, $(filter %/, $(obj-y)) $(obj-m:.o=.ko))
endif
# Handle objects in subdirs # Handle objects in subdirs
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment