ParanoidAndroid: Source Compile Guide: Part I

Bidyut Mukherjee —  September 17, 2012 — Leave a comment

PARANOIDANDROID : JB (Android 4.1.1)

Source Compilation Guide (Part- I)pax3u3k

This guide will walk you through each & every step involved in compiling the ROM, right after the stage of installing Ubuntu.
This is to help you all explore your own development domains. :)

Remember, I’m NOT responsible if something, or anything goes wrong at your end, on any device or system

So, with that,

Good Luck!

——————Pre-requisites——————
Make sure you have:

  • Ubuntu 12.04 (Precise Pangolin) 64-bit
  • Decent Computer, with at least 4GB RAM
  • Decent Internet (Trust me… you DON’T want to do this on a 512 kbits connection…)
  • Functional Device Tree, Hardware tree, Kernel source tree for your device
  • Device running latest CM10/AOSP Jellybean

——————Steps Involved——————
Step 1: Download the sources

Step 2: Add device support to PA, & Builiding ROM

Step 3: The After-life: Git, Gerrit, Patch Submissions

——————Lets Start——————

STEP 1: Downloading the Sources:

For the curious kind, here’s some theoretical information:

Before compiling any ROM, we need some basic ‘stuffs’, or tools if you may.

In short, here’s what we need:

1) Compile Dependencies (libs)
2) Python 2.7.3
3) Java JDK 6.xx
4) Android SDK
5) USB Configs
6) Git, Repo
7) Project Sources
8) CM10/JellyBean Device Tree
9) Device Kernel Tree
10) Device Hardware sources
11) Device Vendor Proprietaries

# Install OpenSSL, for Python:

$ sudo apt-get install libssl1.0.0=1.0.1-4ubuntu5.3
$ sudo apt-get install libssl-dev

# Install Dependencies:

There are some dependencies that might not be useful. But just in case, I’m gonna give you all dependencies that any Android compilation would need. Its better than facing errors while compiling.

$ sudo apt-get install git-core gnupg flex bison gperf build-essential \
  zip curl zlib1g-dev zlib1g-dev:i386 libc6-dev lib32ncurses5-dev \
  ia32-libs 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.6-dev
$ sudo ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1 /usr/lib/i386-linux-gnu/libGL.so

# Configure USB:

1) Open/Create file 51-android.rules:

$ gksudo gedit /etc/udev/rules.d/51-android.rules

-] Add these lines:

#Garmin-Asus
SUBSYSTEM==usb", ATTR{idVendor}==091E", MODE=0666"

#Google
SUBSYSTEM==usb", ATTR{idVendor}==18d1", MODE=0666"

#HTC
SUBSYSTEM==usb", ATTR{idVendor}==0bb4", MODE=0666"

#Huawei
SUBSYSTEM==usb", ATTR{idVendor}==12d1", MODE=0666"

#K-Touch
SUBSYSTEM==usb", ATTR{idVendor}==24e3", MODE=0666"

#KT Tech
SUBSYSTEM==usb", ATTR{idVendor}==2116", MODE=0666"

#Kyocera
SUBSYSTEM==usb", ATTR{idVendor}==0482", MODE=0666"

#Lenevo
SUBSYSTEM==usb", ATTR{idVendor}==17EF", MODE=0666"

#LG
SUBSYSTEM==usb", ATTR{idVendor}==1004", MODE=0666"

#Motorola
SUBSYSTEM==usb", ATTR{idVendor}==22b8", MODE=0666"

#NEC
SUBSYSTEM==usb", ATTR{idVendor}==0409", MODE=0666"

#Nook
SUBSYSTEM==usb", ATTR{idVendor}==2080", MODE=0666"

#Nvidia
SUBSYSTEM==usb", ATTR{idVendor}==0955", MODE=0666"

#OTGV
SUBSYSTEM==usb", ATTR{idVendor}==2257", MODE=0666"

#Pantech
SUBSYSTEM==usb", ATTR{idVendor}==10A9", MODE=0666"

#Philips
SUBSYSTEM==usb", ATTR{idVendor}==0471", MODE=0666"

#PMC-Sierra
SUBSYSTEM==usb", ATTR{idVendor}==04da", MODE=0666"

#Qualcomm
SUBSYSTEM==usb", ATTR{idVendor}==05c6", MODE=0666"

#SK Telesys
SUBSYSTEM==usb", ATTR{idVendor}==1f53", MODE=0666"

#Samsung
SUBSYSTEM==usb", ATTR{idVendor}==04e8", MODE=0666"

#Sharp
SUBSYSTEM==usb", ATTR{idVendor}==04dd", MODE=0666"

#Sony Ericsson
SUBSYSTEM==usb", ATTR{idVendor}==0fce", MODE=0666"

#Toshiba
SUBSYSTEM==usb", ATTR{idVendor}==0930", MODE=0666"

#ZTE
SUBSYSTEM==usb", ATTR{idVendor}==19D2", MODE=0666"

2) Save & Close

3) Set proper permisisons: (Provide read permission to all users, in addition to whatever other permissions are pre-set)

$ sudo chmod a+r /etc/udev/rules.d/51-android.rules

# JAVA JDK Installation:

1) Download & keep aside the latest Oracle Java 6 JDK. (I dislike OpenJDK. Feel free to use it if you prefer that ;) )

Remember: WE NEED JAVA 6, not any other version (5 or 7 etc). Or this will not work for you.

http://www.oracle.com/technetwork/java/javase/downloads/jdk6-downloads-1637591.html

2) Remove other JAVA Packages:

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

3) Install JAVA JDK:

$ sudo mkdir -p /opt/java/64/
$ sudo cp jdk-6u[COLOR=Red]##[/COLOR]-linux-x64.bin /opt/java/64
$ sudo su -
$ cd /opt/java/64
$ chmod +x jdk-6u[COLOR=red]##[/COLOR]-linux-x64.bin
$ ./jdk-6u[COLOR=red]##[/COLOR]-linux-x64.bin
$ exit

REPLACE THE HASHes (#) WITH YOUR VERSION NUMBER.

-] Save & Exit

4) Add JDK PATH to .bashrc:

$ gksudo gedit ~/.bashrc

-] Add these lines:

# Java PATHs
export JAVA_HOME=/opt/java/64/jdk1.6.0_[COLOR=red]##[/COLOR]
export PATH=$PATH:$JAVA_HOME/bin

REPLACE THE HASHes (#) WITH YOUR VERSION NUMBER.

# Python Installation:

For Python installation, I give you two choices. Pick whichever you like. But pick ANY ONE.

Option 1: Direct package installation: (Easy way)

$ sudo apt-get install python

—–OR——

Option 2: Self compile Python from source: (Advanced way. Not recommended if you have no experience with software compilation)

1) Download Python 2.7.3:

http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz

-] For 2.7 you need to explicitly enable SSL after running the ./configure script and before running make:

2) Configure Python:

$ ./configure

3) Navigate to & open Modules/Setup.

There are lines like this:

#SSL=/usr/local/ssl
#_ssl _ssl.c \
#       -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
#       -L$(SSL)/lib -lssl -lcrypto

4) Uncomment these lines and change the SSL variable to /usr:

SSL=/usr
_ssl _ssl.c \
       -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \
       -L$(SSL)/lib -lssl -lcrypto

5) Install Python:

$ make
$ sudo make install

6) Add Python PATH to .bashrc:

$ gksudo gedit .bashrc

-] Add these lines:

# Python
export PATH=/usr/bin:$PATH

-] Save & Exit

# Android SDK:

1) Download the SDK here:

http://developer.android.com/sdk/index.html

2) Extract the SDK and place it in your home directory.

3) Add AndroidSDK PATH to .bashrc:

$ gksudo gedit .bashrc

-] Add the following lines:

# Android tools
export PATH=${PATH}:~/android-sdk/tools
export PATH=${PATH}:~/android-sdk/platform-tools
export PATH=${PATH}:~/bin

-]Save & Exit

4) Add PATH to .profile:

$ gksudo gedit .profile

-] Add these lines:

PATH=$HOME/android-sdk/tools:$HOME/android-sdk/platform-tools:$PATH"

-] Save & Exit

*To use the ADB Update software (or to verify a working adb path), use the following command:

$ android

# Install the Repo:

$ mkdir ~/bin
$ PATH=~/bin:$PATH
$ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo ] ~/bin/repo
$ chmod a+x ~/bin/repo

# Initialize the ParanoidAndroid Repo:

$ mkdir android
$ cd android
$ mkdir system
$ cd system
$ repo init -u git://github.com/ParanoidAndroid/android.git -b jellybean

VERY IMPORTANT: Now, before the final stage sync, make sure there’s no code referring to ‘ParanoidPreferences’ in manifest.

To check that

1) Open your File Browser,

2) Press Ctrl+H (to show hidden files/directories)

3) Navigate to android/system/.repo/manifest.xml

(Right Click & open the XML file in text editor)

*REMOVE ANY ‘PARANOIDPREFERENCES’ CODE FROM MANIFEST*

*REMOVE GROUPER DEVICE TREE FROM MANIFEST* (This’ll be useless, unless you’re compiling for Grouper: Nexus 7)

Now, Lets add the device specific trees:

Add your own device tree, kernel tree, hardware source tree, & vendor proprietaries tree in the manifest. (BEFORE the manifest closing tags)

For example, I’m using all corresponding trees for Samsung Galaxy S3 i9300 – International

Following is just an example, not what you should copy/paste. SEARCH & USE YOUR OWN DEVICE SPECIFIC TREES.

<!-- Add i9300 device tree -->  
<project name="CyanogenMod/android_device_samsung_i9300" path="device/samsung/i9300" remote="github" revision="jellybean" />

<!-- Add Samsung Kernel SMDK4412 -->
<project name="CyanogenMod/android_kernel_samsung_smdk4412" path="kernel/samsung/smdk4412" remote="github" revision="jellybean" />

<!-- Add samsung hardware source tree -->
<project name="CyanogenMod/android_hardware_samsung" path="hardware/samsung" remote="github" revision="jellybean" />

<!-- Add Samsung Proprietary Vendor Files -->
<project name="TheMuppets/proprietary_vendor_samsung" path="vendor/samsung" remote="github" revision="jellybean" /> 

# Sync the Repo

$ repo sync

Now, here’s a reference to the repo sync parameters:

“make” command has ‘-j’ option to run multi jobs parallely. “repo sync” has similar option, too.

Let’s examine command line help:

$ repo sync -h

Usage: repo sync [...]

Options:

-h, --help show this help message and exit
-f, --force-broken continue sync even if a project fails to sync
-l, --local-only only update working tree, don't fetch
-n, --network-only fetch only, don't update working tree
-d, --detach detach projects back to manifest revision
-q, --quiet be more quiet
-jJOBS, --jobs=JOBS number of projects to fetch simultaneously
-s, --smart-sync smart sync using manifest from a known good build

repo Version options:

--no-repo-verify do not verify repo source code

So, for instance, if you want to run 8 fetching jobs parallelly,

$ repo sync -j8

I personally use -j4, due to my awful internet. You may use any no. of jobs value, like -j16.

This can reduce the download time. However, this’ll suck lots of the bandwidth of the network. Just so you know ;)

Now that you have the sources, its time to deal with the precompilation & compilation steps :cowboy:

Move on to Part II.

———————————————————————————

Credits:

- molesarecoming (XDA)

- D4rKn3sSyS (XDA)

- dastin1015 (XDA)

- Perka (XDA)

- pmos69 (XDA)

- ProTekk (Rootzwiki)

+15
-2
  

Bidyut Mukherjee

Posts

No Comments

Be the first to start the conversation.

Leave a Reply

*

Text formatting is available via select HTML. <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>