Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

[Guide] to Build your KitKat ROM (CM-AOKP-Carbon-Slim) x N5 from source (Ubuntu14LTS)

OP PippoX3

20th January 2014, 01:43 PM   |  #1  
PippoX3's Avatar
OP Senior Member
Flag TN - Italy
Thanks Meter: 1,615
 
938 posts
Join Date:Joined: Aug 2010
Donate to Me
More
Hi, my name's Stefano I'm from Italy, and sorry for my poor english. This is the guide to build your own the KitKat (or whatever branch you want) for your HammerHead. We'll start, obviously, setting up your client (PC), and here we'll use ubuntu x64. Is possible to use almost any linux distribution (also MacOSX) but I prefer to stay on what is much supported and known (for me!). This guide is taken from internet and reading forums/blogs. I didn't invent anything, you can found a lot of guides like this. Just this is updated with last changes. For the setup part I read and paste a lot from here (thanks to sylentprofet).
Regard the hardware side you'll need at least of:
  • a Dual Core processor
  • 4 Gb of RAM
  • 80 Gb of hard disk for each repository (Better if SSD but don't required)
  • The Graphics Card don't care, we don't use to compile
  • A good internet connection, you have to download up to 40 Gb of stuff
  • A lot of patience, if you aren't go to download a ready ROM, it's better!
  • Time, time, time, time and again time!

How to Configure Ubuntu for Properly Compiling Android ROMs


This guide applies to Ubuntu 13.04 Raring Ringtail 64 bit (but also down to 12.04 LTS which is the version that I prefer). Do not use the 32 Bit version. Also, PAY CLOSE ATTENTION when to use “sudo” and when to not. It can make things funky if you do something as root that you shouldn’t. During normal build you don't have absolutely need to use "sudo", just during the PC setup.
Much thanks goes out to Google, ProTekk, Canonical, and everyone else that I read a random paragraph here and snippet there.
First, let’s set up the correct JDK.
Many of you probably have some kind of wrong Java installed. Sad cupcake.Let’s get rid of that. Copy and paste this into a Terminal window:
Code:
sudo apt-get purge openjdk-\* icedtea-\* icedtea6-\*
Back to the Terminal. Copypasta the following:
Code:
sudo add-apt-repository ppa:webupd8team/java
This will add the correct PPA to your system for updated builds of Java 6 JDK that are compatible with 13.04 (or less). No more unrecognized Java version errors! Yay! And it’s self updating, so you don’t have to redownload binaries everytime they release a new version.

Next, we actually need to install the package. More copypasta:
Code:
sudo apt-get update && sudo apt-get install oracle-java6-installer
Follow the onscreen instructions. You have to Accept the Licensing Agreement or whatever. Hopefully no human centipede clauses. Once that is completed successfully, you will have to restart any open browsers with Java content for it to display correctly.

To make sure the correct version of Java is activated, run the following at the Terminal prompt:
Code:
java -version
You should see something like the following:
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode)

Ok, back to a fresh Terminal prompt. Time for installing the guts to build stuff in Ubuntu. Because (K)Ubuntu no longer carries ia32-libs-multiarch and ia32-libs (from Saucy onwards), it is necessary to install from precise repos:
Code:
sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu/ precise main restricted universe multiverse"
sudo apt-get update
sudo apt-get install ia32-libs-multiarch
once is installed, you can remove repository:
Code:
sudo add-apt-repository --remove "deb http://archive.ubuntu.com/ubuntu/ precise main restricted universe multiverse"
sudo apt-get update
Before start, install:
Code:
sudo apt-get install dpkg-dev
Code:
sudo apt-get install git-core gnupg flex bison gperf build-essential zip curl zlib1g-dev zlib1g-dev:i386 libc6-dev lib32ncurses5-dev x11proto-core-dev libx11-dev:i386 libreadline6-dev:i386 lib32z-dev libgl1-mesa-glx:i386 libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown libxml2-utils xsltproc readline-common libreadline6-dev libreadline6 lib32readline-gplv2-dev libncurses5-dev lib32readline5 lib32readline6 libreadline-dev libreadline6-dev:i386 libreadline6:i386 bzip2 libbz2-dev libbz2-1.0 libghc-bzlib-dev lib32bz2-dev libsdl1.2-dev libesd0-dev squashfs-tools pngcrush schedtool libwxgtk2.8-dev python
And we wait. Don’t worry, this isn’t the crazy downloading part just yet.
When that is done, do this:
Code:
sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so
Now it's time to download and setup SDK Tools. First of all download Android SDK Tools for Linux x64. Extract the folder “sdk”, inside package, into your "Downloads" folder and rename it to "AndroidSDK" e.g..
Then come to your terminal and type:
Code:
cd ~/Downloads/AndroidSDK/tools
and after:
Code:
./android sdk
You can now see the GUI that propose all installable packages. Install Platform tools and Tools for most recent Android (4.4), with the most higher API (19+) version. Flag "accept" and install.

Once is complete, you have you need the binary for repo that will let you talk to git servers and download all that precious source code:
Code:
mkdir ~/bin

curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo

curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo

chmod a+x ~/bin/repo
Open "~/.bashrc" to add a line:
Code:
sudo nano ~/.bashrc
At the very bottom, add the following line:
Code:
export PATH=~/bin:$PATH
Save it. In nano that would be Ctrl-O and then Enter. Then Ctrl-X to exit back to a prompt. Type to restart bash:
Code:
source ~/.bashrc
Now you have all need to work (or play) with your ubuntu and it's time to give the sources (repositories) from your preferred Team (who share the source code for their rom). The most known host service for sources and projects is GitHub. E.g. https://github.com/CyanogenMod/
The point of start of any repo is its "manifest" (default.xml) where the team list all it's projects (here an example), only the necessary to the building process.
Until last year was necessary to compile (before begin and looking to platform manifest) an own local manifest where we exclude from download all the devices/kernel/vendor parts unnecessary for our device. This saves up to some Gigabytes of download.
Fortunately now the repositories will download itself the necessary devices/kernel/vendor parts when we'll choose ("lunch") the device to build ("make"). With the exception of AOKP who wanna know, before initialize your local repo, for which device/s you'd like build.

Now I'll write a section for each Team/ROM you want to initialize, that's for me has sense. How take a sense to put each "platform/project" in a different folder (e.g. CarbonDev in a folder and Cyanogenmod in another, both sons of your Home folder).
In the waiting to read next part, better familiarize a little with terms like "breakfast, brunch, lunch, make" into Android contest.
Last edited by PippoX3; 19th August 2014 at 03:10 PM. Reason: Updated to Ubuntu 14 LTS
The Following 17 Users Say Thank You to PippoX3 For This Useful Post: [ View ]
20th January 2014, 01:44 PM   |  #2  
PippoX3's Avatar
OP Senior Member
Flag TN - Italy
Thanks Meter: 1,615
 
938 posts
Join Date:Joined: Aug 2010
Donate to Me
More
Video Building Cyanogenmod
In the terminal, now we'll make a folder where to store the Android source code. Typically will make it in your home folder, within a folder called like your projected ROM, to identify from other stuff, open your terminal and type:
Code:
mkdir –p ~/Cyanogenmod
cd ~/Cyanogenmod
Now we are going to initialize your local repository, with the "branch" cm-11.0 (KitKat), in your terminal:
Code:
repo init -u git://github.com/CyanogenMod/android.git -b cm-11.0
And now, the most long part of the story: you’re going to get the source. We have to download around 10-15 Gbytes. First of begin the process, you must to know that you can accelerate the process related to your processor and, obviously, to your internet band. You can choose the number of simultaneous processes to start. They depends from the "#" in the "-j" parameter. E.g. the option -j6 is related to a “normal” processor. If you have a performant processor and/or internet connection, try to increment putting –j10 or more. On terminal:
Code:
repo sync -j6
From time to time, check the situation on output, maybe occurs a pair of hours or a whole night. But when all will be done, you’re ready to build Android!

Once you finish your repo sync, you’ll ready to build. In your terminal, into your working folder type (pay attention at the initial “dot”):
Code:
. build/envsetup.sh
The commands are loaded, now you can build (tune your -j# parameter as you want):
Code:
breakfast hammerhead && make -j6 bacon
At the end of all, your fresh ROM to flash will be in Cyanogenmod/out/target/product/hammerhead. Happy flash!

Thanks @Lloir for supervision.
Last edited by PippoX3; 20th January 2014 at 03:02 PM.
The Following 8 Users Say Thank You to PippoX3 For This Useful Post: [ View ]
20th January 2014, 01:44 PM   |  #3  
PippoX3's Avatar
OP Senior Member
Flag TN - Italy
Thanks Meter: 1,615
 
938 posts
Join Date:Joined: Aug 2010
Donate to Me
More
Angry Building AOKP
Reserved 2
Last edited by PippoX3; 20th January 2014 at 03:21 PM.
The Following User Says Thank You to PippoX3 For This Useful Post: [ View ]
20th January 2014, 06:34 PM   |  #8  
dianlb50's Avatar
Senior Member
Flag Austria
Thanks Meter: 17
 
117 posts
Join Date:Joined: Jul 2010
More
Nice
Thank you man I'm gonna try it out
21st January 2014, 03:47 PM   |  #9  
Cuzz1369's Avatar
Senior Member
Flag Kitchener
Thanks Meter: 2,070
 
2,810 posts
Join Date:Joined: Jan 2013
Donate to Me
More
I am getting a tone of errors while compiling. Is this normal. I'm gonna assume as long as it doesn't stop everything should be OK.

Sent from my hammerhead
21st January 2014, 03:52 PM   |  #10  
PippoX3's Avatar
OP Senior Member
Flag TN - Italy
Thanks Meter: 1,615
 
938 posts
Join Date:Joined: Aug 2010
Donate to Me
More
Quote:
Originally Posted by Cuzz1369

I am getting a tone of errors while compiling. Is this normal. I'm gonna assume as long as it doesn't stop everything should be OK.

Sent from my hammerhead

When u have warnings, it's all right.
When u have errors the building stops itself...

The Following User Says Thank You to PippoX3 For This Useful Post: [ View ]
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes