[Android Software Development] Thunder07:
EDIT:I've haven't had the need to setup a recovery build environment in sometime now, as such, I'd no longer maintaining this, beginners and novice users are recommended to follow standard setup, while advanced users can probably adopt this to work for them.

So lately I broke my CM11 base which i use for kernel/recovery compiling,

trying nearly everything to fix it failed, So i took the lazy route, deleted it and started a new base,

So for the moment, I left it sync'ing and went to watch the TV, knowing it takes around 3 hours for a full sync,

came back few hours later and sync was complete and before anything I scrolled he terminal backup and realised there is alot of 'junk' that is of no use to kernel/recovery compiling, so I asked around and i was told Helicopter88 had a minimal setup just for that, but it's out of date,

and from one thing into another I came up with this.

This is a stripped down version of CM11 that allows you to compile recoveries from,

It's main feature is that all(most) of the 'junk' which isn't used in recovery build is removed not only saving you time in downloading but also space,

Sync'ing this setup took me 1 hour and 4 minutes and saved me alot of space and download bandwidth.

(for a bit of transparency, I'm running a slightly modified setup, so there can be some discrepancies in the steps, if that’s the case, post about it and hopefully I'll fix it, though looking through, everything seems correct, I'll also describe my setup in a new post below if you're interested)

1) setup your packages

For linux based systems (32bit & 64bit)

sudo apt-get install bison build-essential curl flex git gnupg gperf libesd0-dev liblz4-tool libncurses5-dev libsdl1.2-dev libwxgtk2.8-dev libxml2 libxml2-utils lzop openjdk-6-jdk openjdk-6-jre pngcrush schedtool squashfs-tools xsltproc zip zlib1g-dev

For Linux based System (64bits ONLY)

sudo apt-get install g++-multilib gcc-multilib lib32ncurses5-dev lib32readline-gplv2-dev lib32z1-dev

2) Setup Repo

Change droid_root to whatever directory you prefer

mkdir -p ~/bin
PATH="$HOME/bin:$PATH"
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo

droid_root="~/android/cm11"
mkdir -p ~/$droid_root
cd [I]droid_root[/I]
repo init -u https://github.com/Thunder07/minimal_android.git -b cm-11.0_min

3) Setup Up Environment

Now, you're almost done, just wait for the sync to finish and run these commands,

Which will setup your environment and download your device tree if required.

remove the {} and replace the content with actual device code name

Do also keep in-mind that you'd need to run these 2 lines every-time you start a new shell when building the recovery.

and that you're cd into your droid_root.

Note: calling breakfast the 1st time will through few error, call it again should throw a dependency error, which we will fix in the next step

source build/envsetup.sh
breakfast {DEVICE_CODE_NAME}

I'm using an htc one x, so my commands would look like this

DONT RUN THIS CODE, ITS FOR HTC ONE X ONLY

source build/envsetup.sh
breakfast endeavouru

4) Removing Android Build Requirements

the error should look something like this

build/core/product_config.mk:239: *** _nic.PRODUCTS.[[device/BRAND/DEVICE/cm.mk]]: "[B]hardware[/B]/ti/wlan/mac80211/wl128x-wlan-products.mk" does not exist. Stop.

and as you might have guessed from the word hardware, the build (CM) is expecting files assoicated with hardware, which are not required by the recovery.

Open $droid_root/device/BRAND/DEVICE/ preferably in file manager

Note: that DEVICE & BRAND refer to you device name and brand and not a directory called BRAND/DEVICE

open cm.mk and change this

# Inherit some common CM stuff.
$(call inherit-product, vendor/cm/config/common_full_phone.mk)

# Enhanced NFC
$(call inherit-product, vendor/cm/config/nfc_enhanced.mk)

# Inherit device configuration
$(call inherit-product, device/htc/endeavoru/full_endeavoru.mk)

To look like this.

Don't copy and paste as these file contains reference to my device (htc/endeavoru)

as you can see the highlighted bit is the changes you need to make.

# Inherit some common CM stuff.
$(call inherit-product, vendor/cm/config/[B][COLOR="Green"]common.mk[/COLOR][/B])

# Enhanced NFC
[B][COLOR="Green"]#[/COLOR][/B]$(call inherit-product, vendor/cm/config/nfc_enhanced.mk)

# Inherit device configuration
[B][COLOR="Green"]#[/COLOR][/B]$(call inherit-product, device/htc/endeavoru/full_endeavoru.mk)

Now, onto DEVICE.mk

is a bit more messy to desribe so i paste a diff to illustrate: http://pastebin.com/jNDGhSPe

Note you can probably get away with leaving PRODUCT_COPY_FILES alone and just removing the hardware related $(call inherit-product, hardware/*.mk)

but just as well, you've got no use for them in this current setup​

5) Build

Bofore you start Building, make sure you're building the recovery you want TWRP/CWM/CWM_Phil/CM simple Recovery cloned into $droid_root/bootable/recovery/

Now for the building part itself, this will build the kernel & recovery and create a flashable image

Note:Make sure you're cd'ed to $droid_root and remember to do step 3 EVERYTIME you open a new shell

mka recoveryimage