Recent Changes - Search:


Reference:

C

edit SideBar

Gnuautotools

External pages

Gnu Autotools

  • In the root folder lies the file configure.ac which adjusts the complete process and generates the file configure
  • The file Makefile.am which consists a couple of assignments
  • optional are the files gettextize, intltoolize, libtoolize
  • The programm aclocal creates aclocal.m4 with help of search pathes (suffix.m4).
  • autoheader creates file config.h which contains all system specific c-praeprocessor-symbol-defenitions.
  • The call of automake creates for each Makefile.am a template file called Makefile.in
  • The execution of autoconf uses the macroprocessor m4 and creates with aclocal.m4 the macro expandation of the macros from configure.ac
 make DISTDIR=/destfolder install
installs under /destfolder/$PREFIX

A minimal project consists of configure.ac and Makefile.am. The extension ac stands for autoconf and am for automake. The configure.ac file is being transformed by autoconf into configure script. The Makefile.am is being transformed by automake into Makefile.in. The latter is being used to generate the final Makefile. The config.h is being generate from the template config.h.in by autoheader.

hello world

 // main.c
 #if HAVE_CONFIG_H
 #include <config.h>
 #else
 #error "You should not compile outside autotools."
 #endif 

 int main() {
  printf("Hello world! This is " PACKAGE_STRING "!\n");
  return 0;
 }

 // Makefile.am
 bin_PROGRAMS=    hello
 hello_SOURCE=   main.c

configure.ac

  • between open bracket and first argument must not place a space
  • a string literal is between [...]
  • comments are begining with #
 AC_INIT([foobar], [1.0], [me@mail.com], [program_package_name])
 AC_CONFIG_SRCDIR([src/main.c])
 AC_CONFIG_HEADER(config.h)
 AM_INIT_AUTOMAKE
 AC_PROG_CC
or AC_PROG_CXX for c++
 AC_HEADER_STDC

 AC_SUBST(CFLAGS)
 AC_SUBST(CPPFLAGS)
 AC_SUBST(LDFLAGS)

 LIBC_REQUIRED=2.5
 FOO_MODULES="libc-2.5 >= $LIBC_REQUIRED"
 PKG_CHECK_MODULES(FOO, $FOO_MODULES)
 AC_SUBST(FOO_CFLAGS)
 AC_SUBST(FOO_LIBS)

 #AC_CONFIG_FILES([Makefile src/Makefile])
 AC_OUTPUT(Makefile src/Makefile)

For each file which autoconf should create it must exist a template file with suffix ".in". It is not necessary to create these file per hand.

Makefile.am

 SUBDIRS = src pixmaps
 desktopdir = $(datadir)/applications
 bin_PROGRAMS=smallexample
 smallexample_SOURCES=main.c

aclocal

Then you can run aclocal to create the macro file aclocal.m4

autoheader

Afterwards run the program autoheader to create the file config.h.in from which the configure script creates the config.h.

automake

 automake --add-missing -gnu
creates AUTHORS,ChangeLog,COPYING,INSTALL,NEWS,README and Makefile.in from Makefile.am template.

autoconf

creates configure from configure.ac as well as autom4te.ache.

configure

default options are:

  • --help
  • --version
  • --prefix=<asdf>
  • --enable-maintainer-mode

make

has default targets: all, clean, distclean, maintainer-clean, install, install-strip, dist, distcheck uninstall

Edit - History - Print - Recent Changes - Search
Page last modified on October 15, 2009, at 02:08 PM