make disclean V=1 分析

文章目录

  • make distclean
    • 步骤1:2090-2114行,执行依赖 clean
    • 步骤2:2120-2124行,执行依赖 $(mrproper-dirs)
    • 步骤3:2118-2129行,执行依赖 mrproper
    • 步骤4:2135-2142行,实现 distclean

请添加图片描述

编译后执行 make distclean V=1

make -f ./scripts/Makefile.clean obj=api
make -f ./scripts/Makefile.clean obj=cmd
make -f ./scripts/Makefile.clean obj=cmd/arm
make -f ./scripts/Makefile.clean obj=cmd/broadcom
make -f ./scripts/Makefile.clean obj=cmd/mvebu
make -f ./scripts/Makefile.clean obj=cmd/riscv
make -f ./scripts/Makefile.clean obj=cmd/sandbox
make -f ./scripts/Makefile.clean obj=cmd/ti
make -f ./scripts/Makefile.clean obj=cmd/x86
make -f ./scripts/Makefile.clean obj=common
make -f ./scripts/Makefile.clean obj=common/init
make -f ./scripts/Makefile.clean obj=disk
make -f ./scripts/Makefile.clean obj=drivers
make -f ./scripts/Makefile.clean obj=drivers/adc
make -f ./scripts/Makefile.clean obj=drivers/ata
make -f ./scripts/Makefile.clean obj=drivers/axi
make -f ./scripts/Makefile.clean obj=drivers/bios_emulator
make -f ./scripts/Makefile.clean obj=drivers/block
make -f ./scripts/Makefile.clean obj=drivers/bootcount
make -f ./scripts/Makefile.clean obj=drivers/bus
make -f ./scripts/Makefile.clean obj=drivers/button
make -f ./scripts/Makefile.clean obj=drivers/cache
make -f ./scripts/Makefile.clean obj=drivers/clk
make -f ./scripts/Makefile.clean obj=drivers/clk/altera
make -f ./scripts/Makefile.clean obj=drivers/clk/analogbits
make -f ./scripts/Makefile.clean obj=drivers/clk/aspeed
make -f ./scripts/Makefile.clean obj=drivers/clk/at91
make -f ./scripts/Makefile.clean obj=drivers/clk/exynos
make -f ./scripts/Makefile.clean obj=drivers/clk/imx
make -f ./scripts/Makefile.clean obj=drivers/clk/intel
make -f ./scripts/Makefile.clean obj=drivers/clk/kendryte
make -f ./scripts/Makefile.clean obj=drivers/clk/mediatek
make -f ./scripts/Makefile.clean obj=drivers/clk/meson
make -f ./scripts/Makefile.clean obj=drivers/clk/microchip
make -f ./scripts/Makefile.clean obj=drivers/clk/mtmips
make -f ./scripts/Makefile.clean obj=drivers/clk/mvebu
make -f ./scripts/Makefile.clean obj=drivers/clk/owl
make -f ./scripts/Makefile.clean obj=drivers/clk/renesas
make -f ./scripts/Makefile.clean obj=drivers/clk/rockchip
make -f ./scripts/Makefile.clean obj=drivers/clk/sifive
make -f ./scripts/Makefile.clean obj=drivers/clk/sunxi
make -f ./scripts/Makefile.clean obj=drivers/clk/tegra
make -f ./scripts/Makefile.clean obj=drivers/clk/ti
make -f ./scripts/Makefile.clean obj=drivers/clk/uniphier
make -f ./scripts/Makefile.clean obj=drivers/core
make -f ./scripts/Makefile.clean obj=drivers/cpu
make -f ./scripts/Makefile.clean obj=drivers/crypto
make -f ./scripts/Makefile.clean obj=drivers/crypto/fsl
make -f ./scripts/Makefile.clean obj=drivers/crypto/rsa_mod_exp
make -f ./scripts/Makefile.clean obj=drivers/ddr/microchip
make -f ./scripts/Makefile.clean obj=drivers/demo
make -f ./scripts/Makefile.clean obj=drivers/dfu
make -f ./scripts/Makefile.clean obj=drivers/fastboot
make -f ./scripts/Makefile.clean obj=drivers/firmware
make -f ./scripts/Makefile.clean obj=drivers/firmware/scmi
make -f ./scripts/Makefile.clean obj=drivers/fpga
make -f ./scripts/Makefile.clean obj=drivers/gpio
make -f ./scripts/Makefile.clean obj=drivers/hwspinlock
make -f ./scripts/Makefile.clean obj=drivers/i2c
make -f ./scripts/Makefile.clean obj=drivers/i2c/muxes
make -f ./scripts/Makefile.clean obj=drivers/input
make -f ./scripts/Makefile.clean obj=drivers/led
make -f ./scripts/Makefile.clean obj=drivers/mailbox
make -f ./scripts/Makefile.clean obj=drivers/memory
make -f ./scripts/Makefile.clean obj=drivers/misc
make -f ./scripts/Makefile.clean obj=drivers/misc/imx8
make -f ./scripts/Makefile.clean obj=drivers/mmc
make -f ./scripts/Makefile.clean obj=drivers/mtd
make -f ./scripts/Makefile.clean obj=drivers/mtd/nand
make -f ./scripts/Makefile.clean obj=drivers/mtd/nand/raw
make -f ./scripts/Makefile.clean obj=drivers/mtd/nand/raw/brcmnand
make -f ./scripts/Makefile.clean obj=drivers/mtd/nand/spi
make -f ./scripts/Makefile.clean obj=drivers/mtd/onenand
make -f ./scripts/Makefile.clean obj=drivers/mtd/spi
make -f ./scripts/Makefile.clean obj=drivers/mtd/ubi
make -f ./scripts/Makefile.clean obj=drivers/mux
make -f ./scripts/Makefile.clean obj=drivers/nvme
make -f ./scripts/Makefile.clean obj=drivers/pch
make -f ./scripts/Makefile.clean obj=drivers/pci
make -f ./scripts/Makefile.clean obj=drivers/pci_endpoint
make -f ./scripts/Makefile.clean obj=drivers/phy
make -f ./scripts/Makefile.clean obj=drivers/phy/allwinner
make -f ./scripts/Makefile.clean obj=drivers/phy/marvell
make -f ./scripts/Makefile.clean obj=drivers/phy/rockchip
make -f ./scripts/Makefile.clean obj=drivers/pinctrl
make -f ./scripts/Makefile.clean obj=drivers/pinctrl/aspeed
make -f ./scripts/Makefile.clean obj=drivers/pinctrl/ath79
make -f ./scripts/Makefile.clean obj=drivers/pinctrl/broadcom
make -f ./scripts/Makefile.clean obj=drivers/pinctrl/exynos
make -f ./scripts/Makefile.clean obj=drivers/pinctrl/intel
make -f ./scripts/Makefile.clean obj=drivers/pinctrl/mediatek
make -f ./scripts/Makefile.clean obj=drivers/pinctrl/meson
make -f ./scripts/Makefile.clean obj=drivers/pinctrl/mscc
make -f ./scripts/Makefile.clean obj=drivers/pinctrl/mtmips
make -f ./scripts/Makefile.clean obj=drivers/pinctrl/mvebu
make -f ./scripts/Makefile.clean obj=drivers/pinctrl/nexell
make -f ./scripts/Makefile.clean obj=drivers/pinctrl/nxp
make -f ./scripts/Makefile.clean obj=drivers/pinctrl/renesas
make -f ./scripts/Makefile.clean obj=drivers/pinctrl/rockchip
make -f ./scripts/Makefile.clean obj=drivers/pinctrl/uniphier
make -f ./scripts/Makefile.clean obj=drivers/power/acpi_pmc
make -f ./scripts/Makefile.clean obj=drivers/pwm
make -f ./scripts/Makefile.clean obj=drivers/qe
make -f ./scripts/Makefile.clean obj=drivers/ram
make -f ./scripts/Makefile.clean obj=drivers/ram/aspeed
make -f ./scripts/Makefile.clean obj=drivers/ram/k3-ddrss
make -f ./scripts/Makefile.clean obj=drivers/ram/mediatek
make -f ./scripts/Makefile.clean obj=drivers/ram/octeon
make -f ./scripts/Makefile.clean obj=drivers/ram/rockchip
make -f ./scripts/Makefile.clean obj=drivers/ram/sifive
make -f ./scripts/Makefile.clean obj=drivers/ram/stm32mp1
make -f ./scripts/Makefile.clean obj=drivers/remoteproc
make -f ./scripts/Makefile.clean obj=drivers/reset
make -f ./scripts/Makefile.clean obj=drivers/rng
make -f ./scripts/Makefile.clean obj=drivers/rtc
make -f ./scripts/Makefile.clean obj=drivers/scsi
make -f ./scripts/Makefile.clean obj=drivers/serial
make -f ./scripts/Makefile.clean obj=drivers/smem
make -f ./scripts/Makefile.clean obj=drivers/soc
make -f ./scripts/Makefile.clean obj=drivers/soc/ti
make -f ./scripts/Makefile.clean obj=drivers/sound
make -f ./scripts/Makefile.clean obj=drivers/spi
make -f ./scripts/Makefile.clean obj=drivers/spmi
make -f ./scripts/Makefile.clean obj=drivers/sysinfo
make -f ./scripts/Makefile.clean obj=drivers/sysreset
make -f ./scripts/Makefile.clean obj=drivers/tee
make -f ./scripts/Makefile.clean obj=drivers/tee/broadcom
make -f ./scripts/Makefile.clean obj=drivers/tee/optee
make -f ./scripts/Makefile.clean obj=drivers/thermal
make -f ./scripts/Makefile.clean obj=drivers/timer
make -f ./scripts/Makefile.clean obj=drivers/tpm
make -f ./scripts/Makefile.clean obj=drivers/ufs
make -f ./scripts/Makefile.clean obj=drivers/video
make -f ./scripts/Makefile.clean obj=drivers/video/bridge
make -f ./scripts/Makefile.clean obj=drivers/video/exynos
make -f ./scripts/Makefile.clean obj=drivers/video/imx
make -f ./scripts/Makefile.clean obj=drivers/video/meson
make -f ./scripts/Makefile.clean obj=drivers/video/nexell
make -f ./scripts/Makefile.clean obj=drivers/video/nexell/soc
make -f ./scripts/Makefile.clean obj=drivers/video/rockchip
make -f ./scripts/Makefile.clean obj=drivers/video/stm32
make -f ./scripts/Makefile.clean obj=drivers/video/sunxi
make -f ./scripts/Makefile.clean obj=drivers/video/tegra4
make -f ./scripts/Makefile.clean obj=drivers/video/ti
make -f ./scripts/Makefile.clean obj=drivers/virtio
make -f ./scripts/Makefile.clean obj=drivers/w1
make -f ./scripts/Makefile.clean obj=drivers/w1-eeprom
make -f ./scripts/Makefile.clean obj=drivers/watchdog
make -f ./scripts/Makefile.clean obj=drivers/xen
make -f ./scripts/Makefile.clean obj=drivers/ddr/altera
make -f ./scripts/Makefile.clean obj=drivers/ddr/fsl
make -f ./scripts/Makefile.clean obj=drivers/dma
make -f ./scripts/Makefile.clean obj=drivers/dma/ti
make -f ./scripts/Makefile.clean obj=drivers/gpio
make -f ./scripts/Makefile.clean obj=drivers/i2c
make -f ./scripts/Makefile.clean obj=drivers/i2c/muxes
make -f ./scripts/Makefile.clean obj=drivers/net
make -f ./scripts/Makefile.clean obj=drivers/net/fsl-mc
make -f ./scripts/Makefile.clean obj=drivers/net/fsl-mc/dpio
make -f ./scripts/Makefile.clean obj=drivers/net/ldpaa_eth
make -f ./scripts/Makefile.clean obj=drivers/net/mscc_eswitch
make -f ./scripts/Makefile.clean obj=drivers/net/octeontx
make -f ./scripts/Makefile.clean obj=drivers/net/octeontx2
make -f ./scripts/Makefile.clean obj=drivers/net/pfe_eth
make -f ./scripts/Makefile.clean obj=drivers/net/qe
make -f ./scripts/Makefile.clean obj=drivers/net/ti
make -f ./scripts/Makefile.clean obj=drivers/net/fm
make -f ./scripts/Makefile.clean obj=drivers/net/phy
make -f ./scripts/Makefile.clean obj=drivers/power
make -f ./scripts/Makefile.clean obj=drivers/power/battery
make -f ./scripts/Makefile.clean obj=drivers/power/domain
make -f ./scripts/Makefile.clean obj=drivers/power/fuel_gauge
make -f ./scripts/Makefile.clean obj=drivers/power/mfd
make -f ./scripts/Makefile.clean obj=drivers/power/pmic
make -f ./scripts/Makefile.clean obj=drivers/power/regulator
make -f ./scripts/Makefile.clean obj=drivers/serial
make -f ./scripts/Makefile.clean obj=drivers/spi
make -f ./scripts/Makefile.clean obj=drivers/usb/cdns3
make -f ./scripts/Makefile.clean obj=drivers/usb/common
make -f ./scripts/Makefile.clean obj=drivers/usb/dwc3
make -f ./scripts/Makefile.clean obj=drivers/usb/emul
make -f ./scripts/Makefile.clean obj=drivers/usb/eth
make -f ./scripts/Makefile.clean obj=drivers/usb/gadget
make -f ./scripts/Makefile.clean obj=drivers/usb/gadget/udc
make -f ./scripts/Makefile.clean obj=drivers/usb/host
make -f ./scripts/Makefile.clean obj=drivers/usb/mtu3
make -f ./scripts/Makefile.clean obj=drivers/usb/musb
make -f ./scripts/Makefile.clean obj=drivers/usb/musb-new
make -f ./scripts/Makefile.clean obj=drivers/usb/phy
make -f ./scripts/Makefile.clean obj=drivers/usb/ulpi
make -f ./scripts/Makefile.clean obj=dts
make -f ./scripts/Makefile.clean obj=dts/../arch/arm/dts
  rm -f dts/../arch/arm/dts/bcm37-rpi-3-b.dtb dts/../arch/arm/dts/bcm35-rpi-b-plus.dtb dts/../arch/arm/dts/bcm35-rpi-a-plus.dtb dts/../arch/arm/dts/bcm35-rpi-b.dtb dts/../arch/arm/dts/bcm35-rpi-a.dtb dts/../arch/arm/dts/bcm35-rpi-cm1-io1.dtb dts/../arch/arm/dts/bcm37-rpi-3-b-plus.dtb dts/../arch/arm/dts/bcm35-rpi-zero-w.dtb dts/../arch/arm/dts/bcm35-rpi-b-rev2.dtb dts/../arch/arm/dts/bcm36-rpi-2-b.dtb dts/../arch/arm/dts/bcm37-rpi-3-a-plus.dtb dts/../arch/arm/dts/bcm37-rpi-cm3-io3.dtb dts/../arch/arm/dts/bcm35-rpi-zero.dtb
make -f ./scripts/Makefile.clean obj=dts/../arch/microblaze/dts
make -f ./scripts/Makefile.clean obj=dts/../arch/mips/dts
make -f ./scripts/Makefile.clean obj=dts/../arch/powerpc/dts
make -f ./scripts/Makefile.clean obj=dts/../arch/riscv/dts
make -f ./scripts/Makefile.clean obj=dts/../arch/sandbox/dts
make -f ./scripts/Makefile.clean obj=dts/../arch/x86/dts
  rm -f dts/dt.dtb dts/dt.dtb.S
make -f ./scripts/Makefile.clean obj=env
make -f ./scripts/Makefile.clean obj=examples
make -f ./scripts/Makefile.clean obj=fs
make -f ./scripts/Makefile.clean obj=fs/btrfs
make -f ./scripts/Makefile.clean obj=fs/cbfs
make -f ./scripts/Makefile.clean obj=fs/cramfs
make -f ./scripts/Makefile.clean obj=fs/ext4
make -f ./scripts/Makefile.clean obj=fs/fat
make -f ./scripts/Makefile.clean obj=fs/jffs2
make -f ./scripts/Makefile.clean obj=fs/reiserfs
make -f ./scripts/Makefile.clean obj=fs/sandbox
make -f ./scripts/Makefile.clean obj=fs/squashfs
make -f ./scripts/Makefile.clean obj=fs/ubifs
make -f ./scripts/Makefile.clean obj=fs/yaffs2
make -f ./scripts/Makefile.clean obj=fs/zfs
make -f ./scripts/Makefile.clean obj=lib
make -f ./scripts/Makefile.clean obj=lib/acpi
make -f ./scripts/Makefile.clean obj=lib/aes
make -f ./scripts/Makefile.clean obj=lib/at91
make -f ./scripts/Makefile.clean obj=lib/bzip2
make -f ./scripts/Makefile.clean obj=lib/crypto
make -f ./scripts/Makefile.clean obj=lib/dhry
make -f ./scripts/Makefile.clean obj=lib/efi
make -f ./scripts/Makefile.clean obj=lib/efi_driver
make -f ./scripts/Makefile.clean obj=lib/efi_loader
make -f ./scripts/Makefile.clean obj=lib/efi_selftest
make -f ./scripts/Makefile.clean obj=lib/libavb
make -f ./scripts/Makefile.clean obj=lib/libfdt
make -f ./scripts/Makefile.clean obj=lib/lzma
make -f ./scripts/Makefile.clean obj=lib/lzo
make -f ./scripts/Makefile.clean obj=lib/optee
make -f ./scripts/Makefile.clean obj=lib/rsa
make -f ./scripts/Makefile.clean obj=lib/tizen
make -f ./scripts/Makefile.clean obj=lib/zlib
make -f ./scripts/Makefile.clean obj=lib/zstd
make -f ./scripts/Makefile.clean obj=net
make -f ./scripts/Makefile.clean obj=test
make -f ./scripts/Makefile.clean obj=test/cmd
make -f ./scripts/Makefile.clean obj=test/dm
make -f ./scripts/Makefile.clean obj=test/image
make -f ./scripts/Makefile.clean obj=test/lib
make -f ./scripts/Makefile.clean obj=test/log
make -f ./scripts/Makefile.clean obj=test/env
make -f ./scripts/Makefile.clean obj=test/optee
make -f ./scripts/Makefile.clean obj=test/overlay
make -f ./scripts/Makefile.clean obj=tools
make -f ./scripts/Makefile.clean obj=tools/env
make -f ./scripts/Makefile.clean obj=tools/gdb
  rm -f tools/mkenvimage tools/dumpimage tools/mkimage tools/proftool tools/fdtgrep tools/spl_size_limit tools/mkenvimage tools/dumpimage tools/mkimage tools/proftool tools/fdtgrep tools/spl_size_limit tools/gen_eth_addr tools/gen_ethaddr_crc tools/img2srec
  rm -rf tools/lib tools/common
  rm -rf .tmp_versions    
  rm -f include/bmp_logo.h include/bmp_logo_data.h tools/version.h boot* u-boot* MLO* SPL System.map fit-dtb.blob* u-boot-ivt.img.log u-boot-dtb.imx.log SPL.log u-boot.imx.log lpc32xx-* bl31.c bl31.elf bl31_*.bin image.map tispl.bin* idbloader.img flash.bin flash.log defconfig keep-syms-lto.c
make -f ./scripts/Makefile.clean obj=scripts
make -f ./scripts/Makefile.clean obj=scripts/basic
  rm -f scripts/basic/fixdep scripts/basic/fixdep
make -f ./scripts/Makefile.clean obj=scripts/dtc
make -f ./scripts/Makefile.clean obj=scripts/dtc/pylibfdt
  rm -f scripts/dtc/dtc scripts/dtc/dtc
make -f ./scripts/Makefile.clean obj=scripts/kconfig
  rm -f scripts/kconfig/conf
  rm -rf include/config include/generated
  rm -f .config .config.old include/autoconf.mk include/autoconf.mk.dep include/config.h

在这里插入图片描述
在这里插入图片描述

make distclean

94 	ifeq ("$(origin V)", "command line")
95 	  KBUILD_VERBOSE = $(V)
96 	endif
97 	ifndef KBUILD_VERBOSE
98 	  KBUILD_VERBOSE = 0
99 	endif
100
101	ifeq ($(KBUILD_VERBOSE),1)
102	  quiet =
103	  Q =
104	else
105	  quiet=quiet_
106	  Q = @
107	endif
......
224	ifeq ($(KBUILD_SRC),)
225			# building in the source tree
226			srctree := .
227	else
228			ifeq ($(KBUILD_SRC)/,$(dir $(CURDIR)))
229					# building in a subdirectory of the source tree
230					srctree := ..
231			else
232					srctree := $(KBUILD_SRC)
233			endif
234	endif
......
470 export RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o    \
471			  -name CVS -o -name .pc -o -name .hg -o -name .git \) \
472			  -prune -o
......
2090 clean: rm-dirs  := $(CLEAN_DIRS)
2091 clean: rm-files := $(CLEAN_FILES)
2101 clean: $(clean-dirs)
2102 	$(call cmd,rmdirs)
2103 	$(call cmd,rmfiles)
2104	@find $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \
2105		\( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
2106		-o -name '*.ko.*' -o -name '*.su' -o -name '*.pyc' \
2107		-o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
2108		-o -name '*.lex.c' -o -name '*.tab.[ch]' \
2109		-o -name '*.asn1.[ch]' \
2110		-o -name '*.symtypes' -o -name 'modules.order' \
2111		-o -name modules.builtin -o -name '.tmp_*.o.*' \
2112		-o -name 'dsdt.aml' -o -name 'dsdt.asl.tmp' -o -name 'dsdt.c' \
2113		-o -name '*.efi' -o -name '*.gcno' -o -name '*.so' \) \
2114		-type f -print | xargs rm -f
......
2120 mrproper-dirs    := $(addprefix _mrproper_,scripts)
2123 $(mrproper-dirs) :
2124 	$(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@)
......
2118 mrproper: rm-dirs  := $(wildcard $(MRPROPER_DIRS))
2119 mrproper: rm-files := $(wildcard $(MRPROPER_FILES))
2126 mrproper: clean $(mrproper-dirs)
2127 	$(call cmd,rmdirs)
2128 	$(call cmd,rmfiles)
2129 	@rm -f arch/*/include/asm/arch
......
2135 distclean: mrproper
2136	@find $(srctree) $(RCS_FIND_IGNORE) \
2137		\( -name '*.orig' -o -name '*.rej' -o -name '*~' \
2138		-o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
2139		-o -name '.*.rej' -o -name '*%' -o -name 'core' \
2140		-o -name '*.pyc' \) \
2141		-type f -print | xargs rm -f
2142	@rm -f boards.cfg CHANGELOG

当在命令行中输入: make distclean V=1 时,94行条件成立,KBUILD_VERBOSE = 1,101行条件成立,quiet 和 Q 为空,则输出整个命令。
输入命令自动匹配顶层 Makefile 的第2135 行并执行,由于目标 distclean 依赖 mrproper, mrproper 依赖 clean 和 $(mrproper-dirs)执行顺序如下:

1. 优先执行依赖 clean,即 2090-2114行
2. 再执行依赖$(mrproper-dirs),即 2120-2124行
3. 上面两步完成 mrproper 依赖的实现,然后完成 mrproper 最后的实现语句,即2127-2129行
4. 经过上面三步完成 distclean 依赖的实现,最后完成 distclean 的实现语句,即2136-2142行

步骤1:2090-2114行,执行依赖 clean

2090	clean: rm-dirs  := $(CLEAN_DIRS)
2091	clean: rm-files := $(CLEAN_FILES)
2092
2093	clean-dirs	:= $(foreach f,$(u-boot-alldirs),$(if $(wildcard $(srctree)/$f/Makefile),$f))
2094
2095	clean-dirs      := $(addprefix _clean_, $(clean-dirs))
2096
2097
2098	$(clean-dirs):
2099		$(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
2100
2101	clean: $(clean-dirs)
2102		$(call cmd,rmdirs)
2103		$(call cmd,rmfiles)
2104		@find $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \
2105			\( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
2106			-o -name '*.ko.*' -o -name '*.su' -o -name '*.pyc' \
2107			-o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
2108			-o -name '*.lex.c' -o -name '*.tab.[ch]' \
2109			-o -name '*.asn1.[ch]' \
2110			-o -name '*.symtypes' -o -name 'modules.order' \
2111			-o -name modules.builtin -o -name '.tmp_*.o.*' \
2112			-o -name 'dsdt.aml' -o -name 'dsdt.asl.tmp' -o -name 'dsdt.c' \
2113			-o -name '*.efi' -o -name '*.gcno' -o -name '*.so' \) \
2114			-type f -print | xargs rm -f

从上面可以看出,clean 依赖 rm-dirs := $(CLEAN_DIRS)rm-files := $(CLEAN_FILES)$(clean-dirs)

2090行:clean 依赖 rm-dirs := $(CLEAN_DIRS),没有实现语句,所以这里只需要将依赖展开即可。
$(CLEAN_DIRS) 在顶层 Makefile 的第2069-2071行中定义,其中的 $(MODVERDIR) 在第466行中定义, foreach 函数、filter-out函数、patsubst函数、firstword函数

466   export MODVERDIR := $(if $(KBUILD_EXTMOD),$(firstword $(KBUILD_EXTMOD))/).tmp_versions
......
2069  CLEAN_DIRS  += $(MODVERDIR) \
2070			   $(foreach d, spl tpl, $(patsubst %,$d/%, \
2071				$(filter-out include, $(shell ls -1 $d 2>/dev/null))))

当命令行输入make M=dir,则 KBUILD_EXTMOD=dir,否则 KBUILD_EXTMOD 为空。由于命令行没有M=,所以MODVERDIR = .tmp_versions
2070行中的spl、tpl不存在,所以2070-2071行为空,最终展开为:

2090 clean:   rm-dirs := .tmp_versions

2091行:clean 依赖 rm-files := $(CLEAN_FILES),没有实现语句,所以这里只需要将依赖展开即可。
$(CLEAN_FILES) 在顶层 Makefile 的第2073-2077行中定义,

2073	CLEAN_FILES += include/bmp_logo.h include/bmp_logo_data.h tools/version.h \
2074			   boot* u-boot* MLO* SPL System.map fit-dtb.blob* \
2075			   u-boot-ivt.img.log u-boot-dtb.imx.log SPL.log u-boot.imx.log \
2076			   lpc32xx-* bl31.c bl31.elf bl31_*.bin image.map tispl.bin* \
2077			   idbloader.img flash.bin flash.log defconfig keep-syms-lto.c

最终展开为:

2091 clean: rm-files := include/bmp_logo.h include/bmp_logo_data.h tools/version.h boot* u-boot* MLO* SPL System.map fit-dtb.blob* u-boot-ivt.img.log u-boot-dtb.imx.log SPL.log u-boot.imx.log lpc32xx-* bl31.c bl31.elf bl31_*.bin image.map tispl.bin* idbloader.img flash.bin flash.log defconfig keep-syms-lto.c 

2101行:clean 依赖 $(clean-disrs),在第2093-2099行定义:

2093	clean-dirs	 := $(foreach f,$(u-boot-alldirs),$(if $(wildcard $(srctree)/$f/Makefile),$f))
2095	clean-dirs   := $(addprefix _clean_, $(clean-dirs))
2098	$(clean-dirs):
2099		$(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)

2093行:中的$(u-boot-alldirs)在顶层 Makefile 的第792-853行定义:其实就是从变量 $(u-boot-alldirs) 中轮询查找相应目录下是否存在 Makefile 文件,将有 Makefile 文件的目录名依次赋值给变量 clean-dirs。最终: $(clean-dirs) = $(u-boot-alldirs) [即:重新排序去重并且去除目录名最后的/后的 $(libs-) $(libs-y)]

2095行:将变量 $(clean-dirs) 中的所有内容前缀加上 _clean_
2099行:$(clean)在 scripts/Kbuild.include [顶层Makefile第386行中引用]文件的第202行定义: clean := -f $(srctree)/scripts/Makefile.clean obj
在顶层Makefile中,srctree = . 所以: clean := -f ./scripts/Makefile.clean obj
结果:/scripts/Makefile.clean分析,会将2098行目标中所有包含Makefile的目录及其子目录全部回显出来,执行并回显001-250行

001 make -f ./scripts/Makefile.clean obj=api
002 make -f ./scripts/Makefile.clean obj=cmd
......
250 rm -rf tools/lib tools/common

foreach函数、wildcard函数、sort函数、patsubst函数、filter函数、addprefix函数

792  HAVE_VENDOR_COMMON_LIB = $(if $(wildcard $(srctree)/board/$(VENDOR)/common/Makefile),y,n)
793
794  libs-y += lib/
795  libs-$(HAVE_VENDOR_COMMON_LIB) += board/$(VENDOR)/common/
796  libs-$(CONFIG_OF_EMBED) += dts/
797  libs-y += fs/
798  libs-y += net/
799  libs-y += disk/
800  libs-y += drivers/
801  libs-y += drivers/dma/
802  libs-y += drivers/gpio/
803  libs-y += drivers/i2c/
804  libs-y += drivers/net/
805  libs-y += drivers/net/phy/
806  libs-y += drivers/power/ \
807    drivers/power/domain/ \
808    drivers/power/fuel_gauge/ \
809    drivers/power/mfd/ \
810    drivers/power/pmic/ \
811    drivers/power/battery/ \
812    drivers/power/regulator/
813  libs-y += drivers/spi/
814  libs-$(CONFIG_FMAN_ENET) += drivers/net/fm/
815  libs-$(CONFIG_SYS_FSL_DDR) += drivers/ddr/fsl/
816  libs-$(CONFIG_SYS_FSL_MMDC) += drivers/ddr/fsl/
817  libs-$(CONFIG_$(SPL_)ALTERA_SDRAM) += drivers/ddr/altera/
818  libs-y += drivers/serial/
819  libs-y += drivers/usb/cdns3/
820  libs-y += drivers/usb/dwc3/
821  libs-y += drivers/usb/common/
822  libs-y += drivers/usb/emul/
823  libs-y += drivers/usb/eth/
824  libs-$(CONFIG_USB_DEVICE) += drivers/usb/gadget/
825  libs-$(CONFIG_USB_GADGET) += drivers/usb/gadget/
826  libs-$(CONFIG_USB_GADGET) += drivers/usb/gadget/udc/
827  libs-y += drivers/usb/host/
828  libs-y += drivers/usb/mtu3/
829  libs-y += drivers/usb/musb/
830  libs-y += drivers/usb/musb-new/
831  libs-y += drivers/usb/phy/
832  libs-y += drivers/usb/ulpi/
833  libs-y += cmd/
834  libs-y += common/
835  libs-y += env/
836  libs-$(CONFIG_API) += api/
837  ifdef CONFIG_POST
838  libs-y += post/
839  endif
840  libs-$(CONFIG_UNIT_TEST) += test/
841  libs-$(CONFIG_UT_ENV) += test/env/
842  libs-$(CONFIG_UT_OPTEE) += test/optee/
843  libs-$(CONFIG_UT_OVERLAY) += test/overlay/
844
845  libs-y += $(if $(BOARDDIR),board/$(BOARDDIR)/)
846
847  libs-y := $(sort $(libs-y))
848
849  u-boot-dirs  := $(patsubst %/,%,$(filter %/, $(libs-y))) tools examples
850
851  u-boot-alldirs  := $(sort $(u-boot-dirs) $(patsubst %/,%,$(filter %/, $(libs-))))
852

其中所有的变量都未定义,所以 lib- libs-y 变量定义如下:

libs-libs-y
dts/ ;drivers/net/fm/;
drivers/ddr/fsl/
drivers/ddr/fsl/
drivers/ddr/altera/;
drivers/usb/gadget/
drivers/usb/gadget/
drivers/usb/gadget/udc/;
api/;test/ ;test/env/ ;test/optee/ ;test/overlay/;
lib/ ; fs/Cnet/ ; disk/ ; drivers/ ; drivers/dma/ ;drivers/gpio/ ; drivers/i2c/ ; drivers/net/ ; drivers/net/phy/ ; drivers/power/ ; drivers/power/domain/ ; drivers/power/fuel_gauge/ ; drivers/power/mfd/ ; drivers/power/pmic/ ; drivers/power/battery/drivers/power/regulator/ ; drivers/spi/ ; drivers/serial/ ; drivers/usb/cdns3/ ; drivers/usb/dwc3/ ; drivers/usb/common/ ; drivers/usb/emul/ ; drivers/usb/eth/ ; drivers/usb/host/ ; drivers/usb/mtu3/ ; drivers/usb/musb/ ; drivers/usb/musb-new/ ; drivers/usb/phy/ ; drivers/usb/ulpi/ ; cmd/ ; common/ ; env/ ;

第849行,将 $(libs-y) 变量最后一个/去除后的变量,并且追加 tools examples到变量 $(u-boot-dirs)
第851行,将 $(libs-) 变量最后一个/去除后的变量 和 变量 $(u-boot-dirs) 一起重新排序去重后赋值给变量 $(u-boot-alldirs)

2102行:call函数、cmd函数分析,cmd_rmdir 函数:rm -rf $(rm-dirs)
结果:依据上面2090行分析,执行并回显251行命令。

251 rm -rf .tmp_versions 

2103行:call函数、cmd函数分析,cmd_rmfiles 函数:rm -f $(rm-files)
结果:依据上面2091行分析,执行并回显252行命令。

252  rm -f include/bmp_logo.h include/bmp_logo_data.h tools/version.h boot* u-boot* MLO* SPL System.map fit-dtb.blob* u-boot-ivt.img.log u-boot-dtb.imx.log SPL.log u-boot.imx.log lpc32xx-* bl31.c bl31.elf bl31_*.bin image.map tispl.bin* idbloader.img flash.bin flash.log defconfig keep-syms-lto.c

2104行:在顶层Makefile中显示只有当命令行上中输入make M=dir时,KBUILD_EXTMOD=dir,否则KBUILD_EXTMOD为空,由于命令行上没有输入M,所以KBUILD_EXTMOD为空。顶层Makefile中第470行定义RCS_FIND_IGNORE为:

470 export RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS -o -name .pc -o -name .hg -o -name .git \) -prune -o
find命令参数
@:表示不回显
find:用于查找特定文件或目录的命令(在当前目录下能查找SCCS等 则执行-prune, 否则,就print出来)
-name:查找的名称
-o:或者
-prune:忽略一个目录及其之下的文件
-type:类型【f 表示文件,d 表示目录】
-print:显示文件名
xargs:把 find 找出的文件一个一个处理

结果:查找并删除编译后产生的中间文件或目标文件,不回显。

步骤2:2120-2124行,执行依赖 $(mrproper-dirs)

2120 mrproper-dirs   := $(addprefix _mrproper_,scripts)
2123 $(mrproper-dirs):
2124     $(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@)

由于addprefix函数、patsubst函数和上面 2099行分析可知,最终展开为:

_mrproper_scripts:
    make -f ./scripts/Makefile.clean obj=scripts

2124行: /scripts/Makefile.clean分析,
结果:执行并回显253-260行

253 make -f ./scripts/Makefile.clean obj=scripts
254 make -f ./scripts/Makefile.clean obj=scripts/basic
255   rm -f scripts/basic/fixdep scripts/basic/fixdep
256 make -f ./scripts/Makefile.clean obj=scripts/dtc
257 make -f ./scripts/Makefile.clean obj=scripts/dtc/pylibfdt
258   rm -f scripts/dtc/dtc scripts/dtc/dtc
259 make -f ./scripts/Makefile.clean obj=scripts/kconfig
260   rm -f scripts/kconfig/conf

步骤3:2118-2129行,执行依赖 mrproper

2118 mrproper: rm-dirs  := $(wildcard $(MRPROPER_DIRS)) 
2119 mrproper: rm-files := $(wildcard $(MRPROPER_FILES))
2126 mrproper: clean $(mrproper-dirs)
2127 	  $(call cmd,rmdirs)
2128      $(call cmd,rmfiles)
2129	  @rm -f arch/*/include/asm/arch

从上面可以看出,mrproper 依赖 rm-dirs := $(wildcard $(MRPROPER_DIRS))rm-files := $(wildcard $(MRPROPER_FILES))clean$(mrproper-dirs)

2118行:mrproper 依赖 rm-dirs := $(wildcard $(MRPROPER_DIRS)),没有实现语句,所以这里只需要将依赖展开即可。
$(MRPROPER_DIRS) 在顶层 Makefile 的第2080-2081行中定义,

2080	MRPROPER_DIRS  += include/config include/generated spl tpl \
2081		  .tmp_objdiff doc/output

wildcard 函数分析,最终展开为:

2118 mrproper : rm-dirs :=include/config include/generated	#编译后会产生这两个文件夹2118 mrproper : rm-dirs :=	#未编译定义的文件夹都不存在

结果:执行并回显261行

261  rm -rf include/config include/generated	#编译后261  rm -f 	#未编译

2119行:mrproper 依赖 rm-files := $(wildcard $(MRPROPER_FILES)),没有实现语句,所以这里只需要将依赖展开即可。
$(MRPROPER_FILES) 在顶层 Makefile 的第2084-2086行中定义,

2084 MRPROPER_FILES += .config .config.old include/autoconf.mk* include/config.h \
2085		  ctags etags tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \
2086		  drivers/video/fonts/*.S include/asm

wildcard 函数分析,最终展开为:

2091 mrproper : rm-files :=.config .config.old include/autoconf.mk include/autoconf.mk.dep include/config.h	#编译后会产生这些文件2091 mrproper : rm-files :=	#未编译定义的文件都不存在

结果:执行并回显262行

262  rm -f .config .config.old include/autoconf.mk include/autoconf.mk.dep include/config.h	 #编译后262  rm -f 	#未编译

2126行:依赖 clean$(mrproper-dirs) 分别在步骤1和步骤2中实现。

2127行:同2102行分析一样,由于第2102行已经删去了相应文件夹(不回显),所以这里实际执行的是rm -rf

2128行:同2103行分析一样,由于第2103行已经删去了相应文件(不回显),所以这里实际执行的是rm -f

2129行:删除arch/*/include/asm/arch(不回显)

步骤4:2135-2142行,实现 distclean

2135 distclean: mrproper
2136 	@find $(srctree) $(RCS_FIND_IGNORE) \
2137 		\( -name '*.orig' -o -name '*.rej' -o -name '*~' \
2138 		-o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
2139 		-o -name '.*.rej' -o -name '*%' -o -name 'core' \
2140 		-o -name '*.pyc' \) \
2141 		-type f -print | xargs rm -f
2142 	@rm -f boards.cfg CHANGELOG

2135行:依赖 mrproper 在步骤3中实现。
2136行:在顶层Makefile中显示只有当命令行上中输入make M=dir时,KBUILD_EXTMOD=dir,否则KBUILD_EXTMOD为空,由于命令行上没有输入M,所以KBUILD_EXTMOD为空。顶层Makefile中第470行定义RCS_FIND_IGNORE为:

470 export RCS_FIND_IGNORE := \( -name SCCS -o -name BitKeeper -o -name .svn -o -name CVS -o -name .pc -o -name .hg -o -name .git \) -prune -o
find命令参数
@:表示不回显
find:用于查找特定文件或目录的命令(在当前目录下能查找SCCS等 则执行-prune, 否则,就print出来)
-name:查找的名称
-o:或者
-prune:忽略一个目录及其之下的文件
-type:类型【f 表示文件,d 表示目录】
-print:显示文件名
xargs:把 find 找出的文件一个一个处理

结果:查找并删除编译后产生的中间文件或目标文件,不回显。
2142行:删除boards.cfg CHANGELOG,不回显。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/653439.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

小阿轩yx-Shell 编程之循环语句与函数

小阿轩yx-Shell 编程之循环语句与函数 for 循环语句 可以很好地解决顺序编写异常烦琐、困难重重的全部代码 (){}:里边写的都是命令 ):不能嵌套 $():可以嵌套,适合更…

全球伦敦银收盘时间一致吗

跟伦敦金市场相似,伦敦银市场也是一个全球化的无形市场,无论来自世界上什么地方的投资者参与其中,都可以得到全天接近24个小时的连贯行情,只要精力足够,根本不用担心没有交易获利的机会。但由于交易平台始终有维护的需…

Linux:线程

文章目录 前言1. 线程概念1.1 什么是线程1.2 线程比进程更加轻量化1.3 虚拟地址到物理地址的转化物理内存的管理页表 1.4 线程的优点1.5 线程的缺点1.6 线程异常1.7 线程用途 2. 进程 vs 线程3. 线程控制3.1 线程创建3.2 线程退出3.3 线程等待3.4 分离线程3.5 线程取消 4. 线程…

磁盘问题——外部、动态,无法读取

今天,小编又遇到事了,给同事换个电脑,要把他原来的硬盘拆过去,一开始电脑都准备好了,就差拆他的硬盘了,结果装过去,问题来啦!如下图所示: 这下可咋搞呢!我先用…

专业145+总410+成电电子科技大学858信号与系统考研经验电子信息与通信工程,抗干扰,空天,资环,真题,大纲,参考书。

今年考研总分410,专业课858信号与系统145,顺利上岸成电,毕设已经搞得七七八八,就等毕业了,抽空整理回顾一下去年的复习,给群里的同学提供一些参加,少走弯路,对于整体复习的把握有个大概得规划。…

抽象类和接口(2)

1、接口 1、接口的概念 接口就是公共的行为规范标准,大家在实现时,只要符合规范标准,就可以通用。 在Java中,接口可以看成是:多个类的公共规范,是一种引用数据类型。 2、语法规则 接口的定义格式与定义…

Python考试练习题---day1

1.计算2的n次幂结果的后3位 获得用户输入的一个数字N,计算并输出2的N次幂结果的后3位。 【输出样例】-----因为2的10次方等于1024 输入10输出024 ninput() print(str(2**eval(n))[-3:]) 2.分割四位正整数 例1: 编写程序,提示用户从键盘…

2、python环境的安装-mac系统下

打开官网,downloads下边有macOS,点击: 选择最新版本,点击,进入下边的页面,一直往下滑,看到files中有个macOS的版本,点击下载 点击下载后是pkg的安装包,点击安装。 一步步…

350种类型、10W+量级的API,企业应该怎么管?

忽如一夜春风来,万物皆可API。 在互联网时代,API无处不在:企业对外开放的数据、服务和业务能力,以API的形式提供给合作方;企业内部应用与应用、App与App之间的通信,通过API进行;甚至应用内部的…

机器视觉HALCON:3.图像获取,运算,率噪,滤波(边缘),锐化

目录 图像获取生成单通道图像图像运算加法运算减法运算乘法运算除法 仿射变换图像平滑(噪点处理)高斯滤波均值滤波中值滤波多图像均值 边缘滤波索贝尔滤波凯尼滤波 图像锐化索贝尔锐化拉普拉斯锐化高通滤波锐化几种锐化方式对比 图像获取 用到的函数&…

液氮罐内部会污染吗

液氮罐是一种常见的存储液态氮的设备,广泛应用于科研、生物医药、食品冷冻等领域。但是,人们对于液氮罐内部是否会产生污染一直存在疑问。 我们来看液氮罐内部可能的污染源。液氮罐内部主要存在以下几种潜在的污染来源:气体污染、杂质污染、…

MySQL数据处理增删改

数据处理增删改DML 由于约束,以下操作都有可能执行失败(后面讲约束) 插入数据 INSERT 基础添加:VALUES 值的顺序必须和表中字段顺序相同 INSERT INTO class VALUES(1,王小,10); 向指定字段添加: 值的顺序和指定…

使用canarytokens进行入侵检测

canarytokens 基本概念 canarytokens是一种用于识别网络入侵的工具。它们是一种虚拟的“蜜罐”,可以在网络上放置,当有人尝试访问它们时,可以立即触发警报,以便及时发现潜在的安全威胁。这些token可以是各种形式,可以…

工业触摸屏一般用哪种

工业触摸屏一般使用以下几种类型:1.电阻式触摸屏:电阻式触摸屏是最常见和常用的工业触摸屏类型之一。它由两层导电层组成,当屏幕上的物体接触到触摸屏时,两个导电层之间会发生电阻变化,触摸点的坐标信息可以通过测量电…

不仅能逃生,更能自动灭火!神奇的全氟己酮灭火毯的原理是什么?

很多朋友对灭火毯的印象,还停留在火灾发生时披覆在身上逃生时使用,可以隔离火源。近年来兴起的全氟己酮自动灭火毯可以说大为颠覆大家的想法,这是一条真的可以自动灭火的神奇灭火毯!为什么能做到这一点?全氟己酮灭火毯…

黑马聚合的分类及实现

1、什么是聚合? 聚合是对文档数据的统计、分析、计算 聚合的常见种类有哪些? 桶(Bucket)聚合:用来对文档做分组 TermAggregation:按照文档字段值分组 Date Histogram:按照日期阶梯分组,例如一周为一组,或者一月为一组 度量(…

LVM与磁盘配额09

一、LVM 1、lvm概述 lvm (logical volume manager ):逻辑卷管理 linux系统下对硬盘分区的一种管理机制。 场景:lvm机制特别适合于管理大存储设备。 作用:可以动态的对硬盘进行扩容 。 逻辑上的磁盘,概…

IP协议说明

文章目录 前言一、IP协议的简介二、IP数据报1.IP 数据报结构2.IP 数据报的分片解析3.IP 数据报的分片重装 三、IP 数据报的输出四、IP 数据报的输入 前言 IP 指网际互连协议, Internet Protocol 的缩写,是 TCP/IP 体系中的网络层协议。设计 IP 的目的是…

QGis3.34.5工具软件保存样式,软件无反应问题

在使用QGis软件保存SLD样式的时候,每次保存样式,软件都进入无反应状态,导致无法生成样式文件 百度中多次查询问题点,终未能在在3.34.5这个版本上解决问题。 考虑到可能是软件本身问题,于是删除了3.34.5这个版本&#x…

Java面试八股之自旋是什么意思

Java中的自旋是什么意思 自旋是多线程编程中的一种同步机制,尤其在Java中与锁的实现密切相关。当一个线程尝试获取某个锁(如内置锁或显式锁)时,如果锁已被其他线程持有,通常的做法是将该线程置于阻塞状态,…