make: DESTDIR

1 
1 16.4 'DESTDIR': Support for Staged Installs
1 ===========================================
1 
1 'DESTDIR' is a variable prepended to each installed target file, like
1 this:
1 
1      $(INSTALL_PROGRAM) foo $(DESTDIR)$(bindir)/foo
1      $(INSTALL_DATA) libfoo.a $(DESTDIR)$(libdir)/libfoo.a
1 
1    The 'DESTDIR' variable is specified by the user on the 'make' command
1 line as an absolute file name.  For example:
1 
1      make DESTDIR=/tmp/stage install
1 
1 'DESTDIR' should be supported only in the 'install*' and 'uninstall*'
1 targets, as those are the only targets where it is useful.
1 
1    If your installation step would normally install '/usr/local/bin/foo'
1 and '/usr/local/lib/libfoo.a', then an installation invoked as in the
1 example above would install '/tmp/stage/usr/local/bin/foo' and
1 '/tmp/stage/usr/local/lib/libfoo.a' instead.
1 
1    Prepending the variable 'DESTDIR' to each target in this way provides
1 for "staged installs", where the installed files are not placed directly
1 into their expected location but are instead copied into a temporary
1 location ('DESTDIR').  However, installed files maintain their relative
1 directory structure and any embedded file names will not be modified.
1 
1    You should not set the value of 'DESTDIR' in your 'Makefile' at all;
1 then the files are installed into their expected locations by default.
1 Also, specifying 'DESTDIR' should not change the operation of the
1 software in any way, so its value should not be included in any file
1 contents.
1 
1    'DESTDIR' support is commonly used in package creation.  It is also
1 helpful to users who want to understand what a given package will
1 install where, and to allow users who don't normally have permissions to
1 install into protected areas to build and install before gaining those
1 permissions.  Finally, it can be useful with tools such as 'stow', where
1 code is installed in one place but made to appear to be installed
1 somewhere else using symbolic links or special mount operations.  So, we
1 strongly recommend GNU packages support 'DESTDIR', though it is not an
1 absolute requirement.
1