autoconf and automake

Perform the following steps to get autoconf/automake working for you. The example shows how to set things up such that the binary startCompletionServer is built by a call to "./configure; make" and that the distribution autocomplete-0.1.tar.gz is built by a call to "make distcheck".

Create the file configure.in:

AC_INIT(StartCompletionServer.cpp)
AM_INIT_AUTOMAKE(autocomplete,0.1)
AC_PROG_CC
AC_PROG_CXX
AC_PROG_INSTALL
AC_OUTPUT(Makefile)

Create the file Makefile.am:

INCLUDES = -I/.
LDFLAGS =  -L/KM/ir/berkeleydb/lib -static
LDADD = -lpthread -ldb_cxx-4.2 -lz

bin_PROGRAMS = startCompletionServer

startCompletionServer_SOURCES = \
               StartCompletionServer.cpp Globals.cpp \
               HYBCompleter.cpp \
               IndexBase.cpp History.cpp codes.cpp nrutil.c \
               QueryParameters.cpp \
               HYBIndex.cpp INVIndex.cpp WordsFile.cpp \
               ConcurrentLog.cpp DocsDB.cpp Document.cpp \
               ExcerptsGenerator.cpp ExcerptsDB.cpp \
               CompletionServer.cpp CompleterBase.cpp \
codes.h                        HYBIndex.h \
CompleterBase.h                IndexBase.h \
CompletionServer.h             INVCompleter.h \
Completions.h                  INVIndex.h \
CompressionAlgorithm.h         MetaInfo.h \
ConcurrentLog.h                nrutil.h \
DocList.h                      Query.h \
DocsDB.h                       QueryParameters.h \
Document.h                     QueryResult.h \
DummyCompressionAlgorithm.h    ScoreAggregators.h \
Exception.h                    Separator.h \
ExcerptData.h                  server.h \
ExcerptsDB.h                   Simple9CompressionAlgorithm.h \
ExcerptsDB_NEW.h               Timer.h \
ExcerptsGenerator.h            TrivialCompressionAlgorithm.h \
File.h                         Vector.h \
Globals.h                      WordList.h \
History.h                      WordRange.h \
HuffmanCompressionAlgorithm.h  WordsFile.h \
                               ZipfCompressionAlgorithm.h \
HYBCompleter.h

Now type the following commands:

$ aclocal    # create file aclocal.m4 (ignore this file on first use)
$ autoconf   # create file configure from configure.in
$ touch NEWS README AUTHORS ChangeLog   # automake insists on these files existing
$ automake -a   # create file Makefile.in from Makefile.am; create missing files such as install.sh

Now you are in the same state that the end user of your package will be. You can now make the binary and run it:

$ ./configure
$ make
$ ./startCompletionServer

To make the distribution file autocomplete-0.1.tar.gz, type the following:

$ make distcheck

This will create a file called autocomplete-0.1.tar.gz in the current working directory (which contains all the source code), and test it out to see whether all necessary files are included and whether the source code passes the regression test suite (if you have such a suite).

Read here for a fine tutorial on the GNU build system: http://autotoolset.sourceforge.net/tutorial.html#SEC39