[ZenFone 2 General] say99:
COMPILE IT YOURSELF​

Hey everyone, you might be knowing me well :p

so here I am to give a guide on compiling your own kernels

I will not go into basics, like setting up linux in your pc or lappy

we will start from setting up the build environment

Installing the JDK​

Java 8: For the latest version of Android

For Unbuntu >= 15.04

Run the following:

sudo apt-get update
sudo apt-get install openjdk-8-jdk

For Ubuntu LTS 14.04

Download the .deb packages for your architecture from http://packages.ubuntu.com/vivid/openjdk-8-jdk

openjdk-8-jre-headless : http://packages.ubuntu.com/vivid/openjdk-8-jre-headless

openjdk-8-jre : http://packages.ubuntu.com/vivid/openjdk-8-jre

openjdk-8-jdk : http://packages.ubuntu.com/vivid/openjdk-8-jdk

Install the packages:

sudo apt-get update
sudo dpkg -i {downloaded.deb file}
sudo apt-get -f install

Install required packages :

sudo apt-get install git-core gnupg flex bison gperf build-essential \
zip curl zlib1g-dev gcc-multilib g++-multilib libc6-dev-i386 \
lib32ncurses5-dev x11proto-core-dev libx11-dev lib32z-dev ccache \
libgl1-mesa-dev libxml2-utils xsltproc unzip

installing and learn using git is your own task :p​

clone the sources​

my kernel sources(flareM) : git clone https://github.com/Zenfone2-Dev/android_kernel_asus_moorefield

AEL kernel sources : git clone https://github.com/friedrich420/Ael-Zen-Kernel-Asus-Zenfone2-

thessj's project_T : git clone https://github.com/TheSSJ/android_kernel_asus_moorefield

stock cyanogen sources : git clone https://github.com/CyanogenMod/android_kernel_asus_moorefield

stock ASUS sources : http://dlcdnet.asus.com/pub/ASUS/ZenFone/ZE551ML/zenfone2MR912_2_20_40.zip #Download and extract

ok now we need a toolchain to compile our kernel​

MY GCC 5.3.0 toolchain : https://github.com/Zenfone2-Dev/x86_64-toolchain-GCC-5.3.0 # run ./setup to finally setup my toolchain

googles gcc 4.9 toolchain : https://github.com/Zenfone2-Dev/x86_64-linux-android-4.9

hyper linaro gcc 4.9 toolchain : https://github.com/Zenfone2-Dev/x86_64-linux-linaro4.9

SaberMod gcc 4.8 toolchain : https://github.com/hyper-toolchains/x86_64-linux-SM-4.8

I will focus on my toolchain so all command will be for it​

lets get to work

open home folder, show hidden files and open bash.rc

and paste these lines at the last

export ARCH=x86_64
export CCOMPILE=$CROSS_COMPILE
export CROSS_COMPILE=x86_64-linux-

#change cross compile as per your toolchain

open terminal and type :

export PATH=/full path to toolchain/x86_64-toolchain-GCC-5.3.0/bin:$PATH

#I keep changing my toolchains, you can put this line in bash.rc if you dont want to change your toolchain

lets COMPILE :p​

cd where ever you cloned your sources

if building from my source or cm sources :

make cyanogenmod_zenfone2_defconfig

if building for stock :

make x86_64_moor_defconfig

if you want to explore options :

make menuconfig

if building AEL or FlareM :

./buildzf2

#this will produce a flashable zip for all variants and I consider you all to study up the script

if building stock cm or ASUS :

make -j4

change 4 to no. of threads you got in your cpu

this will produce a bzImage in arch/x86/boot/bzImage

this bzImage need to be converted to flashable boot.img

download bzImage packer by [MENTION=334644]sorg[/MENTION] : http://xdaforums.com/attachment.php?attachmentid=3383108&d=1435567526

extract it in a different folder

extract original boot.img from cm zip or asus zips

place it in that folder and open terminal there

type : ./extract_boot

delete the orignal boot.img

you will get a folder named boot which contains ramdisk and zImage and files (I dont exactly remeber)

copy your bzImage image in boot folder, delete zImage and rename bzImage to zImage

if you open ramdisk you will notice that the link to charger is broken (I had this problem)

delete that charger link

download this : https://drive.google.com/file/d/0B2DVhZKJ05fLWkdHUEdVdEU4bGs/view?usp=sharing

and paste it in ramdisk (actual charger binary)

and FINALLY lets get a boot.img​

in the same terminal(the previous location)

type :

./make_boot

and now we have a boot.img :)

wanna make it flashable via twrp (zip)??​

download any of the project_T kernel extract it, replace boot.img by your boot.img and zip it back

all thanks to [MENTION=2388665]TheSSJ[/MENTION] , changing name and all : no I wont tell you, explore the world :p

flash kernel via twrp

Adding features???​

there are numerous guides on adding features to the kernel google them out and start contributing and make our zenny grow more :)

all the best :)