Automake generates support for the DESTDIR
variable in all
install rules. 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
The mkdir command avoids a security problem if the attacker creates a symbolic link from /tmp/staging to a victim area; then 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 /tmp/staging/gnu/share/aclocal/foo.m4.
This feature is commonly used to build install images and packages (see DESTDIR).
Support for DESTDIR
is implemented by coding it directly into
the install rules. If your Makefile.am uses a local install
rule (e.g., install-exec-local
) or an install hook, then you
must write that code to respect DESTDIR
.
See Makefile Conventions, for another usage example.