[LG Optimus G (International)] Haze028:
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

sudo add-apt-repository ppa:webupd8team/java

sudo apt-get update

sudo apt-get install oracle-java6-installer

Installing required packages

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

Set-up ccache This Is Optional

nano ~/.bashrc

Add these two lines

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.

sudo add-apt-repository ppa:nilarimogard/webupd8

sudo apt-get update

sudo apt-get install android-tools-adb android-tools-fastboot

Setup Repo

mkdir ~/bin

PATH=~/bin:$PATH

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

chmod a+x ~/bin/repo

Create working directory

mkdir [I][B]working-dir[/B][/I]

(Replace working-dir with whatever you'd like to call it, ie. aokp)

cd working-dir

Part 2 - Get Source​

ROM Source

Choose which custom rom you are going to build and initialize the repo for it

repo init -u [I][B]chosen-manifest[/B][/I]

(Replace chosen-manifest appropriately from the list below)

Device Source

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

Sync the repo

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​

. build/envsetup.sh

lunch

Locate your device on the list and enter appropriate number

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