### 1.2 Configuring and building libgloss.

Libgloss uses an autoconf based script to configure. Autoconf scripts are portable shell scripts that are generated from a configure.in file. Configure input scripts are based themselves on m4. Most configure scripts run a series of tests to determine features the various supported features of the target. For features that can’t be determined by a feature test, a makefile fragment is merged in. The configure process leaves creates a Makefile in the build directory. For libgloss, there are only a few configure options of importance. These are –target and –srcdir.

Typically libgloss is built in a separate tree just for objects. In this manner, it’s possible to have a single source tree, and multiple object trees. If you only need to configure for a single target environment, then you can configure in the source tree. The argument for –target is a config string. It’s usually safest to use the full canonical opposed to the target alias. So, to configure for a CPU32 (m68k) with a separate source tree, use:

    ../src/libgloss/configure --verbose --target m68k-coff

The configure script is in the source tree. When configure is invoked it will determine it’s own source tree, so the –srcdir is would be redundant here.

Once libgloss is configured, `make` is sufficient to build it. The default values for `Makefiles` are typically correct for all supported systems. The test cases in the testsuite will also built automatically as opposed to a `make check`, where test binaries aren’t built till test time. This is mostly cause the libgloss testsuites are the last thing built when building the entire GNU source tree, so it’s a good test of all the other compilation passes.

The default values for the Makefiles are set in the Makefile fragment merged in during configuration. This fragment typically has rules like

    CC_FOR_TARGET = `if [ -f $${OBJROOT}/gcc/xgcc ] ; \
    	then echo ${OBJROOT}/gcc/xgcc -B${OBJROOT}/gcc/ ; \
    	else t='${program_transform_name}'; echo gcc | sed -e '' $$t ; fi`

Basically this is a runtime test to determine whether there are freshly built executables for the other main passes of the GNU tools. If there isn’t an executable built in the same object tree, then transformedthe generic tool name (like gcc) is transformed to the name typically used in GNU cross compilers. The names are typically based on the target’s canonical name, so if you’ve configured for `m68k-coff` the transformed name is `m68k-coff-gcc` in this case. If you install with aliases or rename the tools, this won’t work, and it will always look for tools in the path. You can force the a different name to work by reconfiguring with the `--program-transform-name` option to configure. This option takes a sed script like this `-e s,^,m68k-coff-,` which produces tools using the standard names (at least here at Cygnus).

The search for the other GNU development tools is exactly the same idea. This technique gets messier when build options like `-msoft-float` support are used. The Makefile fragments set the `MUTILIB` variable, and if it is set, the search path is modified. If the linking is done with an installed cross compiler, then none of this needs to be used. This is done so libgloss will build automatically with a fresh, and uninstalled object tree. It also makes it easier to debug the other tools using libgloss’s test suites.