Most Unix-compatible systems conform to the Filesystem Hierarchy Standard, as described on Wikipedia, the Linux hier man page and the FreeBSD hier man page.
This standard ensures that files such as programs, headers, libraries, configuration files, and documentation are easy to find for both people and software. Installing files where the system naturally looks for them relieves users of the need to modify their environment with problematic alterations to environment variables such as PATH and LD_LIBRARY_PATH. Altering these variables generally has unintended consequences for other programs, creating headaches for users and those who support the software.
The hierarchy standard also eliminates the need for programs to use clever tricks to locate their own files, such as Perl's findbin.
Some people believe that ignoring the hierarchy standard and installing every program into its own directory
Note that the hierarchy is relocatable: Different systems implement
the hierarchy for add-on software under different prefixes. For
example, by default, the Debian package system installs directly under
/usr
, the FreeBSD
Ports system uses /usr/local
, and MacPorts uses
/opt/local
.
Your Makefile should allow these systems to control the installation location by using standard variable names such as DESTDIR and PREFIX, e.g.
install: ${INSTALL} myprog ${DESTDIR}${PREFIX}/bin ${INSTALL} myheader ${DESTDIR}${PREFIX}/include
This is discussed in detail in the section called “Package-friendly Software”.