17b453719SMasahiro Yamada# SPDX-License-Identifier: GPL-2.0-only 27b453719SMasahiro Yamada 35d4aeffbSMasahiro YamadaPHONY := __default 45d4aeffbSMasahiro Yamada__default: vmlinux 55d4aeffbSMasahiro Yamada 67b453719SMasahiro Yamadainclude include/config/auto.conf 77b453719SMasahiro Yamadainclude $(srctree)/scripts/Kbuild.include 87b453719SMasahiro Yamadainclude $(srctree)/scripts/Makefile.lib 97b453719SMasahiro Yamada 105d4aeffbSMasahiro Yamadatargets := 115d4aeffbSMasahiro Yamada 127b453719SMasahiro Yamada%.o: %.c FORCE 13bede1696SMasahiro Yamada $(call if_changed_rule,cc_o_c) 147b453719SMasahiro Yamada 15654102dfSMasahiro Yamada%.o: %.S FORCE 16bede1696SMasahiro Yamada $(call if_changed_rule,as_o_S) 17654102dfSMasahiro Yamada 18654102dfSMasahiro Yamada# Built-in dtb 19654102dfSMasahiro Yamada# --------------------------------------------------------------------------- 20654102dfSMasahiro Yamada 21654102dfSMasahiro Yamadaquiet_cmd_wrap_dtbs = WRAP $@ 22654102dfSMasahiro Yamada cmd_wrap_dtbs = { \ 23654102dfSMasahiro Yamada echo '\#include <asm-generic/vmlinux.lds.h>'; \ 24654102dfSMasahiro Yamada echo '.section .dtb.init.rodata,"a"'; \ 25654102dfSMasahiro Yamada while read dtb; do \ 26654102dfSMasahiro Yamada symbase=__dtb_$$(basename -s .dtb "$${dtb}" | tr - _); \ 27654102dfSMasahiro Yamada echo '.balign STRUCT_ALIGNMENT'; \ 28654102dfSMasahiro Yamada echo ".global $${symbase}_begin"; \ 29654102dfSMasahiro Yamada echo "$${symbase}_begin:"; \ 30654102dfSMasahiro Yamada echo '.incbin "'$$dtb'" '; \ 31654102dfSMasahiro Yamada echo ".global $${symbase}_end"; \ 32654102dfSMasahiro Yamada echo "$${symbase}_end:"; \ 33654102dfSMasahiro Yamada done < $<; \ 34654102dfSMasahiro Yamada } > $@ 35654102dfSMasahiro Yamada 36654102dfSMasahiro Yamada.builtin-dtbs.S: .builtin-dtbs-list FORCE 37654102dfSMasahiro Yamada $(call if_changed,wrap_dtbs) 38654102dfSMasahiro Yamada 39654102dfSMasahiro Yamadaquiet_cmd_gen_dtbs_list = GEN $@ 40654102dfSMasahiro Yamada cmd_gen_dtbs_list = \ 41654102dfSMasahiro Yamada $(if $(CONFIG_BUILTIN_DTB_NAME), echo "arch/$(SRCARCH)/boot/dts/$(CONFIG_BUILTIN_DTB_NAME).dtb",:) > $@ 42654102dfSMasahiro Yamada 43654102dfSMasahiro Yamada.builtin-dtbs-list: arch/$(SRCARCH)/boot/dts/dtbs-list FORCE 44654102dfSMasahiro Yamada $(call if_changed,$(if $(CONFIG_BUILTIN_DTB_ALL),copy,gen_dtbs_list)) 45654102dfSMasahiro Yamada 46654102dfSMasahiro Yamadatargets += .builtin-dtbs-list 47654102dfSMasahiro Yamada 48654102dfSMasahiro Yamadaifdef CONFIG_GENERIC_BUILTIN_DTB 49654102dfSMasahiro Yamadatargets += .builtin-dtbs.S .builtin-dtbs.o 50654102dfSMasahiro Yamadavmlinux: .builtin-dtbs.o 51654102dfSMasahiro Yamadaendif 52654102dfSMasahiro Yamada 53654102dfSMasahiro Yamada# vmlinux 54654102dfSMasahiro Yamada# --------------------------------------------------------------------------- 557b453719SMasahiro Yamada 565d4aeffbSMasahiro Yamadaifdef CONFIG_MODULES 575d4aeffbSMasahiro Yamadatargets += .vmlinux.export.o 585d4aeffbSMasahiro Yamadavmlinux: .vmlinux.export.o 595d4aeffbSMasahiro Yamadaendif 605d4aeffbSMasahiro Yamada 611198c9c6SNaveen N Raoifdef CONFIG_ARCH_WANTS_PRE_LINK_VMLINUX 621198c9c6SNaveen N Raovmlinux: arch/$(SRCARCH)/tools/vmlinux.arch.o 631198c9c6SNaveen N Rao 641198c9c6SNaveen N Raoarch/$(SRCARCH)/tools/vmlinux.arch.o: vmlinux.o FORCE 651198c9c6SNaveen N Rao $(Q)$(MAKE) $(build)=arch/$(SRCARCH)/tools $@ 661198c9c6SNaveen N Raoendif 671198c9c6SNaveen N Rao 685d4aeffbSMasahiro YamadaARCH_POSTLINK := $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink) 695d4aeffbSMasahiro Yamada 705d4aeffbSMasahiro Yamada# Final link of vmlinux with optional arch pass after final link 715d4aeffbSMasahiro Yamadacmd_link_vmlinux = \ 725d4aeffbSMasahiro Yamada $< "$(LD)" "$(KBUILD_LDFLAGS)" "$(LDFLAGS_vmlinux)"; \ 735d4aeffbSMasahiro Yamada $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) 745d4aeffbSMasahiro Yamada 755d4aeffbSMasahiro Yamadatargets += vmlinux 765d4aeffbSMasahiro Yamadavmlinux: scripts/link-vmlinux.sh vmlinux.o $(KBUILD_LDS) FORCE 775d4aeffbSMasahiro Yamada +$(call if_changed_dep,link_vmlinux) 78*18e9944eSThomas Weißschuhifdef CONFIG_DEBUG_INFO_BTF 79*18e9944eSThomas Weißschuhvmlinux: $(RESOLVE_BTFIDS) 80*18e9944eSThomas Weißschuhendif 817b453719SMasahiro Yamada 825f5e7344SKris Van Hees# module.builtin.ranges 835f5e7344SKris Van Hees# --------------------------------------------------------------------------- 845f5e7344SKris Van Heesifdef CONFIG_BUILTIN_MODULE_RANGES 855f5e7344SKris Van Hees__default: modules.builtin.ranges 865f5e7344SKris Van Hees 875f5e7344SKris Van Heesquiet_cmd_modules_builtin_ranges = GEN $@ 885f5e7344SKris Van Hees cmd_modules_builtin_ranges = gawk -f $(real-prereqs) > $@ 895f5e7344SKris Van Hees 905f5e7344SKris Van Heestargets += modules.builtin.ranges 915f5e7344SKris Van Heesmodules.builtin.ranges: $(srctree)/scripts/generate_builtin_ranges.awk \ 925f5e7344SKris Van Hees modules.builtin vmlinux.map vmlinux.o.map FORCE 935f5e7344SKris Van Hees $(call if_changed,modules_builtin_ranges) 945f5e7344SKris Van Hees 955f5e7344SKris Van Heesvmlinux.map: vmlinux 965f5e7344SKris Van Hees @: 975f5e7344SKris Van Hees 985f5e7344SKris Van Heesendif 995f5e7344SKris Van Hees 1008fb4ac1cSMasahiro Yamada# Add FORCE to the prerequisites of a target to force it to be always rebuilt. 1017b453719SMasahiro Yamada# --------------------------------------------------------------------------- 1027b453719SMasahiro Yamada 1037b453719SMasahiro YamadaPHONY += FORCE 1047b453719SMasahiro YamadaFORCE: 1057b453719SMasahiro Yamada 1067b453719SMasahiro Yamada# Read all saved command lines and dependencies for the $(targets) we 1077b453719SMasahiro Yamada# may be building above, using $(if_changed{,_dep}). As an 1087b453719SMasahiro Yamada# optimization, we don't need to read them if the target does not 1097b453719SMasahiro Yamada# exist, we will rebuild anyway in that case. 1107b453719SMasahiro Yamada 1117b453719SMasahiro Yamadaexisting-targets := $(wildcard $(sort $(targets))) 1127b453719SMasahiro Yamada 1137b453719SMasahiro Yamada-include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd) 1147b453719SMasahiro Yamada 1157b453719SMasahiro Yamada.PHONY: $(PHONY) 116