[Android Software Development] Imperticus:
This is a guide to build your own CM7 on Mac OSX Lion. I can't guarantee 100% that this will work for everyone, but it worked for me. I want to thank Paul from Modaco, CyanogenMod team, Batista Harahap, ahbeng, and anyone else I can't remember atm.

1. Download and install Xcode, Java Mac OS X 10.5 SDK (later versions don't seem to work)

2. I recommend uninstalling existing MacPorts (using the codes below) and then install a fresh copy just to be safe.

$ sudo port -fp uninstall --follow-dependents installed
$ sudo rm -rf /opt/local /Applications/DarwinPorts /Applications/MacPorts /Library/LaunchDaemons/org.macports.* /Library/Receipts/DarwinPorts*.pkg /Library/Receipts/MacPorts*.pkg /Library/StartupItems/DarwinPortsStartup /Library/Tcl/darwinports1.0 /Library/Tcl/macports1.0 ~/.macports

3. Follow these steps below to teleport String errors at compile time

$ sudo vi /opt/local/etc/macports/sources.conf

* press ]]

* press i

* Append # at the beginning of the line

* Press Enter

* Add the following lines

file:///Users/Shared/dports
rsync://rsync.macports.org/release/ports/

* Press Esc

* Type :wq and press enter

4. Update Macports and install the necessary packages and revert gmake to 3.81 (This takes a long time)

$ 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
$ vi /opt/local/etc/macports/sources.conf
$ mkdir /Users/Shared/dports
$ cd /Users/Shared/dports
$ svn co --revision 50980 http://svn.macports.org/repository/macports/trunk/dports/devel/gmake/ devel/gmake/
$ portindex /Users/Shared/dports
$ sudo port install gmake @3.81

5. comment a line in one of Darwin’s C Library to get rid of compile time errors

$ sudo vi /usr/include/string.h

* Press :143

* Press i

* Append //

* Press Esc

* Type :wq!

* Press enter

6. Add a symlink for 10.5 SDKs

$ sudo ln -s /Developer/SDKs/MacOSX10.6.sdk /Developer/SDKs/MacOSX10.5.sdk

7. Create a sparseimage with a Case Sensitive FS

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

b.	Click on New Image.

c.	Save as "cyanogenmod.sparseimage" and set the following parameters as followed:

d.	Name: "cyanogenmod"

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

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

g.	Encryption: none, Partition- Single Apple Partition Map

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

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

j.	Your workspace will be: /Volumes/cyanogenmod/

8. Macports version of e2fsprogs will fail to compile, download the source and compile it yourself

$ mkdir -p ~/src
$ cd ~/src
$ git clone http://git.kernel.org/pub/scm/fs/ext2/e2fsprogs.git
$ cd e2fsprogs
$ ./configure --prefix=/opt/local
$ make -j4 && sudo make install

9. Set up the pre-requisites for CyanogenMod to compile, there are

$ cd /Volumes/cyanogenMod
$ mkdir -p bin
$ curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > bin/repo
$ chmod a+x bin/repo
$ mkdir -p android/system/
$ PATH=${PATH}:/Volumes/cyanogenmod/bin:
$ echo "PATH=\${PATH}:/Volumes/cyanogenmod/bin:" >> ~/.profile

10. Clone CyanogenMod repository into our sparse image (This takes a long time)

$ cd /Volumes/cyanogenmod/android/system
$ repo init -u git://github.com/CyanogenMod/android.git -b gingerbread
$ repo sync

11. Now to get all closed source binaries from the device and into our device build folder (replace *company* and *model* with the device you want e.g. /lge/p990)

$ cd /Volumes/cyanogenmod/android/system/device/*company*/*model*
$ ./extract-files.sh

12. ROMManager is a requirement for CyanogenMod

$ /Volumes/cyanogenmod/android/system/vendor/cyanogen/get-rommanager

13. edit cm source to make it compile on lion

Add lines in red to android/system/external/elfutils/config-compat-darwin.h:

[COLOR="Red"]#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 1070 [/COLOR]
static inline size_t strnlen (const char *__string, size_t __maxlen)
{
int len = 0;
while (__maxlen-- && *__string++)
len++;
return len;
}
[COLOR="red"]#endif[/COLOR]

Comment out every line in android/system/external/qemu/Android.mk:

# the following test is made to detect that we were called
# through the 'm' or 'mm' build commands. if not, we use the
# standard QEMU Makefile
#
#ifeq ($(DEFAULT_GOAL),droid)
# LOCAL_PATH:= $(call my-dir)
# include $(LOCAL_PATH)/Makefile.android
#else
# include Makefile.qemu
#endif

14. Now here comes the real fun, let’s compile CyanogenMod. (replace *model* with the device you want e.g. cyanogen_p990)

$ cd /Volumes/gingerbread/android/system/
$ cp ./vendor/cyanogen/products/cyanogen_*model*.mk ./buildspec.mk
$ . build/envsetup.sh
$ lunch cyanogen_*model*-eng
$ make -j`sysctl -an hw.logicalcpu` bacon

If the build was successful, there should be an update-cm-X.X.X-RC0-KANG-signed.zip in the /android/system/out/target/product/*model* folder.

If you were successful, go get yourself a treat.