# Installing GCC: Configuration

Like most GNU software, GCC must be configured before it can be built. This document describes the recommended configuration procedure for both native and cross targets.

We use srcdir to refer to the toplevel source directory for GCC; we use objdir to refer to the toplevel build/object directory.

First, we highly recommend that GCC be built into a separate directory than the sources which does not reside within the source tree. This is how we generally build GCC; building where srcdir == objdir should still work, but doesn't get extensive testing; building where objdir is a subdirectory of srcdir is unsupported.

Second, when configuring a native system, either "cc" or "gcc" must be in your path or you must set CC in your environment before running configure. Otherwise the configuration scripts may fail.

To configure GCC:

> `
> % mkdir objdir
> % cd objdir
> % srcdir/configure [target] [options]`

target specification

- GCC has code to correctly determine the correct value for target for nearly all native systems. Therefore, we highly recommend you not provide a configure target when configuring a native compiler.
- target must be specified when configuring a cross compiler; examples of valid targets would be i960-rtems, m68k-coff, sh-elf, etc.

options specification

Use options to override several configure time options for GCC. A partial list of supported `options`:

- `--prefix=`dirname -- Specify the toplevel installation directory. This is the recommended way to install the tools into a directory other than the default. The toplevel installation directory defaults to /usr/local.

  We highly recommend against prefix being the same or a subdirectory of objdir or vice versa.

  These additional options control where certain parts of the distribution are installed. Normally you should not need to use these options.

  - `--with-local-prefix=`dirname -- Specify the installation directory for local include files. The default is /usr/local.
  - `--with-gxx-include-dir=`dirname -- Specify the installation directory for g++ header files. The default is /usr/local/include/g++.
- `--enable-shared` -- Build shared versions of the C++ runtime libraries if supported `--disable-shared` is the default.
- `--enable-haifa` -- Enable the new Haifa instruction scheduler in the compiler; the new scheduler can significantly improve code on some targets.
  For EGCS 1.0.x releases `--disable-haifa` is the default on all platforms except the HPPA.
  For newer releases `--disable-haifa` is the default on all platforms except the alpha, hppa, powerpc, rs6000, SPARC and m32r.
- `--with-gnu-as` -- Specify that the compiler should assume the GNU assembler (aka gas) is available.
- `--with-gnu-ld` -- Specify that the compiler should assume the GNU linker (aka gld) is available.
- `--with-stabs` -- Specify that stabs debugging information should be used instead of whatever format the host normally uses. Normally GCC uses the same debug format as the host system.
- `--enable-multilib` -- Specify that multiple target libraries should be built to support different target variants, calling conventions, etc. This is the default.
- `--enable-threads` -- Specify that the target supports threads. This affects only the Objective-C compiler and runtime library.
- `--enable-threads=`lib -- Specify that lib is the thread support library. This affects only the Objective-C compiler and runtime library.
- `--with-cpu=`cpu -- Specify which cpu variant the compiler should generate code for by default. This is currently only supported on the some ports, specifically arm, powerpc, and SPARC. If configure does not recognize the model name (e.g. arm700, 603e, or ultrasparc) you provide, please check the configure script for a complete list of supported models.
- `--enable-target-optspace` -- Specify that target libraries should be optimzied for code space instead of code speed. This is the default for the m32r platform.
- `--enable-cpp` -- Specify that a shell script which emulates traditional cpp functionality should be installed.
- `--enable-cpplib` -- Specify that the functionality of CPP should be integrated into the compiler itself. This is still under development, but may be useful in limited situations. This option is never enabled by default.
- `--without-fast-fixincludes` -- Specify that the old, slower method of fixing the system header files should be used. EGCS 1.1.x and older releases default to the slow version. GCC 2.95 and newer releases will default to the fast version.
- `--enable-version-specific-runtime-libs` -- Specify that runtime libraries should be installed in the compiler specific subdirectory (`${libsubdir}`) rather than the usual places. In addition, libstdc++'s include files will be installed in `${libsubdir}/include/g++` unless you overruled it by using `--with-gxx-include-dir=`dirname. Using this option is particularly useful if you intend to use several versions of egcs/gcc in parallel. This is currently supported by `libf2c` and `libstdc++`.
- `--enable-languages=`lang1`,`lang2`,...` -- Specify that only a particular subset of compilers and their runtime libraries should be built. For a list of valid values for lang `x` you can issue the following command in the `gcc` directory of your GCC source tree:
  `grep language= */config-lang.in`
  Currently, you can use any of the following: `CHILL`, `c++`, `f77`, `java` and `objc`. Please note, that this switch does not work with EGCS 1.1.2 or older versions of egcs. It will be supported in GCC 2.95 and newer version.
  If you do not pass this flag, all languages available in the `gcc` sub-tree will be configured. Re-defining LANGUAGES when calling `make bootstrap` *does not* work anymore, as those language sub-directories might not have been configured!
- `--with-dwarf2` -- Specify that the compiler should use DWARF2 debugging information as the default.

Some options which only apply to building cross compilers:

- `--with-headers=`dir -- Specifies a directory which has target include files. These include files will be copied into the gcc install directory. Fixincludes will be run on these files to make them compatible with gcc.
- `--with-libs=`"dir1 dir2 ... dirN" -- Specifies a list of directories which contain the target runtime libraries. These libraries will be copied into the gcc install directory.
- `--with-newlib` -- Specifies that "newlib" is being used as the target C library. This causes __eprintf to be omitted from libgcc.a on the assumption that it will be provided by newlib.

Note that each `--enable` option has a corresponding `--disable` option and that each `--with` option has a corresponding `--without` option.

Last modified on July 16, 1999.