kbuild: remove duplication from modules.order in sub-directories
authorMasahiro Yamada <yamada.masahiro@socionext.com>
Wed, 17 Jul 2019 06:17:51 +0000 (15:17 +0900)
committerMasahiro Yamada <yamada.masahiro@socionext.com>
Wed, 17 Jul 2019 13:39:27 +0000 (22:39 +0900)
Currently, only the top-level modules.order drops duplicated entries.

The modules.order files in sub-directories potentially contain
duplication. To list out the paths of all modules, I want to use
modules.order instead of parsing *.mod files in $(MODVERDIR).

To achieve this, I want to rip off duplication from modules.order
of external modules too.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
scripts/Makefile.build

index 10e92a27ec20635465e6bdc9e2ed68e897625ab4..be32a3752de43405a287401a7483481d1deef0a8 100644 (file)
@@ -423,13 +423,10 @@ endif # builtin-target
 #
 # Create commands to either record .ko file or cat modules.order from
 # a subdirectory
-modorder-cmds =                                                \
-       $(foreach m, $(modorder),                       \
-               $(if $(filter %/modules.order, $m),     \
-                       cat $m;, echo $m;))
-
 $(modorder-target): $(subdir-ym) FORCE
-       $(Q)(cat /dev/null; $(modorder-cmds)) > $@
+       $(Q){ $(foreach m, $(modorder), \
+       $(if $(filter %/modules.order, $m), cat $m, echo $m);) :; } \
+       | $(AWK) '!x[$$0]++' - > $@
 
 #
 # Rule to compile a set of .o files into one .a file (with symbol table)