Building Git 1.6.0.2 on Mac OS X 10.3.9 – Quite an Adventure

gitLogo_vert.gif

I have an old(er) Snow iMac G3 at home that I use for my CVS pserver and I wanted to get it working as my Git repo hosting server as well. The problem was that I didn't have a working Git executable for 10.3.9, and so I needed to get it from source and build it from scratch. This is all the little work I had to do to get that to work. Later, I'll discuss getting the repo hosting going, but that's gotta wait until after I get this done.

I had to get a lot of packages to make this all work, but now that I have them, getting new versions of Git should be easy. Lots of up-front work, but worth it in the end. As a matter of personal preference, I put all the projects in my ~/Developer directory, but you can put them in /usr/local/src or some other place. It really doesn't matter. Also, while you can specify any PREFIX you want, I've chosen the traditional /usr/local so that everything is thrown in there - for all packages.

NOTE: if all you're interested in doing is getting Git running on OS X 10.3.9 - then skip to the section at the end about Git - that's all you need. The rest of this preamble is all about being able to generate the man pages (docs) for Git, and since I am planning on using this for a while, it seemed reasonable at the time (HA!) to do it. What a lot of work for a few man pages.

A Big Help was provided by this page where a lot of the steps were the same, but a lot had to be changed. It was a good place to start, and he clearly, like me, wanted to have it all with Git, and went through the effort to figure it all out. Kindred spirits...

gettext

The problem is a chain of dependencies that OS X 10.3.9 doesn't have. In order to make the build in a "no failure" stream (that means building the core components first, and then get to the successive ones later) we need to start at the bottom. The bottom in this case is gettext. We need it for getopt. We need getopt for xmlto. We need xmlto for building the Git docs. Simple, but a lot of tedious work.

In order to install gettext we need to get it, configure it, build it and install it. Like most good GNU projects, it's pretty clear (if not short and quick):

  curl -o gettext.tar.gz http://mirror.anl.gov/pub/gnu/gettext/gettext-0.17.tar.gz
  tar zxvf gettext.tar.gz
  cd gettext-0.17
  ./configure
  make
  make check

which should look OK on the outputs, and then install it with:

  sudo make install

getopt

The next piece of the puzzle is GNU getopt as it's got the support for the long options - as opposed to the single-character kind in the getopt on OS X 10.3.9. So to get this guy installed we needed to:

  curl -o getopt.tar.gz \
      http://software.frodo.looijaard.name/getopt/files/getopt-1.1.4.tar.gz
  tar zxvf getopt.tar.gz
  cd getopt-1.1.4

but there are a few edits that are needed to make this work on 10.3.9. The first is in the Makefile itself. Change:

    LIBCGETOPT=1

to:

    LIBCGETOPT=0

and then change:

    LDFLAGS=

to:

    LDFLAGS=-lintl

At this point, we can make it and install it:

  make
  sudo make install

There were still errors in the make, but they aren't a problem at this point.

DocBook (XML Catalog)

Because xmlto is the key player in this fiasco, and because OS X doesn't have the default DocBook XSL stylesheets and XML files, we need to create them. It's not too bad, just make room for them, download them, and install them:

  sudo mkdir /etc/xml
  sudo xmlcatalog --noout --create /etc/xml/catalog
 
  sudo mkdir -p /usr/local/share/docbook/xsl
  cd /usr/local/share/docbook/xsl
  sudo curl -o docbook.tar.gz \
     http://voxel.dl.sourceforge.net/sourceforge/docbook/docbook-xsl-1.74.0.tar.gz
  sudo tar zxvf docbook.tar.gz
  mv docbook-xsl-1.74.0 1.74.0
  sudo xmlcatalog --noout \
     --add 'nextCatalog' '' 'file:///usr/local/share/docbook/xsl/1.74.0/catalog.xml' \
     --create /etc/xml/catalog
 
  sudo mkdir -p /usr/local/share/docbook/xml
  cd /usr/local/share/docbook/xml
  sudo curl -o docbook4.2.zip \
     http://www.oasis-open.org/docbook/xml/4.2/docbook-xml-4.2.zip
  unzip docbook4.2.zip
  sudo mkdir 4.2
  cd 4.2
  sudo unzip ../docbook4.2.zip
  sudo xmlcatalog --noout \
     --add 'nextCatalog' '' 'file:///usr/local/share/docbook/xml/4.2/catalog.xml' \
     --create /etc/xml/catalog

Lot of work for something I don't plan on using, but that's the very nature of this exercise, it seems. Very time-consuming.

xmlto

Now that we have everything this guy needs, he's pretty simple (HA!) All we need to do is to get the package, configure, make and install:

  curl -o xmlto.tar.bz2 https://fedorahosted.org/xmlto/export/1/xmlto-0.0.21.tar.bz2
  tar --bzip2 -xvf xmlto.tar.bz2
  ./configure
  make
  make check
  sudo make install

AsciiDoc

The last requirement for the docs is to get asciidoc installed on your machine. So let's get the AsciiDoc project as a tarball from it's downloads page - or use curl, as I did:

  curl -o asciidoc.tar.gz http://www.methods.co.nz/asciidoc/asciidoc-8.2.7.tar.gz
  tar zxvf asciidoc.tar.gz
  cd asciidoc-8.2.7

In the INSTALL file in the project, it explains that you might need to edit a few of the directory locations, and sure enough, I did. The biggest one is the location of the Vim support files. To do this, change the line in the install.sh file to look like:

  VIM_CONFDIR=/usr/share/vim/vim62

which is where Vim's support files are for OS X 10.3.9.

There is a problem in asciidoc with regards to the usage of /etc on Mac OS X. The fact is on OS X, /etc is really /private/etc and so this bug was reported, and the fix is to change asciidoc.py line 127 (or thereabouts) from:

      directory = os.path.abspath(directory)

to:

      directory = os.path.realpath(directory)

At this point, you are ready to install asciidoc by simply following the INSTALL instructions:

  sudo ./install.sh

Git

If you're just interested in getting Git running - no docs, then you can start the process here. It's pretty simple - get, configure, make, and install:

  curl -o git.tar.gz http://www.kernel.org/pub/software/scm/git/git-1.6.0.2.tar.gz
  cd git-1.6.0.2
  ./configure
  make
  sudo make install

If you followed all this crazyness, and want to install the docs (man pages) as well, then you can type this:

  make all doc
  sudo make install-doc

and then make sure that you have /usr/local/share/man in your MANPATH to pick these guys up.

At this point, you're ready to use Git, and if you went through all the work I did, you can view the man pages as well. Took a couple of hours, but it's worth it in the long run - I plan on using Git for a while.

Now I need to get a server set up - which is what caused this detour in the first place...