最近从澳门入手了部Motorola ROKR E6(OS内核是Linux的),就顺便研究了下该手机的交叉编译。
途中,编译busybox的时候遇到了怪异的错误:
GEN .depend
/home/xxx/busybox-1.1.3/include/bbconfigopts.h:28 hmm, unterminated
make[1]: *** [.depend] Erreur 1
make: *** [_all] Erreur 2
在网上查了一番资料,说是与ubuntu的兼容问题。并且有人提供了一种解决方案:
Apaprently it's due to my ubuntu awk/sed version, here the solution in case someone
else fall on the problem :
in the file busybox-1.2.0/scripts/config/mkconfigs, I replaced
echo "`sed 's//"//"/g' $config | grep "^#/? /?CONFIG_" | awk
'{print "//"" $0 "n//"";}'`"
by
echo "`sed 's//"//"/g' $config | grep "^#/? /?CONFIG_" | awk
'{print "//"" $0 "//"";}'`"
我不清楚是1.1.3和1.2.0版本不同还是别的什么问题,以上方法在我的机器上依然不奏效。我只好大致看了下 scripts/config/mkconfigs、include/bbconfigopts.h和该工程的若干个Makefile,终于明白其实 bbconfigopts.h是在make busybox的时候(在make config之后)由shell脚本mkconfigs自动生成的,那么问题就变得明白了。
用vi打开mkconfigs,找到第63行的:
echo "static char const bbconfig_config[] ="
echo "/"CONFIG_BEGIN=n//n//"
echo "`sed 's//"//"/g' $config | grep "^#/? /?CONFIG_" | awk '{ print $0 "n" }' `"
echo "CONFIG_END=n//n/";"
echo "#endif /* _BBCONFIG_H */"
改为:
echo "static char const bbconfig_config[] ="
echo "/"CONFIG_BEGIN=n///n/""
echo "`sed 's//"//"/g' $config | grep "^#/? /?CONFIG_" | awk '{ print "//"" $0 "//"" }' `"
echo "/"CONFIG_END=n///n/";"
echo "#endif /* _BBCONFIG_H */"
编译通过!
记住,make之前要先make clean!