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 Yamada 97b453719SMasahiro Yamada# for c_flags 107b453719SMasahiro Yamadainclude $(srctree)/scripts/Makefile.lib 117b453719SMasahiro Yamada 125d4aeffbSMasahiro Yamadatargets := 135d4aeffbSMasahiro Yamada 147b453719SMasahiro Yamadaquiet_cmd_cc_o_c = CC $@ 157b453719SMasahiro Yamada cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< 167b453719SMasahiro Yamada 177b453719SMasahiro Yamada%.o: %.c FORCE 187b453719SMasahiro Yamada $(call if_changed_dep,cc_o_c) 197b453719SMasahiro Yamada 20*654102dfSMasahiro Yamadaquiet_cmd_as_o_S = AS $@ 21*654102dfSMasahiro Yamada cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $< 22*654102dfSMasahiro Yamada 23*654102dfSMasahiro Yamada%.o: %.S FORCE 24*654102dfSMasahiro Yamada $(call if_changed_dep,as_o_S) 25*654102dfSMasahiro Yamada 26*654102dfSMasahiro Yamada# Built-in dtb 27*654102dfSMasahiro Yamada# --------------------------------------------------------------------------- 28*654102dfSMasahiro Yamada 29*654102dfSMasahiro Yamadaquiet_cmd_wrap_dtbs = WRAP $@ 30*654102dfSMasahiro Yamada cmd_wrap_dtbs = { \ 31*654102dfSMasahiro Yamada echo '\#include <asm-generic/vmlinux.lds.h>'; \ 32*654102dfSMasahiro Yamada echo '.section .dtb.init.rodata,"a"'; \ 33*654102dfSMasahiro Yamada while read dtb; do \ 34*654102dfSMasahiro Yamada symbase=__dtb_$$(basename -s .dtb "$${dtb}" | tr - _); \ 35*654102dfSMasahiro Yamada echo '.balign STRUCT_ALIGNMENT'; \ 36*654102dfSMasahiro Yamada echo ".global $${symbase}_begin"; \ 37*654102dfSMasahiro Yamada echo "$${symbase}_begin:"; \ 38*654102dfSMasahiro Yamada echo '.incbin "'$$dtb'" '; \ 39*654102dfSMasahiro Yamada echo ".global $${symbase}_end"; \ 40*654102dfSMasahiro Yamada echo "$${symbase}_end:"; \ 41*654102dfSMasahiro Yamada done < $<; \ 42*654102dfSMasahiro Yamada } > $@ 43*654102dfSMasahiro Yamada 44*654102dfSMasahiro Yamada.builtin-dtbs.S: .builtin-dtbs-list FORCE 45*654102dfSMasahiro Yamada $(call if_changed,wrap_dtbs) 46*654102dfSMasahiro Yamada 47*654102dfSMasahiro Yamadaquiet_cmd_gen_dtbs_list = GEN $@ 48*654102dfSMasahiro Yamada cmd_gen_dtbs_list = \ 49*654102dfSMasahiro Yamada $(if $(CONFIG_BUILTIN_DTB_NAME), echo "arch/$(SRCARCH)/boot/dts/$(CONFIG_BUILTIN_DTB_NAME).dtb",:) > $@ 50*654102dfSMasahiro Yamada 51*654102dfSMasahiro Yamada.builtin-dtbs-list: arch/$(SRCARCH)/boot/dts/dtbs-list FORCE 52*654102dfSMasahiro Yamada $(call if_changed,$(if $(CONFIG_BUILTIN_DTB_ALL),copy,gen_dtbs_list)) 53*654102dfSMasahiro Yamada 54*654102dfSMasahiro Yamadatargets += .builtin-dtbs-list 55*654102dfSMasahiro Yamada 56*654102dfSMasahiro Yamadaifdef CONFIG_GENERIC_BUILTIN_DTB 57*654102dfSMasahiro Yamadatargets += .builtin-dtbs.S .builtin-dtbs.o 58*654102dfSMasahiro Yamadavmlinux: .builtin-dtbs.o 59*654102dfSMasahiro Yamadaendif 60*654102dfSMasahiro Yamada 61*654102dfSMasahiro Yamada# vmlinux 62*654102dfSMasahiro Yamada# --------------------------------------------------------------------------- 63*654102dfSMasahiro Yamada 645d4aeffbSMasahiro Yamadaifdef CONFIG_MODULES 655d4aeffbSMasahiro Yamadatargets += .vmlinux.export.o 665d4aeffbSMasahiro Yamadavmlinux: .vmlinux.export.o 675d4aeffbSMasahiro Yamadaendif 685d4aeffbSMasahiro Yamada 695d4aeffbSMasahiro YamadaARCH_POSTLINK := $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink) 705d4aeffbSMasahiro Yamada 715d4aeffbSMasahiro Yamada# Final link of vmlinux with optional arch pass after final link 725d4aeffbSMasahiro Yamadacmd_link_vmlinux = \ 735d4aeffbSMasahiro Yamada $< "$(LD)" "$(KBUILD_LDFLAGS)" "$(LDFLAGS_vmlinux)"; \ 745d4aeffbSMasahiro Yamada $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) 755d4aeffbSMasahiro Yamada 765d4aeffbSMasahiro Yamadatargets += vmlinux 775d4aeffbSMasahiro Yamadavmlinux: scripts/link-vmlinux.sh vmlinux.o $(KBUILD_LDS) FORCE 785d4aeffbSMasahiro Yamada +$(call if_changed_dep,link_vmlinux) 797b453719SMasahiro Yamada 805f5e7344SKris Van Hees# module.builtin.ranges 815f5e7344SKris Van Hees# --------------------------------------------------------------------------- 825f5e7344SKris Van Heesifdef CONFIG_BUILTIN_MODULE_RANGES 835f5e7344SKris Van Hees__default: modules.builtin.ranges 845f5e7344SKris Van Hees 855f5e7344SKris Van Heesquiet_cmd_modules_builtin_ranges = GEN $@ 865f5e7344SKris Van Hees cmd_modules_builtin_ranges = gawk -f $(real-prereqs) > $@ 875f5e7344SKris Van Hees 885f5e7344SKris Van Heestargets += modules.builtin.ranges 895f5e7344SKris Van Heesmodules.builtin.ranges: $(srctree)/scripts/generate_builtin_ranges.awk \ 905f5e7344SKris Van Hees modules.builtin vmlinux.map vmlinux.o.map FORCE 915f5e7344SKris Van Hees $(call if_changed,modules_builtin_ranges) 925f5e7344SKris Van Hees 935f5e7344SKris Van Heesvmlinux.map: vmlinux 945f5e7344SKris Van Hees @: 955f5e7344SKris Van Hees 965f5e7344SKris Van Heesendif 975f5e7344SKris Van Hees 988fb4ac1cSMasahiro Yamada# Add FORCE to the prerequisites of a target to force it to be always rebuilt. 997b453719SMasahiro Yamada# --------------------------------------------------------------------------- 1007b453719SMasahiro Yamada 1017b453719SMasahiro YamadaPHONY += FORCE 1027b453719SMasahiro YamadaFORCE: 1037b453719SMasahiro Yamada 1047b453719SMasahiro Yamada# Read all saved command lines and dependencies for the $(targets) we 1057b453719SMasahiro Yamada# may be building above, using $(if_changed{,_dep}). As an 1067b453719SMasahiro Yamada# optimization, we don't need to read them if the target does not 1077b453719SMasahiro Yamada# exist, we will rebuild anyway in that case. 1087b453719SMasahiro Yamada 1097b453719SMasahiro Yamadaexisting-targets := $(wildcard $(sort $(targets))) 1107b453719SMasahiro Yamada 1117b453719SMasahiro Yamada-include $(foreach f,$(existing-targets),$(dir $(f)).$(notdir $(f)).cmd) 1127b453719SMasahiro Yamada 1137b453719SMasahiro Yamada.PHONY: $(PHONY) 114