[GUIDE][Step-by-Step] Build ROM from source

What is your favorite custom ROM?

  • CyanogenMod

    Votes: 507 49.0%
  • AOKP

    Votes: 45 4.3%
  • Paranoid Android

    Votes: 138 13.3%
  • PAC

    Votes: 64 6.2%
  • Omni

    Votes: 49 4.7%
  • Other

    Votes: 232 22.4%

  • Total voters
    1,035
Search This thread

Haze028

Senior Member
Jun 29, 2011
435
615
I put this tutorial together in an attempt to create the most complete and easy to follow guide for building a ROM from source. Including steps for adding apps to your build, changing toolchains and more... The entire guide uses a single Linux terminal window from start to finish in an attempt to keep everything as user friendly as possible. Please feel free to PM me suggestions on where changes need be made.

If you find this guide helpful please press the Thanks button on my posts and rate the thread a 5.​

Prerequisites
1. This guide is for Ubuntu 12+ based machine, I run Linux Mint 15. Follow links at end of OP for alternate directions
Windows Users: Setup Ubuntu in Virtualbox Instructions

2. You need to know the location for your device, vendor, and kernel repos. This can be found fairly easily in the forum for your phone. Also take note of your phones codename.
For example the Optimus G is the gee and its repos can be found here https://github.com/TeamPlaceholder

Note*All terminal commands will be in Code boxes*

Part 1 - Setting Up The Build Environment

Install Java JDK
Code:
sudo add-apt-repository ppa:webupd8team/java
Code:
sudo apt-get update
Code:
sudo apt-get install oracle-java6-installer

Installing required 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
Code:
sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so

Set-up ccache This Is Optional
Code:
nano ~/.bashrc
Add these two lines
export USE_CCACHE=1
export CCACHE_DIR=<path-to-your-cache-directory>
Save and exit by pressing ctrl+x, selecting Y then enter.

Install ADB & Fastboot This is optional, as you may already have them working. If not, they're a good thing to have.
Code:
sudo add-apt-repository ppa:nilarimogard/webupd8
Code:
sudo apt-get update
Code:
sudo apt-get install android-tools-adb android-tools-fastboot

Setup Repo
Code:
mkdir ~/bin
Code:
PATH=~/bin:$PATH
Code:
curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
Code:
chmod a+x ~/bin/repo

Create working directory
Code:
mkdir [I][B]working-dir[/B][/I]
(Replace working-dir with whatever you'd like to call it, ie. aokp)
Code:
cd working-dir

Part 2 - Get Source
ROM Source
Choose which custom rom you are going to build and initialize the repo for it
Code:
repo init -u [I][B]chosen-manifest[/B][/I]
(Replace chosen-manifest appropriately from the list below)
AOKP: https://github.com/AOKP/platform_manifest.git -b Branch
Cyanogenmod: https://github.com/CyanogenMod/android.git -b Branch
CarbonDev: https://github.com/CarbonDev/android.git -b Branch
Liquid Smooth: https://github.com/LiquidSmooth/android.git -b Branch
Replace Branch with appropriate branch from github repo ie cm-10.2 or jb3
If unsure which branch click the link above to locate appropriate branch

Device Source
Go HERE and follow instructions on obtaining your device specific repos.

Sync the repo
Code:
repo sync
This will take a while as it downloads all the required source
Part 3 - Preparing Source
Before you're ready to build your source needs to be configured to include your device. This preparation varies slightly for different custom Roms.
Go HERE and follow instructions for your ROM choice

Part 4 - Edit Source​
This Is Optional​
This is where you can make edits to the source before building to suit your needs.
Go HERE and follow the instructions to tweak source

Part 5 - Building ROM
Code:
. build/envsetup.sh
Code:
lunch
Locate your device on the list and enter appropriate number
Code:
make -j[B][I]# [/I][/B]otapackage
Replace # with the number of cores in your system (Is the number of jobs that will be done at once, more cores means more jobs)
Build Errors

This can be hard, especially if you're new to programming languages and building. Meet Google :p your new best friend.
Here is a basic overview to get you started, and if no more at least googling in the right direction.

Finished
When it's done you're rom will be in working-dir/out/target/product/codename/

Enjoy.

I used these sites while making this guide
http://source.android.com/source/initializing.html
http://www.webupd8.org/2012/11/oracle-sun-java-6-installer-available.html
http://www.webupd8.org/2012/08/install-adb-and-fastboot-android-tools.html
 
Last edited:

Haze028

Senior Member
Jun 29, 2011
435
615
Device Source
As stated in the prerequisites you will need a device specific Device repo, Vendor repo, and Kernel repo. You can find links to them in the threads for your devices. Also take note of your device codename ie Nexus 4 is mako, Optimus G is gee.

There are two options for adding in device specific source, local manifest and git clone.
Note: The local path for your phone's repos should be device/manufacturer/codename, vendor/manufacturer/codename, kernel/manufacturer/codename regardless of method chosen.

Git Clone
Git clone is a one time download of a specific repo to the directory indicated and is not affected when a repo sync is run. This is probably the better choice if you make edits to the device source as they won't be over written or cause conflicts when syncing.
This method is used AFTER the inital rom source sync. Preform a repo sync before cloning repos
Code:
git clone [B][COLOR=DarkOrange]repo[/COLOR][/B] -b [B][COLOR=Red]branch[/COLOR][/B] [B][COLOR=Lime]destination-path[/COLOR][/B]
here is and example for the vendor repo for the E973 from TeamPlaceHolder

Local Manifest
Local manifest syncs the device repos each time a repo sync is run. This is probably the better choice if you don't make edits and rely on the repo's maintainer for changes. Be wary making edits locally to the repos you list as a repo sync may overwrite your changes.
This method is used BEFORE the initial rom sync. This gets your device source during the first repo sync
Code:
mkdir .repo/local_manifests
Code:
touch .repo/local_manifests/local_manifest.xml
Code:
nano .repo/local_manifests/local_manifest.xml

Add these lines:
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<remote name="name-for-remote" fetch="remote-url" />
<project path="destination-folder-path" name="repo-location" remote="name-for-remote" revision="branch" />
</manifest>
name-for-remote - Any name you want to give to identify the url where your repos are stored
remote-url - The url for the remote location your repos are stored
destination-folder-path - Where do you want this repo stored locally
repo-location - Where on the remote url is your repo stored
branch - The branch of the remote repo you are using
**You will need a project line for each repo you wish to add to the source. **

Here is an example for E973 using TeamPlaceHolder repos, adding all device/vendor/kernel repos.
<?xml version="1.0" encoding="UTF-8"?>
<manifest>

<remote name="gh"
fetch="git://github.com/" />

<project path="kernel/lge/gee" name="TeamPlaceholder/android_kernel_lge_gee" remote="gh" revision="cm-10.2-update" />
<project path="device/lge/geeb" name="TeamPlaceholder/android_device_lge_geeb" remote="gh" revision="cm-10.2" />
<project path="device/lge/gee-common" name="TeamPlaceholder/android_device_lge_gee-common" remote="gh" revision="cm-10.2" />
<project path="vendor/lge/gee" name="TeamPlaceholder/proprietary_vendor_lge_gee" remote="gh" revision="cm-10.2" />

</manifest>
 
Last edited:

Haze028

Senior Member
Jun 29, 2011
435
615
Preparing Source

Preparing Source
ROM specific setup instructions prior to building. All source should be downloaded already.
All ROM setup is fairly similar,
1. You must add your device to the ROM's vendor repo(vendor/cm or vendor/aokp) This process is slightly different per rom. Look at how other devices are added in the vendor repo and emulate those.
2. A ROM specific makefile, again look at how other devices are added.
3. If building AOSP based ROMs, a pre-built kernel is generally required. Look here for instructions on how to compile a kernel separately.

Here are examples of how to set up AOKP or Carbon to build. Device used in example is Optimus G.
Manufacturer and codename MUST be updated to reflect your device.
AOKP
Code:
nano vendor/aokp/vendorsetup.sh
Add this line
add_lunch_combo aokp_geeb-userdebug
Save and exit by pressing ctrl+x, selecting Y then enter.
Code:
touch vendor/aokp/products/geeb.mk
Code:
nano vendor/aokp/products/geeb.mk
Add these lines
If building for CDMA network change gsm.mk to cdma.mk
# Inherit AOSP device configuration for geeb
$(call inherit-product, device/lge/geeb/full_geeb.mk)

# Inherit AOKP common bits
$(call inherit-product, vendor/aokp/configs/common.mk)

# Inherit GSM common stuff
$(call inherit-product, vendor/aokp/configs/gsm.mk)

# Setup device specific product configuration
PRODUCT_NAME := aokp_geeb
PRODUCT_BRAND := google
PRODUCT_DEVICE := geeb
PRODUCT_MODEL := Optimus G
PRODUCT_MANUFACTURER := LGE
Save and exit by pressing ctrl+x, selecting Y then enter.
Code:
nano vendor/aokp/products/AndroidProducts.mk
Add this line
$(LOCAL_DIR)/geeb.mk \
Save and exit by pressing ctrl+x, selecting Y then enter.
CarbonDev
Code:
nano vendor/carbon/vendorsetup.sh
Add this line
add_lunch_combo carbon_geeb-userdebug


Once your device has been added you're ready to build! Go back to the OP and complete the guide from where you left off.
 
Last edited:

geokilla

Senior Member
Jun 5, 2010
3,479
383
Toronto
What bout building ROMs based on LG source? I'd rather see more LG based ROMs because the camera quality is higher, and a lot of AOSP/AOKP ROMs feel more or less the same.
 

chadouming

Senior Member
Aug 27, 2009
2,208
1,982
On the interwebz
What bout building ROMs based on LG source? I'd rather see more LG based ROMs because the camera quality is higher, and a lot of AOSP/AOKP ROMs feel more or less the same.

Seriously ? Find me LG source to build a rom and I'll make you one.

@moderator.
Btw, This post and the previous should be removed, that thread locked to prevent post like these and pinned. thanks.
 

d.terenzzo

Senior Member
Aug 18, 2012
167
37
Campinas
Well I had put up build instructions for AOKP but thought I would generalize them so people could use them for other ROM bases. My therory is the more people that are trying to build, the more improvments/enhancements can be put forth to the OG community.
As I've stated before I do not consider myself a dev. So don't be afraid of giving this a try, even if you have little to no android building experience. The instructions are as step by step as I could make them, and I'll always try to help where I can.

When it's done you're rom will be in out/target/product/geeb/

I'm writing this now from memory, so if it doesn't work let me know so I may update accordingly

Enjoy.

It was what I'm looking for...

Thanks a lot..

Definitely I'll give a try!


Seriously ? Find me LG source to build a rom and I'll make you one.
@moderator.
Btw, This post and the previous should be removed, that thread locked to prevent post like these and pinned. thanks.

Why would want to lock the thread? How do we suppose to learning? I think @Haze purpose was opposite that you suggest, if we do not learn, we'll keeping ask you to change this, or do that instead to help you and even do some nice stuff.

Don't be like that be patience and share your great knowledge. I'm your fan. :good:
 
Last edited:
  • Like
Reactions: abhi783821

Haze028

Senior Member
Jun 29, 2011
435
615
Why would want to lock the thread? How do we suppose to learning? I think @Haze purpose was opposite that you suggest, if we do not learn, we'll keeping ask you to change this, or do that instead to help you and even do some nice stuff.

Yeah, I don't think it should get locked, I started it to try to help people out, so they can get assistance through this thread with their builds. Being new to building myself, I have found that the issues, and resolutions to them, in similar threads to this to be a wealth of knowledge.
 
  • Like
Reactions: abhi783821

Recon Freak

Senior Member
Jan 17, 2010
371
127
Evansville, IN
getting error

build/core/product_config.mk:239: *** _nic.PRODUCTS.[[vendor/aokp/products/geeb.mk]]: "device/lge/geeb/full_geeb.mk" does not exist. Stop.

** Don't have a product spec for: 'aokp_geeb'
** Do you have the right repo manifest?

Any idea what i missed?
 

Haze028

Senior Member
Jun 29, 2011
435
615
build/core/product_config.mk:239: *** _nic.PRODUCTS.[[vendor/aokp/products/geeb.mk]]: "device/lge/geeb/full_geeb.mk" does not exist. Stop.

** Don't have a product spec for: 'aokp_geeb'
** Do you have the right repo manifest?

Any idea what i missed?

have you cloned the geeb device tree into device/lge/geeb? seems the error is saying that full_geeb.mk doesn't exist, so either you've not yet cloned the device tree, or you have it in a differnt folder name, I'm assuming currently.


let me know if that's not the case.
 

Paulicat

Senior Member
Mar 12, 2013
914
882
I know most people want to run latest and greatest but I'm curious if we could build a cm10 (4.1.2) using LG's released kernel sources?
Any thoughts??
Would be cool to get a 4.1.2 build without LG's proprietary software...
Hopefully you see my point in posting this here as building from lg's sources and either aosp or cm10 isn't the most straightforward.
I'm attempting but I don't expect to have much success...
 

d.terenzzo

Senior Member
Aug 18, 2012
167
37
Campinas
It all depends on your internet connection, looking at around 10-20gb. I think my AOKP repo is 12gb...give or take

"Once you know the truth, there is no going back"

for learning purpose:

Why should we have to download all projects in AOKP, if I wont use it.
There is a way to choice between what to download and what to not download?

cheers
 
  • Like
Reactions: badagila

Haze028

Senior Member
Jun 29, 2011
435
615
"Once you know the truth, there is no going back"

for learning purpose:

Why should we have to download all projects in AOKP, if I wont use it.
There is a way to choice between what to download and what to not download?

cheers

In the third post i show you how to use a local manifest to remove projects you don't want/need from the repo before you sync, linked to in the build instructions. I always remove the device tree and vendor for other devices before my initial sync.
 
  • Like
Reactions: d.terenzzo

d.terenzzo

Senior Member
Aug 18, 2012
167
37
Campinas
Yeah, I tried that, but I got weird error. Something about manifest, once I removed the example line about Samsung groups, it worked.

Would you mind to share your local_manifest.

Cheers

Sent from my LG-E971 using xda app-developers app
 

Haze028

Senior Member
Jun 29, 2011
435
615
Yeah, I tried that, but I got weird error. Something about manifest, once I removed the example line about Samsung groups, it worked.

Would you mind to share your local_manifest.

Cheers

Sent from my LG-E971 using xda app-developers app

Sorry for the delay, didn't notice your post, anyways here is my current local manifest file for aokp
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<project path="device/lge/geeb" name="Haze028/android_device_lge_geebca" remote="aokp" revision="aokp"/>
<project path="vendor/lge/geeb" name="Haze028/android_vendor_lge_geeb" remote="aokp" revision="cm-10.1"/>
<project path="kernel/lge/geeb" name="Haze028/geeb" remote="aokp" revision="geeb"/>

<project path="prebuilts/gcc/linux-x86/arm/arm-eabi-4.7" name="platform/prebuilts/gcc/linux-x86/arm/arm-eabi-4.7" revision="master" groups="linux,arm" />
<project path="prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7" name="platform/prebuilts/gcc/linux-x86/arm/arm-linux-androideabi-4.7" revision="master" groups="linux,arm" />

<remove-project name="AOKP/packages_apps_Launcher2" />
<remove-project name="AOKP/device_acer_a510" />
<remove-project name="AOKP/device_asus_grouper" />
<remove-project name="AOKP/device_asus_tilapia" />
<remove-project name="CyanogenMod/android_device_common" />
<remove-project name="device/generic/armv7-a-neon" />
<remove-project name="device/generic/armv7-a" />
<remove-project name="device/generic/common" />
<remove-project name="device/generic/goldfish" />
<remove-project name="device/generic/mips" />
<remove-project name="device/generic/x86" />
<remove-project name="device/google/accessory/arduino" />
<remove-project name="device/google/accessory/demokit" />
<remove-project name="AOKP/device_htc_evita" />
<remove-project name="AOKP/device_htc_msm8960-common" />
<remove-project name="AOKP/device_lge_iprj-common" />
<remove-project name="AOKP/device_lge_mako" />
<remove-project name="AOKP/device_lge_p930" />
<remove-project name="AOKP/device_lge_su640" />
<remove-project name="AOKP/device_lge_vs920" />
<remove-project name="AOKP/device_motorola_maserati" />
<remove-project name="AOKP/device_motorola_omap4-common" />
<remove-project name="AOKP/device_motorola_solana" />
<remove-project name="AOKP/device_motorola_spyder" />
<remove-project name="AOKP/device_motorola_targa" />
<remove-project name="AOKP/device_motorola_umts_spyder" />
<remove-project name="device/sample" />
<remove-project name="AOKP/device_samsung_aries-common" />
<remove-project name="AOKP/device_samsung_celox-common" />
<remove-project name="AOKP/device_samsung_d2-common" />
<remove-project name="AOKP/device_samsung_d2att" />
<remove-project name="AOKP/device_samsung_d2tmo" />
<remove-project name="AOKP/device_samsung_d2usc" />
<remove-project name="AOKP/device_samsung_d2vzw" />
<remove-project name="AOKP/device_samsung_galaxys2-common" />
<remove-project name="AOKP/device_samsung_hercules" />
<remove-project name="AOKP/device_samsung_i605" />
<remove-project name="AOKP/device_samsung_i9100" />
<remove-project name="AOKP/device_samsung_i9100g" />
<remove-project name="AOKP/device_samsung_i9300" />
<remove-project name="AOKP/device_samsung_l900" />
<remove-project name="AOKP/device_samsung_maguro" />
<remove-project name="AOKP/device_samsung_manta" />
<remove-project name="AOKP/device_samsung_msm8660-common" />
<remove-project name="AOKP/device_samsung_msm8960-common" />
<remove-project name="CyanogenMod/android_device_samsung_omap4-common" />
<remove-project name="AOKP/device_samsung_qcom-common" />
<remove-project name="AOKP/device_samsung_smdk4412-common" />
<remove-project name="CyanogenMod/android_device_samsung_smdk4412-qcom-common" />
<remove-project name="AOKP/device_samsung_t0lte" />
<remove-project name="AOKP/device_samsung_t0ltecdma" />
<remove-project name="AOKP/device_samsung_toro" />
<remove-project name="AOKP/device_samsung_toroplus" />
<remove-project name="AOKP/device_samsung_tuna" />
<remove-project name="AOKP/device_samsung_vibrantmtd" />
<remove-project name="device/ti/panda" />
<remove-project name="AOKP/vendor_htc" />
<remove-project name="AOKP/vendor_lge" />
<remove-project name="AOKP/vendor_motorola" />
<remove-project name="AOKP/vendor_samsung" />
<remove-project name="AOKP/vendor_acer_a510" />
<remove-project name="AOKP/vendor_asus" />
</manifest>
 
  • Like
Reactions: d.terenzzo

Haze028

Senior Member
Jun 29, 2011
435
615
Hey Haze028, thanks for this great write up!

Anyways, im trying to build this for the Sprint LG OG. Do i need to sync with different device trees then this? Im very new at building from source, so, sorry if this is a stupid question.

Thanks!

I believe you will need different repo's, check out Team LGOG's github(https://github.com/TeamLGOG) They have device tree's for all variants, Chadouming is a member of that team and as such his CM10.1 uses those repo's. The local_manifest for Cyanogenmod in the OP should show you which repo's to use.... then depending on what rom you're looking to build some minor changes might be required.

I've not built using their repo's, but I'll help you in getting it all set up.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 111
    I put this tutorial together in an attempt to create the most complete and easy to follow guide for building a ROM from source. Including steps for adding apps to your build, changing toolchains and more... The entire guide uses a single Linux terminal window from start to finish in an attempt to keep everything as user friendly as possible. Please feel free to PM me suggestions on where changes need be made.

    If you find this guide helpful please press the Thanks button on my posts and rate the thread a 5.​

    Prerequisites
    1. This guide is for Ubuntu 12+ based machine, I run Linux Mint 15. Follow links at end of OP for alternate directions
    Windows Users: Setup Ubuntu in Virtualbox Instructions

    2. You need to know the location for your device, vendor, and kernel repos. This can be found fairly easily in the forum for your phone. Also take note of your phones codename.
    For example the Optimus G is the gee and its repos can be found here https://github.com/TeamPlaceholder

    Note*All terminal commands will be in Code boxes*

    Part 1 - Setting Up The Build Environment

    Install Java JDK
    Code:
    sudo add-apt-repository ppa:webupd8team/java
    Code:
    sudo apt-get update
    Code:
    sudo apt-get install oracle-java6-installer

    Installing required 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
    Code:
    sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so

    Set-up ccache This Is Optional
    Code:
    nano ~/.bashrc
    Add these two lines
    export USE_CCACHE=1
    export CCACHE_DIR=<path-to-your-cache-directory>
    Save and exit by pressing ctrl+x, selecting Y then enter.

    Install ADB & Fastboot This is optional, as you may already have them working. If not, they're a good thing to have.
    Code:
    sudo add-apt-repository ppa:nilarimogard/webupd8
    Code:
    sudo apt-get update
    Code:
    sudo apt-get install android-tools-adb android-tools-fastboot

    Setup Repo
    Code:
    mkdir ~/bin
    Code:
    PATH=~/bin:$PATH
    Code:
    curl http://commondatastorage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
    Code:
    chmod a+x ~/bin/repo

    Create working directory
    Code:
    mkdir [I][B]working-dir[/B][/I]
    (Replace working-dir with whatever you'd like to call it, ie. aokp)
    Code:
    cd working-dir

    Part 2 - Get Source
    ROM Source
    Choose which custom rom you are going to build and initialize the repo for it
    Code:
    repo init -u [I][B]chosen-manifest[/B][/I]
    (Replace chosen-manifest appropriately from the list below)
    AOKP: https://github.com/AOKP/platform_manifest.git -b Branch
    Cyanogenmod: https://github.com/CyanogenMod/android.git -b Branch
    CarbonDev: https://github.com/CarbonDev/android.git -b Branch
    Liquid Smooth: https://github.com/LiquidSmooth/android.git -b Branch
    Replace Branch with appropriate branch from github repo ie cm-10.2 or jb3
    If unsure which branch click the link above to locate appropriate branch

    Device Source
    Go HERE and follow instructions on obtaining your device specific repos.

    Sync the repo
    Code:
    repo sync
    This will take a while as it downloads all the required source
    Part 3 - Preparing Source
    Before you're ready to build your source needs to be configured to include your device. This preparation varies slightly for different custom Roms.
    Go HERE and follow instructions for your ROM choice

    Part 4 - Edit Source​
    This Is Optional​
    This is where you can make edits to the source before building to suit your needs.
    Go HERE and follow the instructions to tweak source

    Part 5 - Building ROM
    Code:
    . build/envsetup.sh
    Code:
    lunch
    Locate your device on the list and enter appropriate number
    Code:
    make -j[B][I]# [/I][/B]otapackage
    Replace # with the number of cores in your system (Is the number of jobs that will be done at once, more cores means more jobs)
    Build Errors

    This can be hard, especially if you're new to programming languages and building. Meet Google :p your new best friend.
    Here is a basic overview to get you started, and if no more at least googling in the right direction.

    Finished
    When it's done you're rom will be in working-dir/out/target/product/codename/

    Enjoy.

    I used these sites while making this guide
    http://source.android.com/source/initializing.html
    http://www.webupd8.org/2012/11/oracle-sun-java-6-installer-available.html
    http://www.webupd8.org/2012/08/install-adb-and-fastboot-android-tools.html
    57
    Device Source
    As stated in the prerequisites you will need a device specific Device repo, Vendor repo, and Kernel repo. You can find links to them in the threads for your devices. Also take note of your device codename ie Nexus 4 is mako, Optimus G is gee.

    There are two options for adding in device specific source, local manifest and git clone.
    Note: The local path for your phone's repos should be device/manufacturer/codename, vendor/manufacturer/codename, kernel/manufacturer/codename regardless of method chosen.

    Git Clone
    Git clone is a one time download of a specific repo to the directory indicated and is not affected when a repo sync is run. This is probably the better choice if you make edits to the device source as they won't be over written or cause conflicts when syncing.
    This method is used AFTER the inital rom source sync. Preform a repo sync before cloning repos
    Code:
    git clone [B][COLOR=DarkOrange]repo[/COLOR][/B] -b [B][COLOR=Red]branch[/COLOR][/B] [B][COLOR=Lime]destination-path[/COLOR][/B]
    here is and example for the vendor repo for the E973 from TeamPlaceHolder

    Local Manifest
    Local manifest syncs the device repos each time a repo sync is run. This is probably the better choice if you don't make edits and rely on the repo's maintainer for changes. Be wary making edits locally to the repos you list as a repo sync may overwrite your changes.
    This method is used BEFORE the initial rom sync. This gets your device source during the first repo sync
    Code:
    mkdir .repo/local_manifests
    Code:
    touch .repo/local_manifests/local_manifest.xml
    Code:
    nano .repo/local_manifests/local_manifest.xml

    Add these lines:
    <?xml version="1.0" encoding="UTF-8"?>
    <manifest>
    <remote name="name-for-remote" fetch="remote-url" />
    <project path="destination-folder-path" name="repo-location" remote="name-for-remote" revision="branch" />
    </manifest>
    name-for-remote - Any name you want to give to identify the url where your repos are stored
    remote-url - The url for the remote location your repos are stored
    destination-folder-path - Where do you want this repo stored locally
    repo-location - Where on the remote url is your repo stored
    branch - The branch of the remote repo you are using
    **You will need a project line for each repo you wish to add to the source. **

    Here is an example for E973 using TeamPlaceHolder repos, adding all device/vendor/kernel repos.
    <?xml version="1.0" encoding="UTF-8"?>
    <manifest>

    <remote name="gh"
    fetch="git://github.com/" />

    <project path="kernel/lge/gee" name="TeamPlaceholder/android_kernel_lge_gee" remote="gh" revision="cm-10.2-update" />
    <project path="device/lge/geeb" name="TeamPlaceholder/android_device_lge_geeb" remote="gh" revision="cm-10.2" />
    <project path="device/lge/gee-common" name="TeamPlaceholder/android_device_lge_gee-common" remote="gh" revision="cm-10.2" />
    <project path="vendor/lge/gee" name="TeamPlaceholder/proprietary_vendor_lge_gee" remote="gh" revision="cm-10.2" />

    </manifest>
    30
    Preparing Source

    Preparing Source
    ROM specific setup instructions prior to building. All source should be downloaded already.
    All ROM setup is fairly similar,
    1. You must add your device to the ROM's vendor repo(vendor/cm or vendor/aokp) This process is slightly different per rom. Look at how other devices are added in the vendor repo and emulate those.
    2. A ROM specific makefile, again look at how other devices are added.
    3. If building AOSP based ROMs, a pre-built kernel is generally required. Look here for instructions on how to compile a kernel separately.

    Here are examples of how to set up AOKP or Carbon to build. Device used in example is Optimus G.
    Manufacturer and codename MUST be updated to reflect your device.
    AOKP
    Code:
    nano vendor/aokp/vendorsetup.sh
    Add this line
    add_lunch_combo aokp_geeb-userdebug
    Save and exit by pressing ctrl+x, selecting Y then enter.
    Code:
    touch vendor/aokp/products/geeb.mk
    Code:
    nano vendor/aokp/products/geeb.mk
    Add these lines
    If building for CDMA network change gsm.mk to cdma.mk
    # Inherit AOSP device configuration for geeb
    $(call inherit-product, device/lge/geeb/full_geeb.mk)

    # Inherit AOKP common bits
    $(call inherit-product, vendor/aokp/configs/common.mk)

    # Inherit GSM common stuff
    $(call inherit-product, vendor/aokp/configs/gsm.mk)

    # Setup device specific product configuration
    PRODUCT_NAME := aokp_geeb
    PRODUCT_BRAND := google
    PRODUCT_DEVICE := geeb
    PRODUCT_MODEL := Optimus G
    PRODUCT_MANUFACTURER := LGE
    Save and exit by pressing ctrl+x, selecting Y then enter.
    Code:
    nano vendor/aokp/products/AndroidProducts.mk
    Add this line
    $(LOCAL_DIR)/geeb.mk \
    Save and exit by pressing ctrl+x, selecting Y then enter.
    CarbonDev
    Code:
    nano vendor/carbon/vendorsetup.sh
    Add this line
    add_lunch_combo carbon_geeb-userdebug


    Once your device has been added you're ready to build! Go back to the OP and complete the guide from where you left off.
    5
    good stuff haze :)
    2
    What bout building ROMs based on LG source? I'd rather see more LG based ROMs because the camera quality is higher, and a lot of AOSP/AOKP ROMs feel more or less the same.

    Seriously ? Find me LG source to build a rom and I'll make you one.

    @moderator.
    Btw, This post and the previous should be removed, that thread locked to prevent post like these and pinned. thanks.