top of page
Setting up a build environment on Ubuntu 12.04 and compiling CM11 from source.

Install Repo:

 

Repo is a tool that makes it simple to download and maintain the Cyanogenmod source code (or whichever branch you choose to build, but that will come in a future guide).

 

Code:

 

$ mkdir ~/bin

$ PATH=~/bin:$PATH

$ cd ~/bin

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

$ chmod a+x ~/bin/repo

Install the build packages:

 

Code:

 

$ sudo apt-get install git gnupg flex bison gperf build-essential \  zip curl libc6-dev libncurses5-dev:i386 x11proto-core-dev \  libx11-dev:i386 libreadline6-dev:i386 libgl1-mesa-glx:i386 \  libgl1-mesa-dev g++-multilib mingw32 tofrodos \  python-markdown libxml2-utils xsltproc zlib1g-dev:i386

 

$ sudo apt-get install git-core libesd0-dev libncurses5-dev libsdl1.2-dev libwxgtk2.8-dev libxml2 lzop openjdk-6-jdk openjdk-6-jre pngcrush schedtool squashfs-tools zlib1g-dev

 

$ sudo apt-get install gcc-multilib lib32ncurses5-dev lib32readline-gplv2-dev lib32z1-dev

Then:

 

Code:

 

$ sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so

Ensure Java installed correctly:

 

Code:

 

$ java -version

Next you will create the Working Directory:

 

Code:

 

$ mkdir ~/cyanogenmod

$ cd ~/cyanogenmod

Initialize Repo:

 

Code:

 

$ repo init -u git://github.com/CyanogenMod/android.git -b cm-11.0

Download the Cyanogenmod source code:

 

Code:

 

$ repo sync

Initialize the build environment:

 

Code:

 

$ . build/envsetup.sh

Obtain the proprietary files for your device:

 

Replace "d2vzw" with the codename of your device.

 

Code:

 

$ breakfast d2lte

Now you will create what is known as a local manifest:

 

To do this, you will create a file named local_manifest.xml in the /local_manifests directory. This directory will be hidden, so if you wish to see it, press crtl+h within the /cyanogenmod directory. This will allow you to ammend your build to include the proprietary vendor files from a source known as themuppets repo, which keeps you from having to extract proprietary blobs from your device, and will save you from various bugs in your build, as they have been corrected here.

 

Code:

 

$ gedit ~/cyanogenmod/.repo/local_manifests/local_manifest.xml

 

 

**At this point, if you are building for another device, you can look up your device's repo directory here. Simply change the lines in the code below to reflect your device's vendor (i.e. from "samsung" to "lge" for LG devices, "htc," "motorola," and so on). Make sure to change it in the path, as well.

 

Paste the following lines into the open file that you just created, then save and exit:

 

Code:

Once saved, go back to the terminal, and run the repo sync cmd again:

 

Code:

 

$ repo sync

Download the necessary prebuilts from Cyanogenmod:

 

Code:

 

$ cd ~/cyanogenmod/vendor/cm

$ ./get-prebuilts

$ croot

Now you're ready to build!!

Run the build:

 

Again, this is where you will change "d2vzw" to your device's codename.

 

  **NOTICE** At this command, if you're building for the Verizon GS3, or any US Lte variant,

you will need to use "d2lte" NOT your device's code name. CyanogenMod merged the US variants into one. In all previous commands ignore this rule, as those commands pull device specific files.**

 

Code:

 

$ brunch d2lte

**Go get some grub, catch a flick, or take a nap, because this is going to take a while, unless you have something like an I7 proccessor with a SSD, and around 16GB of DDR3 RAM.... Then you could be looking at 30min. I wish my girlfriend would let me build on her MAC  >.<

 

In about 3 hours, when the build completes, you can run the following cmds, from the same window, to see your build results:

 

Code:

 

$ cd $OUT

$ ls

Your build results will be located in the following directory:

 

/cyanogenmod/out/target/product/d2vzw

 

Your new, flashable ROM will be named something like this:

 

cm-11-20131223-UNOFFICIAL-d2vzw.zip

 

Next time you want to build, simply follow these cmds from a fresh terminal:

 

Code:

 

$cd ~/cyanogenmod

$make clean

 

 

Wait for it to finish cleaning, then build:

 

Code:

 

$ repo sync

$ . build/envsetup.sh

$ brunch d2lte

<?xml version="1.0" encoding="UTF-8"?>
<manifest>
    <project name="TheMuppets/proprietary_vendor_samsung.git" path="vendor/samsung" remote="github" revision="cm-11.0"/>
</manifest>

Ubuntu 12.04 LTS

Recently ranked #1 in security!

Requirements:

  • A basic working knowledge of Ubuntu and the Linux command line (terminal).

  • A decent machine, on which to run Ubuntu.

    • I'd say absolutely no less than 2GB of RAM. If you can run DDR3, you'll be much better off, if not, shoot for 4 to 12GB of DDR2, the more the better.

    • At least a dual-core processor. Again, the more the better. Idealy, and if I had my choice, I would build using a quad-core Intel Core I7, pushing upwards of 3GHz. I'm currently running a triple-core AMD.

    • Building on a somewhat decent machine can take 3 to 4 hours, but building on a great machine can reduce that time to as fast as 35-45 minutes, so you can see why I say to aim high.

  • At least 30GB of free hard drive space. I build on a terabyte HHD, just for the flexibility. The source, once downloaded, is about 16GB for just one branch of Android. Idealy, building on a SSD would be best, as it is much faster.

  • A decent internet connection for the intial download of the Android source code, and for each time you want to repo sync to update your source from the repositories.

  • Time and patience!! It takes time to get comfortable building, but just how much time depends on your previous experience with Ubuntu and development in general. Don't rush it!

Like this guide? Recommend us on Google!

bottom of page