天天看点

Compile Bash for Android

1. Get the bash source:

$ wget -c http://ftp.gnu.org/gnu/bash/bash-4.1.tar.gz

$ tar zxvf bash-4.1.tar.gz

2. Download the ARM Toolkit , e.g. Sourcery G++ Lite 2008q1-126 for ARM GNU /Linux

$ wget -c http://www.codesourcery.com/sgpp/lite/arm/portal/package2549/public/arm-none-linux-gnueabi/arm-2008q1-126-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2

note:  using the newest toolchain compile bash-4.1 failed, use this toolchain 4.2.3 compiled ok.

3. configure the bash

$ cd bash-4.1

$./configure -host=arm-linux --enable-static-link --without-bash-malloc CC=/yourpath/arm-2008q1/bin/arm-none-linux-gnueabi-gcc

4. compile the bash

$ make

$ arm-none-linux-gnueabi-strip bash

$ file bash

bash: ELF 32-bit LSB executable, ARM, version 1 (SYSV), statically linked, for GNU/Linux 2.6.14, stripped

继续阅读