// vim:set filetype=asciidoc:
[[makefile-single]]
=== Makefile (single-binary package)

Here is an example of creating a simple Debian package from a simple C source program using the *Makefile* as its build system.

This is an enhanced upstream source example for "`<<simple>>`".  This comes with the manpage, the desktop file, and the desktop icon.  This also links to an external library *libm* to be a more practical example.

Let's assume this upstream tarball to be *debhello-1.4.tar.gz*.

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

----
 $ tar -xzmf debhello-1.4.tar.gz
 $ cd debhello-1.4
 $ make
 $ make install
----

Debian packaging requires changing this "`*make install*`" process to install files into the target system image location instead of the normal location under */usr/local*.

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

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

Here, the contents of this source are as follows.

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

.*src/config.h* (v=1.4):
----
include::../examples/debhello-1.4_build-1/step102.slog[]
----

.*Makefile* (v=1.4):
----
include::../examples/debhello-1.4_build-1/step103.slog[]
----

Please note that this *Makefile* has the proper *install* target for the manpage, the desktop file, and the desktop icon.

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

----
include::../examples/debhello-1.4_build-1/step200.slog[lines=1..3]
 ...
include::../examples/debhello-1.4_build-1/step200.slog-sanity[]
 ...
----

The result is practically the same as in "`<<step-debmake>>`".

Let's make this Debian package, which is practically the same as in "`<<step-maintainer>>`", better as the maintainer.


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

If the *DEB_BUILD_MAINT_OPTIONS* environment variable is not exported in *debian/rules*, lintian warns "`W: debhello: hardening-no-relro usr/bin/hello`" for the linking of *libm*.

The *debian/control* file makes it exactly the same as the one in "`<<step-maintainer>>`", since the *libm* library is always available as a part of *libc6* (Priority: required).

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

.Template files under *debian/*. (v=1.4):
----
include::../examples/debhello-1.4_build-1/step400.slog[]
----

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

Here is the generated dependency list of all binary packages.

.The generated dependency list of all binary packages (v=1.4):
----
include::../examples/debhello-1.4_build-1/step702.slog[]
----
