// vim:set filetype=asciidoc:
[[autotools-single]]
=== Autotools (single-binary package)

Here is an example of creating a simple Debian package from a simple C source program using Autotools = Autoconf and Automake (*Makefile.am* and *configure.ac*) as its build system.

This source usually comes with the upstream auto-generated *Makefile.in* and *configure* files, too.  This source can be packaged using these files as in "`<<configure-single>>`" with the help of the *autotools-dev* package.

The better alternative is to regenerate these files using the latest Autoconf and Automake packages if the upstream provided *Makefile.am* and *configure.ac* are compatible with the latest version.  This is advantageous for porting to new CPU architectures, etc.  This can be automated by using the "`*--with autoreconf*`" option for the *dh* command.

Let's assume this upstream tarball to be *debhello-1.6.tar.xz*.

This type of source is meant to be installed as a non-system file, for example, as:

----
[base_dir] $ tar --xz -xmf debhello-1.6.tar.xz
[base_dir] $ cd debhello-1.6
[debhello-1.6] $ autoreconf -ivf # optional
[debhello-1.6] $ ./configure --with-math
[debhello-1.6] $ make
[debhello-1.6] $ make install
----

Let's get the source and make the Debian package.

.Download *debhello-1.6.tar.xz*
----
include::../examples/debhello-1.6_build-1/step000.slog[]
----

Here, the contents of this source are as follows.

.*src/hello.c* (v=1.6):
----
include::../examples/debhello-1.6_build-1/step101.slog[]
----

.*Makefile.am* (v=1.6):
----
include::../examples/debhello-1.6_build-1/step102.slog[]
----

.*configure.ac* (v=1.6):
----
include::../examples/debhello-1.6_build-1/step103.slog[]
----

TIP: Without "`*foreign*`" strictness level specified in *AM_INIT_AUTOMAKE()* as above, *automake* defaults to "`*gnu*`" strictness level requiring several files in the top-level directory.  See "`3.2 Strictness`" in the *automake* document.

Let's package this with the *debmake* command.

----
include::../examples/debhello-1.6_build-1/step200.slog[lines=1..23]
 ...
----

The result is similar to "`<<configure-single>>`" but not exactly the same.

Let's inspect the notable template files generated.

// .The source tree after the basic *debmake* execution. (v=1.6)
// ----
// include::../examples/debhello-1.6_build-1/step201.slog[]
// ----

.*debian/rules* (template file, v=1.6):
----
include::../examples/debhello-1.6_build-1/step202.slog[]
----

Let's make this Debian package better as the maintainer.

.*debian/rules* (maintainer version, v=1.6):
----
include::../examples/debhello-1.6_build-1/step301.slog[]
----

There are several other template files under the *debian/* directory.  These also need to be updated.

The rest of the packaging activities are practically the same as the one in "`<<step-debuild>>`".
