Reading Time: 4 minutes


  • GNU Build System: Automake, Autoconf, Libtool are a suite of programming tools used to make source code packages portable to many Unix-like systems.

Why We Need Autotools:

  • Autoconf: automatically generates configure script by scans of existing tree to find its dependencies, that are supposed to work on all kinds of platforms.
  • configure generates a config.h file (from a template) which programs can include to work around portability issues. For example, if HAVE_LIBPTHREAD is not defined, use forks instead.
  • Automake: No need to write lengthy & complex makefiles. just define target, dependencies, flags, etc.
  •  Libtool: simplifying the building and installation of shared libraries on any Unix-like system.
  • Autotools can handle cross-platform development smoothly.

Above statements may seem like alien right now. But just go through below example & then read again. You will get what I just said

Compiling Hello World With Autotools

  • Creating following files in empty directory

AC_INIT([PackageName], [1.0], [bug-report@address]) # Initialize `Autoconf`. Specify package's name, version & bug-report address.
AM_INIT_AUTOMAKE # Initialize Automake
AC_PROG_CC # Check for a C compiler
AC_CONFIG_HEADERS([config.h]) # Declare config.h as output header
AC_CONFIG_FILES([Makefile src/Makefile]) # Declare Makefile & src/Makefile as output files 
AC_OUTPUT # Output all declared files

SUBDIRS = src # Build recursively in src directory


bin_PROGRAMS = hello # "hello" is target & will be installed in bindir (as specify "bin_")
hello_SOURCES = main.c # Dependencies of target hello is main.c



int main()
        puts("Hello World !");
        return 0;

Directory Structure

$ ls -R
.: src


Build Package

$ autoreconf --install
$ ./configure --prefix=$(pwd)
$ make
$ bin/hello
Hello World !

At this stage, there are a lot of other files are generated as follows :

  •,, config* : expected configuration templates.
  • aclocal.m4: definitions for third-party macros used in
  • depcomp, install-sh, missing: auxiliary tools used during the build.
  • autom4te.cache/: Autotools cache files.

How Autotool Works

Understand Build Package Procedure

Step 1: autoreconf --install
  • autoreconf is a helper that knows how to call autoconf, autoheader, aclocal, automake, libtoolize, autopoint, etc tools in the right order.

Behind autoreconf

  • aclocal: Scan for uses of third-party macros, and gather definitions in aclocal.m4.
  • autoconf: Create configure from & aclocal.m4.
  • autoheader : Create from
  • automake --add-missing: Create s from s, & aclocal.m4. --add-missing option will add required file(like config.guess, config.sub, missing, depcomp, install-sh, etc) to carry out build process.

Note: Run libtoolize, If you use LT_INIT to create a shared library with libtool in, otherwise you will get error as[LINE]: error: required file './' not found.

Step 2 : ./configure --prefix=$(pwd)
  • configure will create Makefiles from Makefile.ins
Step 3: make & make install
  • Finally make & make install – Do all things for you

Generalise Idea

  • Practically, You do not have to remember the interaction of all tools, just call autoreconf yourself and let it deal with all the lower-level tools.
  • autoreconf is your friend. You only need a rough idea of the purpose of each tool to understand errors.
GNU Autoconf
  • autoconf Create configure from
  • autoheader Create from
  • autoreconf Run all tools in the right order.
  • autoscan Scan sources for common portability problems, and related macros missing from
  • autoupdate Update obsolete macros in
  • ifnames Gather identifiers from all #if/#ifdef/... directives.
  • autom4te The heart of Autocon. It drives M4 and implements the features used by most of the above tools. Useful for creating more than just configure files.
GNU Automake
  • automake Create from and
  • aclocal Scan for uses of third-party macros, and gather definitions in aclocal.m4.
GNU Libtool
  • Libtool Helps manage the creation of static and dynamic libraries on various Unix-like operating systems

Distributing Packege

$ make distcheck
packagename-1.0 archives ready for distribution:
  • At the end of command execution you will find packagename-1.0.tar.gz in same folder.

Generating Shared Library With Autotools

AC_INIT([PackageName], [1.0], [bug-report@address])
LT_INIT # Used to initialize libtool to create shared library 
AM_MY_MACRO="-I ./" # Delacring Custome Macro
AC_SUBST([AM_MY_MACRO]) # Passing Custome Macro to
AC_CONFIG_FILES([Makefile sum/Makefile src/Makefile])

SUBDIRS = sum src



int main()
     printf("sum(0,1) = %d\n", sum(0,1));
     return 0;


bin_PROGRAMS = sum
sum_SOURCES = main.c
sum_LDADD = ../sum/ # add & link sum against
sum__LDFLAGS = $(AM_MY_MACRO) # Macro Passed By



int sum(int a, int b)
     return a + b;


libsum_la_SOURCES = sum.c

Directory Structre

$ ls -R
.: src sum


./sum: sum.c

Build Package

$ autoreconf --install
$ ./configure --prefix=$(pwd)
$ make install
$ ./bin/sum
sum(0,1) = 1
$ ldd ./bin/sum => (0x00007fff606ac000) => /home/vishal/asdf/lib/ (0x00007fdcf43a6000) => /lib64/ (0x00007fdcf3fcd000)
/lib64/ (0x00007fdcf45a9000)
  • At the end of make install, there are two folders named lib & bin having a shared library in lib & executable in bin.

What Next ?

  • This is just short introduction of How Autotools help us ! There are lot to discover about its competitors like CMake, Scons, etc.


1. Autotools
GNU Build System