[[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 to change 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::../debhello-1.0-pkg1/step000.slog[]
----

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

.*Makefile* (v=1.0)
----
include::../debhello-1.0-pkg1/step101.slog[]
----

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

----
sys::[head -n12  ../debhello-1.0-pkg1/step200.slog]
...
----

Let's inspect notable template files generated.

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

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

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

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

Since this upstream source has the proper upstream *Makefile*, there are no needs 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 needs to be updated.

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

The rest of the packaging activities are practically the same as the one in <<nomakefile>>.

