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# --------------------------------------------------------------------------- 55654102dfSMasahiro Yamada 565d4aeffbSMasahiro Yamadaifdef CONFIG_MODULES 575d4aeffbSMasahiro Yamadatargets += .vmlinux.export.o 585d4aeffbSMasahiro Yamadavmlinux: .vmlinux.export.o 595d4aeffbSMasahiro Yamadaendif 605d4aeffbSMasahiro Yamada 615d4aeffbSMasahiro YamadaARCH_POSTLINK := $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink) 625d4aeffbSMasahiro Yamada 635d4aeffbSMasahiro Yamada# Final link of vmlinux with optional arch pass after final link 645d4aeffbSMasahiro Yamadacmd_link_vmlinux = \ 655d4aeffbSMasahiro Yamada $< "$(LD)" "$(KBUILD_LDFLAGS)" "$(LDFLAGS_vmlinux)"; \ 665d4aeffbSMasahiro Yamada $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) 675d4aeffbSMasahiro Yamada 685d4aeffbSMasahiro Yamadatargets += vmlinux 695d4aeffbSMasahiro Yamadavmlinux: scripts/link-vmlinux.sh vmlinux.o $(KBUILD_LDS) FORCE 705d4aeffbSMasahiro Yamada +$(call if_changed_dep,link_vmlinux) 71*18e9944eSThomas Weißschuhifdef CONFIG_DEBUG_INFO_BTF 72*18e9944eSThomas Weißschuhvmlinux: $(RESOLVE_BTFIDS) 73*18e9944eSThomas Weißschuhendif 747b453719SMasahiro Yamada 755f5e7344SKris Van Hees# module.builtin.ranges 765f5e7344SKris Van Hees# --------------------------------------------------------------------------- 775f5e7344SKris Van Heesifdef CONFIG_BUILTIN_MODULE_RANGES 785f5e7344SKris Van Hees__default: modules.builtin.ranges 795f5e7344SKris Van Hees 805f5e7344SKris Van Heesquiet_cmd_modules_builtin_ranges = GEN $@ 815f5e7344SKris Van Hees cmd_modules_builtin_ranges = gawk -f $(real-prereqs) > $@ 825f5e7344SKris Van Hees 835f5e7344SKris Van Heestargets += modules.builtin.ranges 845f5e7344SKris Van Heesmodules.builtin.ranges: $(srctree)/scripts/generate_builtin_ranges.awk \ 855f5e7344SKris Van Hees modules.builtin vmlinux.map vmlinux.o.map FORCE 865f5e7344SKris Van Hees $(call if_changed,modules_builtin_ranges) 875f5e7344SKris Van Hees 885f5e7344SKris Van Heesvmlinux.map: vmlinux 895f5e7344SKris Van Hees @: 905f5e7344SKris Van Hees 915f5e7344SKris Van Heesendif 925f5e7344SKris Van Hees 938fb4ac1cSMasahiro Yamada# Add FORCE to the prerequisites of a target to force it to be always rebuilt. 947b453719SMasahiro Yamada# --------------------------------------------------------------------------- 957b453719SMasahiro Yamada 967b453719SMasahiro YamadaPHONY += FORCE 977b453719SMasahiro YamadaFORCE: 987b453719SMasahiro Yamada 997b453719SMasahiro Yamada# Read all saved command lines and dependencies for the $(targets) we 1007b453719SMasahiro Yamada# may be building above, using $(if_changed{,_dep}). As an 1017b453719SMasahiro Yamada# optimization, we don't need to read them if the target does not 1027b453719SMasahiro Yamada# exist, we will rebuild anyway in that case. 1037b453719SMasahiro Yamada 1047b453719SMasahiro Yamadaexisting-targets := $(wildcard $(sort $(targets))) 1057b453719SMasahiro Yamada 1067b453719SMasahiro Yamada-include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd) 1077b453719SMasahiro Yamada 1087b453719SMasahiro Yamada.PHONY: $(PHONY) 109