This document attempts to describe the configuration system used and distributed by Cygnus Support.

Copyright © 1991 Cygnus Support

top
***

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

NOTE: support for a Cygnus experimental option, -subdirs is at least temporarily suspended.  Most of the code is still in configure but the option is disabled.  This document describes that feature, but those parts are prominently marked with NOTE's like this one. FIXME-soon

Invoking
********

The usual way to invoke configure is as follows:

     configure HOST

This asks configure to prepare the source to be compiled in a HOST environment with programs and files to be installed in /usr/local.

NOTE: support for multiple hosts is at least temporarily suspended. FIXME-soon

If more than one host is specified on the command line, then configurations are created for each and -subdirs is assumed.

-datadir=DIR
     This option requests that the source be configured so that host independent files will be installed in DIR.

     This option sets the configure variable datadir.  If datadir is not empty, generated Makefiles will have their datadir variables set to this value. (See Install Details.)

-gas
     Notifies configure that the GNU assembler is available on all specified hosts.

-help
     Displays a quick summary of how to invoke configure.

-host=HOST
     FIXME-soon: I don't think this option should be documented.

     NOTE: support for this -namesubdir= is at least temporary suspended. FIXME-soon

-namesubdir=NAME
     Asks that any subdirectories created by the -subdirs option be named NAME.  Note that using multiple hosts with -namesubdir= isn't terribly useful.

-nfp
     Notifies configure that all of the specified hosts have no floating point units.

-norecursion
     Asks configure to configure only this directory.  Any subdirectories are ignored.  This is used by the executable shell script config.status to reconfigure the current directory. (see FIXME-now:config.status.

-objdir=DIR
     This option is no longer supported.  Use -srcdir= instead.

-prefix=DIR
     This option requests that the source be configured so that programs and files will be installed in DIR.

     This option sets the configure variable prefix.  If prefix is not empty, generated Makefiles will have their prefix variables set to this value. (See Install Details.)

-recurring
     This option is used internally by configure when recurring on subdirectories.  It's sole purpose is to supress status output.  It can be overriden with the -verbose option.

-rm
     Asks configure to remove a configuration rather than create one.

-site=SITE
     Asks that Makefiles be generated using site specific Makefiles for SITE.  (see FIXME-now: site specific Makefiles.)

-srcdir=_DIR
     Tells configure that the sources are located in DIR.  The build directory is assumed to be ..

     NOTE: support for this -subdirs is at least temporary suspended. FIXME-soon

-subdirs
     Asks that configurations be placed in subdirectories named H-HOST of each build directory, for each host specified. If this configuration is not native, (HOST is not TARGET), then he subdir will be named X-HOST-TARGET instead.

     NOTE: support for multiple targets is at least temporarily suspended. FIXME-soon

-target=TARGET
     Requests that the sources be configured to target the TARGET machine.  If no targets are specified explicitly, the target is assumed to be the same as the host.  If multiple targets are specified, configurations for each are created and -subdirs is assumed.

-tmpdir=TMPDIR
     Sets the directory in which configure creates temporary files to TMPDIR.

-verbose

-v
     Asks that configure print status lines for each directory configured.  Normally, only the status lines for the current directory are printed.

-x
     Tells configure that MIT style X11 header files and libraries are available on this machine, even if they are not normally available.

Using Configure
***************

Configure prepares source directories in anticipation of building. Source cannot be built until it has been configured.  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
=================

Using the default configuration, make install will create a single tree of files, some of which are programs.  The location of this tree is determined by the value of the variable $(prefix).  The default value of $(prefix) is /usr/local.  This is probably correct for native tools installed on only one host.

Changing the default install directory
--------------------------------------

In the default configuration, all files are installed in subdirectories of /usr/local.  The actual location is determined by the value of the configure variable ${prefix} which determines the value of the Makefile variable $(prefix).

You can also set the value of the Makefile variable $(prefix) explicitly each time you invoke make if you are so inclined, but because many programs have this location compiled in, you must specify the $(prefix) value precisely on each invocation of make or you will end up with a broken installation.

To make this easier, the value of the configure variable ${prefix} can be set on the command line to configure using the option -prefix=.  (See prefix).

Installing for multiple hosts
-----------------------------

Host independent files are installed in subdirectories of /usr/local/lib.  The actual location is determined by the value of the configure variable ${datadir} which determines the value of the Makefile variable $(datadir).  By default, the value of ${datadir} is ${prefix}/lib.  This makes single host installs simple, and simplifies changing the default location for the install tree, but 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:

     configure HOST1 -prefix=/usr/gnu/H-HOST1 -datadir=/usr/gnu/H-independent
     make all info install install-info clean
     configure HOST2 -prefix=/usr/gnu/H-HOST2 -datadir=/usr/gnu/H-independent
     make all info install install-info

The first line configures the source for HOST1 in such a way that host specific programs will be placed in subdirectories of /usr/gnu/H-HOST1 and host independent files will be placed in /usr/gnu/H-independent.  (See datadir.)

The second line builds and installs all programs for HOST1, including both host independent and host dependent files.

The third line reconfigures the source for HOST2 in such a way that host specific programs will be placed in subdirectories of /usr/gnu/H-HOST2 and host independent files will again be placed in /usr/gnu/H-independent.

The fourth line builds and installs all programs for HOST2.  Host dependent files will be installed in new directories but the host independent files will be installed on top of the host independent files installed for HOST1.  This results in a single copy of the host independent files suitable for use by both hosts.

NOTE: support for -subdirsa and multiple hosts is at least temporarily suspended. FIXME-soon

Previously this was:

     configure HOST1 HOST2 -prefix=/usr/gnu

Full descriptions of all installation subdirectories
----------------------------------------------------

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

Note that configure does not create srcdir at any time. The directory srcdir is not an installation directory. (see FIXME-now.)

All makefile variables can be overridden on the command line to make.  (See Overriding Variables (Make).)  If you do so, you will need to specify the value precisely the same way for each invocation of 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 depedent Makefile fragments.  (See FIXME-now.)

During make install, the following standard directories will be created and populated:

 -- Makefile and configure: prefix
     By default, the value of this variable determines the root of the installation tree.  It may be overridden with the -srcdir= command line option to configure.  (see Invoking.)  The default value for prefix is /usr/local.

 -- Makefile: bindir
     The value of this variable names a directory intended to contain binary programs that users can run.  The default value for bindir depends on prefix so bindir is normally changed only indirectly through prefix.  The default value for $(bindir) is prefix/bin.

 -- Makefile and configure: datadir
     The value of this variable names a directory intended to contain host independent files.  The configure variable, which is used to set the default value of the Makefile variable, can be set at configure time using the -datadir= option to configure. (see Invoking.)  The default value for datadir is prefix/lib.

 -- Makefile: libdir
     The value of this variable names a directory intended to hold libraries and support programs.  The default value for libdir depends on prefix so libdir is normally changed only indirectly through prefix.  The default value for libdir is prefix/lib.

 -- Makefile: mandir
     The value of this variable names a directory intended to hold man format man pages.  The default value for mandir depends on prefix so mandir is normally changed only indirectly through prefix.  The default value for mandir is datadir/man.

 -- Makefile: manNdir
     There are eight of these variables named man1dir, man2dir, etc.  They are intended to name the specific directories which hold the man pages of their respective sections.  That is, man1dir holds emacs.1, the man page for the emacs program while man5dir holds the man page describing the rcs data file format, called rcsfile.5.  The default value for manNdir depends on prefix so manNdir is normally changed only indirectly through prefix.  The default value for manNdir is mandir/manN.

 -- Makefile: manext
     The makefile variable manext is not supported by the configure. The GNU coding standards do not call for man1ext, man2ext, so the intended use for manext is not clear. (See also FIXME-now:extensions.)

 -- Makefile: infodir
     The value of this variable names a directory intended to hold info format documentation.  The default value for infodir depends on prefix so infodir is normally changed only indirectly through prefix.  The default value for infodir is datadir/info.

 -- Makefile: docdir
     The value of this variable names a directory intended to hold any documentation that is in a format other than info or man. The default value for docdir depends on prefix so docdir is normally changed only indirectly through prefix. The default value for docdir is datadir/doc.  Note that this variable is an extension to the GNU coding standards. (See also FIXME-now:extensions.)

 -- Makefile: includedir
     The value of this variable names a directory intended to hold the headers files that accompany the libraries installed in libdir. The default value for includedir depends on prefix so includedir is normally changed only indirectly through prefix.  The default value for includedir is prefix/include.

Build Directories
=================

Normally, configure builds Makefile's and symbolic links in the same directory as the source files.  This is the typical 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 in which configure builds Makefile's as the build directories or sometimes as objdir because these are the directories in which make will build object files, among other things.

The default build directory is the same as the source directory.

You can change the build directory with a sequence like the following:

     mkdir BUILDDIR
     cd BUILDDIR
     configure HOST -srcdir=SOURCEDIRECTORY

          where BUILDDIR is the directory in which you wish to build,
          HOST is the host for which you want to build, and
          SOURCEDIRECTORY is the directory containing the source files.

          If you were to do this twice with different values for BUILDDIR
          and host, then you could make for both at the same time.

          NOTE: The rest of this section describes the -subdirs feature for
          which support is at least temporarily suspended.  FIXME-soon.

          Another way to specify the build directory is with the -subdirs
          option.  For example:

               configure HOST -subdirs

          Using this option, configure will create a subdirectory named
          H-HOST to act as the build directory for each source
          directory.

          Since building for multiple hosts is so common, configure
          recognizes this situation as special.  For example:

               configure HOST1 HOST2

          is precisely the same as:

               configure HOST1 -subdirs
               configure HOST2 -subdirs
               #end example

               That is, when configuring for multiple hosts or multiple targets,
               -subdir is assumed.

               When configuring for cross tools, that is, the host is not the target,
               as in:

                    configure HOST +target=TARG -subdirs

               the subdirectories are named X-HOST-TARG.  This is
               especially useful when configuring for multiple targets.

               If both -subdirs and -srcdir= are given, a tree that
               parallels the source directory structure is created in the current
               directory, except that the current directory represents the source
               directory itself, and the subdirectories are created in this directory
               tree rather than in the source directories.

               NOTE: previously, -subdirs built two level subdirectories as
               ./H-host/T-target, created ./H-host/Makefile for building across all
               targets, ./Makefile for building across all hosts, and ./config.status
               and ./H-host/config.status for rebuilding these Makefiles.

Host
====

NOTE: support for multiple hosts is at least temporarily suspended. FIXME-soon.

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

For example, if some obscure machine running an operating system other than UN*X actually had the GNU POSIX emulation libraries available, it would be possible to configure most GNU source for a POSIX system and build it on the obscure host.

For more on this topic, see cfg-paper (On Configuring Development Tools).

Target
======

For building native development tools, or most of the other tools in the GNU collection, you need not worry about the target.  The target of a configuration defaults to the same as the host.

For building cross development tools, please see cfg-paper (On Configuring Development Tools).

Local Conventions
=================

If you find that a tool does not get configured to your liking or that configure's conventions are not your local conventions, you should probably consider site specific Makefile fragments.  (see FIXME-now: site specific makefile fragments)

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

What Configure Does
*******************

When configure runs, it does the following things for each source directory for each host and target combination.

NOTE: support for multiple hosts and targets is at least temporarily suspended.

  * Create Build Directories (see Build Directories) When configure is run with the -srcdir= option, a directory tree is created that parallels the directory structure of the source directory except that the current directory is treated as the build directory for the source directory proper.  (see Invoking).

     NOTE: support for -subdirs is at least temporarily suspended.

     When configure is run with the -subdirs option, a build directory is created in each source directory.

     If both -subdirs and -srcdir= are given, a tree that parallels the source directory structure is created in the current directory, except that the current directory represents the source directory itself, and the subdirectories are created in this directory tree rather than in the source directories.

  * Generate Makefiles A makefile template, usually called Makefile.in from the source directory is copied to an output file in the build directory.  The output file is usually named Makefile.  A number of makefile macros are prepended to the output file.  If -prefix= or -datadir= were specified on the configure command line, then the makefile variables are set accordingly.  If host, target, or site, specific makefile fragments exist, they are inserted into the output file.  (see Makefiles)

  * Generate .gdbinit If the source directory contains a .gdbinit file and the build directory is different from the source directory, a .gdbinit file is created in the build directory.  (see Command Files)

  * Make Symbolic Links Most directories have some symbolic links with generic names built pointing to specific files in the source directory.  If the system on which configure is run cannot support symbolic links, then hard links are used instead.

  * Miscellaneous If the source directory has special needs, they are handled.  Usually there are none, but sometimes they involve changes to the output makefile.

  * Generate config.status A shell script named config.status is created in the build directory.  This shell script, when run from the build directory, will reconfigure the build directory except that subdirectories are not reconfigured.  This is most often used by make to rebuild the output makefile.  (see bash)

  * Recursion If the source directory has subdirectories that should also be configured, then configure is called for each.

Porting with Configure
**********************

This section explains briefly how to port configure for:

Adding Configure To Existing Programs
-------------------------------------

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

If your

Makefile Support
................

Add Standard Macros (Template Follows)
......................................

  * as defined in standards.text

  * also add

       - includedir This macro defines the directory in which to install any headers files that should be made available to users.

       - docdir This macro defines where to install any documentation that is not either a man page or an info file.  For man pages, see mandir, for info, see infodir.

  * template

          # Makefile for GNU tar program.

          #
          # Makefile
          #   Copyright (C) 1990, 1991 Cygnus Support
          #
          # This file is free software; you can redistribute it and/or modify
          # it under the terms of the GNU General Public License as published by
          # the Free Software Foundation; either version 2 of the License, or
          # (at your option) any later version.
          #
          # This program is distributed in the hope that it will be useful,
          # but WITHOUT ANY WARRANTY; without even the implied warranty of
          # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
          # GNU General Public License for more details.
          #
          # You should have received a copy of the GNU General Public License
          # along with this program; if not, write to the Free Software
          # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
          #

          srcdir = .

          prefix = /usr/local

          bindir = $(prefix)/bin
          datadir = $(prefix)/lib
          libdir = $(prefix)/lib
          mandir = $(datadir)/man
          man1dir = $(mandir)/man1
          man2dir = $(mandir)/man2
          man3dir = $(mandir)/man3
          man4dir = $(mandir)/man4
          man5dir = $(mandir)/man5
          man6dir = $(mandir)/man6
          man7dir = $(mandir)/man7
          man8dir = $(mandir)/man8
          man9dir = $(mandir)/man9
          infodir = $(datadir)/info
          includedir = $(prefix)/include
          docdir = $(datadir)/doc

          SHELL = /bin/sh

          INSTALL = install -c
          INSTALL_PROGRAM = $(INSTALL)
          INSTALL_DATA = $(INSTALL)

          AR = ar
          AR_FLAGS = qv
          BISON = bison
          MAKEINFO = makeinfo
          RANLIB = ranlib

          # In order to disable remote-tape support, add -DNO_REMOTE to the
          # appropriate DEFS line, and remove rtape_lib.* from LOCAL_{SRC,OBJ}
          # For Ultrix 3.1, you will have to compile rtape_lib.c with -DUSG.
          # Add -DUSE_REXEC to use rexec for remote tape operations
          # instead of forking rsh or remsh.
          #
          # If tar fails to properly print error msgs, or core-dumps doing same,
          # you may need to change which version of msg...() you are using.
          # To do so, add one of the following to your DEFS= line
          # -DSTDC_MSG		If you are using an ANSI compiler, and have vfprintf().
          # -DVARARGS_MSG		If you have varargs.h and vfprintf()
          # -DDOPRNT_MSG		If you have _doprnt(), and no useful varargs support
          # -DLOSING_MSG		If nothing else works.
          #
          # Some non-BSD systems may have to add -DNEED_TZSET in order to have getdate.y
          # compile correctly.
          #
          # If you have a system V system which defines size_t, add -DHAVE_SIZE_T.
          # If you have a system which defines strstr, add -DHAVE_STRSTR.
          #
          # If you can't use remote tar with the rmt library, you can still get
          # some stuff to work right by adding -DUSE_REXEC.
          #
          # Some people's systems define a prototype for signal handlers which
          # require them to be declared as void.  If you get such problems in
          # rtape_lib, function command, then define -DSIGNAL_VOID.
          #
          # getdate.y has 8 shift/reduce conflicts.
          #
          # In addition to setting DEFS appropriately for your system, you might
          # have to hand edit the #defines and #undefs in port.c.
          #

          ## GNU version
          DEFS = -DBSD42
          LOCAL_SRC =
          LOCAL_OBJ =
          LDFLAGS =
          LIBS =  -lutils
          LINT = lint
          LINTFLAGS = -abchx
          DEF_AR_FILE = \"-\"
          DEFBLOCKING = 20
          O = o

     #### Host, target, and site specific Makefile fragments come in here. ###

       * Identify Nonstandard Macros

            - Put Defaults Before The Fragment Hook (Cf)

            - Move Non-Defaults To Makefile Fragments (Cf)

            - Map To Those Fragments In Configure.In (Cf)

       * Fragment Hook

            - Should Follow Standard And Non-Standard Macros

            - Should Preceed All Targets

            - Looks Like #### Host, target, and site specific Makefile fragments come in here. ###

               The line beginning with four hashes is the important part.  The comment and the line beginning with three hashes are only a conventional convenience.

       * Makefile Fragments

       * Host

       * Target

       * Site

       * Mv Makefile Makefile.In

       * Standard Targets

       * All (Should Be The Default)

       * Install

       * Clean

       * Info

       * Install-Info

       * Clean-Info

       * The Config Subdirectory

       * Configure.In

       * Declarations

       * Srctrigger

       * Srcname

       * Configdirs

       * Target_Dependent

       * Per-Host

       * Per-Target

       * Post-Target

       * Available Variables

          host Contains the actual name that the user entered for the host.  Since many things that the user could enter would map to the same canonical triple, this variable is innappropriate to use for picking available configurations.  For that, use host_cpu, host_vendor, and/or host_os.  This variable is useful, however, for error messages.

          host_cpu Contains the first element of the canonical triple representing the host as returned by config.subr.  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.

          host_vendor Contains the second element of the canonical triple representing the host as returned by config.subr.  This is usually used to distinguish betwen the numerous variations between common operating systems.

          host_os Contains the the third element of the canonical triple representing the host as returned by config.subr.

          target Contains the actual name that the user entered for the target.  Since many things that the user could enter would map to the same canonical triple, this variable is innappropriate to use for picking available configurations.  For that, use target_cpu, target_vendor, and/or target_os.  This variable is useful, however, for error messages.

          target_cpu Contains the first element of the canonical triple representing the target as returned by config.subr.  This is used heavily by programs involved in building programs, like the compiler, assembler, linker, etc.  Most programs will not need the 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 are other than that of the system on which the program is running.

          target_vendor Contains the second element of the canonical triple representing the target as returned by config.subr.  This is usually used to distinguish betwen the numerous variations between common operating systems or object file formats.  Sometimes it is used to switch between different flavors of users interfaces.

          target_os Contains the the third element of the canonical triple representing the target as returned by config.subr.  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.

          nfp Is set to true if the user invoked configure with the -nfp command line option, otherwise it is empty.  This is a request to target a machine with no floating point unit, even if the machine ordinarily has a floating point unit available.  This option has no negation.

          gas Is set to true if the user invoked configure with the -gas command line option, otherwise it is empty.  This is a request to assume that the target machine has gas available even if it ordinarily does not.  The converse option, -no-gas is not available.

          x Is set to true if the user invoked configure with the -x command line option, otherwise it is empty.  This is a request to assume that MIT X11 compatible headers files and libraries are available, regardless of what is normally available on this host.

          srcdir Is set to the name of the directory containing the source for this program.  This will be different from . if the user has specified either the -srcdir= or the -subdirs options. Note that srcdir is not necessarily an absolute path.

          host_makefile_frag Is set to a file name representing to the default Makefile fragment for this host.  It may be set in configure.in to overide this default.

          target_makefile_frag Is set to a file name representing to the default Makefile fragment for this target.  It may be set in configure.in to overide this default.

          site_makefile_frag Is set to a file name representing to the default Makefile fragment for this host.  It may be set in configure.in to overide this default.  Normally site_makefile_frag is empty, but will have a value if the user specified -site= on the command line.  This variable should probably not be overridden.

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

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

          files If this variable is non-empty following the per-target: section, then each word in it's value will be the target of a symbolic link named in the links variable.

          links If the files variable is non-empty following the per-target: section, then symbolic links will be created with the first word of links pointing to the first word of files, the second word of links pointing to the second word of files, and so on.

Native Ports
============

To port a GNU tool that uses the Cygnus Configure system, do the following.

  Add A Host

  Port An Existing Target

  Add A Target

  Build Host & Target

  Build New Target On Some Other Host

Adding Hosts Or Targets
=======================

Add Canonical Triple To Config.Subr (Cf Config.Subr)
----------------------------------------------------

(Optional) Add Alias (Cf Config.Subr)
-------------------------------------

Monte Carlo - Configure ; Make
------------------------------

Remedies
--------

Automagic Config
................

Symlinked Files
...............

Makefile Fragments (Cf Configure.In)
....................................

Reference
=========

Automagic Configuration Should Be Used If Prep'D Files Don'T Exist.

Known Bugs
**********

The following bugs are known to exist.

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

  * The negations to the options -gas, -x, and -nfp are not available.