diff options
-rw-r--r-- | Makefile | 8 | ||||
-rw-r--r-- | scripts/Makefile.build | 17 | ||||
-rw-r--r-- | scripts/Makefile.lib | 6 |
3 files changed, 29 insertions, 2 deletions
@@ -1021,9 +1021,14 @@ ifdef CONFIG_MODULES | |||
1021 | all: modules | 1021 | all: modules |
1022 | 1022 | ||
1023 | # Build modules | 1023 | # Build modules |
1024 | # | ||
1025 | # A module can be listed more than once in obj-m resulting in | ||
1026 | # duplicate lines in modules.order files. Those are removed | ||
1027 | # using awk while concatenating to the final file. | ||
1024 | 1028 | ||
1025 | PHONY += modules | 1029 | PHONY += modules |
1026 | modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) | 1030 | modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) |
1031 | $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order | ||
1027 | @echo ' Building modules, stage 2.'; | 1032 | @echo ' Building modules, stage 2.'; |
1028 | $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost | 1033 | $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost |
1029 | 1034 | ||
@@ -1051,6 +1056,7 @@ _modinst_: | |||
1051 | rm -f $(MODLIB)/build ; \ | 1056 | rm -f $(MODLIB)/build ; \ |
1052 | ln -s $(objtree) $(MODLIB)/build ; \ | 1057 | ln -s $(objtree) $(MODLIB)/build ; \ |
1053 | fi | 1058 | fi |
1059 | @cp -f $(objtree)/modules.order $(MODLIB)/ | ||
1054 | $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst | 1060 | $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst |
1055 | 1061 | ||
1056 | # This depmod is only for convenience to give the initial | 1062 | # This depmod is only for convenience to give the initial |
@@ -1110,7 +1116,7 @@ clean: archclean $(clean-dirs) | |||
1110 | @find . $(RCS_FIND_IGNORE) \ | 1116 | @find . $(RCS_FIND_IGNORE) \ |
1111 | \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \ | 1117 | \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \ |
1112 | -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \ | 1118 | -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \ |
1113 | -o -name '*.symtypes' \) \ | 1119 | -o -name '*.symtypes' -o -name 'modules.order' \) \ |
1114 | -type f -print | xargs rm -f | 1120 | -type f -print | xargs rm -f |
1115 | 1121 | ||
1116 | # mrproper - Delete all generated files, including .config | 1122 | # mrproper - Delete all generated files, including .config |
diff --git a/scripts/Makefile.build b/scripts/Makefile.build index de9836eee8bb..db38ef465a63 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build | |||
@@ -83,10 +83,12 @@ ifneq ($(strip $(obj-y) $(obj-m) $(obj-n) $(obj-) $(lib-target)),) | |||
83 | builtin-target := $(obj)/built-in.o | 83 | builtin-target := $(obj)/built-in.o |
84 | endif | 84 | endif |
85 | 85 | ||
86 | modorder-target := $(obj)/modules.order | ||
87 | |||
86 | # We keep a list of all modules in $(MODVERDIR) | 88 | # We keep a list of all modules in $(MODVERDIR) |
87 | 89 | ||
88 | __build: $(if $(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(extra-y)) \ | 90 | __build: $(if $(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(extra-y)) \ |
89 | $(if $(KBUILD_MODULES),$(obj-m)) \ | 91 | $(if $(KBUILD_MODULES),$(obj-m) $(modorder-target)) \ |
90 | $(subdir-ym) $(always) | 92 | $(subdir-ym) $(always) |
91 | @: | 93 | @: |
92 | 94 | ||
@@ -276,6 +278,19 @@ targets += $(builtin-target) | |||
276 | endif # builtin-target | 278 | endif # builtin-target |
277 | 279 | ||
278 | # | 280 | # |
281 | # Rule to create modules.order file | ||
282 | # | ||
283 | # Create commands to either record .ko file or cat modules.order from | ||
284 | # a subdirectory | ||
285 | modorder-cmds = \ | ||
286 | $(foreach m, $(modorder), \ | ||
287 | $(if $(filter %/modules.order, $m), \ | ||
288 | cat $m;, echo kernel/$m;)) | ||
289 | |||
290 | $(modorder-target): $(subdir-ym) FORCE | ||
291 | $(Q)(cat /dev/null; $(modorder-cmds)) > $@ | ||
292 | |||
293 | # | ||
279 | # Rule to compile a set of .o files into one .a file | 294 | # Rule to compile a set of .o files into one .a file |
280 | # | 295 | # |
281 | ifdef lib-target | 296 | ifdef lib-target |
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 3c5e88bfecf1..8e440233c27d 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib | |||
@@ -25,6 +25,11 @@ lib-y := $(filter-out $(obj-y), $(sort $(lib-y) $(lib-m))) | |||
25 | # o if we encounter foo/ in $(obj-m), remove it from $(obj-m) | 25 | # o if we encounter foo/ in $(obj-m), remove it from $(obj-m) |
26 | # and add the directory to the list of dirs to descend into: $(subdir-m) | 26 | # and add the directory to the list of dirs to descend into: $(subdir-m) |
27 | 27 | ||
28 | # Determine modorder. | ||
29 | # Unfortunately, we don't have information about ordering between -y | ||
30 | # and -m subdirs. Just put -y's first. | ||
31 | modorder := $(patsubst %/,%/modules.order, $(filter %/, $(obj-y)) $(obj-m:.o=.ko)) | ||
32 | |||
28 | __subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y))) | 33 | __subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y))) |
29 | subdir-y += $(__subdir-y) | 34 | subdir-y += $(__subdir-y) |
30 | __subdir-m := $(patsubst %/,%,$(filter %/, $(obj-m))) | 35 | __subdir-m := $(patsubst %/,%,$(filter %/, $(obj-m))) |
@@ -64,6 +69,7 @@ real-objs-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y) | |||
64 | extra-y := $(addprefix $(obj)/,$(extra-y)) | 69 | extra-y := $(addprefix $(obj)/,$(extra-y)) |
65 | always := $(addprefix $(obj)/,$(always)) | 70 | always := $(addprefix $(obj)/,$(always)) |
66 | targets := $(addprefix $(obj)/,$(targets)) | 71 | targets := $(addprefix $(obj)/,$(targets)) |
72 | modorder := $(addprefix $(obj)/,$(modorder)) | ||
67 | obj-y := $(addprefix $(obj)/,$(obj-y)) | 73 | obj-y := $(addprefix $(obj)/,$(obj-y)) |
68 | obj-m := $(addprefix $(obj)/,$(obj-m)) | 74 | obj-m := $(addprefix $(obj)/,$(obj-m)) |
69 | lib-y := $(addprefix $(obj)/,$(lib-y)) | 75 | lib-y := $(addprefix $(obj)/,$(lib-y)) |