[Moto E General] yeshwanthvshenoy:
How to build your own CyanogenMod 11 ROM from sources for the Moto E

As you all know inorder to compile any rom based on source codes we need a linux environment. We can also use Virtual Machine on Windows but i find it slower when compared to a linux dual boot or linux os totally! So for budding developers i shall write this guide on how to setup Ubuntu 14.04 LTS Trusty Tahr 64 bit version to compile android roms. Please note that 32 bit is not supported to compile roms. So, lets get started!​

I wont be doing through on how to dual boot or install Ubuntu there are many videos on youtube so search them up and get Ubuntu installed! Now open a fresh terminal and do the following:

1) Copy and paste it into a terminal window:

sudo apt-get purge openjdk-\* icedtea-\* icedtea6-\*

This will remove OpenJDK if you have it pre-installed.

2) Copy and paste the following into the terminal:

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 Ubuntu 14.04.

3) Now you need to install the package. Copy and paste the following into the terminal:

sudo apt-get update && sudo apt-get install oracle-java6-installer

Wait.

Follow the on-screen instructions. You must accept the Licensing Agreement to complete the install.

Press Enter to acknowledge the "OK", then tab over to "Yes" and press Enter again to accept the license. The installation will continue automatically.

4) Make sure the correct version of Java is activated. Run the terminal command:

java -version

You should see or something similar:

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)

Close and open a new terminal.

5) Install the main build tools with this command:

sudo apt-get install git gnupg ccache lzop flex bison gperf build-essential zip curl zlib1g-dev zlib1g-dev:i386 libc6-dev lib32bz2-1.0 lib32ncurses5-dev x11proto-core-dev libx11-dev:i386 libreadline6-dev:i386 lib32z1-dev libgl1-mesa-glx:i386 libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown libxml2-utils xsltproc libreadline6-dev lib32readline-gplv2-dev libncurses5-dev bzip2 libbz2-dev libbz2-1.0 libghc-bzlib-dev lib32bz2-dev squashfs-tools pngcrush schedtool dpkg-dev

6) When they are installed, run the next line in your terminal window:

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

That's it packages are done! Now for the sources!

7) Install "repo" using this command:

mkdir ~/bin && curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo && chmod a+x ~/bin/repo

8) Now open .bashrc using Nano:

sudo nano ~/.bashrc

9) At the end of the page paste this code to a new line:

export PATH=~/bin:$PATH

10) Save it using Ctrl+O and then Enter. Then Ctrl+X to exit.

11) Restart bash using this command:

source ~/.bashrc

11) In the terminal, navigate to where you would like to download the Android source code. I will be placing it in "/home/user/" modify according to ur wish.

mkdir ~/cm11
cd ~/cm11

Now configure Git using:

git config --global user.email "example@mail.com"

Replace "example@mail.com" with your mail id of github

and also

git config --global user.name "name"

Replace "name" with your name

12) Now initialize the repo using:

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

The above command is for CM 11 you also do it for other flavours of custom roms too! I will add how to initialise repos for other flavours in second post soon!

13) Now start downloading the sources!!

repo sync

It takes around 11gb so here is where your internet connection plays a major role!! Sit back and do your other works till then!

And your ready to compile your rom when the sources are fully downloaded!!

14) Initialize the build environment:

$ .build/envsetup.sh

15) Add repositories for the MOTO E by creating two files in the local_manifests directory. To see this directory, you have to press Ctrl+H in your file manager. If the directory isn't there, create using

$ mkdir ~/cm11/.repo/local_manifests

16) Use this code to create the file condor.xml

$ gedit ~/cm11/.repo/local_manifests/condor.xml

17) Paste the following lines using an editor to the name.xml:

<manifest>
<project name="CyanogenMod/android_device_qcom_common" path="device/qcom/common" remote="github" revision="cm-11.0"/>
<project name="CyanogenMod/android_device_motorola_qcom-common" path="device/motorola/qcom-common" remote="github" revision="cm-11.0"/>
<project name="CyanogenMod/android_device_motorola_name" path="device/motorola/name" remote="github" revision="cm-11.0"/>
<project name="CyanogenMod/android_kernel_motorola_msm8210" path="kernel/motorola/msm8210" remote="github" revision="cm-11.0"/>
<project name="CyanogenMod/android_device_motorola_msm8210-common" path="device/motorola/msm8210-common" remote="github" revision="cm-11.0"/>
<project name="CyanogenMod/android_hardware_qcom_display-caf-new" path="hardware/qcom/display-caf-new" remote="github" revision="cm-11.0"/>
<project name="CyanogenMod/android_hardware_qcom_media-caf-new" path="hardware/qcom/media-caf-new" remote="github" revision="cm-11.0"/>
<project name="CyanogenMod/android_hardware_qcom_fm" path="hardware/qcom/fm" remote="github" revision="cm-11.0"/>
</manifest>

Save the file and exit.

18) Use this code to create the file vendor.xml using the command:

$ gedit ~/cm11/.repo/local_manifests/vendor.xml

19) Paste the following lines using an editor to vendow.xml:

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

Save the file and exit.

20) Now copy paste the command in terminal:

$ repo sync

To get the files needed.

21) Download the necessary prebuilts from cyanogenmod by copy pasting in terminal:

$ cd ~/cm11
$ vendor/cm/get-prebuilts

21) Now building the rom:

$ brunch condor

For any help or issues you can post your issues/doubts at this thread and people there will help you!

Congrats!!!You are now set to become a Developer soon!!

First building process will take from 3 hours to12 hours based on your computer specifications. Later builds will take lesser time!After the ROM has been successfully compiled you will find your new ROM in ~/cm11/out/target/product/name. It will be as cm-11-DATE-UNOFFICIAL-condor-zip. You can flash it via CWM/TWRP. Use adb and fastboot to logcat and debug your issues!