Skip to content
git-core edited this page Nov 26, 2012 · 4 revisions

Build instructions

  1. Usually su-binary is compiled against AOSP tree. If you're gonna compile it yourself, you have to follow first two steps described in the AOSP Getting Started page: initialize a build environment and download the source tree.
    Note: su-binary doesn't require any Java for successful compilation, so you don't have to install a JDK if you're planning to build su-binary only. Unfortunately, AOSP does check the presence of Sun's JDK even if no Java code are going to be compiled. Well, you have to just fool standard AOSP build procedure, look at the Successful compilation without JDK section I'll tell how to do it a bit later.

  2. After download of the entire AOSP tree is completed, follow first two steps described in the AOSP Building the System page, namely Initialize and Choose a Target.

  3. Clone su-binary repository in the AOSP tree. Top of the tree is a good choice.

  4. Build su-binary
    $ make su-gc

The compilation procedure will check all prerequisites, calculate all dependencies for su-binary, compile calculated dependencies, and, finally, compile su-binary itself. When the procedure finishes, su-binary is left somewhere in the out directory as an executable file named su-gc.

How to test su-binary

Before replacing /system/bin/su with a fresh compiled copy, you have to ensure that newer su works somehow, haven't you? If you don't like to pollute internal memory (flash) of your phone, you may put su-binary executable into the /dev directory, which is on tmpfs. Don't forget to set 06755 permissions (i.e. suid and sgid bits). After that, you can invoke /dev/su for testing purposes.

Successful compilation without JDK

  1. Create an empty lib/tools.jar file somewhere. For example,
    $ touch ~/fake/lib/tools.jar
  2. Set the ANDROID_JAVA_HOME environment variable pointing to "somewhere":
    $ export ANDROID_JAVA_HOME=~/fake
  3. Create a wrapper script for java and javac:
    $ cat > ~/fake/bin/java
    #!/bin/sh
    echo java version \"1.6\"
    <Ctrl+D>
    (Don't forget to make it executable)
    $ ln -s java ~/fake/bin/javac
  4. Add the directory which contains the wrapper script in the PATH environment variable
    $ export PATH=~/fake/bin:$PATH
Clone this wiki locally