linux4.9.78内核Makefile分析(自用)
1、顶层Makefile:
534
include arch/$(SRCARCH)/Makefile
344
include scripts/Kbuild.include
558
init-y:= init/
init-y := $(patsubst %/, %/built-in.o, $(init-y))
core-y+= kernel/ certs/ mm/ fs/ ipc/ security/ crypto/ block/
drivers-y:= drivers/ sound/ firmware/
libs-y:= lib/
vmlinux-dirs:= $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
$(core-y) $(core-m) $(drivers-y) $(drivers-m) \
$(net-y) $(net-m) $(libs-y) $(libs-m) $(virt-y)))
407
# Read KERNELRELEASE from include/config/kernel.release (if it exists)
476
version_h := include/generated/uapi/linux/version.h
old_version_h := include/linux/version.h
1033
prepare1: prepare2 $(version_h) include/generated/utsrelease.h \
include/config/auto.conf
975
vmlinux: scripts/link-vmlinux.sh vmlinux_prereq $(vmlinux-deps) FORCE
+$(call if_changed,link-vmlinux)
export KBUILD_VMLINUX_INIT := $(head-y) $(init-y)
export KBUILD_VMLINUX_MAIN := $(core-y) $(libs-y) $(drivers-y) $(net-y) $(virt-y)
export KBUILD_LDS := arch/$(SRCARCH)/kernel/vmlinux.lds
946
vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_INIT) $(KBUILD_VMLINUX_MAIN)
2、arch/arm/Makefile
328
$(BOOT_TARGETS): vmlinux
$(Q)$(MAKE) $(build)=$(boot) MACHINE=$(MACHINE) $(boot)/$@
@$(kecho) ' Kernel: $(boot)/$@ is ready'
137
head-y:= arch/arm/kernel/head$(MMUEXT).o
3、Kbuild.include
179:
# $(Q)$(MAKE) $(build)=dir
build := -f $(srctree)/scripts/Makefile.build obj
4、scripst/Makefile.build
cmd_link_o_target = $(if $(strip $(obj-y)),\
$(cmd_make_builtin) $@ $(filter $(obj-y), $^) \
$(cmd_secanalysis),\
$(cmd_make_empty_builtin) $@)
cmd_make_builtin = $(LD) $(ld_flags) -r -o
PHONY += $(subdir-ym)
$(subdir-ym):
$(Q)$(MAKE) $(build)=$@
来源:oschina
链接:https://my.oschina.net/u/4297704/blog/4580419