[T-Mobile Samsung Galaxy S II SGH-T989] Royalknight6190:
*WARNING! I Am Not Responsible For Anything That Happens To Your Device or Computer*​

Here is another Gift from the DARKSIDE Dev Team:

Compiling CM from Source

Thank you to Sparksco for building a great base tutorial that I used help build this.

Original Thread Found Here

Updated info for non-debian based systems thanks to Vicodan:

If you want to use this on fedora or non-debian based systems you will need to replace every command that says apt-get to yum. Thanks to Vicodan for pointing this out.​

*Note: Not currently working on Tmobile Hercules, for learning purposes only until source is out for our device​

If you can add anything let me know and I will add to this or edit the tutorial, 2nd post will be for building from Google Source AOSP.​

Hardware Requirements:

- A minimum dual core pc, the more ram the better

- A working wifi connection or network connection

- Linux Operating System. Either 32-bit or 64-bit will work

NOTE: 64-bit will run faster and you need 64bit to build Android 2.3 +

You also need full access to CM source but CM is hording those

Black Bold Print = Instructions

Red Bold Print = Terminal Code

Italic Font = Misc. Details

Optional Recommended Software:

Many of these can be found in the software center using the search box

If you find multiple versions it's ok to install them all, unless it says

otherwise

Python

Open the terminal application and type

[COLOR="red"][B]$ sudo apt-get install python[/B][/COLOR]

awk and gawk

7zip

RAR

[COLOR="red"][B]$ sudo apt-get install rar[/B][/COLOR]

Step 1 java:

Setting up java is one of the most important step to getting your pc prepared for a build environment. Truly this step is whatever is going to work best on your system, I do it this way and you can try it whichever way you want. Take my advise or not.

NOTE: On Ubuntu 11.10, and variants, you need to enable the

parter repository to install sun-java6-jdk:

[COLOR="red"][B]$ sudo add-apt-repository "deb http://archive.canonical.com/ maverick partner"

$ sudo apt-get update

$ sudo apt-get install openjdk-6-jdk[/B][/COLOR]

then do

[COLOR="red"][B]$ sudo apt-get install -y git-core gnupg flex bison gperf libsdl1.2-dev libesd0-dev libwxgtk2.6-dev squashfs-tools build-essential zip curl libncurses5-dev zlib1g-dev pngcrush schedtool g++-multilib lib32z1-dev lib32ncurses5-dev lib32readline5-dev gcc-4.3-multilib g++-4.3-multilib

$ java -version[/B][/COLOR]

The correct version is:

java -version

java version "1.6.0_26"

Java(TM) SE Runtime Environment (build 1.6.0_26-b03)

Java HotSpot(TM) 64-Bit Server VM (build 20.1-b02, mixed mode)

You must have a 1.6.x to compile on the gingerbread branch of cyanogenmod. If you have the correct

Step 2 - Install git

[COLOR="Red"][B]$ sudo apt-get install git[/B][/COLOR]

Step 3 - Prepare the Build Environment

NOTE: You only need to do these steps the first time you build.

If you previously prepared your build environment, skip to Copy

proprietary files.

3a - Install the ADB

To let Samsung Galaxy S2 be recognised by the debugger add these lines to 92-samsung.rules in /etc/udev/rules.d

[COLOR="red"][B]$ sudo gedit 92-samsung.rules in /etc/udev/rules.d[/B][/COLOR]

paste

[B]SUBSYSTEMS=="usb", ATTRS{idVendor}=="04e8",
ATTRS{idProduct}=="6640", MODE="0660", OWNER="root",
GROUP="androiddev", SYMLINK+="android%n"
SUBSYSTEM=="usb", SYSFS{idVendor}=="04e8", MODE="0666"[/B]

save and exit

$ sudo gedit /etc/udev/rules.d/51-android.rules

paste

[B]SUBSYSTEM=="usb", ATTRS{idVendor}=="0bb4", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0502", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="12d1", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="1004", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="22b8", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="04e8", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0fce", MODE="0666"
SUBSYSTEM=="usb", ATTRS{idVendor}=="0489", MODE="0666"
SUBSYSTEM==”usb”, ATTRS{idVendor}==”18d1″, SYMLINK+=”android_adb”, MODE=”0666″
SUBSYSTEM=="usb", ATTRS{idVendor}=="04e8", MODE="0666", GROUP="plugdev"[/B]

save and exit

[COLOR="red"][B]$ sudo gedit .bashrc[/B][/COLOR]

paste at the top

[B]#AndroidDev PATH
export PATH=${PATH}:~/androidsdk/tools
export PATH=${PATH}:~/androidsdk/platform-tools[/B]

save and exit

Now to Install the SDK, be prepared this takes some time:

Go to Android Developers SDK Download Found Here - Link

or

Download directly from This Link - Download Link

Once done extract the contents to your home folder, then rename it to androidsdk.

Once extracted and renamed go to /androidsdk/tools and double click the file android and click run in terminal.

Android SDK updater will pop up, select the option New and start the upgrade. Now wait. When finished do new one more time to make sure you got everything, once done close SDK window and terminal window.

3b - Install the Build Packages

Install using the package manager of your choice:

For 32-bit & 64-bit systems:

[COLOR="red"][B]$ sudo apt-get install git-core gnupg flex bison gperf libsdl1.2-dev libesd0-dev libwxgtk2.6-dev squashfs-tools build-essential zip curl libncurses5-dev zlib1g-dev sun-java6-jdk pngcrush schedtool[/B][/COLOR]

For 64-bit only systems:

[COLOR="red"][B]$ sudo apt-get install g++-multilib lib32z1-dev lib32ncurses5-dev lib32readline-gplv2-dev gcc-multilib g++-multilib[/B][/COLOR]

4a - Create the Directories

You will need to set up some directories in your build environment.

To create them:

[COLOR="red"][B]$ mkdir -p ~/bin

$ mkdir -p ~/android/system[/B][/COLOR]

4b - Install the Repository

Enter the following to download make executable the "repo" binary:

[COLOR="red"][B]$ curl https://raw.github.com/android/tools_repo/master/repo > ~/bin/repo

$ chmod a+x ~/bin/repo[/B][/COLOR]

NOTE: You may need to reboot for these changes to take effect.

Now enter the following to initialize the repository, repo sync will take a long time so sit back and watch the code on terminal scroll, dont touch it, toss in Star Wars Saga or Lord of the Rings Trilogy and watch from start to finish and it might be done:

[COLOR="red"][B]$ cd ~/android/system/

$ repo init -u git://github.com/CyanogenMod/android.git -b gingerbread --repo-url=git://github.com/android/tools_repo.git

$ repo sync[/B][/COLOR]

4c - Copy proprietary files

NOTE: This only needs done the first time you build. If you have

already done these steps, you may skip to Download RomManager.

You will need to have a speedy with a working copy of CyanogenMod

install and ADB working on the computer. This script will copy the

proprietary files from the device.

Connect the device to the computer and ensure that ADB is working

properly.[/B]

[COLOR="red"][B]$ cd ~/android/system/device/samsung/(DEVICE NAME)

./extract-files.sh[/B][/COLOR]

4d - Download RomManager

NOTE: This only needs to be done when an update to

RomManager is released. If you are-up-to date, you may skip to Building

CyanogenMod. Download RomManager which is needed by the build:

[COLOR="red"][B]$ ~/android/system/vendor/cyanogen/get-rommanager[/B][/COLOR]

5a - Building CyanogenMod

Check for updates

First, check for updates in the source:

[COLOR="red"][B]$ cd ~/android/system/

$ repo sync

$ cp build/core/root.mk -f Makefile[/B][/COLOR]

5b - Set up your Compiler

This is optional but helpful for kernel compiling

There are a lot of things that need to be added to the .bashrc to let your

pc know about which type of compiler you want to use. The best way is

to use the one provided in the CM7 work tree.

[COLOR="red"][B]#Android

export ARCH=arm

export CCOMPILE=$CROSS_COMPILE

export PATH=$PATH:~/android/system/prebuilt/linux-x86/toolchain/arm-eabi-4.4.3/bin[/B][/COLOR]

6 - Configure Build & Compile

Now, the environment must be configured to build and the ROM

compiled, from code, for the GalaxyS2.

[COLOR="red"][B]$ . build/envsetup.sh && brunch (DEVICE NAME)[/B][/COLOR]

7 - Install

Copy your .zip file from

~/android/system/out/target/product/galaxys2att/update.cm-XXXXX-

signed.zip to the root of the SD card.

Optional: Download Google Apps for CyanogenMod 7 and place it on the

root of the SD card.

Flash both of these .zip files from recovery.