// vim:set filetype=asciidoc:
[[makefile-sh]]
=== Makefile (shell, CLI)

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

Let's assume its upstream tarball to be *debhello-1.0.tar.gz*.

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

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

Debian packaging requires changing this "`*make install*`" process to install files to 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.0.tar.gz*
----
include::../examples/debhello-1.0_build-1/step000.slog[]
----

Here, the *Makefile* uses *$(DESTDIR)* and *$(prefix)* properly.  All other files are the same as in "`<<nomakefile>>`" and most of the packaging activities are the same.

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

Let's package this with the *debmake* command.  Here, the **-b':sh'** option is used to specify that the generated binary package is a shell script.

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

Let's inspect the notable template files generated.

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

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

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

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

Since this upstream source has the proper upstream *Makefile*, there is no need to create *debian/install* and *debian/manpages* files.

The *debian/control* file is exactly the same as the one in "`<<nomakefile>>`".

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

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

The rest of the packaging activities are practically the same as the ones in "`<<nomakefile>>`".
