\input texinfo    @c -*-texinfo-*-
@setfilename configure.info
@settitle Cygnus configure

@synindex ky cp

@ignore
@tex
\def\$#1${{#1}}  % Kluge: collect RCS revision info without $...$
\xdef\manvers{\$Revision: 1.3 $}  % For use in headers, footers too
@end tex
@end ignore

@setchapternewpage odd

@ifinfo
@format
START-INFO-DIR-ENTRY
* configure: (configure).        Cygnus configure.
END-INFO-DIR-ENTRY
@end format
@end ifinfo

@ifinfo
This document attempts to describe the Cygnus Support version of
@code{configure}.

Copyright (C) 1991, 1992, 1993 Cygnus Support
Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
are preserved on all copies.

@ignore
Permission is granted to process this file through TeX and print the
results, provided the printed document carries copying permission
notice identical to this one except for the removal of this paragraph
(this paragraph not being relevant to the printed manual).
@end ignore

Permission is granted to copy and distribute modified versions of this
manual under the conditions for verbatim copying, provided that the entire
resulting derived work is distributed under the terms of a permission
notice identical to this one.

Permission is granted to copy and distribute translations of this manual
into another language, under the above conditions for modified versions,
except that this permission notice may be stated in a translation approved
by Cygnus Support.
@end ifinfo

@smallbook
@c @cropmarks
@finalout
@titlepage
@title Cygnus configure
@c @subtitle @manvers
@author K. Richard Pixley
@author Cygnus Support
@page

@vskip 0pt plus 1filll
Edited by Jeffrey Osier, Cygnus Support.

Copyright @copyright{} 1991, 1992, 1993 Cygnus Support

Permission is granted to make and distribute verbatim copies of
this manual provided the copyright notice and this permission notice
are preserved on all copies.

Permission is granted to copy and distribute modified versions of this
manual under the conditions for verbatim copying, provided that the entire
resulting derived work is distributed under the terms of a permission
notice identical to this one.

Permission is granted to copy and distribute translations of this manual
into another language, under the above conditions for modified versions,
except that this permission notice may be stated in a translation approved
by Cygnus Support.
@end titlepage

@ifinfo
@node Top, What configure Does, (dir), (dir)
@top Overview

This file documents the configuration system used and distributed by
Cygnus Support.

@menu
* What configure Does::    What @code{configure} Does
* Invoking configure::     Invoking @code{configure}
* Using configure::        Using @code{configure}
* Porting::                Porting with @code{configure}
* Reference::              Gory details described
* Known Bugs::             Known Bugs
* Variables Index::        Variable Index
* Concept Index::          Concept Index

 --- The Detailed Node Listing ---

Using configure

* Install Locations::      Where to install things once they are built
* Build Directories::      Where to build object files
* Host::                   Telling @code{configure} what will source will be built
* Target::                 Telling @code{configure} what the source will target
* Local Conventions::      Adding information about local conventions

Install Locations

* prefix::                 Changing the default install directory
* exec_prefix::            How to separate host independent files from 
                                                     host dependent files when
                                                 installing for multiple hosts
* Install Details::        Full descriptions of all installation subdirectories
                                   
Porting with configure

* Programs::               Adding @code{configure} to new programs
* Hosts and Targets::      Adding hosts and targets
* Sites::                  Adding site info

Gory details described

* Makefile Extensions::    Extensions to the GNU coding standards
* configure.in::           The format of the @file{configure.in} file
* config.status::          @code{config.status}
* Makefile Fragments::     @file{Makefile} Fragments

The format of the @file{configure.in} file

* Minimal::                A minimal @file{configure.in}
* configure Variables::    Variables available to @file{configure.in}
* Declarations::           For each invocation
* Per-host::               For each host
* Per-target::             For each target
* Post-target::            After each target
* Example::                An example @file{configure.in}
@end menu
@end ifinfo

@node What Configure Does, Invoking configure, Top, Top
@chapter What Configure Does

This manual documents Cygnus @code{configure}, a program which helps to
automate much of the mundane setup associated with building large suites of
programs such the Cygnus Support Developer's Kit.  This manual is therefore
geared toward readers who are likely to face the problem of configuring
software in source form before compiling and installing it.  We assume you are
an experienced programmer or system administrator.
@ifinfo
For further background on this topic, see @ref{, , , cfg-paper, On Configuring
Development Tools}, by K. Richard Pixley.
@end ifinfo
@iftex
For further background on this topic, see @cite{On Configuring Development
Tools} by K. Richard Pixley.
@end iftex

@code{configure} prepares source directories for the process of building
working programs.  A program cannot be built until its source has been
configured; this is the first step in the building process.  

When @code{configure} runs, it does the following things:

@table @emph
@item Create build directories
(see @ref{Build Directories}).  When you run @code{configure} with the
@samp{-srcdir=} option, it uses the current directory as the @dfn{build
directory}, creating under it a directory tree that parallels the
directory structure under the source directory.  (@xref{Invoking configure}.)

@item Generate @file{Makefile}s
A @file{Makefile} template from the source directory, usually called
@file{Makefile.in}, is copied to an output file in the build directory.  The
output file is usually named @file{Makefile}.  @code{configure} places
definitions for a number of standard @file{Makefile} macros at the beginning of
the output file.  If @w{@code{-prefix=}} or @w{@code{-exec_prefix}} were
specified on the @code{configure} command line, corresponding @file{Makefile}
variables are set accordingly.  If host, target, or site specific
@file{Makefile} fragments exist, these are inserted into the output file.
(@xref{Makefiles, , Writing Makefiles, make, GNU Make}.)

@item Generate @file{.gdbinit}
If the source directory contains a @file{.gdbinit} file and the build directory
is not the same as the source directory, a @file{.gdbinit} file is created in
the build directory.  This @file{.gdbinit} file will allow @code{gdb} to find
source files in either the source directory or the build directory.
(@xref{Command Files, , Command Files, gdb, Debugging With GDB}.)

@item Make symbolic links
Most directories have some symbolic links with generic names built
pointing to specific files in the source directory.  If the system where
@code{configure} runs cannot support symbolic links, hard links are used
instead.

@item Special Activities
If the source directory has special needs, they are handled by shell script
fragments stored with the @code{configure} source.  Usually there are no
special needs, but sometimes they involve changes to the output
@file{Makefile}.

@item Generate @file{config.status}
@code{configure} creates a shell script named @file{config.status} in
the build directory.  This shell script, when run from the build
directory, will reconfigure the build directory (but not its
subdirectories).  This is most often used to have a @file{Makefile} update
itself automatically if a new source directory is available.

@item Recursion
If the source directory has subdirectories that should also be configured,
@code{configure} is called for each.
@end table

@node Invoking configure, Using configure, What configure Does, Top
@chapter Invoking @code{configure}

The usual way to invoke @code{configure} is from the shell, as follows:
@example
eg$ configure @var{host}
@end example
@noindent
This prepares the source to be compiled in a @var{host} environment with
programs and files to be installed in @file{/usr/local}.

@code{configure} prepares the source as you specify by selecting and
using script and @file{Makefile} fragments prepared in advance, and stored with
the source.  @code{configure}'s command line options also allow you to
specify other aspects of the source configuration:

@smallexample
  configure @var{host}  [-prefix=@var{dir}] [-exec_prefix=@var{dir}]
            [-target=@var{target}] [-site=@var{site}] [-srcdir=@var{dir}] 
            [-gas] [-nfp] [-norecursion] [-s] [-rm] [-x] 
            [-program_prefix] [-tmpdir=@var{dir}] [-v] [-V] [-help]
@end smallexample

@emph{Note:}  @code{configure} supports the use of both a single dash @samp{-}
or two dashes @samp{--} to indicate options on the command line.

@table @code
@item -prefix=@var{dir}
Configure the source to install programs and files under directory
@file{@var{dir}}.

This option sets the @code{configure} variable @code{prefix}.  Generated
@file{Makefile}s will have their @code{prefix} variables set to this value.
(@xref{Install Details}.)

@item -exec_prefix=@var{dir}
Configure the source to install host dependent files in @var{dir}.

This option sets the @code{configure} variable @code{exec_prefix}.
Generated @file{Makefile}s will have their @code{exec_prefix} variables set to
this value. (See @ref{Install Details}.)

@item -target=@var{target}
Requests that the sources be configured to target the @var{target}
machine.  If no target is specified explicitly, the target is assumed
to be the same as the host.  

@item -site=@var{site}
Generate @file{Makefile}s using site specific @file{Makefile} fragments for
@var{site}.  See also @ref{Sites}.

@item -srcdir=@var{dir}
Build @file{Makefile}s to use the sources located in directory
@file{@var{dir}}.  The build directory is assumed to be @file{.}.

@item -gas
Configure to use the @sc{GNU} assembler.

@item -nfp
@emph{No floating point} unit available on the target; configure to
avoid dependencies on hardware floating point.

@item -norecursion
Configure only this directory; ignore any subdirectories.  This is used
by the executable shell script @file{config.status} to reconfigure the
current directory.  (@xref{config.status}.)

@item -s
This option is used internally by @code{configure} when recurring on
subdirectories.  Its sole purpose is to suppress status output.  You can
override this effect with the @code{-verbose} option.

@item -rm
@emph{Remove} the configuration specified by @var{host} and the other
command-line options, rather than creating it.

@item -x
Use @sc{MIT} style @sc{X11} header files and libraries on the host, even
if they are not normally available.

@item -program_prefix=@var{string}
Configure the source to install certain programs using @var{string} as a
prefix.  This applies to programs which might be used for cross-compilation,
such as the compiler and the binary utilities, and also to programs which have
the same names as common Unix programs, such as @code{make}.

This option sets the @code{configure} variable @code{program_prefix}.
Generated @file{Makefile}s will have their @samp{program_prefix} variables set
to this value.  (@xref{Install Details}.)

@item -tmpdir=@var{tmpdir}
Use the directory @var{tmpdir} for @code{configure}'s temporary files.  The
default is the value of the environment variable @w{@code{TMPDIR}}, or
@file{/tmp} if the environment variable is not set.

@item -verbose
@itemx -v
Print status lines for each directory configured.  Normally, only the
status lines for the initial working directory are printed.

@item -version
@itemx -V
Print @code{configure} version number.

@item -help
Display a quick summary of how to invoke @code{configure}.

@end table

@node Using configure, Porting, Invoking configure, Top
@chapter Using @code{configure}

The choices and options available at configuration time generally have valid
defaults, but the defaults do not cover all cases.  The choices available
include install locations, build directories, host, target, and local
conventions.

@menu
* Install Locations::      Where to install things once they are built
* Build Directories::      Where to build object files
* Host::                   Telling configure what will source will be built
* Target::                 Telling configure what the source will target
* Local Conventions::      Adding information about local conventions
@end menu

@node Install Locations, Build Directories, Using configure, Using configure
@section Install Locations
@cindex Where to install

Using the default configuration, @samp{make install} creates a single tree of
files, some of which are programs.  The location of this tree is determined by
the value of the variable @samp{prefix}.  The default value of @samp{prefix} is
@samp{/usr/local}.  This is often correct for native tools installed on only
one host.

@menu
* prefix::            Changing the default install directory
* exec_prefix::       How to separate host independent files
                                         from host dependent files when
                                         installing for multiple hosts
* Install Details::   Full descriptions of all installation subdirectories
@end menu

@node prefix, exec_prefix, Install Locations, Install Locations
@subsection Changing the default install directory
@cindex Changing the default install directory
@cindex Prefix directory

In the default configuration, all files are installed in subdirectories
of @file{/usr/local}.  The location is determined by the value of
the @code{configure} variable @samp{prefix}; in turn, this determines the
value of the @file{Makefile} variable of the same name (@samp{prefix}).

You can also set the value of the @file{Makefile} variable @samp{prefix}
explicitly each time you invoke @code{make} if you are so inclined; but
because many programs have this location compiled in, you must specify
the @samp{prefix} value consistently on each invocation of @code{make},
or you will end up with a broken installation.

To make this easier, the value of the @code{configure} variable
@samp{prefix} can be set on the command line to @code{configure}
using the option @samp{-prefix=}.  


@node exec_prefix, Install Details, prefix, Install Locations
@subsection Installing for multiple hosts
@cindex Configuring for multiple hosts
@cindex Sharing host independent files
@cindex The @file{exec_prefix} directory
@cindex Installing host independent files

By default, host dependent files are installed in subdirectories of
@file{$(exec_prefix)}.  The location is determined by the value of the
@code{configure} variable @samp{exec_prefix}, which determines the value of the
@file{Makefile} variable @samp{exec_prefix}.  This makes it simpler to install
for a single host, and simplifies changing the default location for the install
tree; but the default doesn't allow for multiple hosts to effectively share
host independent files.

To configure so that multiple hosts can share common files, use something like:

@example
configure @var{host1} -prefix=/usr/gnu -exec_prefix=/usr/gnu/H-host1
make all info install install-info clean

configure @var{host2} -prefix=/usr/gnu -exec_prefix=/usr/gnu/H-host2
make all info install install-info
@end example

The first line configures the source for @var{host1} to place host
specific programs in subdirectories of @file{/usr/gnu/H-@var{host1}}.  

The second line builds and installs all programs for @var{host1},
including both host independent and host specific files.

The third line reconfigures the source for @var{host2} to place host
specific programs in subdirectories of @file{/usr/gnu/H-@var{host2}}.

The fourth line builds and installs all programs for @var{host2}.  Host
specific files are installed in new directories, but the host
independent files are installed @emph{on top of} the host
independent files installed for @var{host1}.  This results in a single
copy of the host independent files, suitable for use by both hosts.

@xref{Makefile Extensions}, for more information.

@node Install Details, , exec_prefix, Install Locations
@subsection Full descriptions of all installation subdirectories

During any install, a number of standard directories are created.  Their names
are determined by @file{Makefile} variables.  Some of the defaults for
@file{Makefile} variables can be changed at configure time using command line
options to @code{configure}.  For more information on the standard directories
or the @file{Makefile} variables, please refer to @cite{standards.text}.

Note that @code{configure} does not create the directory @samp{$(srcdir)} at
any time.  @code{$(srcdir)} is not an installation directory.

You can override all @file{Makefile} variables on the command line to
@code{make}.  (@xref{Overriding, , Overriding Variables, make, GNU Make}.)  If
you do so, you will need to specify the value precisely the same way for each
invocation of @code{make}, or you risk ending up with a broken installation.
This is because many programs have the locations of other programs or files
compiled into them.  If you find yourself overriding any of the variables
frequently, you should consider site dependent @file{Makefile} fragments.  See
also @ref{Sites}.

During @samp{make install}, a number of standard directories are created and
populated.  The following @file{Makefile} variables define them.  Those whose
defaults are set by corresponding @code{configure} variables are marked
``@file{Makefile} and @code{configure}''.

@vindex prefix
@defvr {@file{Makefile} and @code{configure}} prefix
The root of the installation tree.  You can set its @file{Makefile} default
with the @samp{-prefix=} command line option to @code{configure}
(@pxref{Invoking configure}).  The default value for @samp{prefix} is
@samp{/usr/local}.
@end defvr

@vindex bindir
@defvr @file{Makefile} bindir
A directory for binary programs that users can run.  The default value for
@samp{bindir} depends on @samp{prefix}; @samp{bindir} is normally changed only
indirectly through @samp{prefix}.  The default value for @samp{bindir} is
@samp{$(prefix)/bin}.
@end defvr

@vindex exec_prefix
@defvr {@file{Makefile} and @code{configure}} exec_prefix
A directory for host dependent files.  You can specify the Makefile default
value by using the @samp{-exec_prefix=} option to @code{configure}.  (See also
@ref{Invoking configure}.)  The default value for @samp{exec_prefix} is
@samp{$(prefix)}.
@end defvr

@vindex libdir
@defvr @file{Makefile} libdir
A directory for libraries and support programs.  The default value for
@samp{libdir} depends on @samp{prefix}; @samp{libdir} is normally
changed only indirectly through @samp{prefix}.  The default value for
@samp{libdir} is @samp{$(prefix)/lib}.
@end defvr

@vindex mandir
@defvr @file{Makefile} mandir
A directory for @code{man} format documentation (``man pages'').  The
default value for @samp{mandir} depends on @samp{prefix};
@samp{mandir} is normally changed only indirectly through @samp{prefix}.
The default value for @samp{mandir} is @samp{$(prefix)/man}.
@end defvr

@vindex man@var{N}dir
@defvr @file{Makefile} man@var{N}dir
These are eight variables named @samp{man1dir}, @samp{man2dir}, etc.  They name
the specific directories for each man page section.  For example,
@samp{man1dir} by default holds the filename @file{$(mandir)/man1}; this
directory contains @file{emacs.1} (the man page for the emacs program).
Similarly, @samp{man5dir} contains the value @file{$(mandir)/man5}, indicating
the directory which holds @file{rcsfile.5} (the man page describing the
@dfn{rcs} data file format).  The default value for any of the
@samp{man@var{N}dir} variables depends indirectly on @samp{prefix}, and is
normally changed only through @samp{prefix}.  The default value for
@samp{man@var{N}dir} is @samp{$(mandir)/man@var{N}}.
@end defvr

@vindex man@var{N}ext
@defvr @file{Makefile} man@var{N}ext
@emph{Not supported by @code{configure}}.  The @sc{gnu} coding standards
do not call for @samp{man1ext}, @samp{man2ext}, so the intended use for
@code{manext} is apparently not parallel to @samp{mandir}.  Its use is
not clear.  (See also @ref{Makefile Extensions}.)
@end defvr

@vindex infodir
@defvr @file{Makefile} infodir
A directory for @code{info} format documentation.  The default value for
@samp{infodir} depends indirectly on @samp{prefix}; @samp{infodir} is
normally changed only through @samp{prefix}.  The default value for
@samp{infodir} is @samp{$(prefix)/info}.
@end defvr

@vindex docdir
@defvr @file{Makefile} docdir
A directory for any documentation that is in a format other than those
used by @code{info} or @code{man}.  The default value for @samp{docdir}
depends indirectly on @samp{prefix}; @samp{docdir} is normally changed only
through @samp{prefix}.  The default value for @samp{docdir}
is @samp{$(datadir)/doc}.  @emph{This variable is an extension to
the @sc{gnu} coding standards}.  (See also @ref{Makefile Extensions}.)
@end defvr

@vindex includedir
@defvr @file{Makefile} includedir
A directory for the header files accompanying the libraries installed in
@samp{libdir}.  The default value for @samp{includedir} depends on
@samp{prefix}; @samp{includedir} is normally changed only indirectly
through @samp{prefix}.  The default value for @samp{includedir} is
@samp{$(prefix)/include}.
@end defvr

@node Build Directories, Host, Install Locations, Using configure
@section Build Directories
@cindex Build directories
@kindex objdir
@cindex Object directories
@kindex subdirs
@cindex Building for multiple hosts
@cindex Building for multiple targets

Normally, @code{configure} builds a @file{Makefile} and symbolic links
in the same directory as the source files.  This is the typical
@sc{un*x} way to build programs, but it has limitations.  For instance,
using this approach, you can only build for one host at a time.

We refer to the directories where @code{configure} builds a
@file{Makefile} as the @dfn{build directories} or sometimes as
@dfn{objdir} because these are the directories in which @code{make}
will build object files, among other things.

The default build directory is the same as the source directory.  You can use a
different build directory with a sequence like the following:

@example
mkdir @var{builddir}
cd @var{builddir}
configure @var{host} -srcdir=@var{sourcedir}
@end example

@noindent
where @var{builddir} is the directory where you wish to build, @var{host} is
the host for which you want to build, and @var{sourcedir} is the directory
containing the source files.

If you were to do this twice with different values for @var{builddir}
and @var{host}, then you could @code{make} for both at the same time.

@node Host, Target, Build Directories, Using configure
@section Host

The arguments to @code{configure} are @dfn{hosts}.  By @dfn{host} we mean the
@dfn{environment} in which the source will be compiled.  This need not
necessarily be the same as the physical machine involved, although it usually
is.

For example, if some obscure machine running an operating system other than
@sc{un*x} had the @sc{gnu} @code{POSIX} emulation libraries available, it would
be possible to configure most @sc{gnu} source for a @code{POSIX} system and
build it on the obscure host.

For more on this topic, see @ref{Host Environments, On Configuring Development
Tools, Host Environments, cfg-paper, On Configuring Development Tools}.

@node Target, Local Conventions, Host, Using configure
@section Target

For building native development tools, or most of the other @sc{gnu}
tools, you need not worry about the target.  The @dfn{target} of a
configuration defaults to the same as the @dfn{host}.

For building cross development tools, please see @ref{Building Development
Environments, On Configuring Development Tools, Building Development
Environments, cfg-paper, On Configuring Development Tools}.

@node Local Conventions, , Target, Using configure
@section Local Conventions

If you find that a tool does not get configured to your liking, or if
@code{configure}'s conventions differ from your local conventions, you should
probably consider @dfn{site-specific @file{Makefile} fragments}.  See also
@ref{Sites}.

These are probably not the right choice for options that can be set from
the @code{configure} command line or for differences that are host or
target dependent.

@node Reference, Known Bugs, Porting, Top
@chapter Gory details described
@cindex Behind the Scenes
@cindex Backends
Here we describe the backend support.

@menu
* Makefile Extensions::    Extensions to the @sc{gnu} coding standards
* configure.in::           The format of the @file{configure.in} file
* config.status::          @file{config.status}
* Makefile Fragments::     @file{Makefile} Fragments
@end menu

@node Makefile Extensions, configure.in, Reference, Reference
@section Extensions to the @sc{gnu} coding standards

@cindex @file{Makefile} extensions
@cindex Cygnus extensions

The following additions to the @sc{gnu} coding standards are required for
Cygnus configure to work properly.

@itemize @bullet
@item
The @file{Makefile} must contain exactly one line starting with @samp{####}.
This line should follow any default macro definitions but precede any rules.
Host, target, and site specific @file{Makefile} fragments will be inserted
immediately after this line.  If the line is missing, the fragments will not be
inserted.
@end itemize

Cygnus adds the following targets to our @file{Makefile}s.  Their existence is
not required for Cygnus configure, but they are documented here for
completeness.

@table @code
@kindex info
@item info
Build all info files from texinfo source.

@kindex install-info
@item install-info
Install all info files.

@kindex clean-info
@item clean-info
Remove all info files and any intermediate files that can be generated
from texinfo source.

@kindex stage1
@item stage1
@kindex stage2
@itemx stage2
@kindex stage3
@itemx stage3
@kindex de-stage1
@itemx de-stage1
@kindex de-stage2
@itemx de-stage2
@kindex de-stage3
@itemx de-stage3
@kindex bootstrap
@itemx bootstrap
@kindex comparison
@itemx comparison
@kindex Makefile
@itemx Makefile
These targets are in transition and may be removed shortly.
@end table

In addition, the following @file{Makefile} targets have revised semantics:

@table @code
@kindex install
@item install
Should @emph{not} depend on the target @code{all}.  If the program is not
already built, @code{make install} should fail.  This allows you to install
programs even when @code{make} would otherwise determine them to be out of
date.  This can happen when the result of a @code{make all} is transported via
tape to another machine for installation as well as in a number of other cases.

@kindex clean
@item clean
Should remove any file that can be regenerated by the @file{Makefile},
excepting only the @file{Makefile} itself, and any links created by
@code{configure}.  That is, @code{make all clean} should return all directories
to their original condition.  If this is not done, then:

@example
configure @var{host1} ; make all clean ; configure @var{host2} ; make all
@end example

@noindent
will fail because of intermediate files intended for @var{host1}.
@end table

Cygnus adds the following macros to all @file{Makefile.in} files, but
you are not required to use them to run Cygnus @code{configure}.

@table @code
@kindex docdir
@item docdir
The directory in which to install any documentation that is not either a
@code{man} page or an @code{info} file.  For @code{man} pages, see
@samp{mandir}; for @code{info}, see @samp{infodir}.

@kindex includedir
@item includedir
The directory in which to install any header files that should be made
available to users.  This is distinct from the @code{gcc} @file{include}
directory which is intended for @code{gcc} only.  Files in @samp{includedir}
may be used by @code{cc} as well.
@end table

In addition, the following macros have revised semantics.  Most of them
describe installation directories; see also @ref{Install Details,,Full
description of all installation subdirectories}.

@table @code
@kindex manext
@item manext
is not used.  The intended usage is not clear.  For example, if you have a
@file{foo.man} and a @file{bar.man}, and @file{foo.man} is destined for
@file{/usr/local/lib/man/man1/foo.1} while @file{bar.man} is destined
for @file{/usr/local/lib/man/man5/bar.5}, then what is the desired value
of @samp{manext}?

@kindex datadir
@item datadir
is used for host independent data files.

@kindex mandir
@item mandir
The default path for @samp{mandir} depends on @samp{prefix}.

@kindex infodir
@item infodir
The default path for @samp{infodir} depends on @samp{prefix}.

@kindex BISON
@item BISON
is assumed to have a @code{yacc} calling convention.  To use @code{bison}, use
@samp{BISON=bison -y}.
@end table

Cygnus @file{Makefile}s also conform to one additional restriction:

@itemize @bullet
@item
When libraries are installed, the line containing the call to
@samp{INSTALL_DATA} should always be followed by a line containing a
call to @samp{RANLIB} on the installed library.  This is to accomodate
systems that use @code{ranlib}.  Systems that do not use @code{ranlib}
can set @samp{RANLIB} to ``@code{echo} in'' a host specific @file{Makefile}
fragment.
@end itemize

@node configure.in, config.status, Makefile Extensions, Reference
@section The format of the @file{configure.in} file
@kindex configure.in

A @file{configure.in} file for Cygnus @code{configure} consists of a
@dfn{per-invocation} section, followed by a @dfn{per-host} section, followed by
a @dfn{per-target} section, optionally followed by a @dfn{post-target} section.
Each section is a shell script fragment, which is @code{source}d by the
@code{configure} shell script at an appropriate time.  Values are passed among
@code{configure} and the shell fragments through a set of shell variables.
When each section is being interpreted (@code{source}d) by the shell, the
shell's current directory is the build directory, and any files created by the
section (or referred to by the section) will be relative to the build
directory.  To reference files in other places (such as the source directory),
prepend a shell variable such as @samp{$(srcdir)/} to the desired file name.

@cindex Per-invocation section
The beginning of the @file{configure.in} file begins the @dfn{per-invocation}
section.

@cindex Per-host section
A line beginning with @samp{# Per-host:} begins the @dfn{per-host} section.

@cindex Per-target section
A line beginning with @samp{# Per-target:} begins the @dfn{per-target} section.

@cindex Post-target section
If it exists, the @dfn{post-target} section begins with @samp{# Per-target:}.

@menu
* Minimal::                A minimal configure.in
* configure Variables::    Variables available to configure.in
* Declarations::           For each invocation
* Per-host::               For each host
* Per-target::             For each target
* Post-target::            After each target
* Example::                An example configure.in
@end menu

@node Minimal, configure Variables, configure.in, configure.in
@subsection A minimal @file{configure.in}

@cindex Minimal @file{configure.in} example
A minimal @file{configure.in} consists of four lines.

@example
srctrigger=foo.c
srcname="source for the foo program"
# Per-host:
# Per-target:
@end example

The @samp{# Per-host:} and @samp{# Per-target:} lines divide the file into the
three required sections.  The @samp{srctrigger} line names a file.
@code{configure} checks to see that this file exists in the source
directory before configuring.  If the @samp{srctrigger} file does not
exist, @code{configure} uses the value of @samp{srcname} to print an
error message about not finding the source.

This particular example uses no links, and only the default host,
target, and site-specific @file{Makefile} fragments if they exist.

@node configure Variables, Declarations, Minimal, configure.in
@subsection Variables available to @file{configure.in}
@cindex @file{configure.in} interface

The following variables pass information between the standard parts of
@code{configure} and the shell-script fragments in @file{configure.in}:

@menu @code
@item srctrigger
Contains the name of a source file that is expected to live in the source
directory.  You must usually set this in the @dfn{per-invocation} section of
@file{configure.in}.  @code{configure} tests to see that this file exists.  If
the file does not exist, @code{configure} prints an error message.  This is
used as a sanity check that @file{configure.in} matches the source directory.

@item srcname
Contains the name of the source collection contained in the source directory.
You must usually set this in the @dfn{per-invocation} section of
@file{configure.in}.  If the file named in @samp{srctrigger} does not exist,
@code{configure} uses the value of this variable when it prints the error
message.

@item configdirs
Contains the names of any subdirectories where @code{configure} should
recur.  You must usually set this in the @dfn{per-invocation} section of
@file{configure.in}.
If @file{Makefile.in} contains a line starting with @samp{SUBDIRS =},
then it will be replaced with an assignment to @samp{SUBDIRS} using
the value of @samp{configdirs} (if @samp{subdirs} is empty).  This can
be used to determine which directories to configure and build depending
on the host and target configurations.
@c Most other matching makefile/config vars use the same name.  Why not
@c this? (FIXME).
@c Can we get rid of SUBDIRS-substitution?  It doesn't work well with subdirs.
Use @samp{configdirs} (instead of the @samp{subdirs} variable
described below) if you want to be able to partition the
sub-directories, or use independent @file{Makefile} fragments.
Each sub-directory can be independent, and independently re-configured.

@item subdirs
Contains the names of any subdirectories where @code{configure} should create a
@file{Makefile} (in addition to the current directory), @emph{without}
recursively running @code{configure}.  Use @samp{subdirs} (instead of the
@samp{configdirs} variable described above) if you want to configure all of the
directories as a unit.  Since there is a single invocation of @code{configure}
that configures many directories, all the directories can use the same
@file{Makefile} fragments, and the same @code{configure.in}.

@item host
Contains the full configuration name (generated by the script
@file{config.sub} from the name that the user entered) for the host.
This is a three-part name of the form 

@example
@var{cpu}-@var{vendor}-@var{os}
@end example

@noindent
There are separate variables @samp{host_cpu}, @samp{host_vendor}, and
@samp{host_os} that you can use to test each of the three parts; this
variable is useful, however, for error messages, and for testing
combinations of the three components.

@item host_cpu
Contains the first element of the canonical triple representing the host
as returned by @file{config.sub}.  This is occasionally used to
distinguish between minor variations of a particular vendor's operating
system and sometimes to determine variations in binary format between
the host and the target.

@item host_vendor
Contains the second element of the canonical triple representing the
host as returned by @file{config.sub}.  This is usually used to
distinguish betwen the numerous variations between @emph{common}
operating systems.
@c "@emph{common} OS" doesn't convey much to me.  Is this meant to cover 
@c cases like Unix, widespread but with many variations?

@item host_os
Contains the the third element of the canonical triple representing the
host as returned by @file{config.sub}.

@item target
Contains the full configuration name (generated by the script
@file{config.sub} from the name that the user entered) for the target.
This is a three-part name of the form 

@example
@var{cpu}-@var{vendor}-@var{os}
@end example

@noindent
There are separate variables @code{target_cpu}, @code{target_vendor}, and
@code{target_os} that you can use to test each of the three parts; this
variable is useful, however, for error messages, and for testing
combinations of the three components.

@item target_cpu
Contains the first element of the canonical triple representing the
target as returned by @file{config.sub}.  This is used heavily by
programs involved in building programs, like the compiler, assembler,
linker, etc.  Most programs will not need the @samp{target} variables at
all, but this one could conceivably be used to build a program, for
instance, that operated on binary data files whose byte order or
alignment differ from the system where the program is running.

@item target_vendor
Contains the second element of the canonical triple representing the target as
returned by @file{config.sub}.  This is usually used to distinguish betwen the
numerous variations between @emph{common} operating systems or object file
formats.  Sometimes it is used to switch between different flavors of user
interfaces.
@c above query re "@emph{common} OS" applies here too

@item target_os
Contains the the third element of the canonical triple representing the
target as returned by @file{config.sub}.  This variable is used by
development tools to distinguish between subtle variations in object
file formats that some vendors use across operating system releases.  It
might also be use to decide which libraries to build or what user
interface the tool should provide.

@item floating_point
Is set to @samp{no} if the user invoked configure with the @samp{-nfp} command
line option, otherwise it is empty.  This is a request to target machines with
@dfn{no floating point} unit, even if the targets ordinarily have floating
point units available.  This option has no negation.

@item gas
Is set to @samp{true} if the user invoked configure with the @samp{-gas}
command line option, otherwise it is empty.  This is a request to assume that
all target machines have @code{gas} available even if they ordinarily do not.
The converse option @samp{-no-gas} is not available.

@item x
Is set to @samp{true} if the user invoked configure with the @samp{-x}
command line option, otherwise it is empty.  This is a request to assume
that @sc{mit x11} compatible headers files and libraries are available
on all hosts, regardless of what is normally available on them.

@item srcdir
Is set to the name of the directory containing the source for this
program.  This will be different from @file{.} if the user has specified
the @samp{-srcdir=} option.  Note that @samp{srcdir} is not necessarily
an absolute path.

@item host_makefile_frag
If set by @file{configure.in}, this variable should be the name a file,
relative to @samp{srcdir} to be included in the resulting @file{Makefile}.  If
the named file does not exist, @code{configure} will print a warning message.
This variable is not set by @code{configure}.

@item target_makefile_frag
If set by @file{configure.in}, this variable should be the name of a file,
relative to @samp{srcdir}, to be included in the resulting @file{Makefile}.  If
the named file does not exist, @code{configure} will print a warning message.
This variable is not set by @code{configure}.

@item site_makefile_frag
Is set to a file name representing to the default @file{Makefile} fragment for
this host.  It may be set in @file{configure.in} to override this default.
Normally @samp{site_makefile_frag} is empty, but will have a value if the user
specified @samp{-site=} on the command line.  It is probably not a good idea to
override this variable from @file{configure.in}, since that may defeat the
@code{configure} user's intentions.

@item Makefile
Is set to the name of the generated @file{Makefile}.  Normally this value is
precisely @file{Makefile} but some programs may want something else.

@item removing
Is normally empty but will be set to some non-empty value if the user
specified @samp{-rm} on the command line.  That is, if @samp{removing}
is non-empty, then configure is @emph{removing} a configuration rather
than creating one.

@item files
If this variable is non-empty following the @dfn{per-target} section,
then each word in its value will be the target of a symbolic link named
in the corresponding word from the @samp{links} variable.

@item links
If the @samp{files} variable is non-empty following the @dfn{per-target}
section, then @code{configure} creates symbolic links with the first word of
@samp{links} pointing to the first word of @samp{files}, the second word of
@samp{links} pointing to the second word of @samp{files}, and so on.

@end menu

@node Declarations, Per-host, configure Variables, configure.in
@subsection For each invocation
@cindex Declarations section

@code{configure} ``@code{source}''s the entire shell script fragment from the
start of @file{configure.in} up to a line beginning with @w{@samp{# Per-host:}}
immediately after parsing command line arguments.  The variables
@samp{srctrigger} and @samp{srcname} @emph{must} be set here.

You might also want to set the variable @samp{configdirs} here.

@node Per-host, Per-target, Declarations, configure.in
@subsection For each host
@cindex per-host section
@cindex host shell-script fragment

The @dfn{per-host} section of @file{configure.in} starts with the line that
begins with @w{@samp{# Per-host:}} and ends before a line beginning with
@w{@samp{# Per-target:}}.  @code{configure} sources the @dfn{per-host} section
once for each host.

This section usually contains a big @samp{case} statement using the variables
@samp{host_cpu}, @samp{host_vendor}, and @samp{host_os} to determine
appropriate values for @samp{host_makefile_frag} and @samp{files}, although
@samp{files} is not usually set here.  Usually, it is set at the end of the
@dfn{per-target} section after determining the names of the target specific
configuration files.

@node Per-target, Post-target, Per-host, configure.in
@subsection For each target
@cindex per-target section
@cindex target shell-script fragment

The @dfn{per-target} section of @file{configure.in} starts with the line that
begins with @w{@samp{# Per-target:}} and ends before the line that begins with
@w{@samp{# Post-target:}}, if there is such a line.  Otherwise the
@dfn{per-target} section extends to the end of the file.  @code{configure}
@code{source}s the @dfn{per-target} section once for each target before
building any files, directories, or links.

This section usually contains a big @samp{case} statement using the variables
called @samp{target_cpu}, @samp{target_vendor}, and @samp{target_os} to
determine appropriate values for @samp{target_makefile_frag} and @samp{files}.
The last lines in the @dfn{per-target} section normally set the variables
@samp{files} and @samp{links}.

@node Post-target, Example, Per-target, configure.in
@subsection After each target

The @dfn{post-target} section is optional.  If it exists, the
@samp{post-target} section starts with a line beginning with @w{@samp{#
Post-target:}} and extends to the end of the file.  If it exists,
@code{configure} ``@code{source}''s this section once for each target after
building all files, directories, or links.

This section is seldom needed, but you can use it to edit the @file{Makefile}
generated by @code{configure}.

@node Example, , Post-target, configure.in
@subsection An example @file{configure.in}
@cindex example @file{configure.in}
@cindex sample @file{configure.in}
@cindex @code{bison} @file{configure.in}

Here is a small example of a @file{configure.in} file.

@c FIXME - for some reason Texinfo doesn't like a @group here
@page
@example
# This file is a collection of shell script fragments
# used to tailor a template configure script as
# appropriate for this directory.  For more information,
# see configure.texi.

configdirs=
srctrigger=warshall.c
srcname="bison"

# per-host:
case "$@{host_os@}" in
m88kbcs)
        host_makefile_frag=config/mh-delta88
        ;;
esac

# per-target:

files="bison_in.hairy"
links="bison.hairy"

# post-target:
@end example

@node config.status, Makefile Fragments, configure.in, Reference
@section @code{config.status}
@kindex config.status

The final step in configuring a directory is to create an executable shell
script, @file{config.status}.  The main purpose of this file is to allow the
@file{Makefile} for the current directory to rebuild itself, if necessary.  For
this reason, @file{config.status} uses the @samp{-norecursion} option to
@code{configure}, and is therefore inappropriate for reconfiguring a tree of
source code.

@c FIXME - should probably be more of an explanation here

@node Makefile Fragments, , config.status, Reference
@section @file{Makefile} Fragments

@cindex @file{Makefile} fragments

Cygnus @code{configure} uses three types of @file{Makefile} fragments.  In a
generated @file{Makefile} they appear in the order: @dfn{target fragment},
@dfn{host fragment}, and @dfn{site fragment}.  This allows @dfn{host fragments}
to override @dfn{target fragments}, and @dfn{site fragments} to override both.

Host-specific @file{Makefile} fragments conventionally reside in the
@file{./config} directory with names of the form @file{mh-@var{host}}.  They
are used for hosts that require odd options to the standard compiler and for
compile time options based on the host configuration.

Target-specific @file{Makefile} fragments conventionally reside in the
@file{./config} directory with names of the form @file{mt-@var{target}}.
They are used for target dependent compile time options.

Site specific @file{Makefile} fragments conventionally reside in the
@file{./config} directory with names of the form @file{ms-@var{site}}.  They
are used to override host- and target- independent compile time options.  Note
that you can also override these options on the @code{make} invocation line.

@node Porting, Reference, Using configure, Top
@chapter Porting with Configure
@cindex Porting

This section explains how to add programs, host and target configuration
names, and site-specific information to Cygnus @code{configure}.

@menu
* Programs::               Adding configure to new programs
* Hosts and Targets::      Adding hosts and targets
* Sites::                  Adding site info
@end menu


@node Programs, Hosts and Targets, Porting, Porting
@section Adding Configure To New Programs

If you are writing a new program, you probably shouldn't worry about porting or
configuration issues until it is running reasonably on some host.  Then refer
back to this section.

If the program in question currently has a @code{configure} script that meets
the criteria set out by the @sc{gnu} @cite{standards.texi} document, please do
not add Cygnus @code{configure}.  It should be possible to add this program
without change to a Cygnus @code{configure} style source tree.

If the program is not target dependent, please consider using @code{autoconf}
instead of Cygnus @code{configure}.  @code{autoconf} is available from the
Free Software Foundation.

To add Cygnus @code{configure} to an existing program, do the following:

@table @asis
@item Make sure the @file{Makefile} conforms to the @sc{gnu} standard
The coding standard for @sc{gnu} @file{Makefile}s is described in
@cite{standards.texi}.

@item Add Cygnus extensions to the @file{Makefile}
These are described in @ref{Makefile Extensions}.

@item Move host support from @file{Makefile} to fragments
This usually involves finding sections of the @file{Makefile} that say things
like ``uncomment these lines for host @var{host}'' and moving them to a new
file called @file{./config/mh-@var{host}}. For more information, see @ref{Hosts
and Targets}.

@item Choose defaults
If the program has compile-time options that determine the way the program
should behave, chose reasonable defaults and make these @file{Makefile}
variables.  Be sure the variables are assigned their default values before the
@samp{####} line so that site-specific @file{Makefile} fragments can override
them (@pxref{Makefile Extensions,,Extensions to the @sc{gnu} coding
standards}).

@item Locate configuration files
If there is configuration information in header files or source files, separate
it in such a way that the files have a generic name.  Then move the specific
instances of those files into the @file{./config} directory.

@item Separate host and target information
Some programs already have this information separated.  If yours does
not, you will need to separate these two kinds of configuration
information.  @dfn{Host specific} information is the information needed to
compile the program.  @dfn{Target specific} information is information on the
format of data files that the program will read or write.  This
information should live in separate files in the @file{./config}
directory with names that reflect the configuration for which they are
intended.

At this point you might skip this step and simply move on.  If you do, you
should end up with a program that can be configured only to build @dfn{native}
tools, that is, tools for which the host system is also the target system.
Later, you could attempt to build a cross tool and separate out the
target-specific information by figuring out what went wrong.  This is often
simpler than combing through all of the source code.

@item Write @code{configure.in}
Usually this involves writing shell script fragments to map from
canonical configuration names into the names of the configuration files.
These files will then be linked at configure time from the specific
instances of those files in @file{./config} to files in the build
directory with more generic names.  (see also @ref{Build Directories}).
The format of @file{configure.in} is described in @ref{configure.in}.

@item Rename @file{Makefile} to @file{Makefile.in}
@end table

At this point you should have a program that can be configured using
Cygnus @code{configure}.

@node Hosts and Targets, Sites, Programs, Porting
@section Adding hosts and targets

To add a host or target to a program that already uses Cygnus @code{configure},
do the following.

@itemize @bullet

@item
Make sure the new configuration name is represented in @file{config.sub}.  If
not, add it.  For more details, see the comments in the shell script
@file{config.sub}.

@item
If you are adding a host configuration, look in @file{configure.in}, in the
@dfn{per-host} section.  Make sure that your configuration name is represented
in the mapping from host configuration names to configuration files.  If not,
add it.  Also see @ref{configure.in}.

@item
If you are adding a target configuration, look in @file{configure.in}, in the
@dfn{per-target} section.  Make sure that your configuration name is
represented in the mapping from target configuration names to configuration
files.  If not, add it.  Also see @ref{configure.in}.

@item
Look in @file{configure.in} for the variables @samp{files}, @samp{links},
@samp{host_makefile_frag}, and @samp{target_makefile_frag}.  The values
assigned to these variables are the names of the configuration files, (relative
to @samp{srcdir}) that the program uses.  Make sure that copies of the files
exist for your host.  If not, create them.  See also @ref{configure Variables}.
@end itemize

This should be enough to @code{configure} for a new host or target
configuration name.  Getting the program to compile and run properly
remains the hard work of the port.

@node Sites, , Hosts and Targets, Porting
@section Adding site info

If some of the @file{Makefile} defaults are not right for your site, you can
build site-specific @file{Makefile} fragments.  To do this, do the following.

@itemize @bullet

@item
Choose a name for your site.  It must be less than eleven characters for now.

@item
If the program source does not have a @file{./config} directory, create it.

@item
Create a file called @file{./config/ms-@var{site}} where @var{site} is the name
of your site.  In it, set whatever @file{Makefile} variables you need to
override to match your site's conventions.

@item
Configure the program with:

@example
configure @dots{} -site=@var{site}
@end example

@end itemize

@node Known Bugs, Variables Index, Reference, Top
@chapter Known Bugs
@cindex bugs

We know of the following bugs:

@itemize @bullet
@item
There is no way to query about known hosts, known targets, or the
porting or testing status of any configuration.

@item
The negations to the options @code{-gas}, @code{-x}, and @code{-nfp} are
not available.

@end itemize

@node Variables Index, Concept Index, Known Bugs, Top
@appendix Variable Index

@printindex vr

@page
@node Concept Index, , Variables Index, Top
@appendix Concept Index

@printindex cp
@contents
@bye

@c Local Variables:
@c fill-column: 79
@c outline-regexp: "@chap"
@c End:
@c (setq outline-regexp "@chapt\\\|@unnum\\\|@setf\\\|@conte\\\|@sectio\\\|@subsect\\\|@itemize\\\|@defvar{")
