automake: Complete

1 
1 4.1 A simple example, start to finish
1 =====================================
1 
1 Let’s suppose you just finished writing ‘zardoz’, a program to make your
1 head float from vortex to vortex.  You’ve been using Autoconf to provide
1 a portability framework, but your ‘Makefile.in’s have been ad-hoc.  You
1 want to make them bulletproof, so you turn to Automake.
1 
1    The first step is to update your ‘configure.ac’ to include the
1 commands that ‘automake’ needs.  The way to do this is to add an
1 ‘AM_INIT_AUTOMAKE’ call just after ‘AC_INIT’:
1 
1      AC_INIT([zardoz], [1.0])
1      AM_INIT_AUTOMAKE
1      ...
1 
1    Since your program doesn’t have any complicating factors (e.g., it
1 doesn’t use ‘gettext’, it doesn’t want to build a shared library),
1 you’re done with this part.  That was easy!
1 
1    Now you must regenerate ‘configure’.  But to do that, you’ll need to
1 tell ‘autoconf’ how to find the new macro you’ve used.  The easiest way
1 to do this is to use the ‘aclocal’ program to generate your ‘aclocal.m4’
1 for you.  But wait... maybe you already have an ‘aclocal.m4’, because
1 you had to write some hairy macros for your program.  The ‘aclocal’
1 program lets you put your own macros into ‘acinclude.m4’, so simply
1 rename and then run:
1 
1      mv aclocal.m4 acinclude.m4
1      aclocal
1      autoconf
1 
1    Now it is time to write your ‘Makefile.am’ for ‘zardoz’.  Since
1 ‘zardoz’ is a user program, you want to install it where the rest of the
1 user programs go: ‘bindir’.  Additionally, ‘zardoz’ has some Texinfo
1 documentation.  Your ‘configure.ac’ script uses ‘AC_REPLACE_FUNCS’, so
1 you need to link against ‘$(LIBOBJS)’.  So here’s what you’d write:
1 
1      bin_PROGRAMS = zardoz
1      zardoz_SOURCES = main.c head.c float.c vortex9.c gun.c
1      zardoz_LDADD = $(LIBOBJS)
1 
1      info_TEXINFOS = zardoz.texi
1 
1    Now you can run ‘automake --add-missing’ to generate your
1 ‘Makefile.in’ and grab any auxiliary files you might need, and you’re
1 done!
1