libtool

GNU libtool simplifies the job of the developer who wants to take advantage of the power of shared libraries, by encapsulating the platform-specific dependencies and the user interface in a single script. libtool is designed so that the complete functionality of each host type is available through a generic interface, but idiosyncrasies are hidden from the programmer. These idiosyncrasies become more of a problem when cross-compiling.

If the package being cross-compiled uses the libtool script to build a library, then it should be rebuilt using the ltconfig command from the package itself (if available). The libtool script must be rebuilt with knowledge of the target architecture. This can be achieved with the following script (in Bourne shell syntax):

#! /bin/sh
 
PREFIX=$1
 
export CC="${PREFIX}-gcc"
export LD="${PREFIX}-ld"
export NM="${PREFIX}-nm -B"
export AR="${PREFIX}-ar"
export RANLIB="${PREFIX}-ranlib"
export LN_S="ln -s"
export CFLAGS="-g -O2"
 
echo "Rebuilding libtool for \"$PREFIX\" ..."
./ltconfig --cache-file="./config.cache" --with-gcc --with-gnu-ld --no-verify \
           ./ltmain.sh $PREFIX
echo "Done."

Call this script makelibtool, and invoke it with a single argument, which is the name of the target architecture, as in:

host% makelibtool sh-linux-gnu
 
Rebuilding libtool for "sh-linux-gnu" ...
Done.

The variable definitions and the ltconfig command can also be embedded in a larger script which takes care of the configuration process. The CFLAGS variable defined in this script will be the default value used by libtool. This value may be overridden by the definition seen by configure. If these commands are embedded in a larger Bourne shell script, CFLAGS can be redefined for the ltconfig invocation alone in this way:

$ CFLAGS="-g -O2"  ./ltconfig --cache-file="./config.cache" ...

The ltconfig command should not be present if the configuration scripts have been generated by autoconf version 2.5 or later. In this case the same configure will generate a new libtool command.