OK6410A 开发板 (三) 15 u-boot-2021.01 boot 解析 U-boot 镜像编译部分 Makefile解析

Makefile 分几层
顶层 : Makefile
	2: scripts/Makefile.build
	2: scripts/Makefile.autoconf
	2: scripts/Makefile.spl

当然还有其他的Makefile , 不过编译log 中没提到 
例如 scripts/Kbuild.include
  • 重要Makefile 以及变量

arm cc 的编译 : rule_cc_o_c 与 cmd_cc_o_c
cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<

# Built-in and composite module parts
$(obj)/%.o: $(src)/%.c $(recordmcount_source) FORCE
	$(call cmd,force_checksrc)
	$(call if_changed_rule,cc_o_c) // 这里调用的是 rule_cc_o_c


arm cc 的链接 : cmd_link_o_target
$(builtin-target): $(obj-y) FORCE
	$(call if_changed,link_o_target) // 这里调用的是 cmd_link_o_target


arm cc 的预处理 : cmd_cc_i_c ,但是没有找到 开关 打开
可以添加 cmd_cc_i_c = $(CC) $(c_flags) -E -o ${
    
    @:.o=.i} $<
并将 cmd_cc_i_c 添加(类似 cmd_cc_o_c 一样)到 rule_cc_o_c 中

diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 705a886..a35d16a 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -183,6 +183,7 @@ quiet_cmd_cc_o_c = CC $(quiet_modtag)  $@
 
 ifndef CONFIG_MODVERSIONS
 cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
+cmd_cc_i_c = $(CC) $(c_flags) -E -o ${
    
    @:.o=.i} $<
 
 else
 # When module versioning is enabled the following steps are executed:
@@ -251,6 +252,7 @@ endif
 define rule_cc_o_c
        $(call echo-cmd,checksrc) $(cmd_checksrc)                         \
        $(call echo-cmd,cc_o_c) $(cmd_cc_o_c);                            \
+       $(call echo-cmd,cc_i_c) $(cmd_cc_i_c);                            \
        $(cmd_modversions)                                                \
        $(call echo-cmd,record_mcount)                                    \
        $(cmd_record_mcount)                                              \


  • 过程
make -C /home/mmt/work/ok6410/u-boot/output KBUILD_SRC=/home/mmt/work/ok6410/u-boot -f /home/mmt/work/ok6410/u-boot/Makefile
make[1]: Entering directory '/home/mmt/work/ok6410/u-boot/output'
make -f ../Makefile syncconfig
make -f ../scripts/Makefile.build obj=scripts/basic 
	// 生成output/Makefile
make -f ../scripts/Makefile.build obj=scripts/kconfig syncconfig 
	// scripts/kconfig/conf  --syncconfig Kconfig
make -f ../scripts/Makefile.autoconf || {
    
     rm -f include/config/auto.conf; false; } 
	// 生成 以下文件
	// include/config.h 
	// u-boot.cfg 
	// include/autoconf.mk.dep 
	// spl/u-boot.cfg 
	// include/config/uboot.release 
	// include/generated/version_autogenerated.h 
	// include/generated/timestamp_autogenerated.h 
	// include/generated/dt.h
make -f ../scripts/Makefile.build obj=scripts/basic // rm -f .tmp_quiet_recordmcount
make -f ../scripts/Makefile.build obj=. 
	// 生成 include/generated/generic-asm-offsets.h 
	// include/generated/asm-offsets.h 
	// spl/include/autoconf.mk
make -f ../scripts/Makefile.build obj=scripts
make -f ../scripts/Makefile.build obj=scripts/dtc
	// host cc 生成 scripts/dtc/dtc
make -f ../scripts/Makefile.build obj=tools
	// host cc 生成各种 tool , 如 tools/gen_eth_addr
make -f ../scripts/Makefile.build obj=arch/arm/cpu
	// arm ar 生成 built-in.o
make -f ../scripts/Makefile.build obj=arch/arm/cpu/arm1176
make -f ../scripts/Makefile.build obj=arch/arm/cpu/arm1176/../arm11
	// arm cc 生成 .o
	// arm ld 生成 built-in.o
make -f ../scripts/Makefile.build obj=arch/arm/lib
make -f ../scripts/Makefile.build obj=arch/arm/mach-s3c64xx
make -f ../scripts/Makefile.build obj=board/samsung/common
make -f ../scripts/Makefile.build obj=board/samsung/ok6410a
make -f ../scripts/Makefile.build obj=cmd
make -f ../scripts/Makefile.build obj=cmd/arm
make -f ../scripts/Makefile.build obj=common
make -f ../scripts/Makefile.build obj=common/init
make -f ../scripts/Makefile.build obj=disk
make -f ../scripts/Makefile.build obj=drivers
make -f ../scripts/Makefile.build obj=drivers/adc
make -f ../scripts/Makefile.build obj=drivers/ata
make -f ../scripts/Makefile.build obj=drivers/axi
make -f ../scripts/Makefile.build obj=drivers/block
make -f ../scripts/Makefile.build obj=drivers/bus
make -f ../scripts/Makefile.build obj=drivers/cache
make -f ../scripts/Makefile.build obj=drivers/clk
make -f ../scripts/Makefile.build obj=drivers/clk/analogbits
make -f ../scripts/Makefile.build obj=drivers/clk/imx
make -f ../scripts/Makefile.build obj=drivers/clk/tegra
make -f ../scripts/Makefile.build obj=drivers/core
make -f ../scripts/Makefile.build obj=drivers/crypto
make -f ../scripts/Makefile.build obj=drivers/crypto/fsl
make -f ../scripts/Makefile.build obj=drivers/crypto/rsa_mod_exp
make -f ../scripts/Makefile.build obj=drivers/dfu
make -f ../scripts/Makefile.build obj=drivers/input
make -f ../scripts/Makefile.build obj=drivers/mailbox
make -f ../scripts/Makefile.build obj=drivers/memory
make -f ../scripts/Makefile.build obj=drivers/misc
make -f ../scripts/Makefile.build obj=drivers/mmc
make -f ../scripts/Makefile.build obj=drivers/mtd
make -f ../scripts/Makefile.build obj=drivers/mtd/nand
make -f ../scripts/Makefile.build obj=drivers/mtd/onenand
make -f ../scripts/Makefile.build obj=drivers/mtd/spi
make -f ../scripts/Makefile.build obj=drivers/phy/allwinner
make -f ../scripts/Makefile.build obj=drivers/phy/marvell
make -f ../scripts/Makefile.build obj=drivers/phy/rockchip
make -f ../scripts/Makefile.build obj=drivers/pwm
make -f ../scripts/Makefile.build obj=drivers/reset
make -f ../scripts/Makefile.build obj=drivers/rtc
make -f ../scripts/Makefile.build obj=drivers/scsi
make -f ../scripts/Makefile.build obj=drivers/smem
make -f ../scripts/Makefile.build obj=drivers/soc
make -f ../scripts/Makefile.build obj=drivers/sound
make -f ../scripts/Makefile.build obj=drivers/spmi
make -f ../scripts/Makefile.build obj=drivers/thermal
make -f ../scripts/Makefile.build obj=drivers/ufs
make -f ../scripts/Makefile.build obj=drivers/video
make -f ../scripts/Makefile.build obj=drivers/video/bridge
make -f ../scripts/Makefile.build obj=drivers/video/sunxi
make -f ../scripts/Makefile.build obj=drivers/watchdog
make -f ../scripts/Makefile.build obj=drivers/dma
make -f ../scripts/Makefile.build obj=drivers/dma/ti
make -f ../scripts/Makefile.build obj=drivers/gpio
make -f ../scripts/Makefile.build obj=drivers/i2c
make -f ../scripts/Makefile.build obj=drivers/net
make -f ../scripts/Makefile.build obj=drivers/net/mscc_eswitch
make -f ../scripts/Makefile.build obj=drivers/net/qe
make -f ../scripts/Makefile.build obj=drivers/net/ti
make -f ../scripts/Makefile.build obj=drivers/net/phy
make -f ../scripts/Makefile.build obj=drivers/power
make -f ../scripts/Makefile.build obj=drivers/power/battery
make -f ../scripts/Makefile.build obj=drivers/power/domain
make -f ../scripts/Makefile.build obj=drivers/power/fuel_gauge
make -f ../scripts/Makefile.build obj=drivers/power/mfd
make -f ../scripts/Makefile.build obj=drivers/power/pmic
make -f ../scripts/Makefile.build obj=drivers/power/regulator
make -f ../scripts/Makefile.build obj=drivers/serial
make -f ../scripts/Makefile.build obj=drivers/spi
make -f ../scripts/Makefile.build obj=drivers/usb/cdns3
make -f ../scripts/Makefile.build obj=drivers/usb/common
make -f ../scripts/Makefile.build obj=drivers/usb/dwc3
make -f ../scripts/Makefile.build obj=drivers/usb/emul
make -f ../scripts/Makefile.build obj=drivers/usb/eth
make -f ../scripts/Makefile.build obj=drivers/usb/host
make -f ../scripts/Makefile.build obj=drivers/usb/mtu3
make -f ../scripts/Makefile.build obj=drivers/usb/musb-new
make -f ../scripts/Makefile.build obj=drivers/usb/musb
make -f ../scripts/Makefile.build obj=drivers/usb/phy
make -f ../scripts/Makefile.build obj=drivers/usb/ulpi
make -f ../scripts/Makefile.build obj=env
make -f ../scripts/Makefile.build obj=fs
make -f ../scripts/Makefile.build obj=fs/fat
make -f ../scripts/Makefile.build obj=lib
make -f ../scripts/Makefile.build obj=lib/crypto
make -f ../scripts/Makefile.build obj=lib/libfdt
make -f ../scripts/Makefile.build obj=lib/zlib
make -f ../scripts/Makefile.build obj=net
make -f ../scripts/Makefile.build obj=examples
// arm cc 预编译生成 u-boot.lda
// arm ld 链接生成 u-boot
// arm objcopy 生成 u-boot-nodtb.bin
make -f ../scripts/Makefile.build obj=dts dtbs
make -f ../scripts/Makefile.build obj=arch/arm/dts dtbs
// arm cc 预编译生成 .s3c64xx-ok6410a.dtb.dts.tmp
// scripts/dtc/dtc 生成 arch/arm/dts/s3c64xx-ok6410a.dtb
// cat arch/arm/dts/s3c64xx-ok6410a.dtb > dts/dt.dtb
// cat u-boot-nodtb.bin dts/dt.dtb > u-boot-dtb.bin
// cp u-boot-dtb.bin u-boot.bin


	// 编译 spl
make obj=spl -f ../scripts/Makefile.spl all
make -f ../scripts/Makefile.build obj=spl/.
	// 生成 spl/./include/generated/generic-asm-offsets.h
	// 生成 spl/./include/generated/asm-offsets.h
make -f ../scripts/Makefile.build obj=spl/arch/arm/mach-s3c64xx
make -f ../scripts/Makefile.build obj=spl/arch/arm/cpu/arm1176
make -f ../scripts/Makefile.build obj=spl/arch/arm/cpu/arm1176/../arm11
make -f ../scripts/Makefile.build obj=spl/arch/arm/cpu
make -f ../scripts/Makefile.build obj=spl/arch/arm/lib
make -f ../scripts/Makefile.build obj=spl/board/samsung/ok6410a
make -f ../scripts/Makefile.build obj=spl/board/samsung/common
make -f ../scripts/Makefile.build obj=spl/common/spl
make -f ../scripts/Makefile.build obj=spl/common/init
make -f ../scripts/Makefile.build obj=spl/lib
make -f ../scripts/Makefile.build obj=spl/disk
make -f ../scripts/Makefile.build obj=spl/drivers
make -f ../scripts/Makefile.build obj=spl/drivers/block
make -f ../scripts/Makefile.build obj=spl/drivers/mtd
make -f ../scripts/Makefile.build obj=spl/drivers/serial
make -f ../scripts/Makefile.build obj=spl/drivers/soc
make -f ../scripts/Makefile.build obj=spl/dts
make -f ../scripts/Makefile.build obj=spl/fs
	// 做完 fs后
	// arm gcc 生成  u-boot-spl.lds
	// arm ld 生成 u-boot-spl
	// arm objcopy 生成 u-boot-spl-nodtb.bin
	// cp spl/u-boot-spl-nodtb.bin spl/u-boot-spl.bin
	
make[1]: Leaving directory '/home/mmt/work/ok6410/u-boot/output'

猜你喜欢

转载自blog.csdn.net/u011011827/article/details/115261318