Skip to content

Instantly share code, notes, and snippets.

@jellybeansoup
Last active April 14, 2022 16:47
  • Star 58 You must be signed in to star a gist
  • Fork 32 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save jellybeansoup/4192307 to your computer and use it in GitHub Desktop.
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."
@LKramer87
Copy link

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-*

@dylanholmes
Copy link

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

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

@mylittlepython
Copy link

Thank you! this is pretty useful

@caiotava
Copy link

caiotava commented Jun 6, 2015

Great job

@jongheeyun
Copy link

thanks a lot.

@krishnavamcs
Copy link

Worked like a charm, thank you.

@dideler
Copy link

dideler commented Oct 24, 2015

Nowadays you can use Homebrew for this

brew install autoconf automake

@laheadle
Copy link

Listen to dylanholmes! watch out for PATH clobbering!

@smco-lee
Copy link

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.

@jellybeansoup
Copy link
Author

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
Copy link

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
Copy link

solakv commented Mar 3, 2016

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

Works in bash. May need adjustment for other shells.

@miguelmorin
Copy link

miguelmorin commented Mar 13, 2018

@hainesc: I like your script. However, it seems that now the URL added icons, so the AUTOMAKE_VERSION and AUTOTOOL_VERSION variables are wrong:

>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
/icons/compressed.gif

Changing the awk argument from $2 to $6 fixes this

>curl -fL http://ftpmirror.gnu.org/automake | grep -E "automake.*tar.gz" | grep -vE "sig|asc" | awk -F \" '{print $6}' | sed 's/automake-//g' | sed 's/.tar.gz//g' | sort | tail -n 1
1.9.6

This returns 1.9.6 but the latest version has two digits, so I modified the sort with this tip, so this parsing works:

>curl -fL http://ftpmirror.gnu.org/automake | grep -E "automake.*tar.gz" | grep -vE "sig|asc" | awk -F \" '{print $6}' | sed 's/automake-//g' | sed 's/.tar.gz//g' | sort -f -t . -k 1,1 -k 2,2n -k 3,3n -k 4,4n | tail -n 1
1.16.1

With the version number set at "/icons/compressed.gif", the installation fails and AUTOMAKE_ERROR and LIBTOOL_ERROR are empty, which removes the left-hand side in this comparison:

[ $AUTOMAKE_ERROR -ne 0 ];
-bash: [: -ne: unary operator expected

I added an else condition and placed the change of directory and removal of the temporary directory outside the condition, so they are always executed.

Here is my revision of hainesc's code:

# 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 $6}' | sed 's/automake-//g' | sed 's/.tar.gz//g' | sort -f -t . -k 1,1 -k 2,2n -k 3,3n -k 4,4n | tail -n 1)
LIBTOOL_VERSION=$(curl -fL http://ftpmirror.gnu.org/libtool | grep -E "libtool.*tar.gz" | grep -vE "sig|asc" | awk -F \" '{print $6}' | 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
if [ $? -eq 0 ]; then
	AUTOCONF_ERROR=0
else
	AUTOCONF_ERROR=1
fi
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
if [ $? -eq 0 ]; then
	AUTOMAKE_ERROR=0
else
	AUTOMAKE_ERROR=1
fi
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
if [ $? -eq 0 ]; then
	LIBTOOL_ERROR=0
else
	LIBTOOL_ERROR=1
fi
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

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