最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

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

Cygwin crifan 5600浏览 0评论

【问题】

折腾:

【记录】在Cygwin上用Buildroot为xscale建立交叉工具链

期间,去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_=\"\"   /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
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 Downloading
--2013-08-23 17:34:25--  http://samba.org/ftp/ccache/ccache-3.1.8.tar.bz2
Resolving samba.org (samba.org)... 216.83.154.106, 2001:470:1f05:1a07::1
Connecting to samba.org (samba.org)|216.83.154.106|:80... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://www.samba.org/ftp/ccache/ccache-3.1.8.tar.bz2 [following]
--2013-08-23 17:34:26--  http://www.samba.org/ftp/ccache/ccache-3.1.8.tar.bz2
Resolving www.samba.org (www.samba.org)... 216.83.154.106, 2001:470:1f05:1a07::1
Reusing existing connection to samba.org:80.
HTTP request sent, awaiting response... 200 OK
Length: 265248 (259K) [application/x-bzip2]
Saving to: `/home/CLi/develop/buildroot/buildroot-2013.05/dl/ccache-3.1.8.tar.bz2.tmp'

100%[==================================================================================================================================>] 265,248      187K/s   in 1.4s

2013-08-23 17:34:28 (187 KB/s) - `/home/CLi/develop/buildroot/buildroot-2013.05/dl/ccache-3.1.8.tar.bz2.tmp' saved [265248/265248]

>>> 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
$

如图:

bin sh c line 0 syntax error near unexpected token

即:

/bin/sh: -c: line 0: syntax error near unexpected token `(‘

【解决过程】

1.此处,看起来是:

cygwin中,不支持:

(cd /home/CLi/develop/buildroot/buildroot-2013.05/output/build/host-ccache-3.1.8/ && ……

即不能识别最开始的左括号。

2.参考:

Automatically Tuned Linear Algebra Soft.

说是:

由于win7 x64中,有类似于:

‘Program Files (x86)’

导致无法识别,括号不匹配。

想要去修复问题,但是发现,此处是输出到命令行中的,而不是某个文件,所以,不好修改。

3.所以,需要想办法,搞清楚,buildroot是怎么生成此:

(cd /home/CLi/develop/buildroot/buildroot-2013.05/output/build/host-ccache-3.1.8/ && rm -rf config.cache; PATH=xxxxxxxxxxx:/cygdrive/c/Program Files/Common Files/Microsoft Shared/Windows Live:xxxxx yyyyyyyy CC="/usr/bin/gcc" ./configure –prefix="/home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr" zzzzzzzzzz )

命令的。

4.参考:

Help with Cygwin bash file

难道是cygwin的bash版本太低?

所以去看看:

CLi@PC-CLI-1 ~/develop/buildroot/buildroot-2013.05
$ bash --version
GNU bash, version 4.1.10(4)-release (i686-pc-cygwin)
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

CLi@PC-CLI-1 ~/develop/buildroot/buildroot-2013.05
$ which bash
/usr/bin/bash

另外去看看Ubuntu 13.04中的bash的版本:

crifan@ubuntu:kconfig$ bash --version
GNU bash, version 4.2.45(1)-release (i686-pc-linux-gnu)
Copyright (C) 2011 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
crifan@ubuntu:kconfig$ which bash
/bin/bash

所以,Ubuntu 13.04中bash是4.2.45的,而Cygwin中bash是4.1.10,貌似也不会很老。

5.这里:

Error building Perl under cygwin

貌似是去掉(x86)后,就可以了。

但是我此处,没法随便去掉PATH中的(x86)的路径的。因为很多都是有意义的,windows下的路径。

6.去手动试试,带括号的,在cygwin命令行下,是否支持:

结果是可以支持的:

CLi@PC-CLI-1 ~/develop/buildroot/buildroot-2013.05
$ (cd /home/CLi/develop/buildroot/buildroot-2013.05/output/build/host-ccache-3.1.8/)

CLi@PC-CLI-1 ~/develop/buildroot/buildroot-2013.05
$ (cd /home/CLi/develop/buildroot/buildroot-2013.05/output/build/host-ccache-3.1.8/ && ls)
args.c        ccache.h     configure*  getopt_long.c  hashtable.h          hashutil.h    language.h    Makefile.in  mdfour.c              NEWS.txt     system.h  version.c
AUTHORS.html  cleanup.c    counters.c  getopt_long.h  hashtable_itr.c      INSTALL.html  LICENSE.html  manifest.c   mdfour.h              README.html  test/     zlib/
AUTHORS.txt   compopt.c    counters.h  GPL-3.0.txt    hashtable_itr.h      INSTALL.txt   LICENSE.txt   manifest.h   murmurhashneutral2.c  README.txt   test.sh*
ccache.1      compopt.h    execute.c   hash.c         hashtable_private.h  install-sh*   lockfile.c    MANUAL.html  murmurhashneutral2.h  snprintf.c   unify.c
ccache.c      config.h.in  exitfn.c    hashtable.c    hashutil.c           language.c    main.c        MANUAL.txt   NEWS.html             stats.c      util.c

那就是,make中,不支持这样的写法。

7.再去试试,中间带空格的这种:

Program Files (x86)

看看能否支持:

果然不支持:

CLi@PC-CLI-1 ~/develop/buildroot/buildroot-2013.05
$ (cd /cygdrive/c/Program Files (x86)/Common Files/Acronis/SnapAPI && ls)
bash: syntax error near unexpected token `('

8.试了试,空格前面即使反斜杠,也不行:

CLi@PC-CLI-1 ~/develop/buildroot/buildroot-2013.05
$ (cd /cygdrive/c/Program\ Files\ (x86)/Common Files/Acronis/SnapAPI && ls)
bash: syntax error near unexpected token `('

CLi@PC-CLI-1 ~/develop/buildroot/buildroot-2013.05
$ (cd /cygdrive/c/Program\ Files\ (x86)/Common\ Files/Acronis/SnapAPI && ls)
bash: syntax error near unexpected token `('

CLi@PC-CLI-1 ~/develop/buildroot/buildroot-2013.05
$ (cd /cygdrive/c/ && ls)
$Recycle.Bin/  BOOTSECT.BAK*            MSOCache/     Program Files/        Recovery/                   Templates/              Windows/
boot/          Documents and Settings@  pagefile.sys  Program Files (x86)/  Renesas/                    Trace-120903-1342.zip*  WorkSpace/
bootmgr*       hiberfil.sys             PerfLogs/     ProgramData/          System Volume Information/  Users/

9.后来参考:

Can I use paths/filenames containing spaces in them?

的:

Cygwin does support spaces in filenames and paths. That said, some utilities that use the library may not, since files don’t typically contain spaces in Unix. If you stumble into problems with this, you will need to either fix the utilities or stop using spaces in filenames used by Cygwin tools.

In particular, bash interprets space as a word separator. You would have to quote a filename containing spaces, or escape the space character. For example:

	bash-2.03$ cd '/cygdrive/c/Program Files'

or

	bash-2.03$ cd /cygdrive/c/Program\ Files

可知:

看来只能自己想办法,去把带空格的路径中,加上引号,貌似就可以了。

10.不过,自己试出来了,不仅是空格,另外的括号,也要加上反斜杠,就可以了:

CLi@PC-CLI-1 ~/develop/buildroot/buildroot-2013.05
$ (cd /cygdrive/c/Program\ Files\ \(x86\)/Common\ Files/Acronis/SnapAPI && ls)
snapapi.dll*

CLi@PC-CLI-1 ~/develop/buildroot/buildroot-2013.05
$ (cd /cygdrive/c/Program\ Files\ \(x86\)/Common\ Files/Microsoft\ Shared/Windows\ Live && ls)
msidcrl40.dll*  WindowsLiveLogin.dll*  wlidcli.dll*  WLIDCREDPROV.DLL*  WLIDNSP.DLL*  WLIDPROV.DLL*  WLIDRES.DLL*  WLive48x48.png*

11.然后再去试试加引号:

然后也是可以的:

CLi@PC-CLI-1 ~/develop/buildroot/buildroot-2013.05
$ (cd "/cygdrive/c/Program Files (x86)/Common Files/Microsoft Shared/Windows Live" && ls)
msidcrl40.dll*  WindowsLiveLogin.dll*  wlidcli.dll*  WLIDCREDPROV.DLL*  WLIDNSP.DLL*  WLIDPROV.DLL*  WLIDRES.DLL*  WLive48x48.png*

12这样看来,的确就是:

需要保证此处调用的内容中,如果有空格,括号等内容,

要么是引号括起来;

要么是用反斜杠转义;

才可以正常执行。

那就想办法去找到,生成此处的命令的地方,看看能否加上对应的括号或手动处理,去转义空格和括号。

13.此处只是找到了host-ccache的文件夹:

D:\tmp\tmp_dev_root\cgwin\home\CLi\develop\buildroot\buildroot-2013.05\output\build\host-ccache-3.1.8

14.后来搜:

buildroot cygwin path include space

看到

http://multiwii.googlecode.com/svn/branches/Hamburger/Arduino-Makefiles/Arduino/Arduino.mk

中也有提到,关于cygwin的路径包含空格的事情:

  ifneq ($(findstring CYGWIN, $(SYSTYPE)),)
	# Most of the following commands are simply to deal with whitespaces in the path
	# Read the "Program Files" system directory from the windows registry
	PROGRAM_FILES		:=	$(shell cat /proc/registry/HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/CurrentVersion/ProgramFilesDir)
	# Convert the path delimiters to /
	PROGRAM_FILES		:=	$(shell cygpath -m ${PROGRAM_FILES})
	# Escape the space with a backslash
	PROGRAM_FILES		:=	$(shell echo $(PROGRAM_FILES) | sed s/\ /\\\\\ / )
	# Use DOS paths because they do not contain spaces
	PROGRAM_FILES		:=	$(shell cygpath -d ${PROGRAM_FILES})
	# Convert the path delimiters to /
	PROGRAM_FILES	:=	$(subst \,/,$(PROGRAM_FILES))
	# Search for an Arduino instalation in a couple of paths
	ARDUINO_SEARCHPATH	:=	c:/arduino* $(PROGRAM_FILES)/arduino*
    ARDUINOS		:=	$(wildcard $(ARDUINO_SEARCHPATH))
  endif

以及:

https://github.com/freddiechopin/NuttX/tree/master/misc/buildroot/configs

也提到了:

Cygwin GCC BUILD NOTES
^^^^^^^^^^^^^^^^^^^^^^

 o Cygwin normally creates a /home directory with your Windows user name.  Unfortunately,
   that could very likely include spaces.  In that case, the Cygwin build will have
   lots of problems.  Here is how I worked around that:

   - I created a /home/buildroot directory and copied buildroot to that location
     (/home/build/buildroot/buildroot)
   - I have the archives directory at /home/buildroot/archives
   - And a symbolic link to the nuttx build directory at /home/buildroot/nuttx

   With those workarounds, the buildroot will build.  However, you will also need
   to either edit the setenv.sh file to reference this new location, or else move
   resulting build diectory.

此处,好像是和我这里,关系,不是很大,因为我此处的是:

我的window的cygwin的home路径是:

/home/CLi/

其中,windows下的绝对路径是:

D:\tmp\tmp_dev_root\cgwin\home\CLi

确保是不包含任何特殊的空格字符的(当前安装cygwin时就会注意到这点的)

而此处的问题是:

在buildroot的make时,编译host-ccache时,期间会调用到PATH环境变量,其中,包括了windows的路径,

被cygwin转化后,得到的是

/cygdrive/c/Program Files/Common Files/Microsoft Shared/Windows Live

/cygdrive/c/Program Files (x86)/Common Files/Microsoft Shared/Windows Live

/cygdrive/c/Program Files/Microsoft SQL Server/100/DTS/Binn

之类的路径,其中的空格和括号,都还是没有经过处理,

所以才导致bash不识别,才报错的。

此处,能想到的一种做法是:

暂时,把PATH中,那些只和windows本身有关的一些path路径,目前看起来包括:

/cygdrive/c/Program Files/Common Files/Microsoft Shared/Windows Live

/cygdrive/c/Program Files (x86)/Common Files/Microsoft Shared/Windows Live

/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/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

/cygdrive/c/Program Files/Microsoft/Web Platform Installer

/cygdrive/c/Program Files/TortoiseSVN/bin

/cygdrive/c/Program Files (x86)/QuickTime/QTSystem

都暂时去掉,等编译完了buildroot,再恢复一下。

估计是可以的,但是很明显,属于很不好的做法。

万一恢复之后,对于以后的buildroot等的编译,还是可能导致此类问题的。

最好的办法还是,去buildroot中,找到哪里调用到了此处的(Cygwin中的)PATH,然后去处理一下:

对于空格和括号,进行转义

是相对最保险的做法。

15.顺带说一下,上面的:

https://github.com/freddiechopin/NuttX/tree/master/misc/buildroot/configs

中,其实,已经帮我们弄好了一个,针对于我此处arm920t的buildroot的配置了:

arm920t-defconfig-4.2.4

arm920t-defconfig-4.3.3

arm920t-eabi-defconfig-4.5.2

有空的话,我们是可以去借用的:

减少自己的麻烦,因为别人已经编译通过了。帮忙验证过了。

不过进去看了看,其没有真正完整的buildroot的配置,但是有主要的gcc,binutils等的版本。

还是可以借鉴的。

 

16.先去make clean一下:

CLi@PC-CLI-1 ~/develop/buildroot/buildroot-2013.05
$ make clean
rm -rf /home/CLi/develop/buildroot/buildroot-2013.05/output/host/usr/arm-buildroot-linux-uclibcgnueabi/sysroot /home/CLi/develop/buildroot/buildroot-2013.05/output/target /home/CLi/develop/buildroot/buildroot-2013.05/output/images /home/CLi/develop/buildroot/buildroot-2013.05/output/host \
                /home/CLi/develop/buildroot/buildroot-2013.05/output/stamps /home/CLi/develop/buildroot/buildroot-2013.05/output/build /home/CLi/develop/buildroot/buildroot-2013.05/output/toolchain /home/CLi/develop/buildroot/buildroot-2013.05/output/staging \
                /home/CLi/develop/buildroot/buildroot-2013.05/output/legal-info

再去make,然后接着去分析其逻辑:

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

17.找到make的逻辑,知道了对应的PATH有何而来,就可以尝试去修改:

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

中的HOST_PATH,改为:

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

再去make试试,然后就解决了问题了:

(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 )
configure: WARNING: unrecognized options: --enable-shared, --disable-static, --disable-gtk-doc, --disable-doc, --disable-docs, --disable-documentation, --with-xmlto, --with-fop
configure: Configuring ccache
checking for gcc... /usr/bin/gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.exe
checking for suffix of executables... .exe
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether /usr/bin/gcc accepts -g... yes
checking for /usr/bin/gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... /usr/bin/cpp
checking for a BSD-compatible install... /usr/bin/install -c

如图:

path quote by parenthesis configure ccache ok

 

【总结】

在cygwin下make编译buildroot,在配置ccache时出现:

/bin/sh: -c: line 0: syntax error near unexpected token `(‘

的错误的:

原因是:

此处在bash中输入的命令:

(cd xxx && rm -rf config.cache; PATH=xxx:/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:xxx …… )

中,那个PATH,很明显,包含了空格和括号,导致bash(/bin/sh)无法识别。

深层次的原因是:

buildroot的makefile中,在从环境中获得PATH变量时,没有考虑到cygwin的环境

导致,此处,得到的PATH,是从cygwin中得到的,其包含了windows中的路径,包含了空格和括号等特殊字符

导致后续的解析无法运行。

 

通过:

【记录】尝试分析Buildroot在make menuconfig后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)

去改为:

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

使得PATH的值,带空格等特殊字符的路径,也可以正确被识别了,从而解决了问题。

 

提示一句:

但是很有意思的是:

buildroot的makefile中,有些变量,又考虑到了(cygwin等环境下得到的)路径可能包含特殊的空格等字符的情况,比如:

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

中的HOST_DIR

相关的内容有:

STAGING_DIR    = $(HOST_DIR)/$(STAGING_SUBDIR)

ifeq ($(BR2_TOOLCHAIN_BUILDROOT)$(BR2_TOOLCHAIN_CTNG),y)
TARGET_CROSS=$(HOST_DIR)/usr/bin/$(GNU_TARGET_NAME)-
else
TARGET_CROSS=$(HOST_DIR)/usr/bin/$(call qstrip,$(BR2_TOOLCHAIN_EXTERNAL_PREFIX))-
endif

# Quotes are needed for spaces et al in path components.
TARGET_PATH="$(HOST_DIR)/bin:$(HOST_DIR)/usr/bin:$(HOST_DIR)/usr/sbin/:$(PATH)"

TARGET_STRIP=$(HOST_DIR)/usr/bin/$(GNU_TARGET_NAME)-sstrip

HOST_CPPFLAGS  = -I$(HOST_DIR)/usr/include
HOST_CFLAGS   ?= -O2
HOST_CFLAGS   += $(HOST_CPPFLAGS)
HOST_CXXFLAGS += $(HOST_CFLAGS)
HOST_LDFLAGS  += -L$(HOST_DIR)/lib -L$(HOST_DIR)/usr/lib -Wl,-rpath,$(HOST_DIR)/usr/lib
HOST_PATH=$(HOST_DIR)/bin:$(HOST_DIR)/usr/bin:$(PATH)

而其中的TARGET_PATH,对于得到的路径值,都是主动加了双引号括起来

-> 从而使得,即使是对于cygwin环境下,也不会由于空格等问题而出错的。

 

感慨:

buildroot,真心没有完全支持cygwin作为host,所以,才会出现这等情况。

等以后,未来的某天,估计buildroot或许可以完整的支持cygwin。。。

转载请注明:在路上 » 【已解决】Cygwin下为xscale编译Buildroot时make出错:/bin/sh: -c: line 0: syntax error near unexpected token `(‘

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
83 queries in 0.169 seconds, using 22.35MB memory