Saturday, August 11, 2012

Autoconf and Automake on Mac OS X Mountain Lion

It's summer and I've been thinking about blogging more regularly again. I'm usually too busy to find time to blog, so I'm going to try a shorter format this time: sort of middle ground between a tweet and a full blown blog.

So, here's my first entry in that shorter format.

If you're upgrading to Mac OS X Mountain Lion and Xcode 4.4.1, you'll find that Xcode does not include anymore the GNU Autoconf, Automake and Libtool build tools used by most open source projects to generate makefiles and dynamic libraries... That's not so great :(

I wanted to share what I did to build them myself from source, as it could help others too:

export build=~/devtools # or wherever you'd like to build
mkdir -p $build

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=$build/autotools-bin
make
make install
export PATH=$PATH:$build/autotools-bin/bin

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=$build/autotools-bin
make
make install

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=$build/autotools-bin
make
make install

Notice how I configured to install in --prefix=$build/autotools-bin? You can also omit that to install the tools in your system dirs if you want. I usually install what I build under my own user dir to avoid polluting the system dirs, but it's really your choice.

Hope this helps

30 comments:

Anonymous said...

On my machine (OS X 10.7.4) I had to add $build/autotools-bin/bin to the path otherwise automake wouldn't find autoconf.

Jean-Sebastien Delfino said...

Good catch. I just fixed the steps to correctly set the path. Thanks!

Mathieu Clerte said...

Can't we just install MacPorts or Brew ?
I've tried your technique and the 2 above and still the system can't find aclocal - although it can find both automake and autoconf...
Any idea ?

Jean-Sebastien Delfino said...

Macports or Brew should work too but I usually prefer a more minimalistic approach and build just what I need from source. The steps I described build the strict minimum to get automake working without duplicating any of the tools installed by Apple.

If you can't find aclocal, check your path and how you invoke it. It should be in $build/autotools-bin/bin besides automake and autoconf.

Anonymous said...

Thanks for sharing.
Three minutes copy-and-paste instead of hours try-and-error.
Wishing you well!

Anonymous said...

Hi,

i had problems with the ./configure command:

checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... build-aux/install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... no
checking build system type... i386-apple-darwin12.1.0
checking host system type... i386-apple-darwin12.1.0
configure: autobuild project... GNU Autoconf
configure: autobuild revision... 2.68
configure: autobuild hostname... tommbp.fritz.box
configure: autobuild timestamp... 20120919T082822Z
checking whether /bin/sh -n is known to work... yes
checking for characters that cannot appear in file names... none
checking whether directories can have trailing spaces... yes
checking for expr... /bin/expr
checking for GNU M4 that supports accurate traces... configure: error: no acceptable m4 could be found in $PATH.
GNU M4 1.4.6 or later is required; 1.4.14 is recommended

how can i solve this?

JFG said...

Thanks Jean-Sebastien, really great stuff for a newbie like myself :)

Clark Wilkins said...

Very helpful. Thank you.

clark@simplexable.com

Clark Wilkins said...

Very helpful. Thank you.

clark@simplexable.com

Simon said...

Very useful.

Xcode 4.2 has a libtool, so I thought I might not need to build that; but it seems to be incomplete (no libtoolize).

Markham said...

After running your script, when I try to run autoconf, I get the error:

"autom4te: cannot create autom4te.cache: No such file or directory"

Any ideas?

Scott Smith said...

This worked well for me on Mountain Lion 10.8.2 and XCode Version 4.6 (4H127).

Thank you.

Anonymous said...

This is great--thanks for posting. I chose to use /usr/local.

KC said...

Thank you so much for this!!

Andrei Ismail said...

Thanks a lot! :) Worked for me.

Anonymous said...

Thank you very much! This was awesome

Anonymous said...

Much, much appreciated!

Anonymous said...

Much appreciated!

Anonymous said...

Thank you very much!

barabanus said...

Thank you!

barabanus said...

Thank you!

Jay Fuerstenberg said...

Thank you for this! I was able to make a protocol buffer unix tool with your help.

Anonymous said...

Thanks a lot! I also need to make autoreconf work. Does a similar strategy work there?

Миша said...

Thanks for sharing. A quick comment, maybe replace autoconf-2.68.tar.gz with autoconf-latest.tar.gz (and likewise for the other autotools).

Anonymous said...

Awesome post. Thanks much. Used it on 10.8.5. For the person who had the M4 error, you need to install the Xcode command line tools (now a Download under Preferences after you install xcode). Or you could build your own m4 if you didn't want to download xcode.

gordon warren said...

Thanks! This was the top google result for "autoconf mac" when I realized Xcode on Mavericks didn't have it.

gordon warren said...

Thanks! This was the top google result for "autoconf mac" when I realized Xcode on Mavericks didn't have it.

Anonymous said...

Thank you, your instructions work flawlessly on 10.9.1. You saved a lot of people a lot of time. :)

Gerben said...

Make sure to check the FTP server for the latest version. For autoconf you can simply use autoconf-latest.tar.gz which always points to the latest version. For automake and libtool, copy and paste the url without the filename in your browser and look for the latest version. The dates are included in the directory listings which may make it easier.

Ecio Silvq said...

Muito obrigado! Seu "HowTo" ficou ótimo!


The postings on this site are my own and don’t necessarily represent positions, strategies or opinions of my employer IBM.