Tuesday, October 9, 2012

Compile binutils on your phone with C4Droid

1. Make your sdcard executable by remounting it as rw, and therefore removing noexec flag.
2. After wget binutils-2.22.tar.gz and extracting it, change shebangs in configure, missing, install-sh and mkinstalldirs to #!/system/bin/sh.
3. I made a shell script in /data/local/bin/ that creates TEMP and TMP environmental variables equal to GCCROOT/tmpdir and then runs arm-linux-androideabi-gcc with any args passed. You could also use a symbolic link or add GCCROOT to your path. Either way do the same for make, ar, as, ld and strip.
4. Run ./configure --prefix=/data/local/ SHELL=/system/bin/sh MAKE_SHELL=/system/bin/sh CFLAGS=-fno-short-enums
5. Forgot to mention patches. (a) unistd.h getpagesize macro isn't detected, so comment out redundant definition in getpagesize.c (b) time returns time_t pointer so cast it from int in archive.c (c) bucomm.c calls mkdtempwhich is never declared in bionic so add extern char * mkdtemp(char * path) to bucomm.h (d) there's one other type mismatch but I can't remember where.
6. Run make and make install and Viola!

No comments:

Post a Comment

Fork me on GitHub