@@ -645,6 +645,8 @@ else
__all: modules
endif
+targets :=
+
# Decide whether to build built-in, modular, or both.
# Normally, just do built-in.
@@ -1149,6 +1151,10 @@ quiet_cmd_autoksyms_h = GEN $@
$(autoksyms_h):
$(call cmd,autoksyms_h)
+targets += vmlinux.o
+vmlinux.o: autoksyms_recursive $(KBUILD_VMLINUX_OBJS) $(KBUILD_VMLINUX_LIBS) FORCE
+ $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.vmlinux_o
+
ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink)
# Final link of vmlinux with optional arch pass after final link
@@ -1156,10 +1162,10 @@ cmd_link-vmlinux = \
$(CONFIG_SHELL) $< "$(LD)" "$(KBUILD_LDFLAGS)" "$(LDFLAGS_vmlinux)"; \
$(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)
-vmlinux: scripts/link-vmlinux.sh autoksyms_recursive $(vmlinux-deps) FORCE
+vmlinux: scripts/link-vmlinux.sh vmlinux.o $(KBUILD_LDS) FORCE
+$(call if_changed_dep,link-vmlinux)
-targets := vmlinux
+targets += vmlinux
# The actual objects are generated when descending,
# make sure no implicit rule kicks in
@@ -214,9 +214,6 @@ if [ "$1" = "clean" ]; then
exit 0
fi
-#link vmlinux.o
-${MAKE} -f "${srctree}/scripts/Makefile.vmlinux_o"
-
# modpost vmlinux.o to check for section mismatches
${MAKE} -f "${srctree}/scripts/Makefile.modpost" MODPOST_VMLINUX=1
Move the build rules of vmlinux.o out of scripts/link-vmlinux.sh to clearly separate 1) pre-modpost, 2) modpost, 3) post-modpost stages. This will make furture refactoring possible. Signed-off-by: Masahiro Yamada <masahiroy@kernel.org> --- (no changes since v1) Makefile | 10 ++++++++-- scripts/link-vmlinux.sh | 3 --- 2 files changed, 8 insertions(+), 5 deletions(-)