Building git on MacOS X

MacOS X installations often lack important software or sometimes what is installed in the fink or MacPorts directories is outdated or just won't work. This page provides some detail about building git, a source code version control system, on a 64-bit MacOS X system.

Required Packages

Here are the packages you'll need to download. Save them to your desktop.

Steps

Open Terminal and follow these commands.

Preparation

# make some install locations in your home directory.
cd
mkdir packages
mkdir i386-apple-darwin

# Make a place to build some packages.
mkdir builds
cd builds

Build OpenSSL

tar zxvf ~/Desktop/openssl-1.0.0e.tar.gz
cd openssl-1.0.0e
./Configure --prefix=~/packages/openssl-1.0.0e darwin64-x86_64-cc no-asm no-hw
make -j 8
make install
cd ..

Build libssh2

tar zxvf ~/Desktop/libssh2-1.3.0.tar.gz
cd libssh2-1.3.0
./configure --with-libssl-prefix=~/packages/openssl-1.0.0e --prefix=~/packages/libssh2-1.3.0
make -j 8
make install
cd ..

Build curl

cp ~/Desktop/curl-7.19.7.tar.bz2 .
bunzip2 curl-7.19.7.tar.bz2
tar xvf curl-7.19.7.tar
cd curl-7.19.7
./configure --with-ssl=~/packages/openssl-1.0.0e \
    --with-libssh2=~/packages/libssh2-1.3.0 \
    --prefix=~/packages/curl-7.19.7/
Edit lib/ssh.c so that the libssh2_{malloc,realloc,free} functions are called curl_libssh2_malloc and so on.
make
make install
cd ..

Build expat

tar zxvf ~/Desktop/expat-2.0.1.tar.gz
cd expat-2.0.1
./configure --prefix=~/packages/expat-2.0.1
make 
make install
cd ..

Build git

tar zxvf ~/Desktop/git-1.7.4.tar.gz
cd git-1.7.4
./configure --with-curl=~/packages/curl-7.19.7 \
     --with-openssl=~/packages/openssl-1.0.0e \
     --with-expat=~/packages/expat-2.0.1 \
     --with-editor=pico \
     --prefix=~/i386-apple-darwin
Edit Makefile and around line 246, add defines:
   NO_FINK=1
   NO_DARWIN_PORTS=1
make
make install
cd ..