The GNU Build System’s
make install and
interface does not exactly fit the needs of a system administrator
who has to deploy and upgrade packages on lots of hosts. In other
words, the GNU Build System does not replace a package manager.
Such package managers usually need to know which files have been
installed by a package, so a mere
make install is
DESTDIR variable can be used to perform a staged
installation. The package should be configured as if it was going to
be installed in its final location (e.g.,
--prefix /usr), but
make install, the
DESTDIR should be set to
the absolute name of a directory into which the installation will be
diverted. From this directory it is easy to review which files are
being installed where, and finally copy them to their final location
by some means.
For instance here is how we could create a binary package containing a snapshot of all the files to be installed.
~/amhello-1.0 % ./configure --prefix /usr … ~/amhello-1.0 % make … ~/amhello-1.0 % make DESTDIR=$HOME/inst install … ~/amhello-1.0 % cd ~/inst ~/inst % find . -type f -print > ../files.lst ~/inst % tar zcvf ~/amhello-1.0-i686.tar.gz `cat ../files.lst` ./usr/bin/hello ./usr/share/doc/amhello/README
After this example,
amhello-1.0-i686.tar.gz is ready to be
uncompressed in / on many hosts. (Using
instead of ‘.’ as argument for
tar avoids entries for
each subdirectory in the archive: we would not like
restore the modification time of /, /usr/, etc.)
Note that when building packages for several architectures, it might
be convenient to use
make install-data and
install-exec (see The Two Parts of Install) to gather
architecture-independent files in a single package.
See Install for more information.
Automake generates support for the
DESTDIR variable in all
DESTDIR is used during the ‘make install’
step to relocate install objects into a staging area. Each object and
path is prefixed with the value of
DESTDIR before being copied
into the install area. Here is an example of typical DESTDIR usage:
mkdir /tmp/staging && make DESTDIR=/tmp/staging install
mkdir command avoids a security problem if the attacker
creates a symbolic link from /tmp/staging to a victim area;
make places install objects in a directory tree built under
/tmp/staging. If /gnu/bin/foo and
/gnu/share/aclocal/foo.m4 are to be installed, the above command
would install /tmp/staging/gnu/bin/foo and
This feature is commonly used to build install images and packages.
DESTDIR is implemented by coding it directly into
the install rules. If your Makefile.am uses a local install
install-exec-local) or an install hook, then you
must write that code to respect
See Makefile Conventions in The GNU Coding Standards for another usage example.