[Xperia Z5 General] CTXz:
The Sony-Kitakami dev team is glad to announce a guide on how to build CM13 or any CM13 based ROM for the entire Z5- series

Note: If you plan to release a ROM using our sources then credits aren't required, however we would deffinately appriciate it very much!

Before we get started

What you need

Any of our supported devices

A PC that is capable of running linux

An Internet connection

And lots of lots of patience

Getting started

Setting up Linux

To be able to build a ROM fully from source a Linux based operating system is required. This is due to the fact that windows is unable to compile the android source code due to lacking tools/libaries. After all you're compiling Linux on Linux (Because android is Linux). We strongly recommend to have AT LEAST 50 GB of space for Ubuntu!!!

Please be aware that this guide is target audiences with Ubuntu specifically and so may not work on other distros. Because of this we prefer ubuntu for everyone that is coming from windows.

Because this guide isn't about how to install ubuntu, I'll let this guide explain all for you : http://www.linuxtechi.com/ubuntu-15-10-desktop-installation-guide/

Installing the required packages

We will start off by downloading openjdk 7 (Note: Open JDK 8 isn't supported by CM yet).

Please open the terminal and enter or copy paste the following :

sudo apt-get update && sudo apt-get install openjdk-7-jdk

After entering the password (Note: you won't be able to see any output when typing the password) hit enter and then type "y" and hit enter again.

Once this is completed we will download the required packages. Please copy paste the following into your terminal :

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 maven schedtool

You may have to enter your password again after hitting enter. Once that is done enter "y" again and hit enter again.

Additionally you can set up ccache by entering the following into the terminal :

echo 'export USE_CCACHE=1' >> ~/.bashrc

after this has been done, restart your PC.

Then we will set up git. Replace "Your name" with your name and "you@example.com" with your email :

git config --global user.name "Your Name"
git config --global user.email "you@example.com"

Now we will need to set up the repo tool. Copy the following into the terminal:

mkdir ~/bin && PATH=~/bin:$PATH && echo 'PATH=~/bin:$PATH' >> ~/.bashrc && curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo && chmod a+x ~/bin/repo

Guides

CyanogenMod 13

Getting the CM13 source

Start out by making a directory called cm13 in your home dir by running the following command :

mkdir ~/cm13/

Now we will initialize the CM13 repository by entering the following in your terminal :

cd ~/cm13/ && repo init -u https://github.com/CyanogenMod/android.git -b cm-13.0

We are now coming to the worst part and that is downloading the entire 20GB big CM13 source code. To sync the source code, run the following command :

repo sync

And now wait.... and wait..... and wait....... until it's done

Getting the Z5/Z5C/Z5P source

To clone the device specific source code we'll have to introduce you to some of the codenames as those are used for simplifying reasons when building from source

NAME CODENAME

Sony Xperia Z5 sumire
Sony Xperia Z5 Compact suzuran
Sony Xperia Z5 Premium satsuki

We will start off by cloning the appropriate manifests for your device. Please enter the following and make sure to replace yourdevicecodename with your device codename :

cd ~/cm13/ && git clone https://github.com/Sony-Kitakami/android_.repo_local_manifests.git -b cm-13.0-yourdevicecodename .repo/local_manifests

Now we will sync our device specific source like this :

repo sync --force-sync

This could again take some time depending on your connection as the kernel source is quite heavy.

Building the ROM

We will now get to the big part, which is compiling. Note this could take from 1 hour to more than 10 hours depending on how good your PC is. Replace yourdevicecodename with your targeted device codename.

Please copy the following to your terminal line by line

cd ~/cm13/

cd .repo/local_manifests/ && git pull && cd ../.. && repo sync --force-sync

. build/envsetup.sh

lunch

cm_yourdevicecodename-userdebug

mka clobber

mka bacon

After a long time of waiting you should be done and your CyanogenMod package should be located in home/cm13/out/target/product/yourdevicecodename/

Congratulations! You have now build your very own CM13 ROM from source!

CyanogenMod 13 based ROMs

If you are planning to build a CM13 based or similar ROM (Bliss Pop, RR, Slim etc.), we're expecting you to be a more advanced user. As much as we would like to give a strict guide, we simply can't cover all as there are always differences between each and every ROM.

You will have to start off by downloading the ROM source. Again this should be similar to CM but the git links are different.

Ex:

RR = repo init -u [url]https://github.com/ResurrectionRemix/platform_manifest.git[/url] -b marshmallow
Bliss = repo init -u [url]https://github.com/BlissRoms/platform_manifest.git[/url] -b mm6.0

and much more. Most of them can be found on the ROMs official git team under the platform_manifest repo.

Here is where things get hard. You will have to edit our manifests and adjust them to work with your target ROM. This is nearly impossible to explain as each ROM contains different repos that may overlap with the CM ones or it may lack repos that you're trying to remove. In other words, you will need to learn how to use the local manifests. A nice guide exists here https://wiki.cyanogenmod.org/w/Doc:_Using_manifests

Once this is done you will have to adjust your device tree to work with your specific ROM. Again this is always different. The best way to learn is to compare a CM tree with a tree from a different ROM

Ex:

Samsung Galaxy S5 mini tree for CyanogenMod : https://github.com/cm-3470/android_device_samsung_kminilte

Samsugn Galaxy S5 mini tree for BlissPop : https://github.com/cm-3470/android_device_samsung_kminilte/tree/bosp-6

The main differences are the cm.mk or device.mk files etc.

Here is a commit that show the transfer from CM to Bliss Pop which usually isn't very hard

https://github.com/cm-3470/android_...mmit/5e902e7dd228c6804b2735af9a96ea02969aa2cf

Once this is completed you can run your build and release it!

XDA:DevDB Information

How to build CM13 from source for the Z5, ROM for the Sony Xperia Z5

Contributors

CTXz, zacharias.maladroit, Moonbutt74

Source Code: https://github.com/Sony-Kitakami

ROM OS Version: 6.0.x Marshmallow

ROM Firmware Required: Stock Marshmalllow

Based On: CyanogenMod

Version Information

Status: Alpha

Created 2016-04-12

Last Updated 2016-04-15