Tell me more ×
Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It's 100% free, no registration required.

I know that the source code for the su binary is located on github. I would like to learn what the procedure is for building/compiling the su source into a file that is usable for device rooting. Thanks!

share|improve this question
Development questions are off-topic; see the FAQ. – Matthew Read Jan 28 '12 at 22:23
@Matthew: Where would be the appropriate place to post this question? – kaspnord Jan 28 '12 at 22:44
The su binary has nothing to do with rooting. It just substitutes the current user with another one. Usually root. – Flow Jan 28 '12 at 23:24

closed as off topic by Matthew Read Jan 28 '12 at 22:25

Questions on Android Enthusiasts Stack Exchange are expected to relate to Android within the scope defined in the FAQ. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about closed questions here.

1 Answer

up vote 2 down vote accepted

There are some instructions for building and testing su on Github. The build procedure is:

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. Change value of the LOCAL_MODULE variable to su-binary (from su) in su-binary/Android.mk. Alternatively, you may remove entire system/extras/su directory or edit system/extras/su/Android.mk

  5. Build su-binary

    $ make su-binary

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.

The last bit about it appearing "somewhere in the out directory" isn't very specific, but the build should tell you where it ends up. On my machine the binary is located at out/target/product/generic/system/xbin/su-binary.

share|improve this answer
Thanks for pointing me in the right direction :) – kaspnord Jan 28 '12 at 22:39

Not the answer you're looking for? Browse other questions tagged or ask your own question.