[One (M7) General] inffy:
This is a guide to build CyanogenMOD 10.2 (Android 4.3) for the HTC One. This guide is for OS X Mountain Lion (10.8.X).

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

1)	go to App Store on your OS X and Download Xcode 4. Once that is installed, open Xcode and go to preferences. 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/

[size=+1]Initializing the build environment[/size]

First we need to set up our OS X to be able to build Android. This needs some extra things compared to for example, building in Linux, but the main stuff is pretty much the same. So let’s get started then, shall we?

Open up Terminal and type

java

If you don’t have java installed you will get a prompt to install it.

Next we will install homebrew (you can also use macports if you like)

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

I also recommend to add this edit to the .bash_profile file:

nano –w ~/.bash_profile

export BUILD_MAC_SDK_EXPERIMENTAL=1

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

brew doctor

If you do (and you probably will once a day) 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 [Not sure if these are needed anymore]:

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]:

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.2 && cd cm10.2

[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.2

Download the sources:

repo sync

Wait until it is finished. It will take a long time, depending on your internet connection.

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

To do this we will use CyanogenMods "tool" called roomservice. Roomservice is replacing the old local_manifest.xml file. Just run the code below to create the file directly into the folder.

nano -w /Volumes/android/cm10.2/.repo/local_manifests/roomservice.xml

Paste the following lines into the file:

<manifest>
<project name="TheMuppets/proprietary_vendor_htc.git" path="vendor/htc" remote="github" revision="cm-10.2"/>
</manifest>

It seems that nowadays you only need to have the TheMuppets repo there, the roomservice process takes care of the rest and downloads the needed mako bits automatically. And actually it doesn't matter what you name the xml file under the local_manifests directory. The process loads every xml file from there in a alphabetical order. If you still have that local_manifest.xml file in your .repo directory, i suggest you remove that, because at that case that file will be read first and after that all the other from the local_manifests folder

Save the file. And rerun the code:

repo sync

Download the necessary pre-builts:

/Volumes/android/cm10.2/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.2/external/elfutils/libelf/elf.h /usr/local/include

FINALLY, we are ready to build:

cd /Volumes/android/cm10.2 && source build/envsetup.sh && brunch m7ul

The upper command will start the build for the international version for the HTC One (m7ul). Just change the m7ul part to the right codename (check it from f.ex www.get.cm webpage).

Then we just let the Mac do the rest. Remember that it will take a while to do the build, and meantime you Macs fans will scream for mercy while CM punishes your system ☺

After the build is finished successfully you can find your newly created flashable zip by typing:

cd $out

Look for .zip file with a tag UNOFFICIAL :)

Happy building!