[Android Software/Hacking General [Developers Only]] XVilka:
This howto is only draft! Sometimes i went upgrade this, or make page on my site and post link on it. Also we have a project for automated building, like buildroot and opkg repository for android.

All needed configs in attached file. If you have error on unpack - just rename my.zip in my.tar.bz2 and try to unpack. Please correct me, if needed.

----------------------------------------------------------------------------------------------------------------------------------

All work will be in home directory (/home/xvilka)

create dir build

mkdir build

1. Download the kernel (for android on your version for device) and unpack

make headers_install ARCH=arm INSTALL_HDR_PATH=~/build/kern_h/

For some optimisations you need know, which proccessor (SoC) in your android-system(gcc.gnu.org/onlinedocs/gcc-4.4.3/gcc/ARM-Options.html#ARM-Options)

Im have Motorola Milestone - SoC = TI OMAP3430 - ARM Cortex a8 (arch - armv7a)

(en.wikipedia.org/wiki/ARM_architecture)

So, if you have OMAP3430-processor - use the config files with -omap3430 suffix

If you have Quallcomm MSM7200A (HTC Hero) - use the config files with -msm7200a suffix

First, we need to define _XXFLAGS, which contain some optimisation options for your compiler:

export _XXCFLAGS=" -mcpu=cortex-a8 -march=armv7-a -mtune=cortex-a8 -mfpu=vfpv3 -O3 -Os" (if you have Motorola Milestone/Droid or other device with TI OMAP3430)

export _XXCFLAGS=" -march=armv6j -mtune=arm1136jf-s -O3 -Os" (if you have HTC Hero or other device with Quallcomm MSM 7200A)

............................................................................................

If you don't know which chip you have in phone use _XXCFLAGS=" -O3 -Os"

2. Download crosstool-ng (ymorin.is-a-geek.org/dokuwiki/projects/crosstool),

unpack, build (you must have make,install,bash,cut,sed,grep,gcc,awk,bison,flex,automake,libtool,stat,

wget,cvs,patch,tar,gzip,bzip2,lzma,readlink,ncurses)

.configure

make

make install

3. Create directory toolchain-android, and copy config to this

XVilka-crosstool-<suffix>.config in .config

XVilka-uClibc-<suffix>.config in uClibc-0.9.30.2.config (or later version, if available)

and then run:

ct-ng menuconfig

you may change some options, if needed!

(Also use options from XXCFLAGS:

Target options -> Target optimizations ->

Architecture-level equal -march, use armv7-a

Emit assembly for CPU equal -mcpu, use cortex-a8

Tune for cpu equal -mtune, use cortex-a8

Use specific FPU equal -mfpu, use vfpv3

Floating point use hardware, because it built-in TI OMAP3430

Target CFLAGS - use -O3 -Os

) - for the Motorola Milestone/Droid

(Also use options from _XXCFLAGS:

Target options -> Target optimizations ->

Architecture-level equal -march, use armv6j

Emit assembly for CPU equal -mcpu, use nothing

Tune for cpu equal -mtune, use arm1136jf-s

Floating point use software

Target CFLAGS - use -O3 -Os

) - for the HTC Hero

Save in .config

In file uClibs-0.9.30.2.config

edit this strings:

{

UCLIBC_HAS_FLOATS=y

UCLIBC_HAS_FPU=y

# UCLIBC_HAS_SOFT_FLOAT=y

UCLIBC_EXTRA_CFLAGS=" -march=armv7-a -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=vfpv3 -O3 -Os"

} - for the Motorola Milestone/Droid

{

UCLIBC_HAS_FLOATS=y

#UCLIBC_HAS_FPU=y

UCLIBC_HAS_SOFT_FLOAT=y

UCLIBC_EXTRA_CFLAGS=" -march=armv6j -mtune=arm1136jf-s -O3 -Os"

} - for the HTC Hero

and then run

ct-ng build

4. Ok, done. We have installed cross - toolchain in directory build/x-tools.

And all programs in it with names arm-android-linux-uclibsgnueabi-*

For easy using add this directory in PATH:

PATH=~/build/x-tools/arm-android-linux-uclibcgnueabi/bin:$PATH

so we can run cross-gcc by the command:

arm-android-linux-uclibcgnueabi-gcc

Root directory of target system is:

~/build/x-tools/arm-android-linux-uclibcgnueabi/arm-android-linux-uclibcgnueabi/sys-root

But for the safe - make new root dir and copy files too.

Copy files in ~/build/cross/sys-root

chmod +w sys-root

chmod +w sys-root/usr

5. Building busybox (only static build, but if we have static busybox in any problems with system problems with libs

we can easy use busybox as repair-mode tool)

copy file XVilka-busybox-<suffix>.config in .config

make menuconfig

make ARCH=arm CC="arm-android-linux-uclibcgnueabi-gcc" CROSS_COMPILE="arm-android-linux-uclibcgnueabi-" \

CFLAGS=" -static $_XXFLAGS"

make install CONFIG_PREFIX=~/build/cross/sys-root

Copy ~/build/cross/sys-root/bin/busybox in /system/bin on device

chown root /system/bin/busybox

chmod 755 /system/bin/busybox

ln -s /system/bin/busybox /system/bin/ash

Or in other directory and you can install all programs included in busybox by the command:

busybox --install

7. Building simple but powerful text editor jupp (mirbsd.org/jupp.htm)

chmod +x configure

./configure --prefix=/system/local --disable-curses --disable-termcap --disable-termidx --host=arm-android-linux-uclibcgnueabi ARCH=arm \

CC="arm-android-linux-uclibcgnueabi-gcc" CROSS_COMPILE="arm-android-linux-uclibcgnueabi-" sysconfdir=/system/usr/local/etc sysconfjoesubdir=/joe \

CFLAGS=" -static $_XXFLAGS"

make

arm-android-linux-uclibcgnueabi-strip joe

On device:

copy joe in /system/bin

copy joerc in /system/usr/local/etc/joe

copy jupprc in /system/usr/local/etc/joe

copy jmacsrc in /system/usr/local/etc/joe

copy sintax files in /system/usr/local/etc/joe/syntax

chmod 755 /system/bin/joe

ln -s /system/bin/joe /system/bin/jupp

ln -s /system/bin/joe /system/bin/jmacs

chmod 644 /system/usr/local/etc/joe/joerc

chmod 644 /system/usr/local/etc/joe/jupprc

chmod 644 /system/usr/local/etc/joe/jmacsrc

before running joe we must define TERM

export TERM=ansi

8. How to use dinamic linking and shared libraries

(if we installed programs in local directory in sys-root,

so copy lib from local)

cd ~/build/cross/sys-root

tar -jcf lib.tar.bz2 lib/

And on device:

cd /system/usr/local

busybox tar -xcf /sdcard/lib.tar.bz2

For our programs, wich uses this non-standart library path we may create this script and run your programs by it:

#!/bin/sh

export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

exec /usr/bin/local/some_program $*

9. Building libFLAC in shared library, which we can use easy and copy to /system/lib,

which have nothing in NEEDED - just kernel and you, also no any libc (bionic, or uClibc) not used.

Download latest version of libFLAC from the official site, unpack and cd to dir:

./autogen.sh --host=arm --target=arm-android-linux-uclibcgnueabi CC="arm-android-linux-uclibcgnueabi-gcc" \

CXX="arm-android-linux-uclibcgnueabi-g++" STRIP="arm-android-linux-uclibcgnueabi-strip" \

AR="arm-android-linux-uclibcgnueabi-ar" AS="arm-android-linux-uclibcgnueabi-as" LD="arm-android-linux-uclibcgnueabi-ld" \

RANLIB="arm-android-linux-uclibcgnueabi-ranlib" OBJDUMP="arm-android-linux-uclibcgnueabi-objdump" \

NM="arm-android-linux-uclibcgnueabi-nm" CROSS_COMPILE="arm-android-linux-uclibcgnueabi-" \

CFLAGS=" -nodefaultlibs -nostdlib -fPIC $_XXFLAGS" \

CXXFLAGS=" -nodefaultlibs -nostdlib -fPIC $_XXFLAGS" \

LDFLAGS=" -fPIC -static -s -L$HOME/build/cross/sys-root/usr/lib -lm -lc" --prefix="$HOME/build/cross/sys-root/usr" \

--disable-ogg --disable-oggtest --disable-rpath --disable-xmms-plugin --disable-cpplibs --disable-altivec \

--disable-3dnow --disable-thorough-tests --disable-doxygen-docs

cd src/libFLAC

make

cd .libs

arm-android-linux-uclibcgnueabi-ld -shared -s -o libFLAC.so -whole-archive libFLAC.a

And now we have shared library libFLAC.so, lybrary without any dependency, and which we can just copy in /system/lib

on device and use it from any program.

For programming on libFLAC you must see header files of libFLAC

10. Building xvid in shared library, without any dependecy, same as libFLAC.

cd src/build/generic

./configure --host=arm --target=arm-android-linux-uclibcgnueabi CC="arm-android-linux-uclibcgnueabi-gcc" \

CXX="arm-android-linux-uclibcgnueabi-g++" STRIP="arm-android-linux-uclibcgnueabi-strip" \

AR="arm-android-linux-uclibcgnueabi-ar" AS="arm-android-linux-uclibcgnueabi-as" \

LD="arm-android-linux-uclibcgnueabi-ld" RANLIB="arm-android-linux-uclibcgnueabi-ranlib" \

OBJDUMP="arm-android-linux-uclibcgnueabi-objdump" NM="arm-android-linux-uclibcgnueabi-nm" \

CROSS_COMPILE="arm-android-linux-uclibcgnueabi-" \

CFLAGS=" -nodefaultlibs -nostdlib -fPIC $_XXFLAGS" \

CXXFLAGS=" -nodefaultlibs -nostdlib -fPIC $_XXFLAGS" \

LDFLAGS=" -fPIC -static -s -L$HOME/build/cross/sys-root/usr/lib -lm -lc" --prefix="$HOME/build/cross/sys-root/usr"

cd =build

rm-android-linux-uclibcgnueabi-ld -shared -s -o libxvidcore.so -whole-archive libxvidcore.a

So we have libxvidcore.so, which using very-very simple and copy-only-use too.

11. Building nmap

svn co --username guest --password "" svn://svn.insecure.org/nmap/

cd nmap

./configure --host=arm-android-linux-uclibcgnueabi CC="arm-android-linux-uclibcgnueabi-gcc" \

CROSS_COMPILE="arm-android-linux-uclibcgnueabi-" CFLAGS=" -static $_XXFLAGS" \

CXXFLAGS=" -static $_XXFLAGS" \

--prefix="$HOME/build/cross/sys-root/system/usr/local" --with-lua=included --with-pcap=included --with-pcre=included --with-dnet=included

make

make install

12. Building dropbear

./configure --host=arm-android-linux-uclibcgnueabi CC="arm-android-linux-uclibcgnueabi-gcc" \

CROSS_COMPILE="arm-android-linux-uclibcgnueabi-" \

CFLAGS=" -static $_XXFLAGS" \

--prefix="$HOME/build/cross/sys-root/system/usr/local" --disable-zlib

make

make install

copy dbclient, dropbearconvert and dropbearkey in /system/bin

copy dropbear in /system/sbin

chown root on all copied files

chmod 755 on all copied files