diff options
Diffstat (limited to 'scripts/Makefile.build')
-rw-r--r-- | scripts/Makefile.build | 42 |
1 files changed, 17 insertions, 25 deletions
diff --git a/scripts/Makefile.build b/scripts/Makefile.build index be38198d98b2..0d434d0afc0b 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build | |||
@@ -63,14 +63,14 @@ ifneq ($(strip $(real-obj-y) $(need-builtin)),) | |||
63 | builtin-target := $(obj)/built-in.a | 63 | builtin-target := $(obj)/built-in.a |
64 | endif | 64 | endif |
65 | 65 | ||
66 | ifdef CONFIG_MODULES | 66 | ifeq ($(CONFIG_MODULES)$(need-modorder),y1) |
67 | modorder-target := $(obj)/modules.order | 67 | modorder-target := $(obj)/modules.order |
68 | endif | 68 | endif |
69 | 69 | ||
70 | # We keep a list of all modules in $(MODVERDIR) | 70 | mod-targets := $(patsubst %.o, %.mod, $(obj-m)) |
71 | 71 | ||
72 | __build: $(if $(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(extra-y)) \ | 72 | __build: $(if $(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(extra-y)) \ |
73 | $(if $(KBUILD_MODULES),$(obj-m) $(modorder-target)) \ | 73 | $(if $(KBUILD_MODULES),$(obj-m) $(mod-targets) $(modorder-target)) \ |
74 | $(subdir-ym) $(always) | 74 | $(subdir-ym) $(always) |
75 | @: | 75 | @: |
76 | 76 | ||
@@ -87,11 +87,6 @@ ifneq ($(KBUILD_ENABLE_EXTRA_GCC_CHECKS),) | |||
87 | cmd_checkdoc = $(srctree)/scripts/kernel-doc -none $< | 87 | cmd_checkdoc = $(srctree)/scripts/kernel-doc -none $< |
88 | endif | 88 | endif |
89 | 89 | ||
90 | # Do section mismatch analysis for each module/built-in.a | ||
91 | ifdef CONFIG_DEBUG_SECTION_MISMATCH | ||
92 | cmd_secanalysis = ; scripts/mod/modpost $@ | ||
93 | endif | ||
94 | |||
95 | # Compile C sources (.c) | 90 | # Compile C sources (.c) |
96 | # --------------------------------------------------------------------------- | 91 | # --------------------------------------------------------------------------- |
97 | 92 | ||
@@ -268,7 +263,7 @@ endef | |||
268 | 263 | ||
269 | # List module undefined symbols (or empty line if not enabled) | 264 | # List module undefined symbols (or empty line if not enabled) |
270 | ifdef CONFIG_TRIM_UNUSED_KSYMS | 265 | ifdef CONFIG_TRIM_UNUSED_KSYMS |
271 | cmd_undef_syms = $(NM) $@ | sed -n 's/^ *U //p' | xargs echo | 266 | cmd_undef_syms = $(NM) $< | sed -n 's/^ *U //p' | xargs echo |
272 | else | 267 | else |
273 | cmd_undef_syms = echo | 268 | cmd_undef_syms = echo |
274 | endif | 269 | endif |
@@ -278,13 +273,15 @@ $(obj)/%.o: $(src)/%.c $(recordmcount_source) $(objtool_dep) FORCE | |||
278 | $(call cmd,force_checksrc) | 273 | $(call cmd,force_checksrc) |
279 | $(call if_changed_rule,cc_o_c) | 274 | $(call if_changed_rule,cc_o_c) |
280 | 275 | ||
281 | # Single-part modules are special since we need to mark them in $(MODVERDIR) | 276 | cmd_mod = { \ |
277 | echo $(if $($*-objs)$($*-y)$($*-m), $(addprefix $(obj)/, $($*-objs) $($*-y) $($*-m)), $(@:.mod=.o)); \ | ||
278 | $(cmd_undef_syms); \ | ||
279 | } > $@ | ||
282 | 280 | ||
283 | $(single-used-m): $(obj)/%.o: $(src)/%.c $(recordmcount_source) $(objtool_dep) FORCE | 281 | $(obj)/%.mod: $(obj)/%.o FORCE |
284 | $(call cmd,force_checksrc) | 282 | $(call if_changed,mod) |
285 | $(call if_changed_rule,cc_o_c) | 283 | |
286 | @{ echo $(@:.o=.ko); echo $@; \ | 284 | targets += $(mod-targets) |
287 | $(cmd_undef_syms); } > $(MODVERDIR)/$(@F:.o=.mod) | ||
288 | 285 | ||
289 | quiet_cmd_cc_lst_c = MKLST $@ | 286 | quiet_cmd_cc_lst_c = MKLST $@ |
290 | cmd_cc_lst_c = $(CC) $(c_flags) -g -c -o $*.o $< && \ | 287 | cmd_cc_lst_c = $(CC) $(c_flags) -g -c -o $*.o $< && \ |
@@ -294,7 +291,7 @@ quiet_cmd_cc_lst_c = MKLST $@ | |||
294 | $(obj)/%.lst: $(src)/%.c FORCE | 291 | $(obj)/%.lst: $(src)/%.c FORCE |
295 | $(call if_changed_dep,cc_lst_c) | 292 | $(call if_changed_dep,cc_lst_c) |
296 | 293 | ||
297 | # header test (header-test-y target) | 294 | # header test (header-test-y, header-test-m target) |
298 | # --------------------------------------------------------------------------- | 295 | # --------------------------------------------------------------------------- |
299 | 296 | ||
300 | quiet_cmd_cc_s_h = CC $@ | 297 | quiet_cmd_cc_s_h = CC $@ |
@@ -423,13 +420,10 @@ endif # builtin-target | |||
423 | # | 420 | # |
424 | # Create commands to either record .ko file or cat modules.order from | 421 | # Create commands to either record .ko file or cat modules.order from |
425 | # a subdirectory | 422 | # a subdirectory |
426 | modorder-cmds = \ | ||
427 | $(foreach m, $(modorder), \ | ||
428 | $(if $(filter %/modules.order, $m), \ | ||
429 | cat $m;, echo kernel/$m;)) | ||
430 | |||
431 | $(modorder-target): $(subdir-ym) FORCE | 423 | $(modorder-target): $(subdir-ym) FORCE |
432 | $(Q)(cat /dev/null; $(modorder-cmds)) > $@ | 424 | $(Q){ $(foreach m, $(modorder), \ |
425 | $(if $(filter %/modules.order, $m), cat $m, echo $m);) :; } \ | ||
426 | | $(AWK) '!x[$$0]++' - > $@ | ||
433 | 427 | ||
434 | # | 428 | # |
435 | # Rule to compile a set of .o files into one .a file (with symbol table) | 429 | # Rule to compile a set of .o files into one .a file (with symbol table) |
@@ -464,12 +458,10 @@ endif | |||
464 | # module is turned into a multi object module, $^ will contain header file | 458 | # module is turned into a multi object module, $^ will contain header file |
465 | # dependencies recorded in the .*.cmd file. | 459 | # dependencies recorded in the .*.cmd file. |
466 | quiet_cmd_link_multi-m = LD [M] $@ | 460 | quiet_cmd_link_multi-m = LD [M] $@ |
467 | cmd_link_multi-m = $(LD) $(ld_flags) -r -o $@ $(filter %.o,$^) $(cmd_secanalysis) | 461 | cmd_link_multi-m = $(LD) $(ld_flags) -r -o $@ $(filter %.o,$^) |
468 | 462 | ||
469 | $(multi-used-m): FORCE | 463 | $(multi-used-m): FORCE |
470 | $(call if_changed,link_multi-m) | 464 | $(call if_changed,link_multi-m) |
471 | @{ echo $(@:.o=.ko); echo $(filter %.o,$^); \ | ||
472 | $(cmd_undef_syms); } > $(MODVERDIR)/$(@F:.o=.mod) | ||
473 | $(call multi_depend, $(multi-used-m), .o, -objs -y -m) | 465 | $(call multi_depend, $(multi-used-m), .o, -objs -y -m) |
474 | 466 | ||
475 | targets += $(multi-used-m) | 467 | targets += $(multi-used-m) |