If you have built Git from source on Mac OS X you probably didn’t have much trouble. That is, unless you were trying to also build the documentation, in which case you probably ran into problems, right? I’m guessing it happened somewhere around getopt, gettext, or some other library or tool you didn’t have installed. And after several attempts to get the nth dependency to build you gave up. Look no further, as these steps will build Git and its documentation on Mac OS X, at least as of today.
This guide was mostly inspired by Setting up the Git documentation build chain on Mac OS X Leopard which was mostly correct at the time it was written, I assume. As of today it’s missing a couple of steps and it deserves an update for Lion and the latest versions of the libraries.
So without further ado, here are the steps.
A. Install AsciiDoc using the usual
sudo make install, which you probably did already since this one is easy.
B. Download gettext, extract the tarball and open the file
gettext-tools/gnulib-lib/stpncpy.c in an editor. Find the
#define __stpncpy stpncpy line and comment it out (hat tip to biow0lf). Now the usual
sudo make install will suffice.
C. Download getopt, extract the tarball, open the
Makefile in an editor and add
-lintl to the
LDFLAGS variable (as described in the original Wincent wiki), at which point
sudo make install should work.
sudo mkdir -p /usr/local/share/docbook
sudo tar jxf ~/Downloads/docbook-xsl-1.77.1.tar.bz2
sudo unzip ~/Downloads/docbook-xml-4.5.zip -d docbook-xml-4.5
sudo mkdir /etc/xml
sudo xmlcatalog --noout --add nextCatalog '' file:///usr/local/share/docbook/docbook-xsl-1.77.1/catalog.xml --create /etc/xml/catalog
sudo xmlcatalog --noout --add nextCatalog '' file:///usr/local/share/docbook/docbook-xml-4.5/catalog.xml --create /etc/xml/catalog
E. Install Docbook2X which apparently wasn’t necessary when the Wincent page was written.
sudo make install
sudo ln -s docbook2texi docbook2x-texi
sudo xmlcatalog --noout --add nextCatalog '' file:///usr/local/share/docbook2X/xslt/catalog.xml --create /etc/xml/catalog
F. Install xmlto by first ensuring that
/usr/local/bin is in your
sudo vi /etc/paths may help). Now the usual
sudo make install and you are nearly there.
G. Install Git, finally!
git clone https://github.com/git/git.git
git checkout v188.8.131.52(or whatever the latest release happens to be)
make prefix=/usr/local all doc info
sudo make prefix=/usr/local install install-doc install-html install-info
At this point you should have a freshly built Git in
/usr/local along with all of the documentation. Hurray! If that doesn’t work for you, feel free to write to me or post a comment. I would like to keep these instructions up to date as best I can.