autoconf: Installation Directory Variables
1
1 4.8.2 Installation Directory Variables
1 --------------------------------------
1
1 The following variables specify the directories for package
11 installation, see ⇒Variables for Installation Directories
(standards)Directory Variables, for more information. Each variable
1 corresponds to an argument of `configure'; trailing slashes are
1 stripped so that expressions such as `${prefix}/lib' expand with only
1 one slash between directory names. See the end of this section for
1 details on when and how to use these variables.
1
1 -- Variable: bindir
1 The directory for installing executables that users run.
1
1 -- Variable: datadir
1 The directory for installing idiosyncratic read-only
1 architecture-independent data.
1
1 -- Variable: datarootdir
1 The root of the directory tree for read-only
1 architecture-independent data files.
1
1 -- Variable: docdir
1 The directory for installing documentation files (other than Info
1 and man).
1
1 -- Variable: dvidir
1 The directory for installing documentation files in DVI format.
1
1 -- Variable: exec_prefix
1 The installation prefix for architecture-dependent files. By
1 default it's the same as `prefix'. You should avoid installing
1 anything directly to `exec_prefix'. However, the default value for
1 directories containing architecture-dependent files should be
1 relative to `exec_prefix'.
1
1 -- Variable: htmldir
1 The directory for installing HTML documentation.
1
1 -- Variable: includedir
1 The directory for installing C header files.
1
1 -- Variable: infodir
1 The directory for installing documentation in Info format.
1
1 -- Variable: libdir
1 The directory for installing object code libraries.
1
1 -- Variable: libexecdir
1 The directory for installing executables that other programs run.
1
1 -- Variable: localedir
1 The directory for installing locale-dependent but
1 architecture-independent data, such as message catalogs. This
1 directory usually has a subdirectory per locale.
1
1 -- Variable: localstatedir
1 The directory for installing modifiable single-machine data.
1
1 -- Variable: mandir
1 The top-level directory for installing documentation in man format.
1
1 -- Variable: oldincludedir
1 The directory for installing C header files for non-GCC compilers.
1
1 -- Variable: pdfdir
1 The directory for installing PDF documentation.
1
1 -- Variable: prefix
1 The common installation prefix for all files. If `exec_prefix' is
1 defined to a different value, `prefix' is used only for
1 architecture-independent files.
1
1 -- Variable: psdir
1 The directory for installing PostScript documentation.
1
1 -- Variable: sbindir
1 The directory for installing executables that system
1 administrators run.
1
1 -- Variable: sharedstatedir
1 The directory for installing modifiable architecture-independent
1 data.
1
1 -- Variable: sysconfdir
1 The directory for installing read-only single-machine data.
1
1 Most of these variables have values that rely on `prefix' or
1 `exec_prefix'. It is deliberate that the directory output variables
1 keep them unexpanded: typically `@datarootdir@' is replaced by
1 `${prefix}/share', not `/usr/local/share', and `@datadir@' is replaced
1 by `${datarootdir}'.
1
1 This behavior is mandated by the GNU Coding Standards, so that when
1 the user runs:
1
1 `make'
1 she can still specify a different prefix from the one specified to
1 `configure', in which case, if needed, the package should hard
1 code dependencies corresponding to the make-specified prefix.
1
1 `make install'
1 she can specify a different installation location, in which case
1 the package _must_ still depend on the location which was compiled
1 in (i.e., never recompile when `make install' is run). This is an
1 extremely important feature, as many people may decide to install
1 all the files of a package grouped together, and then install
1 links from the final locations to there.
1
1 In order to support these features, it is essential that
1 `datarootdir' remains defined as `${prefix}/share', so that its value
1 can be expanded based on the current value of `prefix'.
1
1 A corollary is that you should not use these variables except in
1 makefiles. For instance, instead of trying to evaluate `datadir' in
1 `configure' and hard-coding it in makefiles using e.g.,
1 `AC_DEFINE_UNQUOTED([DATADIR], ["$datadir"], [Data directory.])', you
1 should add `-DDATADIR='$(datadir)'' to your makefile's definition of
1 `CPPFLAGS' (`AM_CPPFLAGS' if you are also using Automake).
1
1 Similarly, you should not rely on `AC_CONFIG_FILES' to replace
1 `bindir' and friends in your shell scripts and other files; instead,
1 let `make' manage their replacement. For instance Autoconf ships
1 templates of its shell scripts ending with `.in', and uses a makefile
1 snippet similar to the following to build scripts like `autoheader' and
1 `autom4te':
1
1 edit = sed \
1 -e 's|@bindir[@]|$(bindir)|g' \
1 -e 's|@pkgdatadir[@]|$(pkgdatadir)|g' \
1 -e 's|@prefix[@]|$(prefix)|g'
1
1 autoheader autom4te: Makefile
1 rm -f $@ $@.tmp
1 srcdir=''; \
1 test -f ./$@.in || srcdir=$(srcdir)/; \
1 $(edit) $${srcdir}$@.in >$@.tmp
1 chmod +x $@.tmp
1 chmod a-w $@.tmp
1 mv $@.tmp $@
1
1 autoheader: $(srcdir)/autoheader.in
1 autom4te: $(srcdir)/autom4te.in
1
1 Some details are noteworthy:
1
1 `@bindir[@]'
1 The brackets prevent `configure' from replacing `@bindir@' in the
1 Sed expression itself. Brackets are preferable to a backslash
1 here, since Posix says `\@' is not portable.
1
1 `$(bindir)'
1 Don't use `@bindir@'! Use the matching makefile variable instead.
1
1 `$(pkgdatadir)'
1 The example takes advantage of the variable `$(pkgdatadir)'
1 provided by Automake; it is equivalent to `$(datadir)/$(PACKAGE)'.
1
1 `/'
1 Don't use `/' in the Sed expressions that replace file names since
1 most likely the variables you use, such as `$(bindir)', contain
1 `/'. Use a shell metacharacter instead, such as `|'.
1
1 special characters
1 File names, file name components, and the value of `VPATH' should
11 not contain shell metacharacters or white space. ⇒Special
Chars in Variables.
1
1 dependency on `Makefile'
1 Since `edit' uses values that depend on the configuration specific
1 values (`prefix', etc.) and not only on `VERSION' and so forth,
1 the output depends on `Makefile', not `configure.ac'.
1
1 `$@'
1 The main rule is generic, and uses `$@' extensively to avoid the
1 need for multiple copies of the rule.
1
1 Separated dependencies and single suffix rules
1 You can't use them! The above snippet cannot be (portably)
1 rewritten as:
1
1 autoconf autoheader: Makefile
1 .in:
1 rm -f $@ $@.tmp
1 $(edit) $< >$@.tmp
1 chmod +x $@.tmp
1 mv $@.tmp $@
1
1 ⇒Single Suffix Rules, for details.
1
1 `$(srcdir)'
1 Be sure to specify the name of the source directory, otherwise the
1 package won't support separated builds.
1
1 For the more specific installation of Erlang libraries, the
1 following variables are defined:
1
1 -- Variable: ERLANG_INSTALL_LIB_DIR
1 The common parent directory of Erlang library installation
1 directories. This variable is set by calling the
1 `AC_ERLANG_SUBST_INSTALL_LIB_DIR' macro in `configure.ac'.
1
1 -- Variable: ERLANG_INSTALL_LIB_DIR_LIBRARY
1 The installation directory for Erlang library LIBRARY. This
1 variable is set by using the `AC_ERLANG_SUBST_INSTALL_LIB_SUBDIR'
1 macro in `configure.ac'.
1
1 ⇒Erlang Libraries, for details.
1