本文以U-boot的配置過程為背景,本文所介紹的方法不局限于解讀U-boot
的Makefile钢颂,同樣適用于linux
和busybox
等開源軟件钞它。
U-boot配置的執(zhí)行命令是
make -C $BOOTLDR_PATH ARCH=arm CROSS_COMPILE=$CROSS_COMPILER_KERNEL_PREFIX s3c2440_config \
--debug=basic > make_boot_config.log
執(zhí)行完后make_boot_config.log
的內(nèi)容是
GNU Make 3.81
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
This program built for x86_64-redhat-linux-gnu
正在讀入 makefiles...
make[1]: Entering directory `/disk2/boot'
make[1]: Leaving directory `/disk2/boot'
GNU Make 3.81
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
This program built for x86_64-redhat-linux-gnu
正在讀入 makefiles...
Updating goal targets....
文件“s3c2440_config”不存在。
文件“unconfig”不存在殊鞭。
必須重新創(chuàng)建目標(biāo)“unconfig”遭垛。
make[1]: Entering directory `/disk2/boot'
重新創(chuàng)建目標(biāo)文件“unconfig”成功。
必須重新創(chuàng)建目標(biāo)“s3c2440_config”操灿。
Configuring for s3c2440 board...
重新創(chuàng)建目標(biāo)文件“s3c2440_config”成功锯仪。
make[1]: Leaving directory `/disk2/boot'
可以看到,下面這些內(nèi)容重復(fù)出現(xiàn)牲尺,并且也不是我們跟蹤Makefile想要了解的信息卵酪。
GNU Make 3.81
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
This program built for x86_64-redhat-linux-gnu
正在讀入 makefiles...
Updating goal targets....
利用sed
來處理一下這個文件幌蚊,新建文件make_info_del.sed
/GNU Make 3.81/,/PARTICULAR PURPOSE./d
/This program built for x86_64-redhat-linux-gnu/d
/Updating goal targets..../d
/makefiles...$/d
執(zhí)行命令
cat make_boot_config.log | sed -f make_info_del.sed > make_boot_config.log.1
生成文件的內(nèi)容是
make[1]: Entering directory `/disk2/boot'
make[1]: Leaving directory `/disk2/boot'
文件“s3c2440_config”不存在谤碳。
文件“unconfig”不存在。
必須重新創(chuàng)建目標(biāo)“unconfig”溢豆。
make[1]: Entering directory `/disk2/boot'
重新創(chuàng)建目標(biāo)文件“unconfig”成功蜒简。
必須重新創(chuàng)建目標(biāo)“s3c2440_config”。
Configuring for s3c2440 board...
重新創(chuàng)建目標(biāo)文件“s3c2440_config”成功漩仙。
make[1]: Leaving directory `/disk2/boot'
這個時候我們就可以很方便的理清u-boot配置時Makefile
中目標(biāo)的依賴關(guān)系搓茬,s3c2440_config
依賴unconfig
,上面U-boot配置的依賴關(guān)系很簡單队他,不太過癮卷仑,稍后我們來利用這種方法說明一下U-boot編譯過程中的依賴關(guān)系,傳送門uboot 2013.04版編譯過程及原理說明麸折。