manpagez: man pages & more
info autoconf
Home | html | info | man
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.8.2 Installation Directory Variables

The following variables specify the directories for package installation, see Variables for Installation Directories in The GNU Coding Standards, for more information. Each variable corresponds to an argument of configure; trailing slashes are stripped so that expressions such as ‘${prefix}/lib’ expand with only one slash between directory names. See the end of this section for details on when and how to use these variables.

Variable: bindir

The directory for installing executables that users run.

Variable: datadir

The directory for installing idiosyncratic read-only architecture-independent data.

Variable: datarootdir

The root of the directory tree for read-only architecture-independent data files.

Variable: docdir

The directory for installing documentation files (other than Info and man).

Variable: dvidir

The directory for installing documentation files in DVI format.

Variable: exec_prefix

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.

Variable: htmldir

The directory for installing HTML documentation.

Variable: includedir

The directory for installing C header files.

Variable: infodir

The directory for installing documentation in Info format.

Variable: libdir

The directory for installing object code libraries.

Variable: libexecdir

The directory for installing executables that other programs run.

Variable: localedir

The directory for installing locale-dependent but architecture-independent data, such as message catalogs. This directory usually has a subdirectory per locale.

Variable: localstatedir

The directory for installing modifiable single-machine data.

Variable: mandir

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

Variable: oldincludedir

The directory for installing C header files for non-GCC compilers.

Variable: pdfdir

The directory for installing PDF documentation.

Variable: prefix

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

Variable: psdir

The directory for installing PostScript documentation.

Variable: sbindir

The directory for installing executables that system administrators run.

Variable: sharedstatedir

The directory for installing modifiable architecture-independent data.

Variable: sysconfdir

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 ‘@datarootdir@’ is replaced by ‘${prefix}/share’, not ‘/usr/local/share’, and ‘@datadir@’ is replaced by ‘${datarootdir}’.

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 should 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 datarootdir remains defined as ‘${prefix}/share’, so that its value can be expanded based on 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 hard-coding it in makefiles using e.g., ‘AC_DEFINE_UNQUOTED([DATADIR], ["$datadir"], [Data directory.])’, you should add ‘-DDATADIR='$(datadir)'’ to your makefile’s definition of CPPFLAGS (AM_CPPFLAGS if you are also using Automake).

Similarly, you should not rely on AC_CONFIG_FILES to replace bindir and friends in your shell scripts and other files; instead, let make manage their replacement. For instance Autoconf ships templates of its shell scripts ending with ‘.in’, and uses a makefile snippet similar to the following to build scripts like autoheader and autom4te:

edit = sed \
        -e 's|@bindir[@]|$(bindir)|g' \
        -e 's|@pkgdatadir[@]|$(pkgdatadir)|g' \
        -e 's|@prefix[@]|$(prefix)|g'
autoheader autom4te: Makefile
        rm -f $@ $@.tmp
        srcdir=''; \
          test -f ./$@.in || srcdir=$(srcdir)/; \
          $(edit) $${srcdir}$@.in >$@.tmp
        chmod +x $@.tmp
        chmod a-w $@.tmp
        mv $@.tmp $@
autoheader: $(srcdir)/autoheader.in
autom4te: $(srcdir)/autom4te.in

Some details are noteworthy:

@bindir[@]

The brackets prevent configure from replacing ‘@bindir@’ in the Sed expression itself. Brackets are preferable to a backslash here, since Posix says ‘\@’ is not portable.

$(bindir)

Don’t use ‘@bindir@’! Use the matching makefile variable instead.

$(pkgdatadir)

The example takes advantage of the variable ‘$(pkgdatadir)’ provided by Automake; it is equivalent to ‘$(datadir)/$(PACKAGE)’.

/

Don’t use ‘/’ in the Sed expressions that replace file names since most likely the variables you use, such as ‘$(bindir)’, contain ‘/’. Use a shell metacharacter instead, such as ‘|’.

special characters

File names, file name components, and the value of VPATH should not contain shell metacharacters or white space. See section Special Characters in Output Variables.

dependency on ‘Makefile

Since edit uses values that depend on the configuration specific values (prefix, etc.) and not only on VERSION and so forth, the output depends on ‘Makefile’, not ‘configure.ac’.

$@

The main rule is generic, and uses ‘$@’ extensively to avoid the need for multiple copies of the rule.

Separated dependencies and single suffix rules

You can’t use them! The above snippet cannot be (portably) rewritten as:

autoconf autoheader: Makefile
.in:
        rm -f $@ $@.tmp
        $(edit) $< >$@.tmp
        chmod +x $@.tmp
        mv $@.tmp $@

See section Single Suffix Rules and Separated Dependencies, for details.

$(srcdir)

Be sure to specify the name of the source directory, otherwise the package won’t support separated builds.

For the more specific installation of Erlang libraries, the following variables are defined:

Variable: ERLANG_INSTALL_LIB_DIR

The common parent directory of Erlang library installation directories. This variable is set by calling the AC_ERLANG_SUBST_INSTALL_LIB_DIR macro in ‘configure.ac’.

Variable: ERLANG_INSTALL_LIB_DIR_library

The installation directory for Erlang library library. This variable is set by using the ‘AC_ERLANG_SUBST_INSTALL_LIB_SUBDIR’ macro in ‘configure.ac’.

See section Erlang Libraries, for details.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on April 26, 2012 using texi2html 5.0.

© manpagez.com 2000-2017
Individual documents may contain additional copyright information.