Makefile.vmlinux 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. ifdef CONFIG_BUILDTIME_TABLE_SORT
  26. vmlinux: scripts/sorttable
  27. endif
  28. # module.builtin.ranges
  29. # ---------------------------------------------------------------------------
  30. ifdef CONFIG_BUILTIN_MODULE_RANGES
  31. __default: modules.builtin.ranges
  32. quiet_cmd_modules_builtin_ranges = GEN $@
  33. cmd_modules_builtin_ranges = gawk -f $(real-prereqs) > $@
  34. targets += modules.builtin.ranges
  35. modules.builtin.ranges: $(srctree)/scripts/generate_builtin_ranges.awk \
  36. modules.builtin vmlinux.map vmlinux.o.map FORCE
  37. $(call if_changed,modules_builtin_ranges)
  38. vmlinux.map: vmlinux
  39. @:
  40. endif
  41. # Add FORCE to the prerequisites of a target to force it to be always rebuilt.
  42. # ---------------------------------------------------------------------------
  43. PHONY += FORCE
  44. FORCE:
  45. # Read all saved command lines and dependencies for the $(targets) we
  46. # may be building above, using $(if_changed{,_dep}). As an
  47. # optimization, we don't need to read them if the target does not
  48. # exist, we will rebuild anyway in that case.
  49. existing-targets := $(wildcard $(sort $(targets)))
  50. -include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd)
  51. .PHONY: $(PHONY)