Debugging with GDB Manual The GNU Source-Level Debugger (769148-001, March 2014)
Running configure host and then running make builds the `bfd', `readline', `mmalloc',
and `libiberty' libraries, then gdb itself. The configured source files, and the binaries, are left in
the corresponding source directories.
configure is a Bourne-shell (/bin/sh) script; if your system does not recognize this automatically
when you run a different shell, you may need to run sh on it explicitly:
sh configure host
If you run configure from a directory that contains source directories for multiple libraries or
programs, such as the gdb-gdb-199991101 source directory for version gdb-199991101,
configure creates configuration files for every directory level underneath (unless you tell it not
to, with the --norecursion option).
You can run the configure script from any of the subordinate directories in the GDB distribution
if you only want to configure that subdirectory, but be sure to specify a path to it.
For example, with version gdb-199991101, type the following to configure only the bfd
subdirectory:
cd gdb-gdb-199991101/bfd
../configure host
You can install (gdb) anywhere; it has no hardwired paths. However, you should make sure that
the shell on your path (named by the SHELL environment variable) is publicly readable. Remember
that GDB uses the shell to start your program|some systems refuse to let GDB debug child processes
whose programs are not readable.
Compiling GDB in another directory
If you want to run GDB versions for several host or target machines, you need a different gdb
compiled for each combination of host and target. configure is designed to make this easy by
allowing you to generate each configuration in a separate subdirectory, rather than in the source
directory. If your make program handles the VPATH feature (GNU make does), running make in
each of these directories builds the gdb program specified there.
To build gdb in a separate directory, run configure with the --srcdir option to specify where
to find the source. (You also need to specify a path to find configure itself from your working
directory. If the path to configure would be the same as the argument to --srcdir, you can leave
out the --srcdir option; it is assumed.)
For example, with version gdb-199991101, you can build GDB in a separate directory for a Sun
4 like this:
cd gdb-gdb-199991101
mkdir ../gdb-sun4
cd ../gdb-sun4
../gdb-gdb-199991101/configure sun4
make
When configure builds a configuration using a remote source directory, it creates a tree for the
binaries with the same structure (and using the same names) as the tree under the source directory.
In the example, you'd find the Sun 4 library `libiberty.a' in the directory gdb-sun4/libiberty,
and GDB itself in `gdb-sun4/gdb.
One popular reason to build several GDB configurations in separate directories is to configure
GDB for cross-compiling (where GDB runs on one machine — the host — while debugging programs
that run on another machine — the target). You specify a cross-debugging target by giving the
--target=target option to configure.
When you run make to build a program or library, you must run it in a configured directory —
whatever directory you were in when you called configure (or one of its subdirectories).
The Makefile that configure generates in each source directory also runs recursively. If you
type make in a source directory such as gdb-gdb-199991101 (or in a separate configured directory
configured with `--srcdir=dirname/gdb-gdb-199991101), you will build all the required
libraries, and then build GDB.
Compiling GDB in another directory 281