01/16/2008

w3m build with CodeSourcery tool chain

Just another log of my try and error while building w3m for Angstrom Zaurus.

I found this post sometime ago and very interrested in CodeSourcery's tool chain.
motz diary: Compile Android kernel from the source

First of all, downlaod the toolchain tar ball. Make sure choice is ARM EABIGNU/Linux and IA32 GNU/Linux.
Download the ARM 2007q3 Release

Correction on Jan 18, 2008: A choice should be a pair of ARM GNU/Linux and IA32 GNU/Linux. We need -arm-none-linux-gnueabi-, not -arm-none-eabi-. Sorry for any inconvenience.

Then unpack it somewhere convenient for you. My case, /opt.
$ cd /opt
$ sudo tar jxvf arm-2007q3-51-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2
$ sudo ln -s arm-2007q3 arm-cc
$ export PATH=/opt/arm-cc/bin:$PATH
$ export CC=arm-none-linux-gnueabi-gcc
Download source code of w3m from SourceForge.

Try configure and build.
$ tar zxvf w3m-0.5.2.tar.gz
$ cd w3m-0.5.2
$ ./configure --host=arm-none-linux-gnueabi --enable-japanese=U
checking GC header location... /usr /usr/local ~/
checking /usr/include... checking gc.h usability... no
checking gc.h presence... no
checking for gc.h... no
So, w3m wants Hans_Boehm gc. After some googling, I found it in HP's site.
$ wget http://www.hpl.hp.com/personal/Hans_Boehm/gc/gc_source/gc.tar.gz
$ tar zxvf gc.tar.gz
$ cd gc6.7
$ ./configure --host=arm-none-linux-gnueabi --prefix=/opt/arm-cc
$ sudo make --dry-run install
$ sudo make install
error!
arm-none-linux-gnueabi-ranlib /opt/arm-cc/lib/libgc.a
./libtool: line 4680: arm-none-linux-gnueabi-ranlib: command not found
Command is there and path is OK. So just edit the shell script to tell the absolute path to ranlib.

Edit libtool at line 172
Before: RANLIB="arm-none-linux-gnueabi-ranlib"
After:  RANLIB="/opt/arm-cc/bin/arm-none-linux-gnueabi-ranlib"

Try again.
$ sudo make install
Seems to be OK.

Go back to w3m build.
$ cd w3m-0.5.2
$ ./configure --host=arm-none-linux-gnueabi \
--prefix=/opt/arm-cc \
--with-gc=/opt/arm-cc \
--enable-japanese=U

checking whether setpgrp takes no argument...
configure: error: cannot check setpgrp when cross compiling
So, w3m really doesn't support cross compiling. Let's edit configure not to bail out on this error.

Comment out exit in configure at line 10501
# { (exit 1); exit 1; };

Try configure again, then make.
$ ./configure --host=arm-none-linux-gnueabi \
--prefix=/opt/arm-cc \
--with-gc=/opt/arm-cc \
--enable-japanese=U
$ make
etc.c: In function 'setup_child':
etc.c:1366: error: too many arguments to function 'setpgrp'
My setpgrp looks like void function. Edit configure again.

Add a following line to configure at line 10554
ac_cv_func_setpgrp_void=yes

Retry.
$ ./configure --host=arm-none-linux-gnueabi \
--prefix=/opt/arm-cc \
--with-gc=/opt/arm-cc \
--enable-japanese=U
$ make
./mktable 100 functable.tab > functable.c
/bin/bash: ./mktable: cannot execute binary file

$ file mktable
mktable: ELF 32-bit LSB executable, ARM, version 1 (SYSV), for GNU/Linux 2.6.14, dynamically linked (uses shared libs), not stripped
Gee. Make try to build a tool runtime.

Edit Makefile to make x86 executable for mktable. It's kind a long story. So see w3m-0.5.2-arm-patch.tar.gz if you are interrested in.

Retry.
$ make clean
$ make
Now I got tons of errors related ncurses is missing.
$ wget http://ftp.gnu.org/pub/gnu/ncurses/ncurses-5.4.tar.gz
$ tar zxvf ncurses-5.4.tar.gz
$ cd ncurses-5.4
$ ./configure --host=arm-none-linux-gnueabi --prefix=/opt/arm-cc
$ make
AWK=mawk sh ./tinfo/MKkeys_list.sh ../include/Caps | sort >keys.list
./make_keys keys.list > init_keytry.h
./make_keys: 1: Syntax error: word unexpected (expecting ")")
It looks like very tough thing to do.

Forget to build ncurses from scratch. Intead, copy them from openembedded image which I already have.
$ pushd ~/openembedded/tmp/work/armv5te-angstrom-linux-gnueabi/ncurses-5.4-r9/image/
$ cd usr/lib
$ cp -a . /opt/arm-cc/lib
$ cd ../share
$ cp -a . /opt/arm-cc/share
Or download ncurses-dev package on Angsrom Zaurus and copy them back.
$ ssh root@zaurus
# ipkg update
# ipkg install ncurses-dev
# ipkg files ncurses-dev
Package ncurses-dev (5.4-r10) is installed on root and has the following files:
/usr/lib/libcurses.a
/usr/lib/libncurses.a
... snip ...
/usr/lib/libncurses.so
/usr/include/unctrl.h
/usr/include/term.h
/usr/include/menu.h
/usr/include/ncurses.h
Try again.
$ make clean
$ make
Looks good. Copy to Angsrom Zaurus and try.
$ tar zcvf /tmp/arm-w3m.tar.gz w3m w3mbookmark w3mhelperpanel w3mimgdisplay
$ pushd /opt/arm-cc/lib/gcc/arm-none-linux-gnueabi/4.2.1/
$ find . -name "libgc.*" -print | xargs tar zcvf /tmp/arm-libgc.tar.gz
$ scp /tmp/arm-w3m.tar.gz root@zaurus:/home/root
$ scp /tmp/arm-libgc.tar.gz root@zaurus:/home/root
$ ssh root@zaurus
# tar zxvf arm-w3m.tar.gz
# cd /usr/lib
# tar zxvf /home/root/arm-libgc.tar.gz
# LANG=c ./w3m http://hogehoge


というわけで、お約束のビルド方法について。こんな感じでクロスビルドしてますよ、ということで。

んでもってCodeSourceryのツールチェーンはAngstromに使えますよ、ということで。
posted by 安藤恐竜 at 20:08 | Comment(0) | TrackBack(0) | 日記

ncftp for Angstrom

Angstrom distribution has sftp but lacks classic ftp client.

I built NcFTP Client. Following is a tar ball of executable files, just in case anybody looking for binary.

o ncftp-3.2.1-arm-linux.tar.gz

And patch file ncftp-3.2.1-arm-linux.patch.

Following is my try and error log.
$ wget ftp://ftp.ncftp.com/ncftp/ncftp-3.2.1-src.tar.bz2
$ tar jxvf ncftp-3.2.1-src.tar.bz2
$ cd ncftp-3.2.1
$ ./configure --host=arm-none-linux-gnueabi --prefix=/opt/arm-cc
$ make
$ file bin/ncftp
bin/ncftp: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.6.8, dynamically linked (uses shared libs), stripped
Oops. I built x86 binary. It looks like configure doesn't support cross compiling. So I modified Makefile to set CC=arm-none-linux-gnueabi-gcc.
$ make clean
$ make
strip: Unable to recognise the format of the input file `../bin/ncftp'
make[1]: [../bin/ncftp] Error (ignored)

Compiling wgets.c: [ERROR]
In file included from wgets.c:9:
syshdrs.h:142:22: error: ncurses.h: No such file or directory
So, strip should be arm-none-linux-gnueabi-strip. And ncurses.h is missing. I have ncurses headers and libraries in my openembedded image. Just copy them.
$ pushd ~/openembedded/tmp/work/armv5te-angstrom-linux-gnueabi
$ pushd ncurses-5.4-r9/image/usr/include/
$ sudo cp * /opt/arm-cc/lib/gcc/arm-none-linux-gnueabi/4.2.1/include/
$ popd
$ cd ncurses-5.4-r9/image/usr/lib
$ sudo cp * /opt/arm-cc/lib/
$ popd

Alternatively, ncurses-dev.ipk could be used.
$ ssh root@zaurus
# ipkg update
# ipkg install ncurses-dev
# ipkg files ncurses-dev
Package ncurses-dev (5.4-r10) is installed on root and has the following files:
/usr/lib/libcurses.a
/usr/lib/libncurses.a
... snip ...
/usr/lib/libncurses.so
/usr/include/unctrl.h
/usr/include/term.h
/usr/include/menu.h
/usr/include/ncurses.h
Copy them back from Zaurus to PC.

Now try again.
$ make clean
$ make
one-linux-gnueabi/bin/ld: cannot find -lncurses
collect2: ld returned 1 exit status
It looks like the linker doesn't know where to find ncurses library. Modify vis/Makefile to add LDFLAGS+= -L/opt/arm-cc/lib.
$ make
$ find bin/ -type f -print | xargs file
bin/ncftp: ELF 32-bit LSB executable, ARM, ...
bin/ncftpbatch: ELF 32-bit LSB executable, ARM, ...
bin/ncftpbookmarks: ELF 32-bit LSB executable, ARM, ...
bin/ncftpget: ELF 32-bit LSB executable, ARM, ...
bin/ncftpls: ELF 32-bit LSB executable, ARM, ...
bin/ncftpput: ELF 32-bit LSB executable, ARM, ...
Now I got executables for arm.

If you want to build using my patch, step would be
$ wget ftp://ftp.ncftp.com/ncftp/ncftp-3.2.1-src.tar.bz2
$ tar jxvf ncftp-3.2.1-src.tar.bz2
$ cd ncftp-3.2.1
$ ./configure --host=arm-none-linux-gnueabi --prefix=/opt/arm-cc
$ cd ..
$ patch -p0 < ncftp-3.2.1-arm-linux.patch
$ cd ncftp-3.2.1
$ make

Cheers,

というわけで、今度はAngstrom用にNcFTP Clientをビルドしてみました。

Angstromにはsftpはあるけど、普通のftpがないので。もしかして欲しい人がいれば、↓をダウンロードして使ってください。

o ncftp-3.2.1-arm-linux.tar.gz

んで、ごにょごにょしたログです。
(以下略)
posted by 安藤恐竜 at 17:43 | Comment(4) | TrackBack(0) | 日記

広告


この広告は60日以上更新がないブログに表示がされております。

以下のいずれかの方法で非表示にすることが可能です。

・記事の投稿、編集をおこなう
・マイブログの【設定】 > 【広告設定】 より、「60日間更新が無い場合」 の 「広告を表示しない」にチェックを入れて保存する。


×

この広告は1年以上新しい記事の投稿がないブログに表示されております。