// vim:set filetype=asciidoc:
[[rules]]
=== *debian/rules* file

The *debian/rules* file is the executable script which re-targets the upstream build system to install files in the **$(DESTDIR)** and creates the archive file of the generated files as the *deb* file.  The *deb* file is used for the binary distribution and installed to the system using the *dpkg* command.

The Debian policy compliant *debian/rules* file supporting all the required targets can be written as simple as footnote:[The *debmake* command generates a bit more complicated *debian/rules* file.  But this is the core part.]:

.Simple *debian/rules*:
----
#!/usr/bin/make -f
#export DH_VERBOSE = 1

%:
	dh $@
----

The *dh* command functions as the sequencer to call all required "`**dh** __target__`" commands at the right moment. footnote:[This simplicity is available since version 7 of the *debhelper* package.  This guide assumes the use of *debhelper* version @@@dhcompat@@@ or newer.]

* *dh clean* : clean files in the source tree.
* *dh build* : build the source tree
* *dh build-arch* : build the source tree for architecture dependent packages
* *dh build-indep* : build the source tree for architecture independent packages
* *dh install* : install the binary files to *$(DESTDIR)*
* *dh install-arch* : install the binary files to *$(DESTDIR)* for architecture dependent packages
* *dh install-indep* : install the binary files to *$(DESTDIR)* for architecture independent packages
* *dh binary* : generate the *deb* file
* *dh binary-arch* : generate the *deb* file for architecture dependent packages
* *dh binary-indep* : generate the *deb* file for architecture independent packages

Here, **$(DESTDIR)** path depends on the build type.

* "`**DESTDIR=debian/**__binarypackage__**/**`" for single binary package footnote:[This is the default up to *debhelper* v13.  At *debhelper* v14, it warns the default change. After *debhelper* v15, it will change the default to **DESTDIR=debian/tmp/** .]
* "`**DESTDIR=debian/tmp/**`" for multi binary package

See "`<<rules-custom>>`" and "`<<rules-variables>>`" for customization.

TIP: Setting "`*export DH_VERBOSE = 1*`" outputs every command that modifies files on the build system.  Also it enables verbose build logs for some build systems.

