[Nexus One Android Development] samir5421:
Building on a Mac

Building on a Mac may not work.

Install MacPorts

Install MacPorts using the instructions at MacPorts.org

Install the Developer Tools

Install the Mac OS X Developer Tools from your Mac OS X DVD or from the Apple developer site.

Install the Java Developer Package

Install the Java Developer Package from Apple's site — you'll need a free developer account from Apple. The installer you are looking for will be "Java for Mac OS X 10.6 Update 3 Developer Package" (Update 3 is the latest as of this writing).

Install the Android SDK using the instructions from the first post

Create a Case-Sensitive Workspace

While normal Macintosh volumes are case insensitive, the CyanogenMod/Android source contains files with the same name but in different cases. To solve this issue, you'll have to create and then work out of a case-sensitive disk image.

1. Open the Disk Utility (/Applications/Utilities/Disk Utility.app).

2. Click on New Image.

3. Save as "CyanogenModWorkspace.sparseimage" and set the following parameters as followed:

Name: "CyanogenModWorkspace"

Size: 15 GB is minimum recommended (A sparseimage will save unused space)

Format: Mac OS Extended (CASE-SENSITIVE, Journaled)

Encryption: none, Partition- Single Apple Partition Map

Image Format: Sparse Disk Image (this will save you disk space)

4. Save this wherever you like, and then double-click the sparseimage file to mount.

5. Your workspace will be:

/Volumes/CyanogenModWorkspace/

Install Required Ports

Now you need to install some stuff from macports:

sudo port selfupdate
POSIXLY_CORRECT=1 sudo port install gmake libsdl git-core gnupg e2fsprogs gsed curl libiptcdata xorg-libX* pngcrush findutils
sudo ln -s /opt/local/bin/gsed /opt/local/bin/sed
sudo ln -s /opt/local/libexec/gnubin/find /opt/local/bin/find

Now you need to downgrade gmake to 3.81 because 3.82 breaks the build.

Here's how to downgrade to 3.81:

1. Visit http://trac.macports.org/log/trunk/dports/devel/gmake

2. Click the link that says "@50980" - although it doesn't explicitly say 3.81, this is it

3. Click the link that says "Portfile"

4. Scroll to the bottom and just below "Download in other formats:" click "Original Format"

5. This is subtle but important: If your browser e.g. Chrome renamed it to Portfile.txt, you need to rename it to simply "Portfile"

6. cd to the location of Portfile and

sudo port install

This should install and configure gmake 3.81, after which:

sudo port installed gmake

will print out:

The following ports are currently installed:

gmake @3.81_0 (active)

gmake @3.82_0

Set up the Workspace

Now to setup the CyanogenMod build environment and to build it

copy each line individually into a terminal and press enter:

(This entire process could take hours, depending on your computer and your Internet speed.)

(And make sure your Nexus One is plugged in for the commands after repo sync.)

(Also, you should be running the latest CM nightly (which is CM7) and you should have clockwork recovery and rom manager)

cd /Volumes/CyanogenModWorkspace/

mkdir -p /Volumes/CyanogenModWorkspace/bin

mkdir -p /Volumes/CyanogenModWorkspace/android-cm7

curl http://android.git.kernel.org/repo > /Volumes/CyanogenModWorkspace/bin/repo

chmod a+x /Volumes/CyanogenModWorkspace/bin/repo

PATH=${PATH}:/Volumes/CyanogenModWorkspace/bin:

echo "PATH=\${PATH}:/Volumes/CyanogenModWorkspace/bin:" >> ~/.profile

cd /Developer/SDKs

sudo ln -s MacOSX10.6.sdk/ MacOSX10.4u.sdk

cd /Volumes/CyanogenModWorkspace/android-cm7

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

repo sync

cd /Volumes/CyanogenModWorkspace/android-cm7/device/htc/passion/

./extract-files.sh

cd /Volumes/CyanogenModWorkspace/android-cm7/vendor/cyanogen/

./get-rommanager

./get-google-files

./extract-google-files

now you your CM build environment is complete.

Build CyanogenMod

open a terminal and type:

touch ~/Desktop/build.sh
chmod u+x ~/Desktop/build.sh
open -e ~/Desktop/build.sh

paste the following into TextEdit and save:

#!/bin/bash

echo "cd to android-cm7";
cd /Volumes/CyanogenModWorkspace/android-cm7

echo "Make clean";
make clean
make installclean

echo "Syncing";
repo sync

echo "Copying the make file";
cp ./vendor/cyanogen/products/cyanogen_passion.mk ./buildspec.mk

echo "Setting up build env\n";
. build/envsetup.sh

echo "Setting up lunch";
lunch cyanogen_passion-eng

cd /Volumes/CyanogenModWorkspace/android-cm7

echo "Using the make command";
make -j`sysctl -an hw.logicalcpu` bacon

save and quit TextEdit.

Run the following command in terminal every time you want to build CM.

~/Desktop/./build.sh

If you get an error saying:

ASSERTION FAILURE external/elfcopy/elfcopy.c:932: [ranges[i].start >= last_end]

You need to open /Volumes/CyanogenModWorkspace/external/elfcopy/elfcopy.c and comment line 932 (Add // in front of the line). This should fix the problem and allow you to successfully build CM.

Congratulations you have just compiled CyanogenMod for the Nexus One on a Mac!

Sources:

Most of this tutorial came from the CM wiki and the first post.

http://wiki.cyanogenmod.com/index.p...for_Passion_(Mac)#Install_the_Developer_Tools

http://xdaforums.com/showthread.php?t=899674