Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Install Autoconf and Automake on OS X Mountain Lion
#!/bin/sh
##
# Install autoconf, automake and libtool smoothly on Mac OS X.
# Newer versions of these libraries are available and may work better on OS X
#
# This script is originally from http://jsdelfino.blogspot.com.au/2012/08/autoconf-and-automake-on-mac-os-x.html
#
export build=~/devtools # or wherever you'd like to build
mkdir -p $build
##
# Autoconf
# http://ftpmirror.gnu.org/autoconf
cd $build
curl -OL http://ftpmirror.gnu.org/autoconf/autoconf-2.68.tar.gz
tar xzf autoconf-2.68.tar.gz
cd autoconf-2.68
./configure --prefix=/usr/local
make
sudo make install
export PATH=$PATH:/usr/local/bin
##
# Automake
# http://ftpmirror.gnu.org/automake
cd $build
curl -OL http://ftpmirror.gnu.org/automake/automake-1.11.tar.gz
tar xzf automake-1.11.tar.gz
cd automake-1.11
./configure --prefix=/usr/local
make
sudo make install
##
# Libtool
# http://ftpmirror.gnu.org/libtool
cd $build
curl -OL http://ftpmirror.gnu.org/libtool/libtool-2.4.tar.gz
tar xzf libtool-2.4.tar.gz
cd libtool-2.4
./configure --prefix=/usr/local
make
sudo make install
echo "Installation complete."

You could use this code to get always the latest version.

curl -OL http://ftpmirror.gnu.org/autoconf/autoconf-latest.tar.gz
tar xzf autoconf-latest.tar.gz
cd autoconf-*
./configure --prefix=/usr/local
make
sudo make install
cd ..
rm -r autoconf-*

On line 24, /usr/local/bin should be appended to $PATH.

export PATH=$PATH:/usr/local/bin

Thank you! this is pretty useful

caiotava commented Jun 6, 2015

Great job

thanks a lot.

Worked like a charm, thank you.

dideler commented Oct 24, 2015

Nowadays you can use Homebrew for this

brew install autoconf automake

Listen to dylanholmes! watch out for PATH clobbering!

smco-lee commented Nov 1, 2015

Add the following under your mkdir call:

# see: http://superuser.com/a/39995/482140
pathadd() {
    if [ -d "$1" ] && [[ ":$PATH:" != *":$1:"* ]]; then
        PATH="${PATH:+"$PATH:"}$1"
    fi
}

and then change export PATH=/usr/local/bin to pathadd "/usr/local/bin" then it will then only add the new path to the existing path if not already part of it.

Owner

jellybeansoup commented Nov 11, 2015

Fixed the issue with PATH clobbering, sorry about that.

I haven't updated version numbers. Please check the index pages (remove the file name from the URL) for the latest versions to ensure better compatibility with your OS X version.

Alternatively, use Homebrew, as suggested by @dideler (it's probably a better solution, anyway).

hainesc commented Jan 21, 2016

Improvement

# Install autotools, including autoconf, automake and libtool on Mac OS X.
BUILD_DIR=autotools # or wherever you'd like to build

# Get the latest version of automake and libtool because they have no latest symbol link.
AUTOMAKE_VERSION=$(curl -fL http://ftpmirror.gnu.org/automake | grep -E "automake.*tar.gz" | grep -vE "sig|asc" | awk -F \" '{print $2}' | sed 's/automake-//g' | sed 's/.tar.gz//g' | sort | tail -n 1)
LIBTOOL_VERSION=$(curl -fL http://ftpmirror.gnu.org/libtool | grep -E "libtool.*tar.gz" | grep -vE "sig|asc" | awk -F \" '{print $2}' | sed 's/libtool-//g' | sed 's/.tar.gz//g' | sort | tail -n 1)

mkdir -p $BUILD_DIR
cd $BUILD_DIR

# Autoconf
echo "Installing the latest autoconf..."
curl -fL http://ftpmirror.gnu.org/autoconf/autoconf-latest.tar.gz | tar xzf -
cd autoconf-*
./configure --prefix=/usr/local
make && sudo make install
[ $? -eq 0 ] && AUTOCONF_ERROR=0 && cd .. && rm -rf autoconf-*

# Automake
echo "Installing automake-${AUTOMAKE_VERSION}..."
curl -fL http://ftpmirror.gnu.org/automake/automake-${AUTOMAKE_VERSION}.tar.gz | tar xzf -
cd automake-*
./configure --prefix=/usr/local
make && sudo make install
[ $? -eq 0 ] && AUTOMAKE_ERROR=0 && cd .. && rm -rf automake-*

# Libtool
echo "Installing libtool-${LIBTOOL_VERSION}"
curl -fL http://ftpmirror.gnu.org/libtool/libtool-${LIBTOOL_VERSION}.tar.gz | tar xzf -
cd libtool-*
./configure --prefix=/usr/local
make && sudo make install
[ $? -eq 0 ] && LIBTOOL_ERROR=0 && cd .. && rm -rf libtool-*

if [ $AUTOCONF_ERROR -ne 0 ]; then
  echo "Autoconf error."
fi

if [ $AUTOMAKE_ERROR -ne 0 ]; then
  echo "Automake error."
fi

if [ $LIBTOOL_ERROR -ne 0 ]; then
  echo "Libtool error."
fi

[ $AUTOCONF_ERROR -eq 0 ] && [ $AUTOMAKE_ERROR -eq 0 ] && [ $LIBTOOL_ERROR -eq 0 ] && echo "Installation complete." && cd .. && cp rmdir $BUILD_DIR

solakv commented Mar 3, 2016

function add_path () {
    [[ ":${PATH}:" =~ .*:$1:.* ]] || PATH="${PATH:+${PATH}:}$1"
}

Works in bash. May need adjustment for other shells.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment