Node:Installation Directory Variables, Next:, Previous:Preset Output Variables, Up:Makefile Substitutions



Installation Directory Variables

The following variables specify the directories where the package will be installed, see Variables for Installation Directories, for more information. See the end of this section for details on when and how to use these variables.

bindir Variable
The directory for installing executables that users run.

datadir Variable
The directory for installing read-only architecture-independent data.

exec_prefix Variable
The installation prefix for architecture-dependent files. By default it's the same as prefix. You should avoid installing anything directly to exec_prefix. However, the default value for directories containing architecture-dependent files should be relative to exec_prefix.

includedir Variable
The directory for installing C header files.

infodir Variable
The directory for installing documentation in Info format.

libdir Variable
The directory for installing object code libraries.

libexecdir Variable
The directory for installing executables that other programs run.

localstatedir Variable
The directory for installing modifiable single-machine data.

mandir Variable
The top-level directory for installing documentation in man format.

oldincludedir Variable
The directory for installing C header files for non-gcc compilers.

prefix Variable
The common installation prefix for all files. If exec_prefix is defined to a different value, prefix is used only for architecture-independent files.

sbindir Variable
The directory for installing executables that system administrators run.

sharedstatedir Variable
The directory for installing modifiable architecture-independent data.

sysconfdir Variable
The directory for installing read-only single-machine data.

Most of these variables have values that rely on prefix or exec_prefix. It is deliberate that the directory output variables keep them unexpanded: typically @datadir@ will be replaced by ${prefix}/share, not /usr/local/share.

This behavior is mandated by the GNU coding standards, so that when the user runs:

make
she can still specify a different prefix from the one specified to configure, in which case, if needed, the package shall hard code dependencies corresponding to the make-specified prefix.
make install
she can specify a different installation location, in which case the package must still depend on the location which was compiled in (i.e., never recompile when make install is run). This is an extremely important feature, as many people may decide to install all the files of a package grouped together, and then install links from the final locations to there.

In order to support these features, it is essential that datadir remains being defined as ${prefix}/share to depend upon the current value of prefix.

A corollary is that you should not use these variables except in Makefiles. For instance, instead of trying to evaluate datadir in configure and hardcoding it in Makefiles using e.g. AC_DEFINE_UNQUOTED(DATADIR, "$datadir"), you should add -DDATADIR="$(datadir)" to your CPPFLAGS.

Similarly you should not rely on AC_OUTPUT_FILES to replace datadir and friends in your shell scripts and other files, rather let make manage their replacement. For instance Autoconf ships templates of its shell scripts ending with .sh, and uses this Makefile snippet:

.sh:
        rm -f $@ [email protected]
        sed 's,@datadir\@,$(pkgdatadir),g' $< >[email protected]
        chmod +x [email protected]
        mv [email protected] $@

Three things are noteworthy:

@datadir\@
The backslash prevents configure from replacing @datadir@ in the sed expression itself.
$(pkgdatadir)
Don't use @pkgdatadir@! Use the matching makefile variable instead.
,
Don't use / in the sed expression(s) since most probably the variables you use, such as $(pkgdatadir), will contain some.