FORUMS
Remove All Ads from XDA

[GUIDE] How To Build CM9 From Source Code Ubuntu 11.10 64-Bit

305 posts
Thanks Meter: 267
 
By gooch1025, Senior Member on 18th March 2012, 02:04 AM
Post Reply Email Thread
Building CM9 From Source On The Epic 4G

I just recently built CM9 for the Epic 4G since Contacts.apk and the Honeycomb Ripple Lockscreen Mod need to be built from source to work properly on our phones. If you follow my instructions exactly, you should have a working CM9 build for the Epic 4G. You can then modify whatever you need to customize your apks, jar files, etc.

Now lets get started. You will need to install Ubuntu 11.10 64-Bit on your computer. It can be a virtual machine, an install using Wubi, or an actual partition for Ubuntu. You will need at least 30gb available for Ubuntu since the repository and the build take up a lot of space.

(Note: It Must Be Ubuntu 11.10 64-Bit And Have A Working Internet Connection!)

Install Java JDK

Once Ubuntu is installed the first thing you will need to do is install Java JDK. Open up a terminal or press Ctrl+Alt+T on the keyboard and copy the following commands:

Code:
sudo add-apt-repository ppa:ferramroberto/java
sudo apt-get update
sudo apt-get install sun-java6-jdk sun-java6-plugin
After the first command is entered, it will ask you for your password. Enter it and continue with the commands. Once Java is about to install, it will tell you how much additional disk space Java will add to your hard drive and ask if you want to continue. Press Y and hit Enter. When Java is done installing, you should see a window that pops up with the Java Licensing Agreement. Use the arrow keys or the Tab key on your keyboard to navigate to the OK button and press Enter. Then Navigate to Yes and hit Enter again. Java is now installed on your Computer!

Install Android SDK For Linux

Next, you will need to install android sdk. Google search android sdk and it should be the first link that pops up. Click on it and download android-sdk_r18-linux.tgz for Linux. Now go back to your terminal and enter the following commands:

Code:
cd Downloads
tar -xvzf android-sdk_r18-linux.tgz 
rm *.tgz
mv android-sdk-linux/ ..
cd ../android-sdk-linux/
In case you don't know what you just did, you navigated to your Downloads folder and extracted the android-sdk-linux folder. Then you deleted the compressed file and moved your android-sdk-linux folder to your Home directory. Finally, you navigated to your android-sdk-linux folder.

Now we need to open the Android SDK Manager and download the necessary packages. In the terminal, copy:

Code:
tools/android
It should pop up the Android SDK Manager. Now make sure the Tools folder, and Android 4.0.3 (API 15) packages are selected and click on Install Packages. Check Accept All and click on Install. Once all the packages have been loaded, close out of the Download window and the Android SDK Manager. Go back to your terminal and Type:

Code:
cd
This will navigate you back to your Home Directory.

The Rest Of The Guide Will Need To Be Done In The Root Terminal!

In the terminal type:

Code:
sudo -i
Then enter your password. You are now logged in as root! (Or superuser)

Install Packages

Now we need to install all the necessary packages to make the CM9 build. In the terminal, copy:

Code:
apt-get install python git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev libc6-dev libncurses5-dev lib32ncurses5-dev ia32-libs x11proto-core-dev libx11-dev lib32readline-gplv2-dev lib32z-dev libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown libxml2-utils libsdl1.2-dev libesd0-dev libwxgtk2.6-dev squashfs-tools build-essential pngcrush schedtool gcc-multilib
Again, press Y and hit Enter.

Configuring USB

Time to set up all devices to work with USB.

Code:
gksudo gedit /etc/udev/rules.d/51-android.rules
This will create a new file to configure the USB devices. Copy and paste this into the file:

Code:
#Acer
SUBSYSTEM==usb, SYSFS{idVendor}==0502, MODE=0666
#ASUS
SUBSYSTEM==usb, SYSFS{idVendor}==0b05, MODE=0666
#Dell
SUBSYSTEM==usb, SYSFS{idVendor}==413c, MODE=0666
#Foxconn
SUBSYSTEM==usb, SYSFS{idVendor}==0489, MODE=0666
#Garmin-Asus
SUBSYSTEM==usb, SYSFS{idVendor}==091E, MODE=0666
#Google
SUBSYSTEM==usb, SYSFS{idVendor}==18d1, MODE=0666
#HTC
SUBSYSTEM=="usb", SYSFS{idVendor}=="0bb4", MODE=0666
#Huawei
SUBSYSTEM==usb, SYSFS{idVendor}==12d1, MODE=0666
#K-Touch
SUBSYSTEM==usb, SYSFS{idVendor}==24e3, MODE=0666
#KT Tech
SUBSYSTEM==usb, SYSFS{idVendor}==2116, MODE=0666
#Kyocera
SUBSYSTEM==usb, SYSFS{idVendor}==0482, MODE=0666
#Lenevo
SUBSYSTEM==usb, SYSFS{idVendor}==17EF, MODE=0666
#LG
SUBSYSTEM==usb, SYSFS{idVendor}==1004, MODE=0666
#Motorola
SUBSYSTEM==usb, SYSFS{idVendor}==22b8, MODE=0666
#NEC
SUBSYSTEM==usb, SYSFS{idVendor}==0409, MODE=0666
#Nook
SUBSYSTEM==usb, SYSFS{idVendor}==2080, MODE=0666
#Nvidia
SUBSYSTEM==usb, SYSFS{idVendor}==0955, MODE=0666
#OTGV
SUBSYSTEM==usb, SYSFS{idVendor}==2257, MODE=0666
#Pantech
SUBSYSTEM==usb, SYSFS{idVendor}==10A9, MODE=0666
#Philips
SUBSYSTEM==usb, SYSFS{idVendor}==0471, MODE=0666
#PMC-Sierra
SUBSYSTEM==usb, SYSFS{idVendor}==04da, MODE=0666
#Qualcomm
SUBSYSTEM==usb, SYSFS{idVendor}==05c6, MODE=0666
#SK Telesys
SUBSYSTEM==usb, SYSFS{idVendor}==1f53, MODE=0666
#Samsung
SUBSYSTEM==usb, SYSFS{idVendor}==04e8, MODE=0666
#Sharp
SUBSYSTEM==usb, SYSFS{idVendor}==04dd, MODE=0666
#Sony Ericsson
SUBSYSTEM==usb, SYSFS{idVendor}==0fce, MODE=0666
#Toshiba
SUBSYSTEM==usb, SYSFS{idVendor}==0930, MODE=0666
#ZTE
SUBSYSTEM==usb, SYSFS{idVendor}==19D2, MODE=0666
Save the file and close the window. Next set the permissions for the file you just created:

Code:
chmod a+r /etc/udev/rules.d/51-android.rules
Installing Repo

Next, we need to install the CM9 repository.

Code:
mkdir ~/bin
gedit /etc/environment
This will open up your Environment Variables so you can use adb and other commands no matter what directory you're in.

Copy and paste this into the end of the file:

Code:
:/home/gooch/android-sdk-linux/tools:/home/gooch/android-sdk-linux/platform-tools:/root/bin
Replace gooch with your Username that you set up and make sure to leave the quotes! It should look like one big line.

Now Logout and Log back in! This will update your Environment Variables.

Once you're logged back in, open up the terminal and log back in as root:

Code:
sudo -i
Enter your password and then copy the following commands:

Code:
curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
chmod a+x ~/bin/repo
mkdir CM9
cd CM9
repo init -u git://github.com/CyanogenMod/android.git -b ics
repo sync
These commands will set everything up and download the CM9 repository. (This will take a long time to download!)

(Note: If your download freezes or hangs, close the terminal and open up a new one. Log back into root and repeat these steps)

Code:
cd CM9
repo sync
This will continue where you left off. Once everything is synced, enter in the terminal:

Code:
nautilus
This will open up a root file explorer. navigate to the CM9/device/samsung folder and see if there is a folder called "epicmtd". If there is, skip to Copy Proprietary Files. If not, close the file explorer and type:

Code:
brunch epicmtd

This should gather the epicmtd folder for you. If it starts to build, exit the terminal Immediately!


Open another terminal, log into root, and open up the root file explorer again:

Code:
nautilus
Check if the "epicmtd" is there again. If it's there, Navigate back to the CM9 folder and then navigate to the out/target/product folder. If there is a folder called "epicmtd", delete it and close the root file explorer.

Copy Proprietary Files

Next you need to download the proprietary files from your phone. You must have a working CM9 ROM currently on your phone. Make sure USB Debugging is on and plug your phone into your computer. (You can find this under Settings-Developer Options-USB Debugging)

In the terminal, navigate the the "CM9" folder if you're not already there:

Code:
cd CM9
Then copy the following commands:

Code:
cd device/samsung/epicmtd
./extract-files.sh
This will gather all the necessary files needed from your phone. Once this is finished, navigated back to the "CM9" folder by entering:

Code:
cd
cd CM9
Now enter:

Code:
vendor/cm/get-prebuilts
(Note: The whole "Copy Proprietary Files" step only needs to be done once to set everything up!)


Build Source

Finally, We can build the CM9 Source Code.

In the terminal, copy the commands:

Code:
. build/envsetup.sh
brunch epicmtd
This will take a while, but if you set up everything correct, you should have a working, flashable CM9 ROM in the CM9/out/target/product/epicmtd folder. The .zip is called something like "update-cm-9.0.0-RC0-epicmtd-KANG-signed".

Copy that to your phone's SD Card and reboot into recovery mode. Wipe user data, cache, and dalvik cache, and flash. If it installs and your phone boots up with CM9, You just made a successful build!

You can delete the "epicmtd" folder created in the CM9/out/target/product directory by running in CM9 directory:

Code:
make clobber
Now you can modify the Source Code, and build again by issuing these two simple commands:

Code:
. build/envsetup.sh
brunch epicmtd

I hope you enjoyed this tutorial and that it helped you. Start building!




Thanks to UberPinguin for helping me with my Source Build
The Following 39 Users Say Thank You to gooch1025 For This Useful Post: [ View ] Gift gooch1025 Ad-Free
 
 
18th March 2012, 02:09 AM |#2  
tazfanatic's Avatar
Senior Member
Flag Brockton, MA
Thanks Meter: 1,263
 
More
let me first off say thanks for this i have book marked and subscribed and FIRST for the first time lol
The Following User Says Thank You to tazfanatic For This Useful Post: [ View ] Gift tazfanatic Ad-Free
18th March 2012, 02:14 AM |#3  
shane6374's Avatar
Senior Member
Flag Minneapolis
Thanks Meter: 1,270
 
Donate to Me
More
Second!!! Gonna set this up now!

Writen in plain english. Amazing!

It's building! (Nexus)
18th March 2012, 03:01 AM |#4  
deciple's Avatar
Senior Member
Flag Salem
Thanks Meter: 46
 
Donate to Me
More
Good job man!
Broadcast to the public; to promote self awareness.
18th March 2012, 04:48 AM |#5  
AproSamurai's Avatar
Inactive Recognized Developer
Flag Van Nuys, CA
Thanks Meter: 1,190
 
More
You can just run 'make clean', if I recall correctly. And it'll remove the epicmtd directory within /out section so that you can build again. No need to manually remove it.

Sent from my SPH-D700 using xda premium
18th March 2012, 04:58 AM |#6  
gooch1025's Avatar
OP Senior Member
Thanks Meter: 267
 
Donate to Me
More
Quote:
Originally Posted by AproSamurai

You can just run 'make clean', if I recall correctly. And it'll remove the epicmtd directory within /out section so that you can build again. No need to manually remove it.

Sent from my SPH-D700 using xda premium

Thanks, I'll test and make sure that works.

Sent from my CM9 Epic Blue Mist using xda premium
The Following User Says Thank You to gooch1025 For This Useful Post: [ View ] Gift gooch1025 Ad-Free
18th March 2012, 05:44 AM |#7  
chuckdez's Avatar
Member
Thanks Meter: 33
 
More
make clobber will wipe the out folder.

Also, ubuntu uses gcc 4.6 which causes problems if try any custom optimization. I personally use debian32 with gcc 4.4.

Another tip is you can add the gihub CyanogemMod vendor samsung epicmtd to your local_manifest.xml instead of pulling the vendor files from your own phone.

Sent from my SPH-D700 using XDA App
The Following User Says Thank You to chuckdez For This Useful Post: [ View ] Gift chuckdez Ad-Free
18th March 2012, 05:48 AM |#8  
thomasskull666's Avatar
Senior Member
Flag St. Louis
Thanks Meter: 415
 
Donate to Me
More
Thanks for this!

Sent from my SPH-D700 using xda premium
18th March 2012, 05:53 AM |#9  
AproSamurai's Avatar
Inactive Recognized Developer
Flag Van Nuys, CA
Thanks Meter: 1,190
 
More
There you go, it was clobber lmao. Hahaha I was thinking of something else.:| Apologies.

Sent from my SPH-D700 using xda premium
18th March 2012, 06:27 AM |#10  
gooch1025's Avatar
OP Senior Member
Thanks Meter: 267
 
Donate to Me
More
Awesome, thanks guys.

Sent from my CM9 Epic Blue Mist using xda premium
18th March 2012, 07:42 AM |#11  
deciple's Avatar
Senior Member
Flag Salem
Thanks Meter: 46
 
Donate to Me
More
Quote:
Originally Posted by chuckdez

make clobber will wipe the out folder.

Also, ubuntu uses gcc 4.6 which causes problems if try any custom optimization. I personally use debian32 with gcc 4.4.

Another tip is you can add the gihub CyanogemMod vendor samsung epicmtd to your local_manifest.xml instead of pulling the vendor files from your own phone.

Sent from my SPH-D700 using XDA App

Soooooo.....git://github.com/CyanogenMod/android.git -b Samsung epicmtd?


Broadcast to the public; to promote self awareness.
Post Reply Subscribe to Thread

Tags
cm9, cm9 source, epic, epic 4g, ubuntu 11.10

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes