Last active
March 7, 2024 22:57
-
-
Save jellybeansoup/4192307 to your computer and use it in GitHub Desktop.
Install Autoconf and Automake on OS X Mountain Lion
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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." |
@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
Works in bash. May need adjustment for other shells.