########################################################################### # Autoconf/Automake Example # # Anuradha Weeraman, 18 April 2004 # # $Id: autoconf-example.txt,v 1.1 2004/06/02 21:17:53 anuradha Exp $ # ########################################################################### For this example I will use a small game I wrote called numero. The program consists of the following C files. checks.c display.c help.c numero.c randomizer.c state.c 1) Firstly, create a directory which would contain your program and build scripts. For instance, numero. And create a directories to store the source files, and separate directories for documents and tests if necessary. -numero \_ src \_ doc \_ tests For the moment, I will only create the src directory. Place all the source files in this directory. 2) In the numero root directory, create a file called "Makefile.am" with the following line : SUBDIRS=src If you have multiple source directories, you would want to mention them here. This will be used by automake to create the root Makefile. Separate Makefile.am's will be required in each of the directories you mention above to create the appropriate Makefile.in's for each of those subdirectories. 3) In the src directory, create a Makefile.am as shown below : bin_PROGRAMS=numero numero_SOURCES=checks.c display.c help.c numero.c randomizer.c state.c 4) Back in the numero root directory, run 'autoscan' to generate a configure.scan. Rename it to 'configure.ac' and edit it. Directly below AC_INIT, add the following line. AM_INIT_AUTOMAKE(numero, 1.0) Under "dnl Checks for programs", add the following : AC_PROG_CC And modify AC_OUTPUT() to say : AC_OUTPUT(Makefile src/Makefile) 5) Run 'aclocal'. 6) Run 'autoconf'. 7) Run 'automake --add-missing'. Run 'automake' again. It will complain of several missing files. Create temporary stub using touch. touch NEWS README AUTHORS ChangeLog Run 'automake' again. It should complete without any problems. Thats it!! To build the system, type ./configure from the root directory of the program, followed by 'make' and 'make install'. Unless certain directories have been overridden at configure time, it will place the program in standard locations. To make a tar ball of your program easily, autoconf will create a target called 'dist' which you can invoke by calling 'make dist' from the program root directory. In this case it will create a tar file called numero-1.0.tar.gz. Very convenient. Happy hacking!