diff --git a/Makefile b/Makefile index d708bfa0c004..8e42be0655cc 100644 --- a/Makefile +++ b/Makefile @@ -1975,7 +1975,7 @@ KBUILD_MODULES := endif # CONFIG_MODULES PHONY += modpost -modpost: $(if $(single-build),, $(if $(KBUILD_BUILTIN), vmlinux.o)) \ +modpost: $(if $(single-build),, $(if $(KBUILD_MIXED_TREE),,$(if $(KBUILD_BUILTIN), vmlinux.o))) \ $(if $(KBUILD_MODULES), modules_check) $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index b315a410d729..1e11f6f582c3 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -60,8 +60,10 @@ ifeq ($(KBUILD_EXTMOD),) # This is used to retrieve symbol versions generated by genksyms. ifdef CONFIG_MODVERSIONS +ifndef KBUILD_MIXED_TREE vmlinux.symvers Module.symvers: .vmlinux.objs endif +endif # Ignore libgcc.a # Some architectures do '$(CC) --print-libgcc-file-name' to borrow libgcc.a @@ -76,9 +78,17 @@ quiet_cmd_vmlinux_objs = GEN $@ esac \ done > $@ +quiet_cmd_vmlinux_symvers = GEN $@ + cmd_vmlinux_symvers = grep "\ $@ + +quiet_cmd_cat_symvers = GEN $@ + cmd_cat_symvers = cat $(real-prereqs) > $@ + +ifndef KBUILD_MIXED_TREE targets += .vmlinux.objs .vmlinux.objs: vmlinux.a $(KBUILD_VMLINUX_LIBS) FORCE $(call if_changed,vmlinux_objs) +endif vmlinux.o-if-present := $(wildcard vmlinux.o) output-symdump := vmlinux.symvers @@ -86,6 +96,27 @@ output-symdump := vmlinux.symvers ifdef KBUILD_MODULES output-symdump := $(if $(vmlinux.o-if-present), Module.symvers, modules-only.symvers) missing-input := $(filter-out $(vmlinux.o-if-present),vmlinux.o) + +targets += vmlinux.symvers +vmlinux.symvers: Module.symvers FORCE + $(call if_changed,vmlinux_symvers) + +__modpost: $(if $(vmlinux.o-if-present),vmlinux.symvers,) +endif + +# Overwrite values for mixed building (overwritting makes merges easier) +ifdef KBUILD_MIXED_TREE +targets += Module.symvers +Module.symvers: $(mixed-build-prefix)vmlinux.symvers modules-only.symvers FORCE + $(call if_changed,cat_symvers) + +__modpost: Module.symvers + +vmlinux.o-if-present := +vmlinux.symvers-if-present := $(wildcard $(mixed-build-prefix)vmlinux.symvers) +modpost-args += $(addprefix -i ,$(vmlinux.symvers-if-present)) +output-symdump := modules-only.symvers +missing-input := $(filter-out $(vmlinux.symvers-if-present),$(mixed-build-prefix)vmlinux.symvers) endif else