Build software on Mac OS X

When trying to use XCode to compile an open source project on Mac OS X Mountain Lion, you might have realized that build tools like GNU Autoconf, Automake or Libtool are no longer available. I think these tools have been removed with XCode 4.3.

One way to make them available again, is to download the source and build them with this script:

#!/bin/bash

# type of compression
#COMPRESSION=gz
#COMPRESSIONFLAGS=-zxf
COMPRESSION=xz
COMPRESSIONFLAGS=-Jxf
#
# path to curl
CURL=/usr/bin/curl
# set to empty if working as root or if you are able to write to /usr/local/
SUDO=""
#SUDO=/usr/bin/sudo
#
# version of autoconf
VAUTOCONF=2.69
#
# version of automake
VAUTOMAKE=1.15
#
# version of libtool
VLIBTOOL=2.4.6

CURRENTDIR=`pwd`

cd $CURRENTDIR
$CURL -OL http://ftpmirror.gnu.org/autoconf/autoconf-$VAUTOCONF.tar.$COMPRESSION
tar $COMPRESSIONFLAGS autoconf-$VAUTOCONF.tar.$COMPRESSION
cd autoconf-$VAUTOCONF
./configure && make && $SUDO make install

cd $CURRENTDIR
$CURL -OL http://ftpmirror.gnu.org/automake/automake-$VAUTOMAKE.tar.$COMPRESSION
tar $COMPRESSIONFLAGS automake-$VAUTOMAKE.tar.$COMPRESSION
cd automake-$VAUTOMAKE
./configure && make && $SUDO make install

cd $CURRENTDIR
$CURL -OL http://ftpmirror.gnu.org/libtool/libtool-$VLIBTOOL.tar.$COMPRESSION
tar $COMPRESSIONFLAGS libtool-$VLIBTOOL.tar.$COMPRESSION
cd libtool-$VLIBTOOL
./configure && make && $SUDO make install

After it ran without errors, the tools are available in /usr/local.

Further you might also need pkg-config. This can be build with this script:

#!/bin/bash

# type of compression
COMPRESSION=gz
COMPRESSIONFLAGS=-zxf
#
# path to curl
CURL=/usr/bin/curl
# set to empty if working as root or if you are able to write to /usr/local/
SUDO=""
#SUDO=/usr/bin/sudo
#
# version of pkg-config
VPKGCONFIG=0.29.1

CURRENTDIR=`pwd`

cd $CURRENTDIR
$CURL -OL https://pkg-config.freedesktop.org/releases/pkg-config-$VPKGCONFIG.tar.$COMPRESSION
tar $COMPRESSIONFLAGS pkg-config-$VPKGCONFIG.tar.$COMPRESSION
cd pkg-config-$VPKGCONFIG
./configure --with-internal-glib && make && $SUDO make install

For Mac OS X it is important that you use at least version 0.29.1 of pkg-config. Otherwise you would get linking errors. Afterwards pkg-config is also available in /usr/local.