How to install and use autotools on Mac OS X

In this article we’ll learn how to install and configure autotools on Mac OS X so that we can start to compile Open Source Software on the Mac.


To follow this article you need to have some confidence using Mac OS terminal application and some basic Mac command line experience. If you don’t have these requirements, please make some practice first or you may end up messing with your Mac. This is a how-to article so I assume you know how to use Mac OS X terminal and commands like sudo.


First of all let’s install the basic requirements:

Mac has two important “porting” projects where 2 communities of developers are constantly porting OSS (Open Source Software) on the Mac platform:

  1. MacPorts
    1. The MacPorts Project is an open-source community initiative to design an easy-to-use system for compiling, installing, and upgrading either command-line, X11 or Aqua based open-source software on the OS X operating system.
    2. I use it since the beginning of this project and recommend to install it to all OSS developers who wants to work on OSS software using their Macs, more info on Mac Ports here.
  2. Homebrew
    1. Homebrew is a free/open source software package management system that simplifies the installation of software on the Mac OS X operating system.
    2. I find Homebrew really useful and easy to use, so I definitely recommend to install it to all novice (or advanced) developers, it will boost all the tedious activities of properly install/configure OSS libraries on the Mac! More info about Homebrew here.

Can MacPorts and Homebrew coexist on the same system?

I have used both of them for quite a long time now without having any issue, but the two solutions are NOT developed to work together, so you need to pay some attention.

Let’s get started!

First of all let’s install MacPorts:

  • To install MacPorts you first need to install Apple Xcode on your Mac, you can install Xcode using the Apple store application on your Mac. Once you’ve installed Xcode, run Mac OS X terminal and type:
$ sudo xcode-select --install

  This will install the required command line developer tools.

  • At this point accept Xcode license by executing:
$ sudo xcodebuild -license
  • Now, download MacPorts Package file correspondent to the Mac OS X version installed on your Mac, you can download the correct Pkg from here:
  • Once you’ve downloaded the correct Pkg file (or dmg file for some version of Mac OS X), install it as your would install a normal Pkg file or dmg file. (So double click on the file icon that will be located in the directory where you downloaded the file and follow instructions from there).
  • Time to synch up your MacPorts installation, to do so get back at your terminal window and type:
$ sudo port -v selfupdate

   This update will take a while, depending on your internet connection and your Mac speed into computing all the received info.

  • Now you have MacPorts installed and updated, but you still need some little hack to make sure it will not interfere with Homebrew later.
  • A possible hack to achieve this is to create the following script to use instead of the standard MacPort syntax to run MacPort installations and everything. I saved this script into my ~/ and called it “macport”, you can call it as you prefer.

# Script wrapper for Macport commands
# this script is meant to help resolving
# conflicts between Homebrew and Macport
# no warranty is provided with it.
# Please note that is is NOT meant to be
# a comprensive solution to the issues 
# between Homebrew and Macport
# Also please note I keep tweaking this
# script if I find more issues, so consider
# this alpha code quality.

# If no parameters are provided then show
# usage:
if [ "$#" -le 0 ]; then
  echo "macport usage: $0 command [arg1, arg2, ...]" >&2
  exit 1

# Check for Macport path and wrap it
if [[ -z $MACPORTS_PREFIX ]]; then

# Get the Macport command line

# Execute it
exec $macport_cmd $*

Don’t forget to give the script executable permissions using “chmod +x” and don’t forget to execute your macport commands using this script to run them!

  • Now let’s install GCC, this because on recent releases of Mac OS X (from Maverick AFAIR) clang is used also when invoking specifically gcc. While this works fine for Mac native code, it won’t work for most of Open Source projects usually created around GCC. To install gcc on Mac using Macports and our previous script:
$ sudo ./macport port install gcc49
  • At this point you should be done.

Now let’s install Homebrew:

  • Homebrew requires only one line of instructions to be installed, so get back at terminal windows and type:
$ ruby -e "$(curl -fsSL"

   This will take a bit of time, depending on your internet connection and your Mac speed.

   Because we installed MacPorts before, homebrew may ask you to confirm changing permission to /opt/local and other directories in there to install OSS libraries you’ll need in the future, you can just press enter to confirm this.

  • To make sure that home-brew is ok please execute
$ brew doctor

And follow the instructions to fix any found issue. Obviously brew doctor will warn you that it has found Macport installed and that this is not an optimal situation…

Now let’s start to have some fun!

At this point all the requirements are in place so we can start installing the libraries we need to make autotools work fine on Mac:

  • First let install autotool, to do this, from terminal window, type:
$ brew install autoconf
  • And finally automake
$ brew install automake
  •  That’s it! You are ready to go 🙂

A little extra help…

By experience I saw that many autogen files ( do not consider little differences with Mac platform compared to other BSD based system, so you may have to add something like this to your file in order for it to work properly when generating the configure file:

case `uname` in Darwin
                      *) glibtoolize --copy ;;
                      *) libtoolize --copy ;;

This because some may still find it difficult to find libtoolize on the Mac.

Also on some Makefile you may want to add Macport GCC specific path, to make it easy for Make to find the right compiler, here is an example of how to do that, open your Makefile and edit the line where the variable CC is defined or add this line if no line with CC is defined in the Makefile:


That’s it! Now you should be able to run all the classic, configure and make/make install for your Open Source Projects on the Mac, enjoy!

Thanks for reading and, if you enjoyed this post, please support my blog by visiting my on-line hacking and engineering merchandise shop on by clicking here, thank you! 🙂


10 thoughts on “How to install and use autotools on Mac OS X

  1. Pingback: C code snippet to measure function execution time for both Linux and Mac OS X | Paolo Fabio Zaino's Blog

    • Thanks for reading the article Humberto.

      I did the job on Yosemite and then updated my Mac to El Captain and it seems to be still working. However the initial setup was done on Yosemite and with the releases of Homebrew and MacPorts of the time, so I would recommend to do the job on a Virtual Machine run Mac OS X Yosemite first and test it properly.

      I shared the info because I have seen many people were struggling to properly setup Mac with Autotools at the time, so, another recommendation is to check first if NOW either Homebrew OR MacPorts have all the pieces together so you don’t need to use a combinations of the two, but, instead, you are able to use only one of the two ports repository (that should be the best way of doing it).

      Hope this helps!
      Cheers 🙂


  2. I, thank you for your effort. I return you this additional info

    Operating System: OSX 10.13.2 (High Sierra)
    Platform development: Xcode 9.2 (current) Android Studio 2.3.2 (next)
    Homebrew 1.4.1

    $ brew doctor
    Warning: You have MacPorts or Fink installed:
    This can cause trouble. You don’t have to uninstall them, but you may want to
    temporarily move them out of the way, e.g.
    sudo mv /opt/local ~/macports

    Nice to have some feedback.

    Liked by 1 person

    • Thanks for your message Giuseppe,
      Brew is showing you a WARNING message, not an Error. This is normal, as explained on the article, they are not made to work together, however they don’t always have all required packages, so in some cases a user don’t have much option. However they are improving this situation over-time, this article is from when there was Mac OS X Mountain Lion and things have improved since then.

      If you don’t try to install the same package using both the two package-managers then they generally work fine. However, if you don’t have experience with either of them, I would not recommend to follow my article here since there can be situations where you’ll have to reconfigure a package installed via one of the package manager in order to make it to work with others installed via the other package manager.

      Unfortunately, I don’t have a High Sierra to test it on yet, so I’ll publish an update later on for High Sierra.

      Hope this helps, best regards,
      – Paolo


      • Thank you for your answer. I have installed autocofig and automake only.

        Operating System: OSX 10.13.2 (High Sierra)
        Platform development: Xcode 9.2 (current) Android Studio 2.3.2 (next)
        Homebrew 1.4.1
        autoconf (GNU Autoconf) 2.69
        automake (GNU automake) 1.15.1

        automake returns this error

        Libtool library used but ‘LIBTOOL’ is undefined The usual way to define ‘LIBTOOL’ is to add ‘LT_INIT’ to ‘’ and run ‘aclocal’ and ‘autoconf’ again. If ‘LT_INIT’ is in ‘’, make sure its definition is in aclocal’s search path.

        Off course I add LT_INIT to, and in the search path I have
        echo $PATH > /opt/local/bin:/opt/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
        which libtool > /usr/bin/libtool
        and even “aclocal -l /usr/bin” command does not solve the open issue.

        1. Do you belive the problem is related to the libtool I use? Currently, I exploit the one obtained from Command Line Tool Xcode 9.2. I would not install the GNU libtool as I compile also in C with Xcode 9.2 too, I would not have troubles after.
        2. Do you belive the istallation of the GNU libtool could give me problem with XCode 9.2?
        3. Where is GNU libtool placed (brew install libtool) on Mointain Lion? May be in /opt/local/bin (brew should not change this directory in High Sierra).

        I thinking about mounting a Linux distribution on a VM but it will take me time 😦

        Grazie / Thank you for help.

        Liked by 1 person

    • Hi Giuseppe,
      glad you figure out the problem you had.

      Just one thought about the Linux VM, please note that installing autotools on macOS is to help people porting Linux applications and tools to macOS and using a Linux VM would be a complete different thing (using a Linux VM means keep building for Linux, not Mac).

      This article is to help people who want to recompile/port Linux code on the Mac running macOS only.

      Thanks for your comments and have fun coding! 🙂


      • Hi Paolo

        Yes clear I do not need to spend time installing and configuring a Linux development environment no matter if in a VM.

        Autoconf and auomake allow building a distribution that can be configured (./configure…), build and install (make, make install) on different OS (autoconf and autonake can be executed on different platform).

        Actually, I’m not porting any Linux tool but my own library + IJG jpeg one (of whom src exibits its own configure, makefile, etc).

        My development environment thanks to your suggestions has not changed: OSX, XCODE, ANDROID STUDIO, for OSX/iOS and Android. Android offre NDK thai permit compiling libraris src on OSX libraries test can be linked only on Android.

        Se my site for info on my project.

        Liked by 1 person

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s