You may be wondering by now where I'm getting these directory names. What if some Unix system out there doesn't use /usr or /usr/local? For one thing, this is another reason for providing the prefix
variable—to allow the user some choice in these matters. However, most Unix-like systems nowadays follow the Filesystem Hierarchy Standard as closely as possible. The FHS defines a number of standard places including the following root-level directories:
/bin | /etc | /home |
/opt | /sbin | /srv |
/tmp | /usr | /var |
This list is by no means exhaustive. I've only mentioned the directories that are most relevant to our study of open source project build systems. In addition, the FHS defines several standard locations beneath these root-level directories. For instance, the /usr directory should contain the following subdirectories:
/usr/bin | /usr/include | /usr/lib |
/usr/local | /usr/sbin | /usr/share |
/usr/src |
The /usr/local directory should contain a structure very similar to that of the /usr directory. The /usr/local directory provides a location for software installation that overrides versions of the same packages installed in the /usr directory structure, because system software updates often overwrite software in /usr without prejudice. The /usr/local directory structure allows a system administrator to decide which version of a package to use on her system, because /usr/local/bin may be (and usually is) added to the PATH
before /usr/bin. A fair amount of thought has gone into designing the FHS, and the GNU Autotools take full advantage of this consensus of understanding.
Not only does the FHS define these standard locations, but it also explains in detail what they're for and what types of files should be kept there. All in all, the FHS leaves you, as project maintainer, just enough flexibility and choice to keep your life interesting but not enough to make you wonder if you're installing your files in the right places.[33]
[33] Before I discovered the FHS, I relied on my personal experience to decide where files should be installed in my projects. Mostly I was right, because I'm a careful guy, but after I read the FHS documentation, I went back to some of my past projects with a bit of chagrin and changed things around. I heartily recommend you become thoroughly familiar with the FHS if you seriously intend to develop Unix software.