@c This file is included by autoconf.texi and is used to produce
@c the INSTALL file.

@ifclear autoconf
@unnumbered Installation Instructions
@end ifclear

@node Basic Installation
@section Basic Installation

The following shell commands:

@example
test -f configure || ./bootstrap
./configure
make
make install
@end example

@noindent
should configure, build, and install this package.
The first line, which bootstraps, is intended for developers;
when building from distribution tarballs it does nothing and can be skipped.
A package might name the bootstrapping script differently;
if the name is @file{autogen.sh}, for example, the first line should say
@command{./autogen.sh} instead of @command{./bootstrap}.

The following
more-detailed instructions are generic; see the @file{README} file for
instructions specific to this package.
@ifclear autoconf
Some packages provide this @file{INSTALL} file but do not implement all
of the features documented below.  The lack of an optional feature in a
given package is not necessarily a bug.
@end ifclear
More recommendations for GNU packages can be found in
@ifset autoconf
@ref{Makefile Conventions, , Makefile Conventions, standards,
GNU Coding Standards}.
@end ifset
@ifclear autoconf
the GNU Coding Standards.
@end ifclear

Many packages have scripts meant for developers instead of ordinary
builders, as they may use developer tools that are less commonly installed,
or they may access the network, which has privacy implications.
These scripts attempt to bootstrap by building the
@command{configure} script and related files, possibly
using developer tools or the network.  Because the output of
bootstrapping is system-independent, it is normally run by a
package developer so that its output can be put into the distribution
tarball and ordinary builders and users need not bootstrap.
Some packages have commands like @command{./autopull.sh} and
@command{./autogen.sh} that you can run instead of @command{./bootstrap},
for more fine-grained control over bootstrapping.

The @command{configure} script attempts to guess correct values
for various system-dependent variables used during compilation.  It uses
those values to create a @file{Makefile} in each directory of the
package.  It may also create one or more @file{.h} files containing
system-dependent definitions.  Finally, it creates a script
@file{config.status} that you can run in the future to recreate the
current configuration, and a file @file{config.log} containing
output useful for debugging @command{configure}.

It can also use an optional file (typically called @file{config.cache}
and enabled with @option{--cache-file=config.cache} or simply
@option{-C}) that saves the results of its tests to speed up
reconfiguring.  Caching is disabled by default to prevent problems with
accidental use of stale cache files.

If you need to do unusual things to compile the package, please try to
figure out how @command{configure} could check whether to do them, and
mail diffs or instructions to the address given in the @file{README} so
they can be considered for the next release.  If you are using the
cache, and at some point @file{config.cache} contains results you don't
want to keep, you may remove or edit it.

The @command{autoconf} program generates @file{configure} from the file
@file{configure.ac}.  Normally you should edit @file{configure.ac}
instead of editing @file{configure} directly.

The simplest way to compile this package is:

@enumerate
@item
@command{cd} to the directory containing the package's source code.

@item
If this is a developer checkout and file @file{configure} does not yet exist,
run the bootstrapping script (typically @command{./bootstrap} or
@command{./autogen.sh}) to bootstrap and create the file.
You may need special developer tools and network access to bootstrap,
and the network access may have privacy implications.

@item
Type @samp{./configure} to configure the package for your system.
This might take a while.  While running, @command{configure} prints
messages telling which features it is checking for.

@item
Type @samp{make} to compile the package.

@item
Optionally, type @samp{make check} to run any self-tests that come with
the package, generally using the just-built uninstalled binaries.

@item
Type @samp{make install} to install the programs and any data files and
documentation.  When installing into a prefix owned by root, it is
recommended that the package be configured and built as a regular user,
and only the @samp{make install} phase executed with root privileges.

@item
Optionally, type @samp{make installcheck} to repeat any self-tests, but
this time using the binaries in their final installed location.  This
target does not install anything.  Running this target as a regular
user, particularly if the prior @samp{make install} required root
privileges, verifies that the installation completed correctly.

@item
You can remove the program binaries and object files from the source
code directory by typing @samp{make clean}.  To also remove the files
that @command{configure} created (so you can compile the package for a
different kind of computer), type @samp{make distclean}.  There is also
a @samp{make maintainer-clean} target, but that is intended mainly for
the package's developers.  If you use it, you may have to bootstrap again.

@item
If the package follows the GNU Coding Standards,
you can type @samp{make uninstall} to remove the installed files.
@end enumerate

@node Compilers and Options
@section Compilers and Options

Some systems require unusual options for compilation or linking that the
@command{configure} script does not know about.  Run @samp{./configure
--help} for details on some of the pertinent environment variables.

You can give @command{configure} initial values for configuration
parameters by setting variables in the command line or in the environment.
Here is an example:

@example
./configure CC=gcc CFLAGS=-g LIBS=-lposix
@end example

@ifplaintext
See ``Defining Variables''
@end ifplaintext
@ifnotplaintext
@ref{Defining Variables}
@end ifnotplaintext
@ifset autoconf
and @ref{Preset Output Variables}
@end ifset
for more details.

@node Multiple Architectures
@section Compiling For Multiple Architectures

You can compile the package for more than one kind of computer at the
same time, by placing the object files for each system in their
own directory.  To do this, you can use GNU @command{make}.
@command{cd} to the directory where you want the object files and
executables to go and run the @command{configure} script.
@command{configure} automatically checks for the source code in the
directory that @command{configure} is in and in @file{..}.  This is
known as a @dfn{VPATH} build.

With a non-GNU @command{make},
it is safer to compile the package for one
system at a time in the source code directory.  After you have
installed the package for one system, use @samp{make distclean}
before reconfiguring for another system.

Some platforms, notably macOS, support ``fat'' or ``universal'' binaries,
where a single binary can execute on different architectures.
On these platforms you can configure and compile just once,
with options specific to that platform.

@node Installation Names
@section Installation Names

By default, @samp{make install} installs the package's commands under
@file{/usr/local/bin}, include files under @file{/usr/local/include}, etc.
You can specify an
installation prefix other than @file{/usr/local} by giving
@command{configure} the option @option{--prefix=@var{prefix}}, where
@var{prefix} must be an absolute file name.

You can specify separate installation prefixes for architecture-specific
files and architecture-independent files.  If you pass the option
@option{--exec-prefix=@var{prefix}} to @command{configure}, the
package uses @var{prefix} as the prefix for installing programs and
libraries.  Documentation and other data files still use the
regular prefix.

In addition, if you use an unusual directory layout you can give options
like @option{--bindir=@var{dir}} to specify different values for
particular kinds of files.  Run @samp{configure --help} for a list of
the directories you can set and what kinds of files go in them.  In
general, the default for these options is expressed in terms of
@samp{$@{prefix@}}, so that specifying just @option{--prefix} will
affect all of the other directory specifications that were not
explicitly provided.

The most portable way to affect installation locations is to pass the
correct locations to @command{configure}; however, many packages provide
one or both of the following shortcuts of passing variable assignments
to the @samp{make install} command line to change installation locations
without having to reconfigure or recompile.

The first method involves providing an override variable for each
affected directory.  For example, @samp{make install
prefix=/alternate/directory} will choose an alternate location for all
directory configuration variables that were expressed in terms of
@samp{$@{prefix@}}.  Any directories that were specified during
@command{configure}, but not in terms of @samp{$@{prefix@}}, must each be
overridden at install time for the entire
installation to be relocated.  The approach of makefile variable
overrides for each directory variable is required by the GNU
Coding Standards, and ideally causes no recompilation.  However, some
platforms have known limitations with the semantics of shared libraries
that end up requiring recompilation when using this method, particularly
noticeable in packages that use GNU Libtool.

The second method involves providing the @samp{DESTDIR} variable.  For
example, @samp{make install DESTDIR=/alternate/directory} will prepend
@samp{/alternate/directory} before all installation names.  The approach
of @samp{DESTDIR} overrides is not required by the GNU Coding
Standards, and does not work on platforms that have drive letters.  On
the other hand, it does better at avoiding recompilation issues, and
works well even when some directory options were not specified in terms
of @samp{$@{prefix@}} at @command{configure} time.

@node Optional Features
@section Optional Features

If the package supports it, you can cause programs to be installed with
an extra prefix or suffix on their names by giving @command{configure}
the option @option{--program-prefix=@var{PREFIX}} or
@option{--program-suffix=@var{SUFFIX}}.

Some packages pay attention to @option{--enable-@var{feature}}
and @option{--disable-@var{feature}} options
to @command{configure}, where @var{feature} indicates an optional part
of the package.  They may also pay attention to
@option{--with-@var{package}} and @option{--without-@var{package}} options,
where @var{package} is something like @samp{gnu-ld}.
@samp{./configure --help} should mention the
@option{--enable-...} and @option{--with-...}
options that the package recognizes.

Some packages offer the ability to configure how verbose the execution
of @command{make} will be.  For these packages, running
@samp{./configure --enable-silent-rules} sets the default to minimal
output, which can be overridden with @code{make V=1}; while running
@samp{./configure --disable-silent-rules} sets the default to verbose,
which can be overridden with @code{make V=0}.

@node System Types
@section Specifying a System Type

By default @command{configure} builds for the current system.
To create binaries that can run on a different system type,
specify a @option{--host=@var{type}} option along with compiler
variables that specify how to generate object code for @var{type}.
For example, to create binaries intended to run on a 64-bit ARM
processor:

@example
./configure --host=aarch64-linux-gnu \
   CC=aarch64-linux-gnu-gcc \
   CXX=aarch64-linux-gnu-g++
@end example

@noindent
If done on a machine that can execute these binaries
(e.g., via @command{qemu-aarch64}, @env{$QEMU_LD_PREFIX}, and Linux's
@code{binfmt_misc} capability), the build behaves like a native build.
Otherwise it is a cross-build: @code{configure}
will make cross-compilation guesses instead of running test programs,
and @code{make check} will not work.

A system type can either be a short name like @samp{mingw64},
or a canonical name like @samp{x86_64-pc-linux-gnu}.
Canonical names have the form @var{cpu}-@var{company}-@var{system}
where @var{system} is either @var{os} or @var{kernel}-@var{os}.
To canonicalize and validate a system type,
you can run the command @file{config.sub},
which is often squirreled away in a subdirectory like @file{build-aux}.
For example:

@example
$ build-aux/config.sub arm64-linux
aarch64-unknown-linux-gnu
$ build-aux/config.sub riscv-lnx
Invalid configuration 'riscv-lnx': OS 'lnx' not recognized
@end example

@noindent
You can look at the @file{config.sub} file to see which types are recognized.
If the file is absent, this package does not need the system type.

If @command{configure} fails with the diagnostic ``cannot guess build type''.
@file{config.sub} did not recognize your system's type.
In this case, first fetch the newest versions of these files
from the @url{https://savannah.gnu.org/projects/config, GNU config package}.
If that fixes things, please report it to the
maintainers of the package containing @command{configure}.
Otherwise, you can try the configure option
@option{--build=@var{type}} where @var{type} comes close to your
system type; also, please report the problem to
@email{config-patches@@gnu.org}.

For more details about configuring system types, see
@ifset autoconf
@ref{Manual Configuration}.
@end ifset
@ifclear autoconf
the Autoconf documentation.
@end ifclear

@node Sharing Defaults
@section Sharing Defaults

If you want to set default values for @command{configure} scripts to
share, you can create a site shell script called @file{config.site} that
gives default values for variables like @code{CC}, @code{cache_file},
and @code{prefix}.  @command{configure} looks for
@file{@var{prefix}/share/config.site} if it exists, then
@file{@var{prefix}/etc/config.site} if it exists.  Or, you can set the
@code{CONFIG_SITE} environment variable to the location of the site
script.  A warning: not all @command{configure} scripts look for a site
script.

@node Defining Variables
@section Defining Variables

Variables not defined in a site shell script can be set in the
environment passed to @command{configure}.  However, some packages may
run configure again during the build, and the customized values of these
variables may be lost.  In order to avoid this problem, you should set
them in the @command{configure} command line, using @samp{VAR=value}.
For example:

@example
./configure CC=/usr/local2/bin/gcc
@end example

@noindent
causes the specified @command{gcc} to be used as the C compiler (unless it is
overridden in the site shell script).

@noindent
Unfortunately, this technique does not work for @env{CONFIG_SHELL} due
to an Autoconf limitation.  Until the limitation is lifted, you can use
this workaround:

@example
CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash
@end example

@node configure Invocation
@section @command{configure} Invocation

@command{configure} recognizes the following options to control how it
operates.

@table @option
@item --help
@itemx -h
Print a summary of all of the options to @command{configure}, and exit.

@item --help=short
@itemx --help=recursive
Print a summary of the options unique to this package's
@command{configure}, and exit.  The @code{short} variant lists options
used only in the top level, while the @code{recursive} variant lists
options also present in any nested packages.

@item --version
@itemx -V
Print the version of Autoconf used to generate the @command{configure}
script, and exit.

@item --cache-file=@var{file}
@cindex Cache, enabling
Enable the cache: use and save the results of the tests in @var{file},
traditionally @file{config.cache}.  @var{file} defaults to
@file{/dev/null} to disable caching.

@item --config-cache
@itemx -C
Alias for @option{--cache-file=config.cache}.

@item --srcdir=@var{dir}
Look for the package's source code in directory @var{dir}.  Usually
@command{configure} can determine that directory automatically.

@item --prefix=@var{dir}
Use @var{dir} as the installation prefix.
@ifplaintext
See ``Installation Names''
@end ifplaintext
@ifnotplaintext
@ref{Installation Names}
@end ifnotplaintext
for more details, including other options available for fine-tuning
the installation locations.

@item --host=@var{type}
Build binaries for system @var{type}.
@ifplaintext
See ``Specifying a System Type''.
@end ifplaintext
@ifnotplaintext
@xref{System Types}.
@end ifnotplaintext

@item --enable-@var{feature}
@itemx --disable-@var{feature}
Enable or disable the optional @var{feature}.
@ifplaintext
See ``Optional Features''.
@end ifplaintext
@ifnotplaintext
@xref{Optional Features}.
@end ifnotplaintext

@item --with-@var{package}
@itemx --without-@var{package}
Use or omit @var{package} when building.
@ifplaintext
See ``Optional Features''.
@end ifplaintext
@ifnotplaintext
@xref{Optional Features}.
@end ifnotplaintext

@item --quiet
@itemx --silent
@itemx -q
Do not print messages saying which checks are being made.  To suppress
all normal output, redirect it to @file{/dev/null} (any error messages
will still be shown).

@item --no-create
@itemx -n
Run the configure checks, but stop before creating any output files.
@end table

@noindent
@command{configure} also recognizes several environment variables,
and accepts some other, less widely useful, options.
Run @samp{configure --help} for more details.

@ifclear autoconf
@node Copyright notice
@section Copyright notice

Copyright @copyright{} 1994--1996, 1999--2002, 2004--2017, 2020--2024
Free Software Foundation, Inc.

Copying and distribution of this file, with or without modification, are
permitted in any medium without royalty provided the copyright notice
and this notice are preserved.  This file is offered as-is, without
warranty of any kind.
@end ifclear

@c Local Variables:
@c fill-column: 72
@c ispell-local-dictionary: "american"
@c indent-tabs-mode: nil
@c whitespace-check-buffer-indent: nil
@c End:
