[Android Software Development] shubhamchamaria:
This is a guide to build Cyanogenmod 10.1/10.1.2 from source on MAC OSX 10.8(Mountain Lion)[SUPPORTED DEVICES]

[size=+1]Requirements:[/size]

1) Go to App Store on your OS X and Download Xcode 4(its free). Once that is installed, open Xcode and go to preferences(on top). There you find a tab “DOWNLOADS”, open it and there you can find “Command line tools” and next to it click INSTALL. It will take a few minutes to download and install

2) Make sure you have the android-sdk downloaded and setup adb and fastboot, so they work. It is recommended to place the android-sdk to /usr/local/

To go to /usr go to Finder and from the Go menu on top press 'GO TO FOLDER' and type /usr

If a local folder is not there inside /usr create it.

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

[size=+1]Setting up Build Environment:[/size]

We need to setup OSX to build Android stuff. For that you need to get a few things sorted..

Open up Terminal and type

java

Scroll down and you should see a version number otherwise you need to download it.

Next we have to install Homebrew which has all the important packages

ruby <(curl -fsSk https://raw.github.com/mxcl/homebrew/go)

Now make sure android-sdk and homebrew are in $PATH

touch ~/.bash_profile && echo "PATH=/usr/local/bin:/usr/local/sbin:$PATH:/usr/local/android-sdk/tools:/usr/local/android-sdk/platform-tools" >> ~/.bash_profile

Now run this and see if you need to update anything.

brew doctor

If you do type:

brew update

Now we need to get our dev packages

brew install git coreutils findutils gnu-sed gnupg pngcrush repo

Once that is done, run

brew outdated

if it shows anything, run

brew upgrade

Now run this the correct a few symlinks:

ln -s /usr/local/bin/gfind /usr/local/bin/find && ln -s /usr/local/bin/gsed /usr/local/bin/sed

Now to create our case sensitive image for our CM work [NOTE: the 60g can be changed to anything. It only takes up what it needs but I used 60GB..eg 100g = 100GB..DOn't use less than 30gb or all files won't fit comfortably]:

hdiutil create -type SPARSE -fs "Case-sensitive Journaled HFS+" -size 60g -volname "android" -attach ~/Desktop/Android

Now to create our working directory

cd /Volumes/Android
mkdir cm10.1
cd cm10.1

YOU DON'T HAVE TO DO THIS EVERYTIME:

From the next time do:

cd /Volumes/Android/cm10.1

[size=+1]Getting the source[/size]

Now to initialize the git and to download it

repo init -u git://github.com/CyanogenMod/android.git -b cm-10.1

Download the sources:

repo sync

Wait until it is finished. It will take a long time, depending on your internet connection. (Few hours to few days...It downloads about 8gb which when extracted is about 15gb)

[size=+1]Obtain the device build files and proprietary files:[/size]

We need to modify the manifest to build for your specific device.(Google for your device)

Go to the cm10.1 folder by going into Android which is accessible through the Desktop or Finder.

Expand cm10.1 and from the Go menu in Finder click on Go to folder...Type .repo

Then expand the folder local_manifests

And then modify roomservice.xml with TextEdit or XCode

The nexus 4(mako) manifest is given below

FOR YOUR DEVICE SEARCH GOOGLE FOR 'local_manifest.xml for (your device)'..Most probably you will find it.

<manifest>
<project name="TheMuppets/proprietary_vendor_lge.git" path="vendor/lge" remote="github" revision="cm-10.1"/>
<project name="CyanogenMod/android_device_lge_mako" path="device/lge/mako" remote="github" revision="cm-10.1"/>
<project name="CyanogenMod/lge-kernel-mako" path="kernel/lge/mako" remote="github" revision="jellybean"/>
</manifest>

Save the file. And rerun:

repo sync

Download the necessary pre-builts:

/Volumes/android/cm10.1/vendor/cm/get-prebuilts

That is all. The sources are now ready.

[size=+1]Building CyanogenMOD[/size]

If you build now, you're probably gonna get kernel build errors regarding the missing elf.h header (this error might be device specific). Fortunately, we already have this file downloaded, so we only need to copy it to /usr/local/include:

cp /Volumes/android/cm10.1/external/elfutils/libelf/elf.h /usr/local/include

FINALLY, we are ready to build:

cd /Volumes/android/cm10.1
source build/envsetup.sh && BUILD_MAC_SDK_EXPERIMENTAL=1 brunch mako

Change “mako” to something else if you are building for another device (of course needs to be supported by CM)

Then we just WAIT and let CM build....The first build will take lots of time but the build times should reduce significantly from the second build

After the build is finished successfully you can find your newly created flashable zip in the out folder

Look for .zip file with a tag UNOFFICIAL :)

Happy building!

Credits:​

inffy (updated his guide as i encountered hurdles on the way)​