Here is a minimal example of what you need for the situation that you describe.
You need a makefile.am
containing the name of the binary to build, and the source files used to build it (you do not have to list header files, they will be detected automatically):
bin_PROGRAMS = example
example_SOURCES = main.c header.c
And you need a configure.ac
. Here you set up the name and version number of the program, initialize Automake with the foreign
argument so that it won't complain to you about missing files that the GNU project requires, tell it that you require a C compiler, tell it to build your Makefile
, and finally tell it to output the results of the previous configuration.
AC_INIT([example], [1.0])
AM_INIT_AUTOMAKE([foreign])
AC_PROG_CC
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
If your existing program has any kind of library dependencies, you can run autoscan
to detect possible dependencies. It produces a file configure.scan
, which contains a template that can be used to help build your configure.ac
; but if your program is simple, you can skip this step and use the minimal example above.
Now run autoreconf --install
to copy in some files that are necessary and build Makefile.in
and configure
from the above configuration files. Then, run ./configure
to configure your script, generating a Makefile
. Finally, run make
to build your program.
Once you have done these steps, the Makefile
that you have generated will detect changes to your makefile.am
and run the steps again, so from now on, you should be able to just run make
without having to go through all these steps again.
See the Automake and Autoconf manuals for more information.