See How Debian Does It

Debian has packaged several thousand pieces of software, and done so in a way that builds on a wide variety of architectures. The way that Debian packages software is, at its core, remarkably similar to GAR.

Before you can See How Debian Does It, you need to add the following lines to the /etc/apt/sources.list file (or make sure that similar deb-src lines exist) and run apt-get update (as root):

deb-src http://http.us.debian.org/debian stable main contrib 
deb-src http://non-us.debian.org/debian-non-US stable/non-US main contrib 

Once you have done this, you can now open up a package and look inside. Just run (as yourself) apt-get source <packagename> and the source code will download. It should make a subdirectory like foo-2.4.2/ for you. Just cd into it and then have a look at debian/rules. This is actually a Makefile that has its own way of doing things. It should let you know what configure switches to use and whether or not the package supports DESTDIR, etc.

Note specifically the pre-build-stamp (much like our configure step), build-stamp (much like our build step), and pre-binary (much like our install) stages. See if they override DESTDIR or some other variables. See what they do manually and what they do via dh_ scripts. Note the configure_args variables.

While not always the best way, if you See How Debian Does It, you may learn a thing or two!