【记录】尝试分析Buildroot在make menuconfig后make时的内部执行逻辑

【背景】

折腾:

【已解决】Cygwin下为xscale编译BuildRoot时make出错:/bin/sh: -c: line 0: syntax error near unexpected token `(‘

期间,需要去分析Buildroot的make的逻辑。

对于Buildroot在make menuconfig后,(又去make clean了一下,然后)去make,此时的输出是:

CLi@PC-CLI-1 ~/develop/buildroot/buildroot-2013.05
$ make
/usr/bin/make -j4  HOSTCC="/usr/bin/gcc" HOSTCXX="/usr/bin/g++" silentoldconfig
make[1]: Entering directory `/home/CLi/develop/buildroot/buildroot-2013.05'
mkdir -p /home/CLi/develop/buildroot/buildroot-2013.05/output/build/buildroot-config/lxdialog
/usr/bin/make CC="/usr/bin/gcc" HOSTCC="/usr/bin/gcc" obj=/home/CLi/develop/buildroot/buildroot-2013.05/output/build/buildroot-config -C support/kconfig -f Makefile.br conf
make[2]: Entering directory `/home/CLi/develop/buildroot/buildroot-2013.05/support/kconfig'
/usr/bin/gcc -I/usr/include/ncursesw -DCURSES_LOC="<ncursesw/curses.h>"  -DNCURSES_WIDECHAR=1 -DLOCALE -DKBUILD_NO_NLS -I/home/CLi/develop/buildroot/buildroot-2013.05/output/build/buildroot-config -DCONFIG_=\"\"  -MM *.c > /home/CLi/develop/buildroot/buildroot-2013.05/output/build/buildroot-config/.depend 2>/dev/null || :
make[2]: Leaving directory `/home/CLi/develop/buildroot/buildroot-2013.05/support/kconfig'
make[2]: Entering directory `/home/CLi/develop/buildroot/buildroot-2013.05/support/kconfig'
/usr/bin/gcc -I/usr/include/ncursesw -DCURSES_LOC="<ncursesw/curses.h>"  -DNCURSES_WIDECHAR=1 -DLOCALE -DKBUILD_NO_NLS -I/home/CLi/develop/buildroot/buildroot-2013.05/output/build/buildroot-config -DCONFIG_=\"\"   -c conf.c -o /home/CLi/develop/buildroot/buildroot-2013.05/output/build/buildroot-config/conf.o
/usr/bin/gcc -I/usr/include/ncursesw -DCURSES_LOC="<ncursesw/curses.h>"  -DNCURSES_WIDECHAR=1 -DLOCALE -DKBUILD_NO_NLS -I/home/CLi/develop/buildroot/buildroot-2013.05/output/build/buildroot-config -DCONFIG_=\"\"  -I. -c /home/CLi/develop/buildroot/buildroot-2013.05/output/build/buildroot-config/zconf.tab.c -o /home/CLi/develop/buildroot/buildroot-2013.05/output/build/buildroot-config/zconf.tab.o
In file included from /home/CLi/develop/buildroot/buildroot-2013.05/output/build/buildroot-config/zconf.tab.c:2500:0:
./confdata.c: In function ‘conf_split_config’:
./confdata.c:849:6: warning: assignment makes pointer from integer without a cast [enabled by default]
/usr/bin/gcc -I/usr/include/ncursesw -DCURSES_LOC="<ncursesw/curses.h>"  -DNCURSES_WIDECHAR=1 -DLOCALE -DKBUILD_NO_NLS -I/home/CLi/develop/buildroot/buildroot-2013.05/output/build/buildroot-config -DCONFIG_=\"\"   /home/CLi/develop/buildroot/buildroot-2013.05/output/build/buildroot-config/conf.o /home/CLi/develop/buildroot/buildroot-2013.05/output/build/buildroot-config/zconf.tab.o  -o /home/CLi/develop/buildroot/buildroot-2013.05/output/build/buildroot-config/conf
rm /home/CLi/develop/buildroot/buildroot-2013.05/output/build/buildroot-config/zconf.tab.c
make[2]: Leaving directory `/home/CLi/develop/buildroot/buildroot-2013.05/support/kconfig'
BR2_DEFCONFIG='' KCONFIG_AUTOCONFIG=/home/CLi/develop/buildroot/buildroot-2013.05/output/build/buildroot-config/auto.conf KCONFIG_AUTOHEADER=/home/CLi/develop/buildroot/buildroot-2013.05/output/build/buildroot-config/autoconf.h KCONFIG_TRISTATE=/home/CLi/develop/buildroot/buildroot-2013.05/output/build/buildroot-config/tristate.config BUILDROOT_CONFIG=/home/CLi/develop/buildroot/buildroot-2013.05/.config /home/CLi/develop/buildroot/buildroot-2013.05/output/build/buildroot-config/conf --silentoldconfig Config.in
make[1]: Leaving directory `/home/CLi/develop/buildroot/buildroot-2013.05'
mkdir -p /home/CLi/develop/buildroot/buildroot-2013.05/output/target
rsync -a \
                --exclude .empty --exclude .svn --exclude .git \
                --exclude .hg --exclude=CVS --exclude '*~' \
                /home/CLi/develop/buildroot/buildroot-2013.05/system/skeleton/ /home/CLi/develop/buildroot/buildroot-2013.05/output/target/
cp support/misc/target-dir-warning.txt /home/CLi/develop/buildroot/buildroot-2013.05/output/target/THIS_IS_NOT_YOUR_ROOT_FILESYSTEM
touch /home/CLi/develop/buildroot/buildroot-2013.05/output/build/.root
>>> host-ccache 3.1.8 Extracting
bzcat /home/CLi/develop/buildroot/buildroot-2013.05/dl/ccache-3.1.8.tar.bz2 | tar --strip-components=1 -C /home/CLi/develop/buildroot/buildroot-2013.05/output/build/host-ccache-3.1.8  -xf -
>>> host-ccache 3.1.8 Patching package//ccache
>>> host-ccache 3.1.8 Updating config.sub and config.guess
for file in config.guess config.sub; do for i in $(find /home/CLi/develop/buildroot/buildroot-2013.05/output/build/host-ccache-3.1.8 -name $file); do cp support/gnuconfig/$file $i; done; done
>>> host-ccache 3.1.8 Patching libtool
>>> host-ccache 3.1.8 Configuring
(cd /home/CLi/develop/buildroot/buildroot-2013.05/output/build/host-ccache-3.1.8/ && rm -rf config.cache; PATH=/home/CLi/develop/buildroot/buildroot-2013.05/output/host/bin:/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/bin:/home/CLi/develop/crosstool-ng/x-tools/arm-xscale-linux-gnueabi/bin:/opt/crosstool-ng/bin:/home/CLi/develop/crosstool-ng/x-tools/armxscalecurl/bin:/usr/local/bin:/usr/bin:/cygdrive/d/tmp/dev_install_root/Python27_x64:/cygdrive/d/tmp/dev_install_root/Python27_x64/Lib/site-packages/PyQt4:/cygdrive/d/tmp/dev_install_root/Perl64/site/bin:/cygdrive/d/tmp/dev_install_root/Perl64/bin:/cygdrive/c/Program Files/Common Files/Microsoft Shared/Windows Live:/cygdrive/c/Program Files (x86)/Common Files/Microsoft Shared/Windows Live:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0:/cygdrive/c/Program Files (x86)/Microsoft SQL Server/100/Tools/Binn:/cygdrive/c/Program Files/Microsoft SQL Server/100/Tools/Binn:/cygdrive/c/Program Files/Microsoft SQL Server/100/DTS/Binn:/cygdrive/d/tmp/WordPress/mysql/mysql-5.5.18/MySQL/MySQL Server 5.5/bin:/cygdrive/d/tmp/WordPress/DevRoot/MySQL/MySQL Server 5.5/bin:/cygdrive/d/tmp/WordPress/DevRoot/php-5.3.6-Win32-VC9-x64:/cygdrive/d/tmp/WordPress/DevRoot/php-5.3.6-Win32-VC9-x64/ext:/cygdrive/d/tmp/WordPress/DevRoot/Python27:/cygdrive/c/Program Files (x86)/Common Files/Acronis/SnapAPI:/cygdrive/c/Program Files (x86)/Windows Live/Shared:/cygdrive/c/Program Files/Java/jdk1.7.0_11/bin:/home/CLi/develop/docbook/tools/fop/lib:/home/CLi/develop/docbook/tools/fop:/cygdrive/d/DevInstallRoot/FF/DD_IDE_1.1.2/TOK/BIN:/cygdrive/d/DevInstallRoot/FF/DD_IDE_1.2.0/TOK/BIN:/cygdrive/d/DevRoot/EmbeddedDevelop/trunk/Research/CLI/FF/FBK/develop/tools/develop-tools:/cygdrive/d/tmp/WordPress/DevRoot/Python27/Scripts:/cygdrive/d/tmp/dev_install_root/PostgreSQL/8.3/bin:/cygdrive/d/tmp/dev_install_root/ant/apache-ant-1.8.4/bin:/cygdrive/c/Program Files/nodejs:/cygdrive/c/Program Files/Microsoft/Web Platform Installer:/cygdrive/c/Program Files/TortoiseSVN/bin:/cygdrive/d/DevRoot/IndustrialMobileAutomation/HandheldDataSetter/ANTLR/batchFile:/cygdrive/c/Program Files (x86)/QuickTime/QTSystem:/cygdrive/d/tmp/tmp_dev_root/android/adt-bundle-windows/sdk/platform-tools:/cygdrive/d/tmp/dev_install_root/Tesseract-OCR:/cygdrive/d/tmp/dev_install_root/jython2.5.3/bin:/cygdrive/d/devinstallroot/gnuarm/bin:/cygdrive/d/tmp/dev_install_root/HTML Help Workshop:/cygdrive/c/Users/CLi/AppData/Roaming/npm:/usr/lib/lapack:/opt/gcc-4.0.4-glibc-2.3.6-kernel-2.6.17/sysroot-arm-xscale-linux-gnu/usr/include:/opt/gcc-4.0.4-glibc-2.3.6-kernel-2.6.17/sysroot-arm-xscale-linux-gnu/usr/include/linux AR="/usr/bin/ar" AS="/usr/bin/as" LD="/usr/bin/ld" NM="/usr/bin/nm" CC="/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/bin/ccache /usr/bin/gcc" GCC="/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/bin/ccache /usr/bin/gcc" CXX="/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/bin/ccache /usr/bin/g++" CPP="/usr/bin/cpp" CPPFLAGS="-I/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/include" CFLAGS="-O2 -I/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/include" CXXFLAGS="-O2 -I/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/include" LDFLAGS="-L/home/CLi/develop/buildroot/buildroot-2013.05/output/host/lib -L/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/lib -Wl,-rpath,/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/lib" PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 PKG_CONFIG="/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/bin/pkg-config" PKG_CONFIG_SYSROOT_DIR="/" PKG_CONFIG_LIBDIR="/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/lib/pkgconfig:/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/share/pkgconfig" PERLLIB="/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/lib/perl" LD_LIBRARY_PATH="/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/lib:" CFLAGS="-O2 -I/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/include" LDFLAGS="-L/home/CLi/develop/buildroot/buildroot-2013.05/output/host/lib -L/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/lib -Wl,-rpath,/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/lib" CC="/usr/bin/gcc" ./configure --prefix="/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr" --sysconfdir="/home/CLi/develop/buildroot/buildroot-2013.05/output/host/etc" --enable-shared --disable-static --disable-gtk-doc --disable-doc --disable-docs --disable-documentation --with-xmlto=no --with-fop=no ccache_cv_zlib_1_2_3=no )
/bin/sh: -c: line 0: syntax error near unexpected token `('
/bin/sh: -c: line 0: `(cd /home/CLi/develop/buildroot/buildroot-2013.05/output/build/host-ccache-3.1.8/ && rm -rf config.cache; PATH=/home/CLi/develop/buildroot/buildroot-2013.05/output/host/bin:/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/bin:/home/CLi/develop/crosstool-ng/x-tools/arm-xscale-linux-gnueabi/bin:/opt/crosstool-ng/bin:/home/CLi/develop/crosstool-ng/x-tools/armxscalecurl/bin:/usr/local/bin:/usr/bin:/cygdrive/d/tmp/dev_install_root/Python27_x64:/cygdrive/d/tmp/dev_install_root/Python27_x64/Lib/site-packages/PyQt4:/cygdrive/d/tmp/dev_install_root/Perl64/site/bin:/cygdrive/d/tmp/dev_install_root/Perl64/bin:/cygdrive/c/Program Files/Common Files/Microsoft Shared/Windows Live:/cygdrive/c/Program Files (x86)/Common Files/Microsoft Shared/Windows Live:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0:/cygdrive/c/Program Files (x86)/Microsoft SQL Server/100/Tools/Binn:/cygdrive/c/Program Files/Microsoft SQL Server/100/Tools/Binn:/cygdrive/c/Program Files/Microsoft SQL Server/100/DTS/Binn:/cygdrive/d/tmp/WordPress/mysql/mysql-5.5.18/MySQL/MySQL Server 5.5/bin:/cygdrive/d/tmp/WordPress/DevRoot/MySQL/MySQL Server 5.5/bin:/cygdrive/d/tmp/WordPress/DevRoot/php-5.3.6-Win32-VC9-x64:/cygdrive/d/tmp/WordPress/DevRoot/php-5.3.6-Win32-VC9-x64/ext:/cygdrive/d/tmp/WordPress/DevRoot/Python27:/cygdrive/c/Program Files (x86)/Common Files/Acronis/SnapAPI:/cygdrive/c/Program Files (x86)/Windows Live/Shared:/cygdrive/c/Program Files/Java/jdk1.7.0_11/bin:/home/CLi/develop/docbook/tools/fop/lib:/home/CLi/develop/docbook/tools/fop:/cygdrive/d/DevInstallRoot/FF/DD_IDE_1.1.2/TOK/BIN:/cygdrive/d/DevInstallRoot/FF/DD_IDE_1.2.0/TOK/BIN:/cygdrive/d/DevRoot/EmbeddedDevelop/trunk/Research/CLI/FF/FBK/develop/tools/develop-tools:/cygdrive/d/tmp/WordPress/DevRoot/Python27/Scripts:/cygdrive/d/tmp/dev_install_root/PostgreSQL/8.3/bin:/cygdrive/d/tmp/dev_install_root/ant/apache-ant-1.8.4/bin:/cygdrive/c/Program Files/nodejs:/cygdrive/c/Program Files/Microsoft/Web Platform Installer:/cygdrive/c/Program Files/TortoiseSVN/bin:/cygdrive/d/DevRoot/IndustrialMobileAutomation/HandheldDataSetter/ANTLR/batchFile:/cygdrive/c/Program Files (x86)/QuickTime/QTSystem:/cygdrive/d/tmp/tmp_dev_root/android/adt-bundle-windows/sdk/platform-tools:/cygdrive/d/tmp/dev_install_root/Tesseract-OCR:/cygdrive/d/tmp/dev_install_root/jython2.5.3/bin:/cygdrive/d/devinstallroot/gnuarm/bin:/cygdrive/d/tmp/dev_install_root/HTML Help Workshop:/cygdrive/c/Users/CLi/AppData/Roaming/npm:/usr/lib/lapack:/opt/gcc-4.0.4-glibc-2.3.6-kernel-2.6.17/sysroot-arm-xscale-linux-gnu/usr/include:/opt/gcc-4.0.4-glibc-2.3.6-kernel-2.6.17/sysroot-arm-xscale-linux-gnu/usr/include/linux AR="/usr/bin/ar" AS="/usr/bin/as" LD="/usr/bin/ld" NM="/usr/bin/nm" CC="/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/bin/ccache /usr/bin/gcc" GCC="/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/bin/ccache /usr/bin/gcc" CXX="/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/bin/ccache /usr/bin/g++" CPP="/usr/bin/cpp" CPPFLAGS="-I/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/include" CFLAGS="-O2 -I/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/include" CXXFLAGS="-O2 -I/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/include" LDFLAGS="-L/home/CLi/develop/buildroot/buildroot-2013.05/output/host/lib -L/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/lib -Wl,-rpath,/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/lib" PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 PKG_CONFIG="/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/bin/pkg-config" PKG_CONFIG_SYSROOT_DIR="/" PKG_CONFIG_LIBDIR="/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/lib/pkgconfig:/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/share/pkgconfig" PERLLIB="/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/lib/perl" LD_LIBRARY_PATH="/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/lib:" CFLAGS="-O2 -I/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/include" LDFLAGS="-L/home/CLi/develop/buildroot/buildroot-2013.05/output/host/lib -L/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/lib -Wl,-rpath,/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/lib" CC="/usr/bin/gcc" ./configure --prefix="/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr" --sysconfdir="/home/CLi/develop/buildroot/buildroot-2013.05/output/host/etc" --enable-shared --disable-static --disable-gtk-doc --disable-doc --disable-docs --disable-documentation --with-xmlto=no --with-fop=no ccache_cv_zlib_1_2_3=no )'
make: *** [/home/CLi/develop/buildroot/buildroot-2013.05/output/build/host-ccache-3.1.8/.stamp_configured] Error 1

CLi@PC-CLI-1 ~/develop/buildroot/buildroot-2013.05
$

然后,对照着makefile,看看能否看出完整的make的逻辑。

 

【折腾过程】

1.此处的:

/usr/bin/make -j4 HOSTCC="/usr/bin/gcc" HOSTCXX="/usr/bin/g++" silentoldconfig

很明显,对应着是:

$(BUILD_DIR)/buildroot-config/auto.conf: $(BUILDROOT_CONFIG)
	$(MAKE) $(EXTRAMAKEARGS) HOSTCC="$(HOSTCC_NOCCACHE)" HOSTCXX="$(HOSTCXX_NOCCACHE)" silentoldconfig

对应的关系是:

make时,调用的是:

all: world

->

world: toolchain $(TARGETS_ALL)

->

toolchain: prepare dirs dependencies $(BASE_TARGETS)

->

prepare: $(BUILD_DIR)/buildroot-config/auto.conf

->

$(BUILD_DIR)/buildroot-config/auto.conf: $(BUILDROOT_CONFIG)
	$(MAKE) $(EXTRAMAKEARGS) HOSTCC="$(HOSTCC_NOCCACHE)" HOSTCXX="$(HOSTCXX_NOCCACHE)" silentoldconfig

 

2.然后继续看剩下的逻辑。

mkdir -p /home/CLi/develop/buildroot/buildroot-2013.05/output/build/buildroot-config/lxdialog

此处,也容易分析出来是:

$(BUILD_DIR)/buildroot-config/%onf:
	mkdir -p $(@D)/lxdialog
	$(MAKE) CC="$(HOSTCC_NOCCACHE)" HOSTCC="$(HOSTCC_NOCCACHE)" obj=$(@D) -C $(CONFIG) -f Makefile.br $(@F)

然后反推出来,好像是:

.PHONY: all world toolchain dirs clean distclean source outputmakefile \
	legal-info legal-info-prepare legal-info-clean \
	$(BASE_TARGETS) $(TARGETS) $(TARGETS_ALL) \
	$(TARGETS_CLEAN) $(TARGETS_DIRCLEAN) $(TARGETS_SOURCE) $(TARGETS_LEGAL_INFO) \
	$(TOOLCHAIN_DIR) $(BUILD_DIR) $(STAGING_DIR) $(TARGET_DIR) \
	$(HOST_DIR) $(BINARIES_DIR) $(STAMP_DIR)

调用到了all:

all: menuconfig

->

menuconfig: $(BUILD_DIR)/buildroot-config/mconf outputmakefile
	@mkdir -p $(BUILD_DIR)/buildroot-config
	@$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)

->

$(BUILD_DIR)/buildroot-config/%onf:
	mkdir -p $(@D)/lxdialog
	$(MAKE) CC="$(HOSTCC_NOCCACHE)" HOSTCC="$(HOSTCC_NOCCACHE)" obj=$(@D) -C $(CONFIG) -f Makefile.br $(@F)

好像是的。

3.不管如何,此处,先去创建lxdialog文件夹,然后继续去:

/usr/bin/make CC="/usr/bin/gcc" HOSTCC="/usr/bin/gcc" obj=/home/CLi/develop/buildroot/buildroot-2013.05/output/build/buildroot-config -C support/kconfig -f Makefile.br conf

此处很明显,其实是对应的是:

config: $(BUILD_DIR)/buildroot-config/conf outputmakefile
	@mkdir -p $(BUILD_DIR)/buildroot-config
	@$(COMMON_CONFIG_ENV) $< $(CONFIG_CONFIG_IN)

oldconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
	mkdir -p $(BUILD_DIR)/buildroot-config
	@$(COMMON_CONFIG_ENV) $< --oldconfig $(CONFIG_CONFIG_IN)

randconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
	@mkdir -p $(BUILD_DIR)/buildroot-config
	@$(COMMON_CONFIG_ENV) $< --randconfig $(CONFIG_CONFIG_IN)

allyesconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
	@mkdir -p $(BUILD_DIR)/buildroot-config
	@$(COMMON_CONFIG_ENV) $< --allyesconfig $(CONFIG_CONFIG_IN)

allnoconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
	@mkdir -p $(BUILD_DIR)/buildroot-config
	@$(COMMON_CONFIG_ENV) $< --allnoconfig $(CONFIG_CONFIG_IN)

randpackageconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
	@mkdir -p $(BUILD_DIR)/buildroot-config
	@grep -v BR2_PACKAGE_ $(BUILDROOT_CONFIG) > $(CONFIG_DIR)/.config.nopkg
	@grep '^config BR2_PACKAGE_' Config.in.legacy | \
		while read config pkg; do \
		echo "# $$pkg is not set" >> $(CONFIG_DIR)/.config.nopkg; done
	@$(COMMON_CONFIG_ENV) \
		KCONFIG_ALLCONFIG=$(CONFIG_DIR)/.config.nopkg \
		$< --randconfig $(CONFIG_CONFIG_IN)
	@rm -f $(CONFIG_DIR)/.config.nopkg

allyespackageconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
	@mkdir -p $(BUILD_DIR)/buildroot-config
	@grep -v BR2_PACKAGE_ $(BUILDROOT_CONFIG) > $(CONFIG_DIR)/.config.nopkg
	@grep '^config BR2_PACKAGE_' Config.in.legacy | \
		while read config pkg; do \
		echo "# $$pkg is not set" >> $(CONFIG_DIR)/.config.nopkg; done
	@$(COMMON_CONFIG_ENV) \
		KCONFIG_ALLCONFIG=$(CONFIG_DIR)/.config.nopkg \
		$< --allyesconfig $(CONFIG_CONFIG_IN)
	@rm -f $(CONFIG_DIR)/.config.nopkg

allnopackageconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
	@mkdir -p $(BUILD_DIR)/buildroot-config
	@grep -v BR2_PACKAGE_ $(BUILDROOT_CONFIG) > $(CONFIG_DIR)/.config.nopkg
	@$(COMMON_CONFIG_ENV) \
		KCONFIG_ALLCONFIG=$(CONFIG_DIR)/.config.nopkg \
		$< --allnoconfig $(CONFIG_CONFIG_IN)
	@rm -f $(CONFIG_DIR)/.config.nopkg

silentoldconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
	@mkdir -p $(BUILD_DIR)/buildroot-config
	$(COMMON_CONFIG_ENV) $< --silentoldconfig $(CONFIG_CONFIG_IN)

olddefconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
	@mkdir -p $(BUILD_DIR)/buildroot-config
	$(COMMON_CONFIG_ENV) $< --olddefconfig $(CONFIG_CONFIG_IN)

defconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
	@mkdir -p $(BUILD_DIR)/buildroot-config
	@$(COMMON_CONFIG_ENV) $< --defconfig$(if $(DEFCONFIG),=$(DEFCONFIG)) $(CONFIG_CONFIG_IN)

%_defconfig: $(BUILD_DIR)/buildroot-config/conf $(TOPDIR)/configs/%_defconfig outputmakefile
	@mkdir -p $(BUILD_DIR)/buildroot-config
	@$(COMMON_CONFIG_ENV) $< --defconfig=$(TOPDIR)/configs/$@ $(CONFIG_CONFIG_IN)

savedefconfig: $(BUILD_DIR)/buildroot-config/conf outputmakefile
	@mkdir -p $(BUILD_DIR)/buildroot-config
	@$(COMMON_CONFIG_ENV) $< \
		--savedefconfig=$(if $(DEFCONFIG),$(DEFCONFIG),$(CONFIG_DIR)/defconfig) \
		$(CONFIG_CONFIG_IN)

中的某一个。

4.然后去看了看对应的文件夹:

D:\tmp\tmp_dev_root\cgwin\home\CLi\develop\buildroot\buildroot-2013.05\support\kconfig

以及其中的Makefile文件:

Makefile.br

然后其又用:

include Makefile

而调用了:

D:\tmp\tmp_dev_root\cgwin\home\CLi\develop\buildroot\buildroot-2013.05\support\kconfig\Makefile

此处,即:

执行Makefile.br,传入conf的目标;

而Makefile.br先会去包含Makefile

5.但是具体执行逻辑没看懂。

但是通过:

make[2]: Entering directory `/home/CLi/develop/buildroot/buildroot-2013.05/support/kconfig'
/usr/bin/gcc -I/usr/include/ncursesw -DCURSES_LOC="<ncursesw/curses.h>"  -DNCURSES_WIDECHAR=1 -DLOCALE -DKBUILD_NO_NLS -I/home/CLi/develop/buildroot/buildroot-2013.05/output/build/buildroot-config -DCONFIG_=\"\"  -MM *.c > /home/CLi/develop/buildroot/buildroot-2013.05/output/build/buildroot-config/.depend 2>/dev/null || :

中的:

2>/dev/null

而找到对应的地方了,是:

Makefile.br中的:

$(obj)/.depend: $(wildcard *.h *.c)
	$(HOSTCC) $(HOST_EXTRACFLAGS) $(HOSTCFLAGS) -MM *.c > $@ 2>/dev/null || :

此处,也不是完全懂,但是不关心。跳过。

后来看懂了一点:

是生成对应的依赖文件:

D:\tmp\tmp_dev_root\cgwin\home\CLi\develop\buildroot\buildroot-2013.05\output\build\buildroot-config\.depend

此处其内容为:

conf.o: conf.c lkc.h expr.h list.h lkc_proto.h
confdata.o: confdata.c lkc.h expr.h list.h lkc_proto.h
expr.o: expr.c lkc.h expr.h list.h lkc_proto.h
images.o: images.c
kxgettext.o: kxgettext.c lkc.h expr.h list.h lkc_proto.h
mconf.o: mconf.c lkc.h expr.h list.h lkc_proto.h lxdialog/dialog.h
menu.o: menu.c lkc.h expr.h list.h lkc_proto.h
nconf.o: nconf.c lkc.h expr.h list.h lkc_proto.h nconf.h \
 /usr/include/ncursesw/curses.h /usr/include/ncursesw/menu.h \
 /usr/include/ncursesw/panel.h /usr/include/ncursesw/form.h \
 /usr/include/ncursesw/ncurses.h
nconf.gui.o: nconf.gui.c nconf.h /usr/include/ncursesw/curses.h \
 /usr/include/ncursesw/menu.h /usr/include/ncursesw/panel.h \
 /usr/include/ncursesw/form.h /usr/include/ncursesw/ncurses.h
symbol.o: symbol.c lkc.h expr.h list.h lkc_proto.h
util.o: util.c lkc.h expr.h list.h lkc_proto.h

6.接下来,主要是去编译一些.c文件:

make[2]: Leaving directory `/home/CLi/develop/buildroot/buildroot-2013.05/support/kconfig'
make[2]: Entering directory `/home/CLi/develop/buildroot/buildroot-2013.05/support/kconfig'
/usr/bin/gcc -I/usr/include/ncursesw -DCURSES_LOC="<ncursesw/curses.h>"  -DNCURSES_WIDECHAR=1 -DLOCALE -DKBUILD_NO_NLS -I/home/CLi/develop/buildroot/buildroot-2013.05/output/build/buildroot-config -DCONFIG_=\"\"   -c conf.c -o /home/CLi/develop/buildroot/buildroot-2013.05/output/build/buildroot-config/conf.o
/usr/bin/gcc -I/usr/include/ncursesw -DCURSES_LOC="<ncursesw/curses.h>"  -DNCURSES_WIDECHAR=1 -DLOCALE -DKBUILD_NO_NLS -I/home/CLi/develop/buildroot/buildroot-2013.05/output/build/buildroot-config -DCONFIG_=\"\"  -I. -c /home/CLi/develop/buildroot/buildroot-2013.05/output/build/buildroot-config/zconf.tab.c -o /home/CLi/develop/buildroot/buildroot-2013.05/output/build/buildroot-config/zconf.tab.o
In file included from /home/CLi/develop/buildroot/buildroot-2013.05/output/build/buildroot-config/zconf.tab.c:2500:0:
./confdata.c: In function ‘conf_split_config’:
./confdata.c:849:6: warning: assignment makes pointer from integer without a cast [enabled by default]
/usr/bin/gcc -I/usr/include/ncursesw -DCURSES_LOC="<ncursesw/curses.h>"  -DNCURSES_WIDECHAR=1 -DLOCALE -DKBUILD_NO_NLS -I/home/CLi/develop/buildroot/buildroot-2013.05/output/build/buildroot-config -DCONFIG_=\"\"   /home/CLi/develop/buildroot/buildroot-2013.05/output/build/buildroot-config/conf.o /home/CLi/develop/buildroot/buildroot-2013.05/output/build/buildroot-config/zconf.tab.o  -o /home/CLi/develop/buildroot/buildroot-2013.05/output/build/buildroot-config/conf
rm /home/CLi/develop/buildroot/buildroot-2013.05/output/build/buildroot-config/zconf.tab.c

所以无需关心。

7.对于:

make[2]: Leaving directory `/home/CLi/develop/buildroot/buildroot-2013.05/support/kconfig'
BR2_DEFCONFIG='' KCONFIG_AUTOCONFIG=/home/CLi/develop/buildroot/buildroot-2013.05/output/build/buildroot-config/auto.conf KCONFIG_AUTOHEADER=/home/CLi/develop/buildroot/buildroot-2013.05/output/build/buildroot-config/autoconf.h KCONFIG_TRISTATE=/home/CLi/develop/buildroot/buildroot-2013.05/output/build/buildroot-config/tristate.config BUILDROOT_CONFIG=/home/CLi/develop/buildroot/buildroot-2013.05/.config /home/CLi/develop/buildroot/buildroot-2013.05/output/build/buildroot-config/conf --silentoldconfig Config.in

则是去调用对应的conf,加上一堆参数,然后去silent的去配置。

传入的参数有

D:\tmp\tmp_dev_root\cgwin\home\CLi\develop\buildroot\buildroot-2013.05\Config.in

存为对应的

D:\tmp\tmp_dev_root\cgwin\home\CLi\develop\buildroot\buildroot-2013.05\.config

8.然后对于:

make[1]: Leaving directory `/home/CLi/develop/buildroot/buildroot-2013.05'
mkdir -p /home/CLi/develop/buildroot/buildroot-2013.05/output/target
rsync -a \
                --exclude .empty --exclude .svn --exclude .git \
                --exclude .hg --exclude=CVS --exclude '*~' \
                /home/CLi/develop/buildroot/buildroot-2013.05/system/skeleton/ /home/CLi/develop/buildroot/buildroot-2013.05/output/target/
cp support/misc/target-dir-warning.txt /home/CLi/develop/buildroot/buildroot-2013.05/output/target/THIS_IS_NOT_YOUR_ROOT_FILESYSTEM

对应着,是:

D:\tmp\tmp_dev_root\cgwin\home\CLi\develop\buildroot\buildroot-2013.05\Makefile

中的:

$(BUILD_DIR)/.root:
	mkdir -p $(TARGET_DIR)
	rsync -a \
		--exclude .empty --exclude .svn --exclude .git \
		--exclude .hg --exclude=CVS --exclude '*~' \
		$(TARGET_SKELETON)/ $(TARGET_DIR)/
	cp support/misc/target-dir-warning.txt $(TARGET_DIR_WARNING_FILE)
	touch $@

$(TARGET_DIR): $(BUILD_DIR)/.root

作用是:

去创建target文件夹。

然后再去看看rsync的-a,–exclude参数的含义:

【整理】Linux命令rsync的用法

然后去拷贝target-dir-warning.txt文件。

而关于target-dir-warning.txt,即THIS_IS_NOT_YOUR_ROOT_FILESYSTEM,详见:

【整理】Buildroot生成的output/target下面的根文件系统rootfs不能直接使用

另外也去对比了rsync和cp:

【整理】Linux命令中:rsync和cp之间的区别

9.然后对于后面的:

>>> host-ccache 3.1.8 Extracting
bzcat /home/CLi/develop/buildroot/buildroot-2013.05/dl/ccache-3.1.8.tar.bz2 | tar --strip-components=1 -C /home/CLi/develop/buildroot/buildroot-2013.05/output/build/host-ccache-3.1.8  -xf -
>>> host-ccache 3.1.8 Patching package//ccache
>>> host-ccache 3.1.8 Updating config.sub and config.guess
for file in config.guess config.sub; do for i in $(find /home/CLi/develop/buildroot/buildroot-2013.05/output/build/host-ccache-3.1.8 -name $file); do cp support/gnuconfig/$file $i; done; done
>>> host-ccache 3.1.8 Patching libtool
>>> host-ccache 3.1.8 Configuring

都找不到对应的makefile是哪里的

其中,关于bzcat,是可以找到:

D:\tmp\tmp_dev_root\cgwin\home\CLi\develop\buildroot\buildroot-2013.05\Makefile

中有:

BZCAT:=$(call qstrip,$(BR2_BZCAT))

但是没找到被别人调用。

10.后来终于找到了,是在:

(此处忽略之前已经下载:

D:\tmp\tmp_dev_root\cgwin\home\CLi\develop\buildroot\buildroot-2013.05\package\pkg-download.mk

的部分)

D:\tmp\tmp_dev_root\cgwin\home\CLi\develop\buildroot\buildroot-2013.05\package\pkg-generic.mk

中的:

# default extract command
$(2)_EXTRACT_CMDS ?= \
	$$(if $$($(2)_SOURCE),$$(INFLATE$$(suffix $$($(2)_SOURCE))) $(DL_DIR)/$$($(2)_SOURCE) | \
	$(TAR) $(TAR_STRIP_COMPONENTS)=1 -C $$($(2)_DIR) $(TAR_OPTIONS) -)

# Unpack the archive
$(BUILD_DIR)/%/.stamp_extracted:
	@$(call MESSAGE,"Extracting")
	$(Q)mkdir -p $(@D)
	$($(PKG)_EXTRACT_CMDS)
    
$(BUILD_DIR)/%/.stamp_patched:
	@$(call MESSAGE,"Patching $($(PKG)_DIR_PREFIX)/$(RAWNAME)")
	$(foreach hook,$($(PKG)_PRE_PATCH_HOOKS),$(call $(hook))$(sep))
	$(foreach p,$($(PKG)_PATCH),support/scripts/apply-patches.sh $(@D) $(DL_DIR) $(p)$(sep))
	$(Q)( \
	for D in $(PATCH_BASE_DIRS); do \
	  if test -d $${D}; then \
	    if test -d $${D}/$($(PKG)_VERSION); then \
	      support/scripts/apply-patches.sh $(@D) $${D}/$($(PKG)_VERSION) \*.patch \*.patch.$(ARCH) || exit 1; \
	    else \
	      support/scripts/apply-patches.sh $(@D) $${D} \*.patch \*.patch.$(ARCH) || exit 1; \
	    fi; \
	  fi; \
	done; \
	)
	$(foreach hook,$($(PKG)_POST_PATCH_HOOKS),$(call $(hook))$(sep))
	$(Q)touch $@

# Configure
$(BUILD_DIR)/%/.stamp_configured:
	$(foreach hook,$($(PKG)_PRE_CONFIGURE_HOOKS),$(call $(hook))$(sep))
	@$(call MESSAGE,"Configuring")
	$($(PKG)_CONFIGURE_CMDS)
	$(foreach hook,$($(PKG)_POST_CONFIGURE_HOOKS),$(call $(hook))$(sep))
	$(Q)touch $@

去解压Extracting,打补丁Patching和配置Configuring的。其中在:

D:\tmp\tmp_dev_root\cgwin\home\CLi\develop\buildroot\buildroot-2013.05\package\pkg-autotools.mk

中调用对应的PATCH的HOOK的:

#
# Utility function to upgrade config.sub and config.guess files
#
# argument 1 : directory into which config.guess and config.sub need
# to be updated. Note that config.sub and config.guess are searched
# recursively in this directory.
#
define CONFIG_UPDATE
	for file in config.guess config.sub; do \
		for i in $$(find $(1) -name $$file); do \
			cp support/gnuconfig/$$file $$i; \
		done; \
	done
endef

#
# Hook to update config.sub and config.guess if needed
#
define UPDATE_CONFIG_HOOK
       @$$(call MESSAGE,"Updating config.sub and config.guess")
       $$(call CONFIG_UPDATE,$$(@D))
endef

$(2)_POST_PATCH_HOOKS += UPDATE_CONFIG_HOOK

此时,真正明白了:

是在:

D:\tmp\tmp_dev_root\cgwin\home\CLi\develop\buildroot\buildroot-2013.05\package\pkg-generic.mk

中的:

# Configure
$(BUILD_DIR)/%/.stamp_configured:
	$(foreach hook,$($(PKG)_PRE_CONFIGURE_HOOKS),$(call $(hook))$(sep))
	@$(call MESSAGE,"Configuring")
	$($(PKG)_CONFIGURE_CMDS)
	$(foreach hook,$($(PKG)_POST_CONFIGURE_HOOKS),$(call $(hook))$(sep))
	$(Q)touch $@

中的:

$($(PKG)_CONFIGURE_CMDS)

去产生对应的:

(cd /home/CLi/develop/buildroot/buildroot-2013.05/output/build/host-ccache-3.1.8/ && rm -rf config.cache; PATH=xxxxxx …… )

即,其中包含了我们此处关心的PATH的。

11.而对应的:

$($(PKG)_CONFIGURE_CMDS)

是在

D:\tmp\tmp_dev_root\cgwin\home\CLi\develop\buildroot\buildroot-2013.05\package\pkg-autotools.mk

中的host的package的configure的:

# Configure package for host
# disable all kind of documentation generation in the process,
# because it often relies on host tools which may or may not be
# installed.
define $(2)_CONFIGURE_CMDS
	(cd $$($$(PKG)_SRCDIR) && rm -rf config.cache; \
	        $$(HOST_CONFIGURE_OPTS) \
		CFLAGS="$$(HOST_CFLAGS)" \
		LDFLAGS="$$(HOST_LDFLAGS)" \
                $$($$(PKG)_CONF_ENV) \
		./configure \
		--prefix="$$(HOST_DIR)/usr" \
		--sysconfdir="$$(HOST_DIR)/etc" \
		--enable-shared --disable-static \
		--disable-gtk-doc \
		--disable-doc \
		--disable-docs \
		--disable-documentation \
		--with-xmlto=no \
		--with-fop=no \
		$$($$(PKG)_CONF_OPT) \
	)
endef
endif
endif

此处,对应着是:

$$(HOST_CONFIGURE_OPTS)

包括了我们关心的PATH变量的。

12.而

$$(HOST_CONFIGURE_OPTS)

是在:

D:\tmp\tmp_dev_root\cgwin\home\CLi\develop\buildroot\buildroot-2013.05\package\Makefile.in

中的:

TARGET_MAKE_ENV=PATH=$(TARGET_PATH) \
		PERLLIB="$(HOST_DIR)/usr/lib/perl"

HOST_CONFIGURE_OPTS=PATH=$(HOST_PATH) \
		AR="$(HOSTAR)" \
		AS="$(HOSTAS)" \
		LD="$(HOSTLD)" \
		NM="$(HOSTNM)" \
		CC="$(HOSTCC)" \
		GCC="$(HOSTCC)" \
		CXX="$(HOSTCXX)" \
		CPP="$(HOSTCPP)" \
		CPPFLAGS="$(HOST_CPPFLAGS)" \
		CFLAGS="$(HOST_CFLAGS)" \
		CXXFLAGS="$(HOST_CXXFLAGS)" \
		LDFLAGS="$(HOST_LDFLAGS)" \
		PKG_CONFIG_ALLOW_SYSTEM_CFLAGS=1 \
		PKG_CONFIG_ALLOW_SYSTEM_LIBS=1 \
		PKG_CONFIG="$(PKG_CONFIG_HOST_BINARY)" \
		PKG_CONFIG_SYSROOT_DIR="/" \
		PKG_CONFIG_LIBDIR="$(HOST_DIR)/usr/lib/pkgconfig:$(HOST_DIR)/usr/share/pkgconfig" \
		PERLLIB="$(HOST_DIR)/usr/lib/perl" \
		LD_LIBRARY_PATH="$(HOST_DIR)/usr/lib:$(LD_LIBRARY_PATH)"

至此,彻底明白了,对应的PATH,就是此处添加的:

PATH=$(HOST_PATH)

13.而对应的:

HOST_PATH

是对应的同文件:

D:\tmp\tmp_dev_root\cgwin\home\CLi\develop\buildroot\buildroot-2013.05\package\Makefile.in

中的:

HOST_PATH=$(HOST_DIR)/bin:$(HOST_DIR)/usr/bin:$(PATH)

而其中是,直接包含:

$(PATH)

进来的。

所以:

cygwin中的PATH包含了Window中的一些变量,其中包含了空格和括号,导致之前出错的。

所以此处,应该是去对PATH得到的值,加上引号,估计就可以解决问题了。

 

【总结】

至此,算是搞懂了,绝大部分的,Buildroot中的make的逻辑。

也找到了真正的,此处所关心的,PATH路径引入的位置,是:

D:\tmp\tmp_dev_root\cgwin\home\CLi\develop\buildroot\buildroot-2013.05\package\Makefile.in

中的:

HOST_PATH=$(HOST_DIR)/bin:$(HOST_DIR)/usr/bin:$(PATH)

所以如果有路径方面的问题,估计就是关心一下package\Makefile.in中的各种路径变量即可。


后续问题的解决,详见:

【已解决】Cygwin下为xscale编译BuildRoot时make出错:/bin/sh: -c: line 0: syntax error near unexpected token `(‘



发表评论

电子邮件地址不会被公开。 必填项已用*标注

无觅相关文章插件,快速提升流量