Makefile.vmlinux 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. # SPDX-License-Identifier: GPL-2.0-only
  2. PHONY := __default
  3. __default: vmlinux
  4. include include/config/auto.conf
  5. include $(srctree)/scripts/Kbuild.include
  6. # for c_flags
  7. include $(srctree)/scripts/Makefile.lib
  8. targets :=
  9. quiet_cmd_cc_o_c = CC $@
  10. cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
  11. %.o: %.c FORCE
  12. $(call if_changed_dep,cc_o_c)
  13. ifdef CONFIG_MODULES
  14. targets += .vmlinux.export.o
  15. vmlinux: .vmlinux.export.o
  16. endif
  17. ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink)
  18. # Final link of vmlinux with optional arch pass after final link
  19. cmd_link_vmlinux = \
  20. $< "$(LD)" "$(KBUILD_LDFLAGS)" "$(LDFLAGS_vmlinux)"; \
  21. $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true)
  22. targets += vmlinux
  23. vmlinux: scripts/link-vmlinux.sh vmlinux.o $(KBUILD_LDS) FORCE
  24. +$(call if_changed_dep,link_vmlinux)
  25. # Add FORCE to the prequisites of a target to force it to be always rebuilt.
  26. # ---------------------------------------------------------------------------
  27. PHONY += FORCE
  28. FORCE:
  29. # Read all saved command lines and dependencies for the $(targets) we
  30. # may be building above, using $(if_changed{,_dep}). As an
  31. # optimization, we don't need to read them if the target does not
  32. # exist, we will rebuild anyway in that case.
  33. existing-targets := $(wildcard $(sort $(targets)))
  34. -include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
  35. .PHONY: $(PHONY)