[Author: Bo Shen <voice.shen@gmail.com>

[u-boot: 2014.01-rc1]

u-boot的Makefile中包括以下几个清除命令:unconfig, clean, tidy, clobber, mrproper, distclean。另外,涉及一个backup命令。

下面具体分析每一个清除所做的工作。

1. unconfig

766 unconfig:
767         @rm -f $(obj)include/config.h $(obj)include/config.mk \
768                 $(obj)board/*/config.tmp $(obj)board/*/*/config.tmp \
769                 $(obj)include/autoconf.mk $(obj)include/autoconf.mk.dep \
770                 $(obj)include/spl-autoconf.mk \
771                 $(obj)include/tpl-autoconf.mk

unconfig就是对一些自动生成的文件进行删除。

2. clean

783 clean:
784         @rm -f $(obj)examples/standalone/82559_eeprom                     \
785                $(obj)examples/standalone/atmel_df_pow2                    \
786                $(obj)examples/standalone/eepro100_eeprom                  \
787                $(obj)examples/standalone/hello_world                      \
788                $(obj)examples/standalone/interrupt                        \
789                $(obj)examples/standalone/mem_to_mem_idma2intr             \
790                $(obj)examples/standalone/sched                            \
791                $(obj)examples/standalone/smc911{11,x}_eeprom              \
792                $(obj)examples/standalone/test_burst                       \
793                $(obj)examples/standalone/timer
794         @rm -f $(obj)examples/api/demo{,.bin}
795         @rm -f $(obj)tools/bmp_logo        $(obj)tools/easylogo/easylogo  \
796                $(obj)tools/env/{fw_printenv,fw_setenv}                    \
797                $(obj)tools/envcrc                                         \
798                $(obj)tools/gdb/{astest,gdbcont,gdbsend}                   \
799                $(obj)tools/gen_eth_addr    $(obj)tools/img2srec           \
800                $(obj)tools/mk{env,}image   $(obj)tools/mpc86x_clk         \
801                $(obj)tools/mk{$(BOARD),}spl                               \
802                $(obj)tools/mxsboot                                        \
803                $(obj)tools/ncb             $(obj)tools/ubsha1             \
804                $(obj)tools/kernel-doc/docproc                             \
805                $(obj)tools/proftool
806         @rm -f $(obj)board/cray/L1/{bootscript.c,bootscript.image}        \
807                $(obj)board/matrix_vision/*/bootscript.img                 \
808                $(obj)board/voiceblue/eeprom                               \
809                $(obj)u-boot.lds                                           \
810                $(obj)arch/blackfin/cpu/init.{lds,elf}
811         @rm -f $(obj)include/bmp_logo.h
812         @rm -f $(obj)include/bmp_logo_data.h
813         @rm -f $(obj)lib/asm-offsets.s
814         @rm -f $(obj)include/generated/asm-offsets.h
815         @rm -f $(obj)$(CPUDIR)/$(SOC)/asm-offsets.s
816         @rm -f $(TIMESTAMP_FILE) $(VERSION_FILE)
817         @$(MAKE) -s -C doc/DocBook/ cleandocs
818         @find $(OBJTREE) -type f \
819                 \( -name 'core' -o -name '*.bak' -o -name '*~' -o -name '*.su' \
820                 -o -name '*.o'  -o -name '*.a' -o -name '*.exe' \
821                 -o -name '*.cfgtmp' \) -print \
822                 | xargs rm -f

818~822: The find "-print"参数:man find后可查找到对此的解释如下:

—>8—

print the full file name on the standard output, followed by a newline. If you are piping the output of find into another program and there is the faintest possibility that the files which you are searching for might contain a newline, then you should seriously consider using the "-print0" option instead of "-print".

—8<—

3. tidy

825 tidy:   clean
826         find $(OBJTREE) -type f \( -name '*.depend*' \) -print | xargs rm -f

tidy在clean的基础上,对depend文件进行删除。

4. clobber

828 clobber:        tidy
829         @find $(OBJTREE) -type f \( -name '*.srec' \
830                 -o -name '*.bin' -o -name u-boot.img \) \
831                 -print0 | xargs -0 rm -f
832         @rm -f $(OBJS) $(obj)*.bak $(obj)ctags $(obj)etags $(obj)TAGS \
833                 $(obj)cscope.* $(obj)*.*~
834         @rm -f $(obj)u-boot $(obj)u-boot.map $(obj)u-boot.hex $(ALL-y)
835         @rm -f $(obj)u-boot.kwb
836         @rm -f $(obj)u-boot.pbl
837         @rm -f $(obj)u-boot.imx
838         @rm -f $(obj)u-boot-with-spl.imx
839         @rm -f $(obj)u-boot-with-nand-spl.imx
840         @rm -f $(obj)u-boot.ubl
841         @rm -f $(obj)u-boot.ais
842         @rm -f $(obj)u-boot.dtb
843         @rm -f $(obj)u-boot.sb
844         @rm -f $(obj)u-boot.bd
845         @rm -f $(obj)u-boot.spr
846         @rm -f $(obj)nand_spl/{u-boot.{lds,lst},System.map}
847         @rm -f $(obj)nand_spl/{u-boot-nand_spl.lds,u-boot-spl,u-boot-spl.map}
848         @rm -f $(obj)spl/{u-boot-spl,u-boot-spl.bin,u-boot-spl.map}
849         @rm -f $(obj)spl/u-boot-spl.lds
850         @rm -f $(obj)tpl/{u-boot-tpl,u-boot-tpl.bin,u-boot-tpl.map}
851         @rm -f $(obj)tpl/u-boot-spl.lds
852         @rm -f $(obj)MLO MLO.byteswap
853         @rm -f $(obj)SPL
854         @rm -f $(obj)tools/xway-swap-bytes
855         @rm -fr $(obj)include/asm/proc $(obj)include/asm/arch $(obj)include/asm
856         @rm -fr $(obj)include/generated
857         @[ ! -d $(obj)nand_spl ] || find $(obj)nand_spl -name "*" -type l -print | xargs rm -f
858         @rm -f $(obj)dts/*.tmp
859         @rm -f $(obj)spl/u-boot-spl{,-pad}.ais

clobber在tidy的基础上更进一步的进行删除操作。

829~831: The find "-print0"参数:man find后可查找到对此的解释如下:

—>8—

print the full file name on the standard output, followed by a null character (instead of the newline character that "-print" uses). This allows file names that contain newlines or other types of white space to be correctly interpreted by programs that process the find output. This option corresponds to the -0 option of xargs.

—8<—

5. mrproper/distclean

861 mrproper \
862 distclean:      clobber unconfig
863 ifneq ($(OBJTREE),$(SRCTREE))
864         rm -rf $(obj)*
865 endif

mrproper与distclean进行的操作是一样的。在clobber与unconfig的基础上,看是否需要将obj目录删除。

6. backup.

867 backup:
868         F=`basename $(TOPDIR)` ; cd .. ; \
869         gtar --force-local -zcvf `LC_ALL=C date "+$$F-%Y-%m-%d-%T.tar.gz"` $$F

将源代码打成一个gzip的tar包。

gtar命令可能没有:workaround –> ln -s /bin/tar /bin/gtar