autoconf: Site Defaults
1
1 15.8 Setting Site Defaults
1 ==========================
1
1 Autoconf-generated `configure' scripts allow your site to provide
1 default values for some configuration values. You do this by creating
1 site- and system-wide initialization files.
1
1 If the environment variable `CONFIG_SITE' is set, `configure' uses
1 its value as the name of a shell script to read; it is recommended that
1 this be an absolute file name. Otherwise, it reads the shell script
1 `PREFIX/share/config.site' if it exists, then `PREFIX/etc/config.site'
1 if it exists. Thus, settings in machine-specific files override those
1 in machine-independent ones in case of conflict.
1
1 Site files can be arbitrary shell scripts, but only certain kinds of
1 code are really appropriate to be in them. Because `configure' reads
1 any cache file after it has read any site files, a site file can define
1 a default cache file to be shared between all Autoconf-generated
1 `configure' scripts run on that system (⇒Cache Files). If you
1 set a default cache file in a site file, it is a good idea to also set
1 the output variable `CC' in that site file, because the cache file is
1 only valid for a particular compiler, but many systems have several
1 available.
1
1 You can examine or override the value set by a command line option to
1 `configure' in a site file; options set shell variables that have the
1 same names as the options, with any dashes turned into underscores.
1 The exceptions are that `--without-' and `--disable-' options are like
1 giving the corresponding `--with-' or `--enable-' option and the value
1 `no'. Thus, `--cache-file=localcache' sets the variable `cache_file'
1 to the value `localcache'; `--enable-warnings=no' or
1 `--disable-warnings' sets the variable `enable_warnings' to the value
1 `no'; `--prefix=/usr' sets the variable `prefix' to the value `/usr';
1 etc.
1
1 Site files are also good places to set default values for other
1 output variables, such as `CFLAGS', if you need to give them non-default
1 values: anything you would normally do, repetitively, on the command
1 line. If you use non-default values for PREFIX or EXEC_PREFIX
1 (wherever you locate the site file), you can set them in the site file
1 if you specify it with the `CONFIG_SITE' environment variable.
1
1 You can set some cache values in the site file itself. Doing this is
1 useful if you are cross-compiling, where it is impossible to check
1 features that require running a test program. You could "prime the
1 cache" by setting those values correctly for that system in
1 `PREFIX/etc/config.site'. To find out the names of the cache variables
1 you need to set, see the documentation of the respective Autoconf
1 macro. If the variables or their semantics are undocumented, you may
1 need to look for shell variables with `_cv_' in their names in the
1 affected `configure' scripts, or in the Autoconf M4 source code for
1 those macros; but in that case, their name or semantics may change in a
1 future Autoconf version.
1
1 The cache file is careful to not override any variables set in the
1 site files. Similarly, you should not override command-line options in
1 the site files. Your code should check that variables such as `prefix'
1 and `cache_file' have their default values (as set near the top of
1 `configure') before changing them.
1
1 Here is a sample file `/usr/share/local/gnu/share/config.site'. The
1 command `configure --prefix=/usr/share/local/gnu' would read this file
1 (if `CONFIG_SITE' is not set to a different file).
1
1 # /usr/share/local/gnu/share/config.site for configure
1 #
1 # Change some defaults.
1 test "$prefix" = NONE && prefix=/usr/share/local/gnu
1 test "$exec_prefix" = NONE && exec_prefix=/usr/local/gnu
1 test "$sharedstatedir" = '${prefix}/com' && sharedstatedir=/var
1 test "$localstatedir" = '${prefix}/var' && localstatedir=/var
1
1 # Give Autoconf 2.x generated configure scripts a shared default
1 # cache file for feature test results, architecture-specific.
1 if test "$cache_file" = /dev/null; then
1 cache_file="$prefix/var/config.cache"
1 # A cache file is only valid for one C compiler.
1 CC=gcc
1 fi
1
1 Another use of `config.site' is for priming the directory variables
1 in a manner consistent with the Filesystem Hierarchy Standard (FHS).
1 Once the following file is installed at `/usr/share/config.site', a
1 user can execute simply `./configure --prefix=/usr' to get all the
1 directories chosen in the locations recommended by FHS.
1
1 # /usr/share/config.site for FHS defaults when installing below /usr,
1 # and the respective settings were not changed on the command line.
1 if test "$prefix" = /usr; then
1 test "$sysconfdir" = '${prefix}/etc' && sysconfdir=/etc
1 test "$sharedstatedir" = '${prefix}/com' && sharedstatedir=/var
1 test "$localstatedir" = '${prefix}/var' && localstatedir=/var
1 fi
1
1 Likewise, on platforms where 64-bit libraries are built by default,
1 then installed in `/usr/local/lib64' instead of `/usr/local/lib', it is
1 appropriate to install `/usr/local/share/config.site':
1
1 # /usr/local/share/config.site for platforms that prefer
1 # the directory /usr/local/lib64 over /usr/local/lib.
1 test "$libdir" = '${exec_prefix}/lib' && libdir='${exec_prefix}/lib64'
1