Building Git on Mac, with docs!

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 configure, make, 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 configure, make, 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 configure, make, sudo make install should work.

D. Install Docbook XSL and Docbook XML, which is a bit more involved. This is a streamlined version of what you will find on the Wincent wiki.

  1. sudo mkdir -p /usr/local/share/docbook
  2. cd /usr/local/share/docbook
  3. sudo tar jxf ~/Downloads/docbook-xsl-1.77.1.tar.bz2
  4. sudo unzip ~/Downloads/ -d docbook-xml-4.5
  5. sudo mkdir /etc/xml
  6. sudo xmlcatalog --noout --add nextCatalog '' file:///usr/local/share/docbook/docbook-xsl-1.77.1/catalog.xml --create /etc/xml/catalog
  7. 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.

  1. ./configure
  2. make
  3. sudo make install
  4. cd /usr/local/bin
  5. sudo ln -s docbook2texi docbook2x-texi
  6. 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 PATH before /usr/bin (sudo vi /etc/paths may help). Now the usual configure, make, sudo make install and you are nearly there.

G. Install Git, finally!

  1. git clone
  2. git checkout v1.7.11.5 (or whatever the latest release happens to be)
  3. make prefix=/usr/local all doc info
  4. 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.

About these ads
This entry was posted in Compiling, Computing, HowTo and tagged , , . Bookmark the permalink.

One Response to Building Git on Mac, with docs!

  1. THX. The symlink was a good idea.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s