Building of a project by using of
configure, automake, autoconf and other «autotools»

One can make a project architecturally independent by using of «autotools» and minimize the creating time of Makefile.

For example, there is a simple project written in C:

1. Let's create a directory for the project test

2. Let's create the directory src in the directory test

3. Let's create the file main.c in src

/* src/main.c */
#include "main.h"

int main (void) {
   test ();
   return 0;

4. Let's create the file named test.c in src

/* src/test.c */
#include "main.h"

void test (void){
   printf("i am test!\n");

5. Let's create the file named main.h in src

/* src/main.h */
#include <stdio.h>

extern void test (void);

For building of such a project one can create Makefile manually, but it would be better to use autotools which will generate it automatically.

For automatic creating of Makefile one needs two templates only - and The first one should be written manually, the second will be generated automatically and should be edited manually.

In the kernel directory of the project (in the directory test) let's create the file named with following content:



The keyword SUBDIRS means that the source files for building are in this directory.

The file named should be also created in the directory src with the following content:

## src/

bin_PROGRAMS = hello
hello_SOURCES = main.c main.h test.c

The keyword bin_PROGRAMS determinates the name of the program that will be received as a result of building.

The keyword hello_SOURCES is used for listing of files' names of the source code which the file «hello» will be created from.

If it is required to connect an additional library, it is necessary to add the next line:

hello_LDADD = -lpthread

In such a way the lpthread library is connected.

For specifying of a flag we should do the following:

AM_LDFLAGS = -rdynamic


AM_LDFLAGS = -L. -Wl,-rpath,.

In the latter case the way is added to the library (the point means "in the current directory").

If it is required to connect any directory with headers, it is necessary to add the following:

INCLUDES = -I/usr/src/linux-headers-2.6.32-23-generic/include/

That is all.

Let's create by using of the utility autoscan. This program creates the file configure.scan, which is the prototype of

Let's run the following:


Let's edit the configure.scan and then rename it into :

#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_INIT([hello], [1.0], [])


# Checks for programs.

# Checks for libraries.

# Checks for header files.

# Checks for typedefs, structures, and compiler characteristics.

# Checks for library functions.


Macro AC_INIT. A program name, its version, email are transferred as parameters.

Macro AC_CONFIG_SRCDIR. File path is transferred - as parameter, the building begins with it.

Macro AM_INIT_AUTOMAKE activates the support Automake.

Macro AC_PROG_CC checks if C-compiler is supported by the system.

Macro AC_OUTPUT specifies the Makefile that will be created as a result of running of the configure script.

THAT IS ALL! Now let's run the following sequence and Makefile is ready.

aclocal - creates aclocal.m4.

autoconf - the utility creates the script configure in accordance with macros which are listed in the file `'.

autoheader — creates the header file (

touch NEWS README AUTHORS ChangeLog (these files are needed for automake )

automake --add-missing - the utility creates the files "" based on the files "".

configure — creates Makefile

make — compiles the project