libtool automatically inserts `-rpath' settings when compiling your
program. But `-rpath' can cause big problems if the referenced
libraries get updated. Therefore, no Debian package should use the
`-rpath' option.

libtool also refuses to link shared libraries against other shared
libraries.  Debian packages have to at least link against libc (with
"-lc"), so that the dynamic linker knows whether to use the
libc5-compat libraries or not.

Yann Dirson provided a workaround for the -rpath problem, as a patch
to configure.in.  I have added code to it to handle -lc as well, and I
have made an alternative version that works as a patch to debian/rules
instead of configure.in.  (It significantly cuts down on the size of
the Debian diffs if you don't have to re-run autoconf.)

Richard Braakman

Workaround number one, the configure.in patch:

It is a configure.in code snippet.  Be sure to insert it *after* call
to AM_PROG_LIBTOOL.

====
# Turn around -rpath and -lc problems with libtool 1.0c
# This define should be improbable enough to not conflict with anything
case ${host} in
  *-*-linux-gnu)
    AC_MSG_RESULT([Fixing libtool for -rpath problems.])
    sed < libtool > libtool-2 \
      -e 's/^hardcode_libdir_flag_spec.*$/hardcode_libdir_flag_spec=" -D__LIBTOOL_IS_A_FOOL__ "/' \
      -e '/^archive_cmds="/s/"$/ \\$deplibs"/'
    mv libtool-2 libtool
    chmod 755 libtool
  ;;
esac
====

You'll note that the -D__LIBTOOL_IS_A_FOOL__ is just here to fool
libtool by making it believe it gave some useful info to gcc ;)

Workaround number two, the debian/rules patch:

If you would rather not touch the configure.in file, and your
debian/rules file calls "configure" separately, you can try inserting
the following code right after the call to "configure":

====
# Patch the generated libtool to avoid passing -rpath when linking,
# and to explicitly link libraries against the libraries they
# depend on.
        sed < libtool > libtool-2 \
        -e 's/^hardcode_libdir_flag_spec.*$$/hardcode_libdir_flag_spec=" -D__LIBTOOL_IS_A_FOOL__ "/' \
	-e '/^archive_cmds="/s/"$$/ \\$$deplibs"/'
        mv libtool-2 libtool
        chmod 755 libtool
====

This works if the configure script merely generates libtool and does
not try to use it itself.  See the lesstif package for an example
of where this works.  dpkg now uses it too.
