[RFA] Add --with-libz-prefix option in config/zlib.m4

Message ID 20150107144548.GX5432@adacore.com
State New, archived
Headers

Commit Message

Joel Brobecker Jan. 7, 2015, 2:45 p.m. UTC
  Hello,

This patch enhances config/zlib.m4 to introduce an extra option
--with-libz-prefix which allows us to provide the location of
the zlib library we want to use during the build.

config/ChangeLog:

        * zlib.m4 (AM_ZLIB): Add --with-libz-prefix option support.

I didn't see any file in the GCC project that uses this macro,
so for the GCC repository, the change to zlib.m4 is it. But
I am also attaching to this email a copy of the patch that
will be applied to the binutils-gdb.git repository, with all
configury using this macro being re-generated - mostly for info,
also as a heads-up to both binutils and GDB.

This was tested by regenerating all autoconf/automake files in
the binutils-gdb project, and rebuilding GDB, using the following
combinations:

  --with-zlib (system zlib used)
  --with-libz-prefix=/zlib/prefix (specific zlib linked in)
  --with-zlib --with-libz-prefix=/zlib/prefix (specific zlib linked in)

  --without-zlib (zlib support turned off)
  --without-zlib --with-zlib-prefix (zlib support turned off)

  --with-zlib (no system zlib available, configure fails with expected error)
  --with-zlib --with-libz-prefix=/invalid/zlib/prefix
              (no system zlib, configure fails with same error)

OK to commit?

Thank you!
  

Comments

Tristan Gingold Jan. 7, 2015, 4 p.m. UTC | #1
> On 07 Jan 2015, at 15:45, Joel Brobecker <brobecker@adacore.com> wrote:
> 
> Hello,
> 
> This patch enhances config/zlib.m4 to introduce an extra option
> --with-libz-prefix which allows us to provide the location of
> the zlib library we want to use during the build.

I prefer the gcc way to provide external library:

--with-zlib -> system zlib used
--with-zlib=pathname -> zlib from pathname is used

I have never needed different include and lib paths, but
this is supported by gcc.

(Furthermore, I think that --with-zlib vs --with-libz-prefix is confusing).

Cf:

--with-gmp=pathname
--with-gmp-include=pathname
--with-gmp-lib=pathname
--with-mpfr=pathname
--with-mpfr-include=pathname
--with-mpfr-lib=pathname
--with-mpc=pathname
--with-mpc-include=pathname
--with-mpc-lib=pathname
If you want to build GCC but do not have the GMP library, the MPFR library and/or the MPC library installed in a standard location and do not have their sources present in the GCC source tree then you can explicitly specify the directory where they are installed (‘--with-gmp=gmpinstalldir’, ‘--with-mpfr=mpfrinstalldir’, ‘--with-mpc=mpcinstalldir’). The --with-gmp=gmpinstalldir option is shorthand for --with-gmp-lib=gmpinstalldir/lib and --with-gmp-include=gmpinstalldir/include. Likewise the --with-mpfr=mpfrinstalldir option is shorthand for --with-mpfr-lib=mpfrinstalldir/lib and --with-mpfr-include=mpfrinstalldir/include, also the --with-mpc=mpcinstalldir option is shorthand for --with-mpc-lib=mpcinstalldir/lib and --with-mpc-include=mpcinstalldir/include. If these shorthand assumptions are not correct, you can use the explicit include and lib options directly. You might also need to ensure the shared libraries can be found by the dynamic linker when building and using GCC, for example by setting the runtime shared library path variable (LD_LIBRARY_PATH on GNU/Linux and Solaris systems).
These flags are applicable to the host platform only. When building a cross compiler, they will not be used to configure target libraries.
  
Joel Brobecker Jan. 7, 2015, 5:02 p.m. UTC | #2
> > This patch enhances config/zlib.m4 to introduce an extra option
> > --with-libz-prefix which allows us to provide the location of
> > the zlib library we want to use during the build.
> 
> I prefer the gcc way to provide external library:
> 
> --with-zlib -> system zlib used
> --with-zlib=pathname -> zlib from pathname is used

Unfortunately, we took a different route with GDB (with-...-prefix).
For instance:

  --with-libiconv-prefix
  --with-liblzma-prefix
  --with-libbabeltrace-prefix

We already have a really nice macro that takes care of a lot of
configury for us with respect to lib depenencies, which I see
in gcc's root configure.ac that gmp/mpfr/mpc options is done
via specific code.

What I'm getting at is that, to achieve your prefered option
(which I agree is more elegant), it would take a significant
effort.
  
Joel Brobecker Jan. 21, 2015, 7:47 a.m. UTC | #3
Thank you! :)

On Wed, Jan 07, 2015 at 06:45:48PM +0400, Joel Brobecker wrote:
> Hello,
> 
> This patch enhances config/zlib.m4 to introduce an extra option
> --with-libz-prefix which allows us to provide the location of
> the zlib library we want to use during the build.
> 
> config/ChangeLog:
> 
>         * zlib.m4 (AM_ZLIB): Add --with-libz-prefix option support.
> 
> I didn't see any file in the GCC project that uses this macro,
> so for the GCC repository, the change to zlib.m4 is it. But
> I am also attaching to this email a copy of the patch that
> will be applied to the binutils-gdb.git repository, with all
> configury using this macro being re-generated - mostly for info,
> also as a heads-up to both binutils and GDB.
> 
> This was tested by regenerating all autoconf/automake files in
> the binutils-gdb project, and rebuilding GDB, using the following
> combinations:
> 
>   --with-zlib (system zlib used)
>   --with-libz-prefix=/zlib/prefix (specific zlib linked in)
>   --with-zlib --with-libz-prefix=/zlib/prefix (specific zlib linked in)
> 
>   --without-zlib (zlib support turned off)
>   --without-zlib --with-zlib-prefix (zlib support turned off)
> 
>   --with-zlib (no system zlib available, configure fails with expected error)
>   --with-zlib --with-libz-prefix=/invalid/zlib/prefix
>               (no system zlib, configure fails with same error)
> 
> OK to commit?
> 
> Thank you!
> -- 
> Joel
> 
> ---
>  config/zlib.m4 | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/config/zlib.m4 b/config/zlib.m4
> index b017499..1581124 100644
> --- a/config/zlib.m4
> +++ b/config/zlib.m4
> @@ -9,8 +9,15 @@ AC_DEFUN([AM_ZLIB],
>      [], [with_zlib=auto])
>  
>    if test "$with_zlib" != "no"; then
> -    AC_SEARCH_LIBS(zlibVersion, z, [AC_CHECK_HEADERS(zlib.h)])
> -    if test "$with_zlib" = "yes" -a "$ac_cv_header_zlib_h" != "yes"; then
> +    AC_LIB_HAVE_LINKFLAGS([z], [], [#include "zlib.h";],
> +                          [int ret = deflateInit(NULL, 1);])
> +    if test "$HAVE_LIBZ" = "yes"; then
> +      # Make sure HAVE_ZLIB_H gets defined.  Some code uses that over
> +      # HAVE_LIBZ, since initially we were only defining HAVE_ZLIB_H.
> +      AC_CHECK_HEADERS(zlib.h)
> +      LIBS="$LIBS $LIBZ"
> +    fi
> +    if test "$with_zlib" = "yes" -a "$HAVE_LIBZ" != "yes"; then
>        AC_MSG_ERROR([zlib (libz) library was explicitly requested but not found])
>      fi
>    fi
> -- 
> 1.9.1

> >From 9dfb8ddb97c6dc56a5e1482e7029120d07dc07c8 Mon Sep 17 00:00:00 2001
> From: Joel Brobecker <brobecker@adacore.com>
> Date: Wed, 7 Jan 2015 14:47:51 +0400
> Subject: [PATCH] config/zlib.m4: Add support for --with-libz-prefix
> 
> This patch enhances config/zlib.m4 to introduce an extra option
> --with-libz-prefix which allows us to provide the location of
> the zlib library we want to use during the build.
> 
> config/ChangeLog:
> 
>         * zlib.m4 (AM_ZLIB): Add --with-libz-prefix option support.
> 
> bfd/ChangeLog:
> 
>         * Makefile.in, aclocal.m4, config.in, configure: Regenerate.
> 
> bfd/doc/ChangeLog:
> 
>         * doc/Makefile.in: Regenerate.
> 
> binutils/ChangeLog:
> 
>         * Makefile.in, config.in, configure: Regenerate.
> 
> binutils/doc/ChangeLog:
> 
>         * Makefile.in: Regenerate.
> 
> gas/ChangeLog:
> 
>         * Makefile.in, aclocal.m4, config.in, configure, doc/Makefile.in:
>         Regenerate.
> 
> gdb/ChangeLog:
> 
>         * config.in, configure: Regenerate.
> 
> gold/ChangeLog:
> 
>         * Makefile.in, aclocal.m4, config.in, configure,
>         testsuite/Makefile.in: Regenerate.
> 
> ld/ChangeLog:
> 
>         * Makefile.in, aclocal.m4, config.in, configure: Regenerate.
> 
> sim/common/ChangeLog:
> 
>         * acinclude.m4, config.in, configure: Regenerate.
> 
> sim/ppc/ChangeLog:
> 
>         * config.in, configure: Regenerate.
> 
> This was tested by regenerating all autoconf/automake files in
> the binutils-gdb project, and rebuilding GDB, using the following
> combinations:
> 
>   --with-zlib (system zlib used)
>   --with-libz-prefix=/zlib/prefix (specific zlib linked in)
>   --with-zlib --with-libz-prefix=/zlib/prefix (specific zlib linked in)
> 
>   --without-zlib (zlib support turned off)
>   --without-zlib --with-zlib-prefix (zlib support turned off)
> 
>   --with-zlib (no system zlib available, configure fails with expected error)
>       --with-zlib --with-libz-prefix=/invalid/zlib/prefix
>                   (no system zlib, configure fails with same error)
> ---
>  bfd/Makefile.in            |   6 +
>  bfd/aclocal.m4             |   3 +
>  bfd/config.in              |   3 +
>  bfd/configure              | 669 +++++++++++++++++++++++++++---
>  bfd/doc/Makefile.in        |   6 +
>  binutils/Makefile.in       |   3 +
>  binutils/config.in         |   3 +
>  binutils/configure         | 652 ++++++++++++++++++++++++------
>  binutils/doc/Makefile.in   |   3 +
>  config/zlib.m4             |  11 +-
>  gas/Makefile.in            |   6 +
>  gas/aclocal.m4             |   3 +
>  gas/config.in              |   3 +
>  gas/configure              | 669 +++++++++++++++++++++++++++---
>  gas/doc/Makefile.in        |   6 +
>  gdb/config.in              |   3 +
>  gdb/configure              | 986 ++++++++++++++++++++++++++++++++-------------
>  gold/Makefile.in           |   6 +
>  gold/aclocal.m4            |   3 +
>  gold/config.in             |   3 +
>  gold/configure             | 666 ++++++++++++++++++++++++++++--
>  gold/testsuite/Makefile.in |   6 +
>  ld/Makefile.in             |   6 +
>  ld/aclocal.m4              |   3 +
>  ld/config.in               |   3 +
>  ld/configure               | 669 +++++++++++++++++++++++++++---
>  sim/common/acinclude.m4    |   3 +
>  sim/common/config.in       |   3 +
>  sim/common/configure       | 671 +++++++++++++++++++++++++++---
>  sim/ppc/config.in          |   3 +
>  sim/ppc/configure          | 697 ++++++++++++++++++++++++++++++--
>  31 files changed, 5107 insertions(+), 670 deletions(-)
> 
> diff --git a/bfd/Makefile.in b/bfd/Makefile.in
> index 2c9435c..934d62a 100644
> --- a/bfd/Makefile.in
> +++ b/bfd/Makefile.in
> @@ -70,6 +70,9 @@ am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
>  	$(top_srcdir)/../config/gettext-sister.m4 \
>  	$(top_srcdir)/../config/largefile.m4 \
>  	$(top_srcdir)/../config/lead-dot.m4 \
> +	$(top_srcdir)/../config/lib-ld.m4 \
> +	$(top_srcdir)/../config/lib-link.m4 \
> +	$(top_srcdir)/../config/lib-prefix.m4 \
>  	$(top_srcdir)/../config/nls.m4 \
>  	$(top_srcdir)/../config/override.m4 \
>  	$(top_srcdir)/../config/plugins.m4 \
> @@ -204,6 +207,7 @@ FGREP = @FGREP@
>  GENCAT = @GENCAT@
>  GMSGFMT = @GMSGFMT@
>  GREP = @GREP@
> +HAVE_LIBZ = @HAVE_LIBZ@
>  HDEFINES = @HDEFINES@
>  INCINTL = @INCINTL@
>  INSTALL = @INSTALL@
> @@ -220,9 +224,11 @@ LIBM = @LIBM@
>  LIBOBJS = @LIBOBJS@
>  LIBS = @LIBS@
>  LIBTOOL = @LIBTOOL@
> +LIBZ = @LIBZ@
>  LIPO = @LIPO@
>  LN_S = @LN_S@
>  LTLIBOBJS = @LTLIBOBJS@
> +LTLIBZ = @LTLIBZ@
>  MAINT = @MAINT@
>  MAKEINFO = @MAKEINFO@
>  MKDIR_P = @MKDIR_P@
> diff --git a/bfd/aclocal.m4 b/bfd/aclocal.m4
> index d9e743e..358fe09 100644
> --- a/bfd/aclocal.m4
> +++ b/bfd/aclocal.m4
> @@ -973,6 +973,9 @@ m4_include([../config/depstand.m4])
>  m4_include([../config/gettext-sister.m4])
>  m4_include([../config/largefile.m4])
>  m4_include([../config/lead-dot.m4])
> +m4_include([../config/lib-ld.m4])
> +m4_include([../config/lib-link.m4])
> +m4_include([../config/lib-prefix.m4])
>  m4_include([../config/nls.m4])
>  m4_include([../config/override.m4])
>  m4_include([../config/plugins.m4])
> diff --git a/bfd/config.in b/bfd/config.in
> index b911bf6..cf1a97a 100644
> --- a/bfd/config.in
> +++ b/bfd/config.in
> @@ -125,6 +125,9 @@
>  /* Define to 1 if you have the <inttypes.h> header file. */
>  #undef HAVE_INTTYPES_H
>  
> +/* Define if you have the z library. */
> +#undef HAVE_LIBZ
> +
>  /* Define if <sys/procfs.h> has lwpstatus_t. */
>  #undef HAVE_LWPSTATUS_T
>  
> diff --git a/bfd/configure b/bfd/configure
> index f7a9e81..8c92742 100755
> --- a/bfd/configure
> +++ b/bfd/configure
> @@ -620,6 +620,9 @@ SHARED_LDFLAGS
>  LIBM
>  COREFLAG
>  COREFILE
> +LTLIBZ
> +LIBZ
> +HAVE_LIBZ
>  EXEEXT_FOR_BUILD
>  CC_FOR_BUILD
>  BFD_HOSTPTR_T
> @@ -798,6 +801,8 @@ enable_maintainer_mode
>  enable_install_libbfd
>  enable_nls
>  with_zlib
> +enable_rpath
> +with_libz_prefix
>  '
>        ac_precious_vars='build_alias
>  host_alias
> @@ -1449,6 +1454,7 @@ Optional Features:
>  			  (and sometimes confusing) to the casual installer
>    --enable-install-libbfd controls installation of libbfd and related headers
>    --disable-nls           do not use Native Language Support
> +  --disable-rpath         do not hardcode runtime library paths
>  
>  Optional Packages:
>    --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
> @@ -1464,6 +1470,9 @@ Optional Packages:
>                            Binutils"
>    --with-bugurl=URL       Direct users to URL to report a bug
>    --with-zlib             include zlib support (auto/yes/no) default=auto
> +  --with-gnu-ld           assume the C compiler uses GNU ld default=no
> +  --with-libz-prefix[=DIR]  search for libz in DIR/include and DIR/lib
> +  --without-libz-prefix     don't search for libz in includedir and libdir
>  
>  Some influential environment variables:
>    CC          C compiler command
> @@ -11421,7 +11430,7 @@ else
>    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>    lt_status=$lt_dlunknown
>    cat > conftest.$ac_ext <<_LT_EOF
> -#line 11424 "configure"
> +#line 11433 "configure"
>  #include "confdefs.h"
>  
>  #if HAVE_DLFCN_H
> @@ -11527,7 +11536,7 @@ else
>    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>    lt_status=$lt_dlunknown
>    cat > conftest.$ac_ext <<_LT_EOF
> -#line 11530 "configure"
> +#line 11539 "configure"
>  #include "confdefs.h"
>  
>  #if HAVE_DLFCN_H
> @@ -13854,6 +13863,164 @@ _ACEOF
>  # Link in zlib if we can.  This allows us to read compressed debug sections.
>  # This is used only by compress.c.
>  
> +      if test "X$prefix" = "XNONE"; then
> +    acl_final_prefix="$ac_default_prefix"
> +  else
> +    acl_final_prefix="$prefix"
> +  fi
> +  if test "X$exec_prefix" = "XNONE"; then
> +    acl_final_exec_prefix='${prefix}'
> +  else
> +    acl_final_exec_prefix="$exec_prefix"
> +  fi
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
> +  prefix="$acl_save_prefix"
> +
> +
> +# Check whether --with-gnu-ld was given.
> +if test "${with_gnu_ld+set}" = set; then :
> +  withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
> +else
> +  with_gnu_ld=no
> +fi
> +
> +# Prepare PATH_SEPARATOR.
> +# The user is always right.
> +if test "${PATH_SEPARATOR+set}" != set; then
> +  echo "#! /bin/sh" >conf$$.sh
> +  echo  "exit 0"   >>conf$$.sh
> +  chmod +x conf$$.sh
> +  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
> +    PATH_SEPARATOR=';'
> +  else
> +    PATH_SEPARATOR=:
> +  fi
> +  rm -f conf$$.sh
> +fi
> +ac_prog=ld
> +if test "$GCC" = yes; then
> +  # Check if gcc -print-prog-name=ld gives a path.
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by GCC" >&5
> +$as_echo_n "checking for ld used by GCC... " >&6; }
> +  case $host in
> +  *-*-mingw*)
> +    # gcc leaves a trailing carriage return which upsets mingw
> +    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
> +  *)
> +    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
> +  esac
> +  case $ac_prog in
> +    # Accept absolute paths.
> +    [\\/]* | [A-Za-z]:[\\/]*)
> +      re_direlt='/[^/][^/]*/\.\./'
> +      # Canonicalize the path of ld
> +      ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
> +      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
> +	ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
> +      done
> +      test -z "$LD" && LD="$ac_prog"
> +      ;;
> +  "")
> +    # If it fails, then pretend we aren't using GCC.
> +    ac_prog=ld
> +    ;;
> +  *)
> +    # If it is relative, then search for the first ld in PATH.
> +    with_gnu_ld=unknown
> +    ;;
> +  esac
> +elif test "$with_gnu_ld" = yes; then
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
> +$as_echo_n "checking for GNU ld... " >&6; }
> +else
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
> +$as_echo_n "checking for non-GNU ld... " >&6; }
> +fi
> +if test "${acl_cv_path_LD+set}" = set; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +  if test -z "$LD"; then
> +  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
> +  for ac_dir in $PATH; do
> +    test -z "$ac_dir" && ac_dir=.
> +    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
> +      acl_cv_path_LD="$ac_dir/$ac_prog"
> +      # Check to see if the program is GNU ld.  I'd rather use --version,
> +      # but apparently some GNU ld's only accept -v.
> +      # Break only if it was the GNU/non-GNU ld that we prefer.
> +      if "$acl_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
> +	test "$with_gnu_ld" != no && break
> +      else
> +	test "$with_gnu_ld" != yes && break
> +      fi
> +    fi
> +  done
> +  IFS="$ac_save_ifs"
> +else
> +  acl_cv_path_LD="$LD" # Let the user override the test with a path.
> +fi
> +fi
> +
> +LD="$acl_cv_path_LD"
> +if test -n "$LD"; then
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
> +$as_echo "$LD" >&6; }
> +else
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
> +$as_echo "no" >&6; }
> +fi
> +test -z "$LD" && as_fn_error "no acceptable ld found in \$PATH" "$LINENO" 5
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
> +$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; }
> +if test "${acl_cv_prog_gnu_ld+set}" = set; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +  # I'd rather use --version here, but apparently some GNU ld's only accept -v.
> +if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
> +  acl_cv_prog_gnu_ld=yes
> +else
> +  acl_cv_prog_gnu_ld=no
> +fi
> +fi
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_prog_gnu_ld" >&5
> +$as_echo "$acl_cv_prog_gnu_ld" >&6; }
> +with_gnu_ld=$acl_cv_prog_gnu_ld
> +
> +
> +
> +                                                { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5
> +$as_echo_n "checking for shared library run path origin... " >&6; }
> +if test "${acl_cv_rpath+set}" = set; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +
> +    CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
> +    ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
> +    . ./conftest.sh
> +    rm -f ./conftest.sh
> +    acl_cv_rpath=done
> +
> +fi
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_rpath" >&5
> +$as_echo "$acl_cv_rpath" >&6; }
> +  wl="$acl_cv_wl"
> +  libext="$acl_cv_libext"
> +  shlibext="$acl_cv_shlibext"
> +  hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
> +  hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
> +  hardcode_direct="$acl_cv_hardcode_direct"
> +  hardcode_minus_L="$acl_cv_hardcode_minus_L"
> +    # Check whether --enable-rpath was given.
> +if test "${enable_rpath+set}" = set; then :
> +  enableval=$enable_rpath; :
> +else
> +  enable_rpath=yes
> +fi
> +
> +
> +
>    # See if the user specified whether he wants zlib support or not.
>  
>  # Check whether --with-zlib was given.
> @@ -13865,60 +14032,472 @@ fi
>  
>  
>    if test "$with_zlib" != "no"; then
> -    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing zlibVersion" >&5
> -$as_echo_n "checking for library containing zlibVersion... " >&6; }
> -if test "${ac_cv_search_zlibVersion+set}" = set; then :
> +
> +
> +
> +
> +
> +
> +
> +
> +    use_additional=yes
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +
> +    eval additional_includedir=\"$includedir\"
> +    eval additional_libdir=\"$libdir\"
> +
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +
> +# Check whether --with-libz-prefix was given.
> +if test "${with_libz_prefix+set}" = set; then :
> +  withval=$with_libz_prefix;
> +    if test "X$withval" = "Xno"; then
> +      use_additional=no
> +    else
> +      if test "X$withval" = "X"; then
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +
> +          eval additional_includedir=\"$includedir\"
> +          eval additional_libdir=\"$libdir\"
> +
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +      else
> +        additional_includedir="$withval/include"
> +        additional_libdir="$withval/lib"
> +      fi
> +    fi
> +
> +fi
> +
> +      LIBZ=
> +  LTLIBZ=
> +  INCZ=
> +  rpathdirs=
> +  ltrpathdirs=
> +  names_already_handled=
> +  names_next_round='z '
> +  while test -n "$names_next_round"; do
> +    names_this_round="$names_next_round"
> +    names_next_round=
> +    for name in $names_this_round; do
> +      already_handled=
> +      for n in $names_already_handled; do
> +        if test "$n" = "$name"; then
> +          already_handled=yes
> +          break
> +        fi
> +      done
> +      if test -z "$already_handled"; then
> +        names_already_handled="$names_already_handled $name"
> +                        uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
> +        eval value=\"\$HAVE_LIB$uppername\"
> +        if test -n "$value"; then
> +          if test "$value" = yes; then
> +            eval value=\"\$LIB$uppername\"
> +            test -z "$value" || LIBZ="${LIBZ}${LIBZ:+ }$value"
> +            eval value=\"\$LTLIB$uppername\"
> +            test -z "$value" || LTLIBZ="${LTLIBZ}${LTLIBZ:+ }$value"
> +          else
> +                                    :
> +          fi
> +        else
> +                              found_dir=
> +          found_la=
> +          found_so=
> +          found_a=
> +          if test $use_additional = yes; then
> +            if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then
> +              found_dir="$additional_libdir"
> +              found_so="$additional_libdir/lib$name.$shlibext"
> +              if test -f "$additional_libdir/lib$name.la"; then
> +                found_la="$additional_libdir/lib$name.la"
> +              fi
> +            else
> +              if test -f "$additional_libdir/lib$name.$libext"; then
> +                found_dir="$additional_libdir"
> +                found_a="$additional_libdir/lib$name.$libext"
> +                if test -f "$additional_libdir/lib$name.la"; then
> +                  found_la="$additional_libdir/lib$name.la"
> +                fi
> +              fi
> +            fi
> +          fi
> +          if test "X$found_dir" = "X"; then
> +            for x in $LDFLAGS $LTLIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +              case "$x" in
> +                -L*)
> +                  dir=`echo "X$x" | sed -e 's/^X-L//'`
> +                  if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then
> +                    found_dir="$dir"
> +                    found_so="$dir/lib$name.$shlibext"
> +                    if test -f "$dir/lib$name.la"; then
> +                      found_la="$dir/lib$name.la"
> +                    fi
> +                  else
> +                    if test -f "$dir/lib$name.$libext"; then
> +                      found_dir="$dir"
> +                      found_a="$dir/lib$name.$libext"
> +                      if test -f "$dir/lib$name.la"; then
> +                        found_la="$dir/lib$name.la"
> +                      fi
> +                    fi
> +                  fi
> +                  ;;
> +              esac
> +              if test "X$found_dir" != "X"; then
> +                break
> +              fi
> +            done
> +          fi
> +          if test "X$found_dir" != "X"; then
> +                        LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-L$found_dir -l$name"
> +            if test "X$found_so" != "X"; then
> +                                                        if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then
> +                                LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +              else
> +                                                                                haveit=
> +                for x in $ltrpathdirs; do
> +                  if test "X$x" = "X$found_dir"; then
> +                    haveit=yes
> +                    break
> +                  fi
> +                done
> +                if test -z "$haveit"; then
> +                  ltrpathdirs="$ltrpathdirs $found_dir"
> +                fi
> +                                if test "$hardcode_direct" = yes; then
> +                                                      LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +                else
> +                  if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then
> +                                                            LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +                                                            haveit=
> +                    for x in $rpathdirs; do
> +                      if test "X$x" = "X$found_dir"; then
> +                        haveit=yes
> +                        break
> +                      fi
> +                    done
> +                    if test -z "$haveit"; then
> +                      rpathdirs="$rpathdirs $found_dir"
> +                    fi
> +                  else
> +                                                                                haveit=
> +                    for x in $LDFLAGS $LIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                      if test "X$x" = "X-L$found_dir"; then
> +                        haveit=yes
> +                        break
> +                      fi
> +                    done
> +                    if test -z "$haveit"; then
> +                      LIBZ="${LIBZ}${LIBZ:+ }-L$found_dir"
> +                    fi
> +                    if test "$hardcode_minus_L" != no; then
> +                                                                                        LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +                    else
> +                                                                                                                                                                                LIBZ="${LIBZ}${LIBZ:+ }-l$name"
> +                    fi
> +                  fi
> +                fi
> +              fi
> +            else
> +              if test "X$found_a" != "X"; then
> +                                LIBZ="${LIBZ}${LIBZ:+ }$found_a"
> +              else
> +                                                LIBZ="${LIBZ}${LIBZ:+ }-L$found_dir -l$name"
> +              fi
> +            fi
> +                        additional_includedir=
> +            case "$found_dir" in
> +              */lib | */lib/)
> +                basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'`
> +                additional_includedir="$basedir/include"
> +                ;;
> +            esac
> +            if test "X$additional_includedir" != "X"; then
> +                                                                                                                if test "X$additional_includedir" != "X/usr/include"; then
> +                haveit=
> +                if test "X$additional_includedir" = "X/usr/local/include"; then
> +                  if test -n "$GCC"; then
> +                    case $host_os in
> +                      linux*) haveit=yes;;
> +                    esac
> +                  fi
> +                fi
> +                if test -z "$haveit"; then
> +                  for x in $CPPFLAGS $INCZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                    if test "X$x" = "X-I$additional_includedir"; then
> +                      haveit=yes
> +                      break
> +                    fi
> +                  done
> +                  if test -z "$haveit"; then
> +                    if test -d "$additional_includedir"; then
> +                                            INCZ="${INCZ}${INCZ:+ }-I$additional_includedir"
> +                    fi
> +                  fi
> +                fi
> +              fi
> +            fi
> +                        if test -n "$found_la"; then
> +                                                        save_libdir="$libdir"
> +              case "$found_la" in
> +                */* | *\\*) . "$found_la" ;;
> +                *) . "./$found_la" ;;
> +              esac
> +              libdir="$save_libdir"
> +                            for dep in $dependency_libs; do
> +                case "$dep" in
> +                  -L*)
> +                    additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
> +                                                                                                                                                                if test "X$additional_libdir" != "X/usr/lib"; then
> +                      haveit=
> +                      if test "X$additional_libdir" = "X/usr/local/lib"; then
> +                        if test -n "$GCC"; then
> +                          case $host_os in
> +                            linux*) haveit=yes;;
> +                          esac
> +                        fi
> +                      fi
> +                      if test -z "$haveit"; then
> +                        haveit=
> +                        for x in $LDFLAGS $LIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                          if test "X$x" = "X-L$additional_libdir"; then
> +                            haveit=yes
> +                            break
> +                          fi
> +                        done
> +                        if test -z "$haveit"; then
> +                          if test -d "$additional_libdir"; then
> +                                                        LIBZ="${LIBZ}${LIBZ:+ }-L$additional_libdir"
> +                          fi
> +                        fi
> +                        haveit=
> +                        for x in $LDFLAGS $LTLIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                          if test "X$x" = "X-L$additional_libdir"; then
> +                            haveit=yes
> +                            break
> +                          fi
> +                        done
> +                        if test -z "$haveit"; then
> +                          if test -d "$additional_libdir"; then
> +                                                        LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-L$additional_libdir"
> +                          fi
> +                        fi
> +                      fi
> +                    fi
> +                    ;;
> +                  -R*)
> +                    dir=`echo "X$dep" | sed -e 's/^X-R//'`
> +                    if test "$enable_rpath" != no; then
> +                                                                  haveit=
> +                      for x in $rpathdirs; do
> +                        if test "X$x" = "X$dir"; then
> +                          haveit=yes
> +                          break
> +                        fi
> +                      done
> +                      if test -z "$haveit"; then
> +                        rpathdirs="$rpathdirs $dir"
> +                      fi
> +                                                                  haveit=
> +                      for x in $ltrpathdirs; do
> +                        if test "X$x" = "X$dir"; then
> +                          haveit=yes
> +                          break
> +                        fi
> +                      done
> +                      if test -z "$haveit"; then
> +                        ltrpathdirs="$ltrpathdirs $dir"
> +                      fi
> +                    fi
> +                    ;;
> +                  -l*)
> +                                        names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
> +                    ;;
> +                  *.la)
> +                                                                                names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
> +                    ;;
> +                  *)
> +                                        LIBZ="${LIBZ}${LIBZ:+ }$dep"
> +                    LTLIBZ="${LTLIBZ}${LTLIBZ:+ }$dep"
> +                    ;;
> +                esac
> +              done
> +            fi
> +          else
> +                                                            LIBZ="${LIBZ}${LIBZ:+ }-l$name"
> +            LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-l$name"
> +          fi
> +        fi
> +      fi
> +    done
> +  done
> +  if test "X$rpathdirs" != "X"; then
> +    if test -n "$hardcode_libdir_separator"; then
> +                        alldirs=
> +      for found_dir in $rpathdirs; do
> +        alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir"
> +      done
> +            acl_save_libdir="$libdir"
> +      libdir="$alldirs"
> +      eval flag=\"$hardcode_libdir_flag_spec\"
> +      libdir="$acl_save_libdir"
> +      LIBZ="${LIBZ}${LIBZ:+ }$flag"
> +    else
> +            for found_dir in $rpathdirs; do
> +        acl_save_libdir="$libdir"
> +        libdir="$found_dir"
> +        eval flag=\"$hardcode_libdir_flag_spec\"
> +        libdir="$acl_save_libdir"
> +        LIBZ="${LIBZ}${LIBZ:+ }$flag"
> +      done
> +    fi
> +  fi
> +  if test "X$ltrpathdirs" != "X"; then
> +            for found_dir in $ltrpathdirs; do
> +      LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-R$found_dir"
> +    done
> +  fi
> +
> +
> +        ac_save_CPPFLAGS="$CPPFLAGS"
> +
> +  for element in $INCZ; do
> +    haveit=
> +    for x in $CPPFLAGS; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +      if test "X$x" = "X$element"; then
> +        haveit=yes
> +        break
> +      fi
> +    done
> +    if test -z "$haveit"; then
> +      CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element"
> +    fi
> +  done
> +
> +
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libz" >&5
> +$as_echo_n "checking for libz... " >&6; }
> +if test "${ac_cv_libz+set}" = set; then :
>    $as_echo_n "(cached) " >&6
>  else
> -  ac_func_search_save_LIBS=$LIBS
> -cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> -/* end confdefs.h.  */
>  
> -/* Override any GCC internal prototype to avoid an error.
> -   Use char because int might match the return type of a GCC
> -   builtin and then its argument prototype would still apply.  */
> -#ifdef __cplusplus
> -extern "C"
> -#endif
> -char zlibVersion ();
> +    ac_save_LIBS="$LIBS"
> +    LIBS="$LIBS $LIBZ"
> +    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> +/* end confdefs.h.  */
> +#include "zlib.h";
>  int
>  main ()
>  {
> -return zlibVersion ();
> +int ret = deflateInit(NULL, 1);
>    ;
>    return 0;
>  }
>  _ACEOF
> -for ac_lib in '' z; do
> -  if test -z "$ac_lib"; then
> -    ac_res="none required"
> -  else
> -    ac_res=-l$ac_lib
> -    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
> -  fi
> -  if ac_fn_c_try_link "$LINENO"; then :
> -  ac_cv_search_zlibVersion=$ac_res
> +if ac_fn_c_try_link "$LINENO"; then :
> +  ac_cv_libz=yes
> +else
> +  ac_cv_libz=no
>  fi
>  rm -f core conftest.err conftest.$ac_objext \
> -    conftest$ac_exeext
> -  if test "${ac_cv_search_zlibVersion+set}" = set; then :
> -  break
> -fi
> -done
> -if test "${ac_cv_search_zlibVersion+set}" = set; then :
> +    conftest$ac_exeext conftest.$ac_ext
> +    LIBS="$ac_save_LIBS"
>  
> -else
> -  ac_cv_search_zlibVersion=no
>  fi
> -rm conftest.$ac_ext
> -LIBS=$ac_func_search_save_LIBS
> -fi
> -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_zlibVersion" >&5
> -$as_echo "$ac_cv_search_zlibVersion" >&6; }
> -ac_res=$ac_cv_search_zlibVersion
> -if test "$ac_res" != no; then :
> -  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
> -  for ac_header in zlib.h
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_libz" >&5
> +$as_echo "$ac_cv_libz" >&6; }
> +  if test "$ac_cv_libz" = yes; then
> +    HAVE_LIBZ=yes
> +
> +$as_echo "#define HAVE_LIBZ 1" >>confdefs.h
> +
> +    { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libz" >&5
> +$as_echo_n "checking how to link with libz... " >&6; }
> +    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBZ" >&5
> +$as_echo "$LIBZ" >&6; }
> +  else
> +    HAVE_LIBZ=no
> +            CPPFLAGS="$ac_save_CPPFLAGS"
> +    LIBZ=
> +    LTLIBZ=
> +  fi
> +
> +
> +
> +
> +
> +
> +    if test "$HAVE_LIBZ" = "yes"; then
> +      # Make sure HAVE_ZLIB_H gets defined.  Some code uses that over
> +      # HAVE_LIBZ, since initially we were only defining HAVE_ZLIB_H.
> +      for ac_header in zlib.h
>  do :
>    ac_fn_c_check_header_mongrel "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default"
>  if test "x$ac_cv_header_zlib_h" = x""yes; then :
> @@ -13930,9 +14509,9 @@ fi
>  
>  done
>  
> -fi
> -
> -    if test "$with_zlib" = "yes" -a "$ac_cv_header_zlib_h" != "yes"; then
> +      LIBS="$LIBS $LIBZ"
> +    fi
> +    if test "$with_zlib" = "yes" -a "$HAVE_LIBZ" != "yes"; then
>        as_fn_error "zlib (libz) library was explicitly requested but not found" "$LINENO" 5
>      fi
>    fi
> diff --git a/bfd/doc/Makefile.in b/bfd/doc/Makefile.in
> index 3be6a5e..7257ed9 100644
> --- a/bfd/doc/Makefile.in
> +++ b/bfd/doc/Makefile.in
> @@ -66,6 +66,9 @@ am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
>  	$(top_srcdir)/../config/gettext-sister.m4 \
>  	$(top_srcdir)/../config/largefile.m4 \
>  	$(top_srcdir)/../config/lead-dot.m4 \
> +	$(top_srcdir)/../config/lib-ld.m4 \
> +	$(top_srcdir)/../config/lib-link.m4 \
> +	$(top_srcdir)/../config/lib-prefix.m4 \
>  	$(top_srcdir)/../config/nls.m4 \
>  	$(top_srcdir)/../config/override.m4 \
>  	$(top_srcdir)/../config/plugins.m4 \
> @@ -164,6 +167,7 @@ FGREP = @FGREP@
>  GENCAT = @GENCAT@
>  GMSGFMT = @GMSGFMT@
>  GREP = @GREP@
> +HAVE_LIBZ = @HAVE_LIBZ@
>  HDEFINES = @HDEFINES@
>  INCINTL = @INCINTL@
>  INSTALL = @INSTALL@
> @@ -180,9 +184,11 @@ LIBM = @LIBM@
>  LIBOBJS = @LIBOBJS@
>  LIBS = @LIBS@
>  LIBTOOL = @LIBTOOL@
> +LIBZ = @LIBZ@
>  LIPO = @LIPO@
>  LN_S = @LN_S@
>  LTLIBOBJS = @LTLIBOBJS@
> +LTLIBZ = @LTLIBZ@
>  MAINT = @MAINT@
>  MAKEINFO = @MAKEINFO@
>  MKDIR_P = @MKDIR_P@
> diff --git a/binutils/Makefile.in b/binutils/Makefile.in
> index aaf4d51..05fb968 100644
> --- a/binutils/Makefile.in
> +++ b/binutils/Makefile.in
> @@ -316,6 +316,7 @@ FGREP = @FGREP@
>  GENCAT = @GENCAT@
>  GMSGFMT = @GMSGFMT@
>  GREP = @GREP@
> +HAVE_LIBZ = @HAVE_LIBZ@
>  HDEFINES = @HDEFINES@
>  INCINTL = @INCINTL@
>  INSTALL = @INSTALL@
> @@ -335,10 +336,12 @@ LIBINTL_DEP = @LIBINTL_DEP@
>  LIBOBJS = @LIBOBJS@
>  LIBS = @LIBS@
>  LIBTOOL = @LIBTOOL@
> +LIBZ = @LIBZ@
>  LIPO = @LIPO@
>  LN_S = @LN_S@
>  LTLIBICONV = @LTLIBICONV@
>  LTLIBOBJS = @LTLIBOBJS@
> +LTLIBZ = @LTLIBZ@
>  MAINT = @MAINT@
>  MAKEINFO = @MAKEINFO@
>  MKDIR_P = @MKDIR_P@
> diff --git a/binutils/config.in b/binutils/config.in
> index a0ed034..dd7d832 100644
> --- a/binutils/config.in
> +++ b/binutils/config.in
> @@ -102,6 +102,9 @@
>  /* Define if your <locale.h> file defines LC_MESSAGES. */
>  #undef HAVE_LC_MESSAGES
>  
> +/* Define if you have the z library. */
> +#undef HAVE_LIBZ
> +
>  /* Define to 1 if you have the <limits.h> header file. */
>  #undef HAVE_LIMITS_H
>  
> diff --git a/binutils/configure b/binutils/configure
> index b960c19..8280dd8 100755
> --- a/binutils/configure
> +++ b/binutils/configure
> @@ -618,6 +618,9 @@ BUILD_NLMCONV
>  NLMCONV_DEFS
>  LTLIBICONV
>  LIBICONV
> +LTLIBZ
> +LIBZ
> +HAVE_LIBZ
>  ALLOCA
>  DEMANGLER_NAME
>  EXEEXT_FOR_BUILD
> @@ -779,6 +782,7 @@ enable_nls
>  enable_maintainer_mode
>  with_zlib
>  enable_rpath
> +with_libz_prefix
>  with_libiconv_prefix
>  '
>        ac_precious_vars='build_alias
> @@ -1441,6 +1445,8 @@ Optional Packages:
>    --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
>    --with-zlib             include zlib support (auto/yes/no) default=auto
>    --with-gnu-ld           assume the C compiler uses GNU ld default=no
> +  --with-libz-prefix[=DIR]  search for libz in DIR/include and DIR/lib
> +  --without-libz-prefix     don't search for libz in includedir and libdir
>    --with-libiconv-prefix[=DIR]  search for libiconv in DIR/include and DIR/lib
>    --without-libiconv-prefix     don't search for libiconv in includedir and libdir
>  
> @@ -11219,7 +11225,7 @@ else
>    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>    lt_status=$lt_dlunknown
>    cat > conftest.$ac_ext <<_LT_EOF
> -#line 11222 "configure"
> +#line 11228 "configure"
>  #include "confdefs.h"
>  
>  #if HAVE_DLFCN_H
> @@ -11325,7 +11331,7 @@ else
>    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>    lt_status=$lt_dlunknown
>    cat > conftest.$ac_ext <<_LT_EOF
> -#line 11328 "configure"
> +#line 11334 "configure"
>  #include "confdefs.h"
>  
>  #if HAVE_DLFCN_H
> @@ -13540,121 +13546,6 @@ _ACEOF
>  # sections.  This is used only by readelf.c (objdump uses bfd for
>  # reading compressed sections).
>  
> -  # See if the user specified whether he wants zlib support or not.
> -
> -# Check whether --with-zlib was given.
> -if test "${with_zlib+set}" = set; then :
> -  withval=$with_zlib;
> -else
> -  with_zlib=auto
> -fi
> -
> -
> -  if test "$with_zlib" != "no"; then
> -    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing zlibVersion" >&5
> -$as_echo_n "checking for library containing zlibVersion... " >&6; }
> -if test "${ac_cv_search_zlibVersion+set}" = set; then :
> -  $as_echo_n "(cached) " >&6
> -else
> -  ac_func_search_save_LIBS=$LIBS
> -cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> -/* end confdefs.h.  */
> -
> -/* Override any GCC internal prototype to avoid an error.
> -   Use char because int might match the return type of a GCC
> -   builtin and then its argument prototype would still apply.  */
> -#ifdef __cplusplus
> -extern "C"
> -#endif
> -char zlibVersion ();
> -int
> -main ()
> -{
> -return zlibVersion ();
> -  ;
> -  return 0;
> -}
> -_ACEOF
> -for ac_lib in '' z; do
> -  if test -z "$ac_lib"; then
> -    ac_res="none required"
> -  else
> -    ac_res=-l$ac_lib
> -    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
> -  fi
> -  if ac_fn_c_try_link "$LINENO"; then :
> -  ac_cv_search_zlibVersion=$ac_res
> -fi
> -rm -f core conftest.err conftest.$ac_objext \
> -    conftest$ac_exeext
> -  if test "${ac_cv_search_zlibVersion+set}" = set; then :
> -  break
> -fi
> -done
> -if test "${ac_cv_search_zlibVersion+set}" = set; then :
> -
> -else
> -  ac_cv_search_zlibVersion=no
> -fi
> -rm conftest.$ac_ext
> -LIBS=$ac_func_search_save_LIBS
> -fi
> -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_zlibVersion" >&5
> -$as_echo "$ac_cv_search_zlibVersion" >&6; }
> -ac_res=$ac_cv_search_zlibVersion
> -if test "$ac_res" != no; then :
> -  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
> -  for ac_header in zlib.h
> -do :
> -  ac_fn_c_check_header_mongrel "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default"
> -if test "x$ac_cv_header_zlib_h" = x""yes; then :
> -  cat >>confdefs.h <<_ACEOF
> -#define HAVE_ZLIB_H 1
> -_ACEOF
> -
> -fi
> -
> -done
> -
> -fi
> -
> -    if test "$with_zlib" = "yes" -a "$ac_cv_header_zlib_h" != "yes"; then
> -      as_fn_error "zlib (libz) library was explicitly requested but not found" "$LINENO" 5
> -    fi
> -  fi
> -
> -
> -
> -case "${host}" in
> -*-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows*)
> -
> -$as_echo "#define USE_BINARY_FOPEN 1" >>confdefs.h
> - ;;
> -esac
> -
> -# target-specific stuff:
> -
> -# Canonicalize the secondary target names.
> -if test -n "$enable_targets"; then
> -    for targ in `echo $enable_targets | sed 's/,/ /g'`
> -    do
> -	result=`$ac_config_sub $targ 2>/dev/null`
> -	if test -n "$result"; then
> -	    canon_targets="$canon_targets $result"
> -	else
> -	    # Allow targets that config.sub doesn't recognize, like "all".
> -	    canon_targets="$canon_targets $targ"
> -	fi
> -    done
> -fi
> -
> -ac_fn_c_check_header_mongrel "$LINENO" "iconv.h" "ac_cv_header_iconv_h" "$ac_includes_default"
> -if test "x$ac_cv_header_iconv_h" = x""yes; then :
> -
> -fi
> -
> -
> -
>        if test "X$prefix" = "XNONE"; then
>      acl_final_prefix="$ac_default_prefix"
>    else
> @@ -13813,6 +13704,533 @@ fi
>  
>  
>  
> +  # See if the user specified whether he wants zlib support or not.
> +
> +# Check whether --with-zlib was given.
> +if test "${with_zlib+set}" = set; then :
> +  withval=$with_zlib;
> +else
> +  with_zlib=auto
> +fi
> +
> +
> +  if test "$with_zlib" != "no"; then
> +
> +
> +
> +
> +
> +
> +
> +
> +    use_additional=yes
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +
> +    eval additional_includedir=\"$includedir\"
> +    eval additional_libdir=\"$libdir\"
> +
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +
> +# Check whether --with-libz-prefix was given.
> +if test "${with_libz_prefix+set}" = set; then :
> +  withval=$with_libz_prefix;
> +    if test "X$withval" = "Xno"; then
> +      use_additional=no
> +    else
> +      if test "X$withval" = "X"; then
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +
> +          eval additional_includedir=\"$includedir\"
> +          eval additional_libdir=\"$libdir\"
> +
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +      else
> +        additional_includedir="$withval/include"
> +        additional_libdir="$withval/lib"
> +      fi
> +    fi
> +
> +fi
> +
> +      LIBZ=
> +  LTLIBZ=
> +  INCZ=
> +  rpathdirs=
> +  ltrpathdirs=
> +  names_already_handled=
> +  names_next_round='z '
> +  while test -n "$names_next_round"; do
> +    names_this_round="$names_next_round"
> +    names_next_round=
> +    for name in $names_this_round; do
> +      already_handled=
> +      for n in $names_already_handled; do
> +        if test "$n" = "$name"; then
> +          already_handled=yes
> +          break
> +        fi
> +      done
> +      if test -z "$already_handled"; then
> +        names_already_handled="$names_already_handled $name"
> +                        uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
> +        eval value=\"\$HAVE_LIB$uppername\"
> +        if test -n "$value"; then
> +          if test "$value" = yes; then
> +            eval value=\"\$LIB$uppername\"
> +            test -z "$value" || LIBZ="${LIBZ}${LIBZ:+ }$value"
> +            eval value=\"\$LTLIB$uppername\"
> +            test -z "$value" || LTLIBZ="${LTLIBZ}${LTLIBZ:+ }$value"
> +          else
> +                                    :
> +          fi
> +        else
> +                              found_dir=
> +          found_la=
> +          found_so=
> +          found_a=
> +          if test $use_additional = yes; then
> +            if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then
> +              found_dir="$additional_libdir"
> +              found_so="$additional_libdir/lib$name.$shlibext"
> +              if test -f "$additional_libdir/lib$name.la"; then
> +                found_la="$additional_libdir/lib$name.la"
> +              fi
> +            else
> +              if test -f "$additional_libdir/lib$name.$libext"; then
> +                found_dir="$additional_libdir"
> +                found_a="$additional_libdir/lib$name.$libext"
> +                if test -f "$additional_libdir/lib$name.la"; then
> +                  found_la="$additional_libdir/lib$name.la"
> +                fi
> +              fi
> +            fi
> +          fi
> +          if test "X$found_dir" = "X"; then
> +            for x in $LDFLAGS $LTLIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +              case "$x" in
> +                -L*)
> +                  dir=`echo "X$x" | sed -e 's/^X-L//'`
> +                  if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then
> +                    found_dir="$dir"
> +                    found_so="$dir/lib$name.$shlibext"
> +                    if test -f "$dir/lib$name.la"; then
> +                      found_la="$dir/lib$name.la"
> +                    fi
> +                  else
> +                    if test -f "$dir/lib$name.$libext"; then
> +                      found_dir="$dir"
> +                      found_a="$dir/lib$name.$libext"
> +                      if test -f "$dir/lib$name.la"; then
> +                        found_la="$dir/lib$name.la"
> +                      fi
> +                    fi
> +                  fi
> +                  ;;
> +              esac
> +              if test "X$found_dir" != "X"; then
> +                break
> +              fi
> +            done
> +          fi
> +          if test "X$found_dir" != "X"; then
> +                        LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-L$found_dir -l$name"
> +            if test "X$found_so" != "X"; then
> +                                                        if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then
> +                                LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +              else
> +                                                                                haveit=
> +                for x in $ltrpathdirs; do
> +                  if test "X$x" = "X$found_dir"; then
> +                    haveit=yes
> +                    break
> +                  fi
> +                done
> +                if test -z "$haveit"; then
> +                  ltrpathdirs="$ltrpathdirs $found_dir"
> +                fi
> +                                if test "$hardcode_direct" = yes; then
> +                                                      LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +                else
> +                  if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then
> +                                                            LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +                                                            haveit=
> +                    for x in $rpathdirs; do
> +                      if test "X$x" = "X$found_dir"; then
> +                        haveit=yes
> +                        break
> +                      fi
> +                    done
> +                    if test -z "$haveit"; then
> +                      rpathdirs="$rpathdirs $found_dir"
> +                    fi
> +                  else
> +                                                                                haveit=
> +                    for x in $LDFLAGS $LIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                      if test "X$x" = "X-L$found_dir"; then
> +                        haveit=yes
> +                        break
> +                      fi
> +                    done
> +                    if test -z "$haveit"; then
> +                      LIBZ="${LIBZ}${LIBZ:+ }-L$found_dir"
> +                    fi
> +                    if test "$hardcode_minus_L" != no; then
> +                                                                                        LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +                    else
> +                                                                                                                                                                                LIBZ="${LIBZ}${LIBZ:+ }-l$name"
> +                    fi
> +                  fi
> +                fi
> +              fi
> +            else
> +              if test "X$found_a" != "X"; then
> +                                LIBZ="${LIBZ}${LIBZ:+ }$found_a"
> +              else
> +                                                LIBZ="${LIBZ}${LIBZ:+ }-L$found_dir -l$name"
> +              fi
> +            fi
> +                        additional_includedir=
> +            case "$found_dir" in
> +              */lib | */lib/)
> +                basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'`
> +                additional_includedir="$basedir/include"
> +                ;;
> +            esac
> +            if test "X$additional_includedir" != "X"; then
> +                                                                                                                if test "X$additional_includedir" != "X/usr/include"; then
> +                haveit=
> +                if test "X$additional_includedir" = "X/usr/local/include"; then
> +                  if test -n "$GCC"; then
> +                    case $host_os in
> +                      linux*) haveit=yes;;
> +                    esac
> +                  fi
> +                fi
> +                if test -z "$haveit"; then
> +                  for x in $CPPFLAGS $INCZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                    if test "X$x" = "X-I$additional_includedir"; then
> +                      haveit=yes
> +                      break
> +                    fi
> +                  done
> +                  if test -z "$haveit"; then
> +                    if test -d "$additional_includedir"; then
> +                                            INCZ="${INCZ}${INCZ:+ }-I$additional_includedir"
> +                    fi
> +                  fi
> +                fi
> +              fi
> +            fi
> +                        if test -n "$found_la"; then
> +                                                        save_libdir="$libdir"
> +              case "$found_la" in
> +                */* | *\\*) . "$found_la" ;;
> +                *) . "./$found_la" ;;
> +              esac
> +              libdir="$save_libdir"
> +                            for dep in $dependency_libs; do
> +                case "$dep" in
> +                  -L*)
> +                    additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
> +                                                                                                                                                                if test "X$additional_libdir" != "X/usr/lib"; then
> +                      haveit=
> +                      if test "X$additional_libdir" = "X/usr/local/lib"; then
> +                        if test -n "$GCC"; then
> +                          case $host_os in
> +                            linux*) haveit=yes;;
> +                          esac
> +                        fi
> +                      fi
> +                      if test -z "$haveit"; then
> +                        haveit=
> +                        for x in $LDFLAGS $LIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                          if test "X$x" = "X-L$additional_libdir"; then
> +                            haveit=yes
> +                            break
> +                          fi
> +                        done
> +                        if test -z "$haveit"; then
> +                          if test -d "$additional_libdir"; then
> +                                                        LIBZ="${LIBZ}${LIBZ:+ }-L$additional_libdir"
> +                          fi
> +                        fi
> +                        haveit=
> +                        for x in $LDFLAGS $LTLIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                          if test "X$x" = "X-L$additional_libdir"; then
> +                            haveit=yes
> +                            break
> +                          fi
> +                        done
> +                        if test -z "$haveit"; then
> +                          if test -d "$additional_libdir"; then
> +                                                        LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-L$additional_libdir"
> +                          fi
> +                        fi
> +                      fi
> +                    fi
> +                    ;;
> +                  -R*)
> +                    dir=`echo "X$dep" | sed -e 's/^X-R//'`
> +                    if test "$enable_rpath" != no; then
> +                                                                  haveit=
> +                      for x in $rpathdirs; do
> +                        if test "X$x" = "X$dir"; then
> +                          haveit=yes
> +                          break
> +                        fi
> +                      done
> +                      if test -z "$haveit"; then
> +                        rpathdirs="$rpathdirs $dir"
> +                      fi
> +                                                                  haveit=
> +                      for x in $ltrpathdirs; do
> +                        if test "X$x" = "X$dir"; then
> +                          haveit=yes
> +                          break
> +                        fi
> +                      done
> +                      if test -z "$haveit"; then
> +                        ltrpathdirs="$ltrpathdirs $dir"
> +                      fi
> +                    fi
> +                    ;;
> +                  -l*)
> +                                        names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
> +                    ;;
> +                  *.la)
> +                                                                                names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
> +                    ;;
> +                  *)
> +                                        LIBZ="${LIBZ}${LIBZ:+ }$dep"
> +                    LTLIBZ="${LTLIBZ}${LTLIBZ:+ }$dep"
> +                    ;;
> +                esac
> +              done
> +            fi
> +          else
> +                                                            LIBZ="${LIBZ}${LIBZ:+ }-l$name"
> +            LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-l$name"
> +          fi
> +        fi
> +      fi
> +    done
> +  done
> +  if test "X$rpathdirs" != "X"; then
> +    if test -n "$hardcode_libdir_separator"; then
> +                        alldirs=
> +      for found_dir in $rpathdirs; do
> +        alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir"
> +      done
> +            acl_save_libdir="$libdir"
> +      libdir="$alldirs"
> +      eval flag=\"$hardcode_libdir_flag_spec\"
> +      libdir="$acl_save_libdir"
> +      LIBZ="${LIBZ}${LIBZ:+ }$flag"
> +    else
> +            for found_dir in $rpathdirs; do
> +        acl_save_libdir="$libdir"
> +        libdir="$found_dir"
> +        eval flag=\"$hardcode_libdir_flag_spec\"
> +        libdir="$acl_save_libdir"
> +        LIBZ="${LIBZ}${LIBZ:+ }$flag"
> +      done
> +    fi
> +  fi
> +  if test "X$ltrpathdirs" != "X"; then
> +            for found_dir in $ltrpathdirs; do
> +      LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-R$found_dir"
> +    done
> +  fi
> +
> +
> +        ac_save_CPPFLAGS="$CPPFLAGS"
> +
> +  for element in $INCZ; do
> +    haveit=
> +    for x in $CPPFLAGS; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +      if test "X$x" = "X$element"; then
> +        haveit=yes
> +        break
> +      fi
> +    done
> +    if test -z "$haveit"; then
> +      CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element"
> +    fi
> +  done
> +
> +
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libz" >&5
> +$as_echo_n "checking for libz... " >&6; }
> +if test "${ac_cv_libz+set}" = set; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +
> +    ac_save_LIBS="$LIBS"
> +    LIBS="$LIBS $LIBZ"
> +    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> +/* end confdefs.h.  */
> +#include "zlib.h";
> +int
> +main ()
> +{
> +int ret = deflateInit(NULL, 1);
> +  ;
> +  return 0;
> +}
> +_ACEOF
> +if ac_fn_c_try_link "$LINENO"; then :
> +  ac_cv_libz=yes
> +else
> +  ac_cv_libz=no
> +fi
> +rm -f core conftest.err conftest.$ac_objext \
> +    conftest$ac_exeext conftest.$ac_ext
> +    LIBS="$ac_save_LIBS"
> +
> +fi
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_libz" >&5
> +$as_echo "$ac_cv_libz" >&6; }
> +  if test "$ac_cv_libz" = yes; then
> +    HAVE_LIBZ=yes
> +
> +$as_echo "#define HAVE_LIBZ 1" >>confdefs.h
> +
> +    { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libz" >&5
> +$as_echo_n "checking how to link with libz... " >&6; }
> +    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBZ" >&5
> +$as_echo "$LIBZ" >&6; }
> +  else
> +    HAVE_LIBZ=no
> +            CPPFLAGS="$ac_save_CPPFLAGS"
> +    LIBZ=
> +    LTLIBZ=
> +  fi
> +
> +
> +
> +
> +
> +
> +    if test "$HAVE_LIBZ" = "yes"; then
> +      # Make sure HAVE_ZLIB_H gets defined.  Some code uses that over
> +      # HAVE_LIBZ, since initially we were only defining HAVE_ZLIB_H.
> +      for ac_header in zlib.h
> +do :
> +  ac_fn_c_check_header_mongrel "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default"
> +if test "x$ac_cv_header_zlib_h" = x""yes; then :
> +  cat >>confdefs.h <<_ACEOF
> +#define HAVE_ZLIB_H 1
> +_ACEOF
> +
> +fi
> +
> +done
> +
> +      LIBS="$LIBS $LIBZ"
> +    fi
> +    if test "$with_zlib" = "yes" -a "$HAVE_LIBZ" != "yes"; then
> +      as_fn_error "zlib (libz) library was explicitly requested but not found" "$LINENO" 5
> +    fi
> +  fi
> +
> +
> +
> +case "${host}" in
> +*-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows*)
> +
> +$as_echo "#define USE_BINARY_FOPEN 1" >>confdefs.h
> + ;;
> +esac
> +
> +# target-specific stuff:
> +
> +# Canonicalize the secondary target names.
> +if test -n "$enable_targets"; then
> +    for targ in `echo $enable_targets | sed 's/,/ /g'`
> +    do
> +	result=`$ac_config_sub $targ 2>/dev/null`
> +	if test -n "$result"; then
> +	    canon_targets="$canon_targets $result"
> +	else
> +	    # Allow targets that config.sub doesn't recognize, like "all".
> +	    canon_targets="$canon_targets $targ"
> +	fi
> +    done
> +fi
> +
> +ac_fn_c_check_header_mongrel "$LINENO" "iconv.h" "ac_cv_header_iconv_h" "$ac_includes_default"
> +if test "x$ac_cv_header_iconv_h" = x""yes; then :
> +
> +fi
> +
> +
> +
>  
>  
>  
> diff --git a/binutils/doc/Makefile.in b/binutils/doc/Makefile.in
> index c828aae..96657ed 100644
> --- a/binutils/doc/Makefile.in
> +++ b/binutils/doc/Makefile.in
> @@ -166,6 +166,7 @@ FGREP = @FGREP@
>  GENCAT = @GENCAT@
>  GMSGFMT = @GMSGFMT@
>  GREP = @GREP@
> +HAVE_LIBZ = @HAVE_LIBZ@
>  HDEFINES = @HDEFINES@
>  INCINTL = @INCINTL@
>  INSTALL = @INSTALL@
> @@ -185,10 +186,12 @@ LIBINTL_DEP = @LIBINTL_DEP@
>  LIBOBJS = @LIBOBJS@
>  LIBS = @LIBS@
>  LIBTOOL = @LIBTOOL@
> +LIBZ = @LIBZ@
>  LIPO = @LIPO@
>  LN_S = @LN_S@
>  LTLIBICONV = @LTLIBICONV@
>  LTLIBOBJS = @LTLIBOBJS@
> +LTLIBZ = @LTLIBZ@
>  MAINT = @MAINT@
>  MAKEINFO = @MAKEINFO@
>  MKDIR_P = @MKDIR_P@
> diff --git a/config/zlib.m4 b/config/zlib.m4
> index b017499..1581124 100644
> --- a/config/zlib.m4
> +++ b/config/zlib.m4
> @@ -9,8 +9,15 @@ AC_DEFUN([AM_ZLIB],
>      [], [with_zlib=auto])
>  
>    if test "$with_zlib" != "no"; then
> -    AC_SEARCH_LIBS(zlibVersion, z, [AC_CHECK_HEADERS(zlib.h)])
> -    if test "$with_zlib" = "yes" -a "$ac_cv_header_zlib_h" != "yes"; then
> +    AC_LIB_HAVE_LINKFLAGS([z], [], [#include "zlib.h";],
> +                          [int ret = deflateInit(NULL, 1);])
> +    if test "$HAVE_LIBZ" = "yes"; then
> +      # Make sure HAVE_ZLIB_H gets defined.  Some code uses that over
> +      # HAVE_LIBZ, since initially we were only defining HAVE_ZLIB_H.
> +      AC_CHECK_HEADERS(zlib.h)
> +      LIBS="$LIBS $LIBZ"
> +    fi
> +    if test "$with_zlib" = "yes" -a "$HAVE_LIBZ" != "yes"; then
>        AC_MSG_ERROR([zlib (libz) library was explicitly requested but not found])
>      fi
>    fi
> diff --git a/gas/Makefile.in b/gas/Makefile.in
> index f190714..dd21288 100644
> --- a/gas/Makefile.in
> +++ b/gas/Makefile.in
> @@ -73,6 +73,9 @@ am__aclocal_m4_deps = $(top_srcdir)/../bfd/acinclude.m4 \
>  	$(top_srcdir)/../config/largefile.m4 \
>  	$(top_srcdir)/../config/lcmessage.m4 \
>  	$(top_srcdir)/../config/lead-dot.m4 \
> +	$(top_srcdir)/../config/lib-ld.m4 \
> +	$(top_srcdir)/../config/lib-link.m4 \
> +	$(top_srcdir)/../config/lib-prefix.m4 \
>  	$(top_srcdir)/../config/nls.m4 \
>  	$(top_srcdir)/../config/override.m4 \
>  	$(top_srcdir)/../config/plugins.m4 \
> @@ -181,6 +184,7 @@ GDBINIT = @GDBINIT@
>  GENCAT = @GENCAT@
>  GMSGFMT = @GMSGFMT@
>  GREP = @GREP@
> +HAVE_LIBZ = @HAVE_LIBZ@
>  INCINTL = @INCINTL@
>  INSTALL = @INSTALL@
>  INSTALL_DATA = @INSTALL_DATA@
> @@ -199,9 +203,11 @@ LIBM = @LIBM@
>  LIBOBJS = @LIBOBJS@
>  LIBS = @LIBS@
>  LIBTOOL = @LIBTOOL@
> +LIBZ = @LIBZ@
>  LIPO = @LIPO@
>  LN_S = @LN_S@
>  LTLIBOBJS = @LTLIBOBJS@
> +LTLIBZ = @LTLIBZ@
>  MAINT = @MAINT@
>  MAKEINFO = @MAKEINFO@
>  MKDIR_P = @MKDIR_P@
> diff --git a/gas/aclocal.m4 b/gas/aclocal.m4
> index ea731ac..3d9deaf 100644
> --- a/gas/aclocal.m4
> +++ b/gas/aclocal.m4
> @@ -997,6 +997,9 @@ m4_include([../config/gettext-sister.m4])
>  m4_include([../config/largefile.m4])
>  m4_include([../config/lcmessage.m4])
>  m4_include([../config/lead-dot.m4])
> +m4_include([../config/lib-ld.m4])
> +m4_include([../config/lib-link.m4])
> +m4_include([../config/lib-prefix.m4])
>  m4_include([../config/nls.m4])
>  m4_include([../config/override.m4])
>  m4_include([../config/plugins.m4])
> diff --git a/gas/config.in b/gas/config.in
> index fef16ee..c326c74 100644
> --- a/gas/config.in
> +++ b/gas/config.in
> @@ -100,6 +100,9 @@
>  /* Define if your <locale.h> file defines LC_MESSAGES. */
>  #undef HAVE_LC_MESSAGES
>  
> +/* Define if you have the z library. */
> +#undef HAVE_LIBZ
> +
>  /* Define to 1 if you have the <limits.h> header file. */
>  #undef HAVE_LIMITS_H
>  
> diff --git a/gas/configure b/gas/configure
> index 75d8a52..7ebd36a 100755
> --- a/gas/configure
> +++ b/gas/configure
> @@ -602,6 +602,9 @@ ac_subst_vars='am__EXEEXT_FALSE
>  am__EXEEXT_TRUE
>  LTLIBOBJS
>  LIBOBJS
> +LTLIBZ
> +LIBZ
> +HAVE_LIBZ
>  LIBM
>  ALLOCA
>  GENINSRC_NEVER_FALSE
> @@ -767,6 +770,8 @@ enable_build_warnings
>  enable_nls
>  enable_maintainer_mode
>  with_zlib
> +enable_rpath
> +with_libz_prefix
>  '
>        ac_precious_vars='build_alias
>  host_alias
> @@ -1415,6 +1420,7 @@ Optional Features:
>    --disable-nls           do not use Native Language Support
>    --enable-maintainer-mode  enable make rules and dependencies not useful
>  			  (and sometimes confusing) to the casual installer
> +  --disable-rpath         do not hardcode runtime library paths
>  
>  Optional Packages:
>    --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
> @@ -1423,6 +1429,9 @@ Optional Packages:
>                            both]
>    --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
>    --with-zlib             include zlib support (auto/yes/no) default=auto
> +  --with-gnu-ld           assume the C compiler uses GNU ld default=no
> +  --with-libz-prefix[=DIR]  search for libz in DIR/include and DIR/lib
> +  --without-libz-prefix     don't search for libz in includedir and libdir
>  
>  Some influential environment variables:
>    CC          C compiler command
> @@ -10967,7 +10976,7 @@ else
>    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>    lt_status=$lt_dlunknown
>    cat > conftest.$ac_ext <<_LT_EOF
> -#line 10970 "configure"
> +#line 10979 "configure"
>  #include "confdefs.h"
>  
>  #if HAVE_DLFCN_H
> @@ -11073,7 +11082,7 @@ else
>    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>    lt_status=$lt_dlunknown
>    cat > conftest.$ac_ext <<_LT_EOF
> -#line 11076 "configure"
> +#line 11085 "configure"
>  #include "confdefs.h"
>  
>  #if HAVE_DLFCN_H
> @@ -14321,6 +14330,164 @@ esac
>  
>  # Link in zlib if we can.  This allows us to write compressed debug sections.
>  
> +      if test "X$prefix" = "XNONE"; then
> +    acl_final_prefix="$ac_default_prefix"
> +  else
> +    acl_final_prefix="$prefix"
> +  fi
> +  if test "X$exec_prefix" = "XNONE"; then
> +    acl_final_exec_prefix='${prefix}'
> +  else
> +    acl_final_exec_prefix="$exec_prefix"
> +  fi
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
> +  prefix="$acl_save_prefix"
> +
> +
> +# Check whether --with-gnu-ld was given.
> +if test "${with_gnu_ld+set}" = set; then :
> +  withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
> +else
> +  with_gnu_ld=no
> +fi
> +
> +# Prepare PATH_SEPARATOR.
> +# The user is always right.
> +if test "${PATH_SEPARATOR+set}" != set; then
> +  echo "#! /bin/sh" >conf$$.sh
> +  echo  "exit 0"   >>conf$$.sh
> +  chmod +x conf$$.sh
> +  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
> +    PATH_SEPARATOR=';'
> +  else
> +    PATH_SEPARATOR=:
> +  fi
> +  rm -f conf$$.sh
> +fi
> +ac_prog=ld
> +if test "$GCC" = yes; then
> +  # Check if gcc -print-prog-name=ld gives a path.
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by GCC" >&5
> +$as_echo_n "checking for ld used by GCC... " >&6; }
> +  case $host in
> +  *-*-mingw*)
> +    # gcc leaves a trailing carriage return which upsets mingw
> +    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
> +  *)
> +    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
> +  esac
> +  case $ac_prog in
> +    # Accept absolute paths.
> +    [\\/]* | [A-Za-z]:[\\/]*)
> +      re_direlt='/[^/][^/]*/\.\./'
> +      # Canonicalize the path of ld
> +      ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
> +      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
> +	ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
> +      done
> +      test -z "$LD" && LD="$ac_prog"
> +      ;;
> +  "")
> +    # If it fails, then pretend we aren't using GCC.
> +    ac_prog=ld
> +    ;;
> +  *)
> +    # If it is relative, then search for the first ld in PATH.
> +    with_gnu_ld=unknown
> +    ;;
> +  esac
> +elif test "$with_gnu_ld" = yes; then
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
> +$as_echo_n "checking for GNU ld... " >&6; }
> +else
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
> +$as_echo_n "checking for non-GNU ld... " >&6; }
> +fi
> +if test "${acl_cv_path_LD+set}" = set; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +  if test -z "$LD"; then
> +  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
> +  for ac_dir in $PATH; do
> +    test -z "$ac_dir" && ac_dir=.
> +    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
> +      acl_cv_path_LD="$ac_dir/$ac_prog"
> +      # Check to see if the program is GNU ld.  I'd rather use --version,
> +      # but apparently some GNU ld's only accept -v.
> +      # Break only if it was the GNU/non-GNU ld that we prefer.
> +      if "$acl_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
> +	test "$with_gnu_ld" != no && break
> +      else
> +	test "$with_gnu_ld" != yes && break
> +      fi
> +    fi
> +  done
> +  IFS="$ac_save_ifs"
> +else
> +  acl_cv_path_LD="$LD" # Let the user override the test with a path.
> +fi
> +fi
> +
> +LD="$acl_cv_path_LD"
> +if test -n "$LD"; then
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
> +$as_echo "$LD" >&6; }
> +else
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
> +$as_echo "no" >&6; }
> +fi
> +test -z "$LD" && as_fn_error "no acceptable ld found in \$PATH" "$LINENO" 5
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
> +$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; }
> +if test "${acl_cv_prog_gnu_ld+set}" = set; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +  # I'd rather use --version here, but apparently some GNU ld's only accept -v.
> +if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
> +  acl_cv_prog_gnu_ld=yes
> +else
> +  acl_cv_prog_gnu_ld=no
> +fi
> +fi
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_prog_gnu_ld" >&5
> +$as_echo "$acl_cv_prog_gnu_ld" >&6; }
> +with_gnu_ld=$acl_cv_prog_gnu_ld
> +
> +
> +
> +                                                { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5
> +$as_echo_n "checking for shared library run path origin... " >&6; }
> +if test "${acl_cv_rpath+set}" = set; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +
> +    CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
> +    ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
> +    . ./conftest.sh
> +    rm -f ./conftest.sh
> +    acl_cv_rpath=done
> +
> +fi
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_rpath" >&5
> +$as_echo "$acl_cv_rpath" >&6; }
> +  wl="$acl_cv_wl"
> +  libext="$acl_cv_libext"
> +  shlibext="$acl_cv_shlibext"
> +  hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
> +  hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
> +  hardcode_direct="$acl_cv_hardcode_direct"
> +  hardcode_minus_L="$acl_cv_hardcode_minus_L"
> +    # Check whether --enable-rpath was given.
> +if test "${enable_rpath+set}" = set; then :
> +  enableval=$enable_rpath; :
> +else
> +  enable_rpath=yes
> +fi
> +
> +
> +
>    # See if the user specified whether he wants zlib support or not.
>  
>  # Check whether --with-zlib was given.
> @@ -14332,60 +14499,472 @@ fi
>  
>  
>    if test "$with_zlib" != "no"; then
> -    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing zlibVersion" >&5
> -$as_echo_n "checking for library containing zlibVersion... " >&6; }
> -if test "${ac_cv_search_zlibVersion+set}" = set; then :
> +
> +
> +
> +
> +
> +
> +
> +
> +    use_additional=yes
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +
> +    eval additional_includedir=\"$includedir\"
> +    eval additional_libdir=\"$libdir\"
> +
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +
> +# Check whether --with-libz-prefix was given.
> +if test "${with_libz_prefix+set}" = set; then :
> +  withval=$with_libz_prefix;
> +    if test "X$withval" = "Xno"; then
> +      use_additional=no
> +    else
> +      if test "X$withval" = "X"; then
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +
> +          eval additional_includedir=\"$includedir\"
> +          eval additional_libdir=\"$libdir\"
> +
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +      else
> +        additional_includedir="$withval/include"
> +        additional_libdir="$withval/lib"
> +      fi
> +    fi
> +
> +fi
> +
> +      LIBZ=
> +  LTLIBZ=
> +  INCZ=
> +  rpathdirs=
> +  ltrpathdirs=
> +  names_already_handled=
> +  names_next_round='z '
> +  while test -n "$names_next_round"; do
> +    names_this_round="$names_next_round"
> +    names_next_round=
> +    for name in $names_this_round; do
> +      already_handled=
> +      for n in $names_already_handled; do
> +        if test "$n" = "$name"; then
> +          already_handled=yes
> +          break
> +        fi
> +      done
> +      if test -z "$already_handled"; then
> +        names_already_handled="$names_already_handled $name"
> +                        uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
> +        eval value=\"\$HAVE_LIB$uppername\"
> +        if test -n "$value"; then
> +          if test "$value" = yes; then
> +            eval value=\"\$LIB$uppername\"
> +            test -z "$value" || LIBZ="${LIBZ}${LIBZ:+ }$value"
> +            eval value=\"\$LTLIB$uppername\"
> +            test -z "$value" || LTLIBZ="${LTLIBZ}${LTLIBZ:+ }$value"
> +          else
> +                                    :
> +          fi
> +        else
> +                              found_dir=
> +          found_la=
> +          found_so=
> +          found_a=
> +          if test $use_additional = yes; then
> +            if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then
> +              found_dir="$additional_libdir"
> +              found_so="$additional_libdir/lib$name.$shlibext"
> +              if test -f "$additional_libdir/lib$name.la"; then
> +                found_la="$additional_libdir/lib$name.la"
> +              fi
> +            else
> +              if test -f "$additional_libdir/lib$name.$libext"; then
> +                found_dir="$additional_libdir"
> +                found_a="$additional_libdir/lib$name.$libext"
> +                if test -f "$additional_libdir/lib$name.la"; then
> +                  found_la="$additional_libdir/lib$name.la"
> +                fi
> +              fi
> +            fi
> +          fi
> +          if test "X$found_dir" = "X"; then
> +            for x in $LDFLAGS $LTLIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +              case "$x" in
> +                -L*)
> +                  dir=`echo "X$x" | sed -e 's/^X-L//'`
> +                  if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then
> +                    found_dir="$dir"
> +                    found_so="$dir/lib$name.$shlibext"
> +                    if test -f "$dir/lib$name.la"; then
> +                      found_la="$dir/lib$name.la"
> +                    fi
> +                  else
> +                    if test -f "$dir/lib$name.$libext"; then
> +                      found_dir="$dir"
> +                      found_a="$dir/lib$name.$libext"
> +                      if test -f "$dir/lib$name.la"; then
> +                        found_la="$dir/lib$name.la"
> +                      fi
> +                    fi
> +                  fi
> +                  ;;
> +              esac
> +              if test "X$found_dir" != "X"; then
> +                break
> +              fi
> +            done
> +          fi
> +          if test "X$found_dir" != "X"; then
> +                        LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-L$found_dir -l$name"
> +            if test "X$found_so" != "X"; then
> +                                                        if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then
> +                                LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +              else
> +                                                                                haveit=
> +                for x in $ltrpathdirs; do
> +                  if test "X$x" = "X$found_dir"; then
> +                    haveit=yes
> +                    break
> +                  fi
> +                done
> +                if test -z "$haveit"; then
> +                  ltrpathdirs="$ltrpathdirs $found_dir"
> +                fi
> +                                if test "$hardcode_direct" = yes; then
> +                                                      LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +                else
> +                  if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then
> +                                                            LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +                                                            haveit=
> +                    for x in $rpathdirs; do
> +                      if test "X$x" = "X$found_dir"; then
> +                        haveit=yes
> +                        break
> +                      fi
> +                    done
> +                    if test -z "$haveit"; then
> +                      rpathdirs="$rpathdirs $found_dir"
> +                    fi
> +                  else
> +                                                                                haveit=
> +                    for x in $LDFLAGS $LIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                      if test "X$x" = "X-L$found_dir"; then
> +                        haveit=yes
> +                        break
> +                      fi
> +                    done
> +                    if test -z "$haveit"; then
> +                      LIBZ="${LIBZ}${LIBZ:+ }-L$found_dir"
> +                    fi
> +                    if test "$hardcode_minus_L" != no; then
> +                                                                                        LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +                    else
> +                                                                                                                                                                                LIBZ="${LIBZ}${LIBZ:+ }-l$name"
> +                    fi
> +                  fi
> +                fi
> +              fi
> +            else
> +              if test "X$found_a" != "X"; then
> +                                LIBZ="${LIBZ}${LIBZ:+ }$found_a"
> +              else
> +                                                LIBZ="${LIBZ}${LIBZ:+ }-L$found_dir -l$name"
> +              fi
> +            fi
> +                        additional_includedir=
> +            case "$found_dir" in
> +              */lib | */lib/)
> +                basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'`
> +                additional_includedir="$basedir/include"
> +                ;;
> +            esac
> +            if test "X$additional_includedir" != "X"; then
> +                                                                                                                if test "X$additional_includedir" != "X/usr/include"; then
> +                haveit=
> +                if test "X$additional_includedir" = "X/usr/local/include"; then
> +                  if test -n "$GCC"; then
> +                    case $host_os in
> +                      linux*) haveit=yes;;
> +                    esac
> +                  fi
> +                fi
> +                if test -z "$haveit"; then
> +                  for x in $CPPFLAGS $INCZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                    if test "X$x" = "X-I$additional_includedir"; then
> +                      haveit=yes
> +                      break
> +                    fi
> +                  done
> +                  if test -z "$haveit"; then
> +                    if test -d "$additional_includedir"; then
> +                                            INCZ="${INCZ}${INCZ:+ }-I$additional_includedir"
> +                    fi
> +                  fi
> +                fi
> +              fi
> +            fi
> +                        if test -n "$found_la"; then
> +                                                        save_libdir="$libdir"
> +              case "$found_la" in
> +                */* | *\\*) . "$found_la" ;;
> +                *) . "./$found_la" ;;
> +              esac
> +              libdir="$save_libdir"
> +                            for dep in $dependency_libs; do
> +                case "$dep" in
> +                  -L*)
> +                    additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
> +                                                                                                                                                                if test "X$additional_libdir" != "X/usr/lib"; then
> +                      haveit=
> +                      if test "X$additional_libdir" = "X/usr/local/lib"; then
> +                        if test -n "$GCC"; then
> +                          case $host_os in
> +                            linux*) haveit=yes;;
> +                          esac
> +                        fi
> +                      fi
> +                      if test -z "$haveit"; then
> +                        haveit=
> +                        for x in $LDFLAGS $LIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                          if test "X$x" = "X-L$additional_libdir"; then
> +                            haveit=yes
> +                            break
> +                          fi
> +                        done
> +                        if test -z "$haveit"; then
> +                          if test -d "$additional_libdir"; then
> +                                                        LIBZ="${LIBZ}${LIBZ:+ }-L$additional_libdir"
> +                          fi
> +                        fi
> +                        haveit=
> +                        for x in $LDFLAGS $LTLIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                          if test "X$x" = "X-L$additional_libdir"; then
> +                            haveit=yes
> +                            break
> +                          fi
> +                        done
> +                        if test -z "$haveit"; then
> +                          if test -d "$additional_libdir"; then
> +                                                        LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-L$additional_libdir"
> +                          fi
> +                        fi
> +                      fi
> +                    fi
> +                    ;;
> +                  -R*)
> +                    dir=`echo "X$dep" | sed -e 's/^X-R//'`
> +                    if test "$enable_rpath" != no; then
> +                                                                  haveit=
> +                      for x in $rpathdirs; do
> +                        if test "X$x" = "X$dir"; then
> +                          haveit=yes
> +                          break
> +                        fi
> +                      done
> +                      if test -z "$haveit"; then
> +                        rpathdirs="$rpathdirs $dir"
> +                      fi
> +                                                                  haveit=
> +                      for x in $ltrpathdirs; do
> +                        if test "X$x" = "X$dir"; then
> +                          haveit=yes
> +                          break
> +                        fi
> +                      done
> +                      if test -z "$haveit"; then
> +                        ltrpathdirs="$ltrpathdirs $dir"
> +                      fi
> +                    fi
> +                    ;;
> +                  -l*)
> +                                        names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
> +                    ;;
> +                  *.la)
> +                                                                                names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
> +                    ;;
> +                  *)
> +                                        LIBZ="${LIBZ}${LIBZ:+ }$dep"
> +                    LTLIBZ="${LTLIBZ}${LTLIBZ:+ }$dep"
> +                    ;;
> +                esac
> +              done
> +            fi
> +          else
> +                                                            LIBZ="${LIBZ}${LIBZ:+ }-l$name"
> +            LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-l$name"
> +          fi
> +        fi
> +      fi
> +    done
> +  done
> +  if test "X$rpathdirs" != "X"; then
> +    if test -n "$hardcode_libdir_separator"; then
> +                        alldirs=
> +      for found_dir in $rpathdirs; do
> +        alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir"
> +      done
> +            acl_save_libdir="$libdir"
> +      libdir="$alldirs"
> +      eval flag=\"$hardcode_libdir_flag_spec\"
> +      libdir="$acl_save_libdir"
> +      LIBZ="${LIBZ}${LIBZ:+ }$flag"
> +    else
> +            for found_dir in $rpathdirs; do
> +        acl_save_libdir="$libdir"
> +        libdir="$found_dir"
> +        eval flag=\"$hardcode_libdir_flag_spec\"
> +        libdir="$acl_save_libdir"
> +        LIBZ="${LIBZ}${LIBZ:+ }$flag"
> +      done
> +    fi
> +  fi
> +  if test "X$ltrpathdirs" != "X"; then
> +            for found_dir in $ltrpathdirs; do
> +      LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-R$found_dir"
> +    done
> +  fi
> +
> +
> +        ac_save_CPPFLAGS="$CPPFLAGS"
> +
> +  for element in $INCZ; do
> +    haveit=
> +    for x in $CPPFLAGS; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +      if test "X$x" = "X$element"; then
> +        haveit=yes
> +        break
> +      fi
> +    done
> +    if test -z "$haveit"; then
> +      CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element"
> +    fi
> +  done
> +
> +
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libz" >&5
> +$as_echo_n "checking for libz... " >&6; }
> +if test "${ac_cv_libz+set}" = set; then :
>    $as_echo_n "(cached) " >&6
>  else
> -  ac_func_search_save_LIBS=$LIBS
> -cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> -/* end confdefs.h.  */
>  
> -/* Override any GCC internal prototype to avoid an error.
> -   Use char because int might match the return type of a GCC
> -   builtin and then its argument prototype would still apply.  */
> -#ifdef __cplusplus
> -extern "C"
> -#endif
> -char zlibVersion ();
> +    ac_save_LIBS="$LIBS"
> +    LIBS="$LIBS $LIBZ"
> +    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> +/* end confdefs.h.  */
> +#include "zlib.h";
>  int
>  main ()
>  {
> -return zlibVersion ();
> +int ret = deflateInit(NULL, 1);
>    ;
>    return 0;
>  }
>  _ACEOF
> -for ac_lib in '' z; do
> -  if test -z "$ac_lib"; then
> -    ac_res="none required"
> -  else
> -    ac_res=-l$ac_lib
> -    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
> -  fi
> -  if ac_fn_c_try_link "$LINENO"; then :
> -  ac_cv_search_zlibVersion=$ac_res
> +if ac_fn_c_try_link "$LINENO"; then :
> +  ac_cv_libz=yes
> +else
> +  ac_cv_libz=no
>  fi
>  rm -f core conftest.err conftest.$ac_objext \
> -    conftest$ac_exeext
> -  if test "${ac_cv_search_zlibVersion+set}" = set; then :
> -  break
> -fi
> -done
> -if test "${ac_cv_search_zlibVersion+set}" = set; then :
> +    conftest$ac_exeext conftest.$ac_ext
> +    LIBS="$ac_save_LIBS"
>  
> -else
> -  ac_cv_search_zlibVersion=no
>  fi
> -rm conftest.$ac_ext
> -LIBS=$ac_func_search_save_LIBS
> -fi
> -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_zlibVersion" >&5
> -$as_echo "$ac_cv_search_zlibVersion" >&6; }
> -ac_res=$ac_cv_search_zlibVersion
> -if test "$ac_res" != no; then :
> -  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
> -  for ac_header in zlib.h
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_libz" >&5
> +$as_echo "$ac_cv_libz" >&6; }
> +  if test "$ac_cv_libz" = yes; then
> +    HAVE_LIBZ=yes
> +
> +$as_echo "#define HAVE_LIBZ 1" >>confdefs.h
> +
> +    { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libz" >&5
> +$as_echo_n "checking how to link with libz... " >&6; }
> +    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBZ" >&5
> +$as_echo "$LIBZ" >&6; }
> +  else
> +    HAVE_LIBZ=no
> +            CPPFLAGS="$ac_save_CPPFLAGS"
> +    LIBZ=
> +    LTLIBZ=
> +  fi
> +
> +
> +
> +
> +
> +
> +    if test "$HAVE_LIBZ" = "yes"; then
> +      # Make sure HAVE_ZLIB_H gets defined.  Some code uses that over
> +      # HAVE_LIBZ, since initially we were only defining HAVE_ZLIB_H.
> +      for ac_header in zlib.h
>  do :
>    ac_fn_c_check_header_mongrel "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default"
>  if test "x$ac_cv_header_zlib_h" = x""yes; then :
> @@ -14397,9 +14976,9 @@ fi
>  
>  done
>  
> -fi
> -
> -    if test "$with_zlib" = "yes" -a "$ac_cv_header_zlib_h" != "yes"; then
> +      LIBS="$LIBS $LIBZ"
> +    fi
> +    if test "$with_zlib" = "yes" -a "$HAVE_LIBZ" != "yes"; then
>        as_fn_error "zlib (libz) library was explicitly requested but not found" "$LINENO" 5
>      fi
>    fi
> diff --git a/gas/doc/Makefile.in b/gas/doc/Makefile.in
> index 02841d9..86d5a5d 100644
> --- a/gas/doc/Makefile.in
> +++ b/gas/doc/Makefile.in
> @@ -64,6 +64,9 @@ am__aclocal_m4_deps = $(top_srcdir)/../bfd/acinclude.m4 \
>  	$(top_srcdir)/../config/largefile.m4 \
>  	$(top_srcdir)/../config/lcmessage.m4 \
>  	$(top_srcdir)/../config/lead-dot.m4 \
> +	$(top_srcdir)/../config/lib-ld.m4 \
> +	$(top_srcdir)/../config/lib-link.m4 \
> +	$(top_srcdir)/../config/lib-prefix.m4 \
>  	$(top_srcdir)/../config/nls.m4 \
>  	$(top_srcdir)/../config/override.m4 \
>  	$(top_srcdir)/../config/plugins.m4 \
> @@ -150,6 +153,7 @@ GDBINIT = @GDBINIT@
>  GENCAT = @GENCAT@
>  GMSGFMT = @GMSGFMT@
>  GREP = @GREP@
> +HAVE_LIBZ = @HAVE_LIBZ@
>  INCINTL = @INCINTL@
>  INSTALL = @INSTALL@
>  INSTALL_DATA = @INSTALL_DATA@
> @@ -168,9 +172,11 @@ LIBM = @LIBM@
>  LIBOBJS = @LIBOBJS@
>  LIBS = @LIBS@
>  LIBTOOL = @LIBTOOL@
> +LIBZ = @LIBZ@
>  LIPO = @LIPO@
>  LN_S = @LN_S@
>  LTLIBOBJS = @LTLIBOBJS@
> +LTLIBZ = @LTLIBZ@
>  MAINT = @MAINT@
>  MAKEINFO = @MAKEINFO@
>  MKDIR_P = @MKDIR_P@
> diff --git a/gdb/config.in b/gdb/config.in
> index 9d3f32d..9b04c29 100644
> --- a/gdb/config.in
> +++ b/gdb/config.in
> @@ -213,6 +213,9 @@
>  /* Define to 1 if you have the `w' library (-lw). */
>  #undef HAVE_LIBW
>  
> +/* Define if you have the z library. */
> +#undef HAVE_LIBZ
> +
>  /* Define to 1 if you have the <linux/perf_event.h> header file. */
>  #undef HAVE_LINUX_PERF_EVENT_H
>  
> diff --git a/gdb/configure b/gdb/configure
> index 7ff74ba..0ae5c79 100755
> --- a/gdb/configure
> +++ b/gdb/configure
> @@ -680,6 +680,9 @@ READLINE_TEXI_INCFLAG
>  READLINE_CFLAGS
>  READLINE_DEPS
>  READLINE
> +LTLIBZ
> +LIBZ
> +HAVE_LIBZ
>  MIG
>  WINDRES
>  DLLTOOL
> @@ -813,13 +816,14 @@ enable_profiling
>  with_pkgversion
>  with_bugurl
>  with_zlib
> +with_gnu_ld
> +enable_rpath
> +with_libz_prefix
>  with_libiconv_prefix
>  with_iconv_bin
>  with_system_readline
>  with_jit_reader_dir
>  with_expat
> -with_gnu_ld
> -enable_rpath
>  with_libexpat_prefix
>  with_python
>  with_guile
> @@ -1528,6 +1532,9 @@ Optional Packages:
>    --with-pkgversion=PKG   Use PKG in the version string in place of "GDB"
>    --with-bugurl=URL       Direct users to URL to report a bug
>    --with-zlib             include zlib support (auto/yes/no) default=auto
> +  --with-gnu-ld           assume the C compiler uses GNU ld default=no
> +  --with-libz-prefix[=DIR]  search for libz in DIR/include and DIR/lib
> +  --without-libz-prefix     don't search for libz in includedir and libdir
>    --with-libiconv-prefix=DIR
>                            search for libiconv in DIR/include and DIR/lib
>    --with-iconv-bin=PATH   specify where to find the iconv program
> @@ -1535,7 +1542,6 @@ Optional Packages:
>    --with-jit-reader-dir=PATH
>                            directory to load the JIT readers from
>    --with-expat            include expat support (auto/yes/no)
> -  --with-gnu-ld           assume the C compiler uses GNU ld default=no
>    --with-libexpat-prefix[=DIR]  search for libexpat in DIR/include and DIR/lib
>    --without-libexpat-prefix     don't search for libexpat in includedir and libdir
>    --with-python[=PYTHON]  include python support
> @@ -6682,163 +6688,733 @@ fi
>  
>  # Link in zlib if we can.  This allows us to read compressed debug sections.
>  
> -  # See if the user specified whether he wants zlib support or not.
> -
> -# Check whether --with-zlib was given.
> -if test "${with_zlib+set}" = set; then :
> -  withval=$with_zlib;
> -else
> -  with_zlib=auto
> -fi
> +      if test "X$prefix" = "XNONE"; then
> +    acl_final_prefix="$ac_default_prefix"
> +  else
> +    acl_final_prefix="$prefix"
> +  fi
> +  if test "X$exec_prefix" = "XNONE"; then
> +    acl_final_exec_prefix='${prefix}'
> +  else
> +    acl_final_exec_prefix="$exec_prefix"
> +  fi
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
> +  prefix="$acl_save_prefix"
>  
>  
> -  if test "$with_zlib" != "no"; then
> -    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing zlibVersion" >&5
> -$as_echo_n "checking for library containing zlibVersion... " >&6; }
> -if test "${ac_cv_search_zlibVersion+set}" = set; then :
> -  $as_echo_n "(cached) " >&6
> +# Check whether --with-gnu-ld was given.
> +if test "${with_gnu_ld+set}" = set; then :
> +  withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
>  else
> -  ac_func_search_save_LIBS=$LIBS
> -cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> -/* end confdefs.h.  */
> +  with_gnu_ld=no
> +fi
>  
> -/* Override any GCC internal prototype to avoid an error.
> -   Use char because int might match the return type of a GCC
> -   builtin and then its argument prototype would still apply.  */
> -#ifdef __cplusplus
> -extern "C"
> -#endif
> -char zlibVersion ();
> -int
> -main ()
> -{
> -return zlibVersion ();
> -  ;
> -  return 0;
> -}
> -_ACEOF
> -for ac_lib in '' z; do
> -  if test -z "$ac_lib"; then
> -    ac_res="none required"
> +# Prepare PATH_SEPARATOR.
> +# The user is always right.
> +if test "${PATH_SEPARATOR+set}" != set; then
> +  echo "#! /bin/sh" >conf$$.sh
> +  echo  "exit 0"   >>conf$$.sh
> +  chmod +x conf$$.sh
> +  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
> +    PATH_SEPARATOR=';'
>    else
> -    ac_res=-l$ac_lib
> -    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
> +    PATH_SEPARATOR=:
>    fi
> -  if ac_fn_c_try_link "$LINENO"; then :
> -  ac_cv_search_zlibVersion=$ac_res
> +  rm -f conf$$.sh
>  fi
> -rm -f core conftest.err conftest.$ac_objext \
> -    conftest$ac_exeext
> -  if test "${ac_cv_search_zlibVersion+set}" = set; then :
> -  break
> +ac_prog=ld
> +if test "$GCC" = yes; then
> +  # Check if gcc -print-prog-name=ld gives a path.
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by GCC" >&5
> +$as_echo_n "checking for ld used by GCC... " >&6; }
> +  case $host in
> +  *-*-mingw*)
> +    # gcc leaves a trailing carriage return which upsets mingw
> +    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
> +  *)
> +    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
> +  esac
> +  case $ac_prog in
> +    # Accept absolute paths.
> +    [\\/]* | [A-Za-z]:[\\/]*)
> +      re_direlt='/[^/][^/]*/\.\./'
> +      # Canonicalize the path of ld
> +      ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
> +      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
> +	ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
> +      done
> +      test -z "$LD" && LD="$ac_prog"
> +      ;;
> +  "")
> +    # If it fails, then pretend we aren't using GCC.
> +    ac_prog=ld
> +    ;;
> +  *)
> +    # If it is relative, then search for the first ld in PATH.
> +    with_gnu_ld=unknown
> +    ;;
> +  esac
> +elif test "$with_gnu_ld" = yes; then
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
> +$as_echo_n "checking for GNU ld... " >&6; }
> +else
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
> +$as_echo_n "checking for non-GNU ld... " >&6; }
>  fi
> -done
> -if test "${ac_cv_search_zlibVersion+set}" = set; then :
> -
> +if test "${acl_cv_path_LD+set}" = set; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +  if test -z "$LD"; then
> +  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
> +  for ac_dir in $PATH; do
> +    test -z "$ac_dir" && ac_dir=.
> +    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
> +      acl_cv_path_LD="$ac_dir/$ac_prog"
> +      # Check to see if the program is GNU ld.  I'd rather use --version,
> +      # but apparently some GNU ld's only accept -v.
> +      # Break only if it was the GNU/non-GNU ld that we prefer.
> +      if "$acl_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
> +	test "$with_gnu_ld" != no && break
> +      else
> +	test "$with_gnu_ld" != yes && break
> +      fi
> +    fi
> +  done
> +  IFS="$ac_save_ifs"
>  else
> -  ac_cv_search_zlibVersion=no
> +  acl_cv_path_LD="$LD" # Let the user override the test with a path.
>  fi
> -rm conftest.$ac_ext
> -LIBS=$ac_func_search_save_LIBS
>  fi
> -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_zlibVersion" >&5
> -$as_echo "$ac_cv_search_zlibVersion" >&6; }
> -ac_res=$ac_cv_search_zlibVersion
> -if test "$ac_res" != no; then :
> -  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
> -  for ac_header in zlib.h
> -do :
> -  ac_fn_c_check_header_mongrel "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default"
> -if test "x$ac_cv_header_zlib_h" = x""yes; then :
> -  cat >>confdefs.h <<_ACEOF
> -#define HAVE_ZLIB_H 1
> -_ACEOF
>  
> +LD="$acl_cv_path_LD"
> +if test -n "$LD"; then
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
> +$as_echo "$LD" >&6; }
> +else
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
> +$as_echo "no" >&6; }
> +fi
> +test -z "$LD" && as_fn_error "no acceptable ld found in \$PATH" "$LINENO" 5
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
> +$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; }
> +if test "${acl_cv_prog_gnu_ld+set}" = set; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +  # I'd rather use --version here, but apparently some GNU ld's only accept -v.
> +if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
> +  acl_cv_prog_gnu_ld=yes
> +else
> +  acl_cv_prog_gnu_ld=no
>  fi
> -
> -done
> -
>  fi
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_prog_gnu_ld" >&5
> +$as_echo "$acl_cv_prog_gnu_ld" >&6; }
> +with_gnu_ld=$acl_cv_prog_gnu_ld
>  
> -    if test "$with_zlib" = "yes" -a "$ac_cv_header_zlib_h" != "yes"; then
> -      as_fn_error "zlib (libz) library was explicitly requested but not found" "$LINENO" 5
> -    fi
> -  fi
>  
>  
> -# On HP/UX we may need libxpdl for dlgetmodinfo (used by solib-pa64.c).
> -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing dlgetmodinfo" >&5
> -$as_echo_n "checking for library containing dlgetmodinfo... " >&6; }
> -if test "${ac_cv_search_dlgetmodinfo+set}" = set; then :
> +                                                { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5
> +$as_echo_n "checking for shared library run path origin... " >&6; }
> +if test "${acl_cv_rpath+set}" = set; then :
>    $as_echo_n "(cached) " >&6
>  else
> -  ac_func_search_save_LIBS=$LIBS
> -cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> -/* end confdefs.h.  */
>  
> -/* Override any GCC internal prototype to avoid an error.
> -   Use char because int might match the return type of a GCC
> -   builtin and then its argument prototype would still apply.  */
> -#ifdef __cplusplus
> -extern "C"
> -#endif
> -char dlgetmodinfo ();
> -int
> -main ()
> -{
> -return dlgetmodinfo ();
> -  ;
> -  return 0;
> -}
> -_ACEOF
> -for ac_lib in '' dl xpdl; do
> -  if test -z "$ac_lib"; then
> -    ac_res="none required"
> -  else
> -    ac_res=-l$ac_lib
> -    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
> -  fi
> -  if ac_fn_c_try_link "$LINENO"; then :
> -  ac_cv_search_dlgetmodinfo=$ac_res
> +    CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
> +    ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
> +    . ./conftest.sh
> +    rm -f ./conftest.sh
> +    acl_cv_rpath=done
> +
>  fi
> -rm -f core conftest.err conftest.$ac_objext \
> -    conftest$ac_exeext
> -  if test "${ac_cv_search_dlgetmodinfo+set}" = set; then :
> -  break
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_rpath" >&5
> +$as_echo "$acl_cv_rpath" >&6; }
> +  wl="$acl_cv_wl"
> +  libext="$acl_cv_libext"
> +  shlibext="$acl_cv_shlibext"
> +  hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
> +  hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
> +  hardcode_direct="$acl_cv_hardcode_direct"
> +  hardcode_minus_L="$acl_cv_hardcode_minus_L"
> +    # Check whether --enable-rpath was given.
> +if test "${enable_rpath+set}" = set; then :
> +  enableval=$enable_rpath; :
> +else
> +  enable_rpath=yes
>  fi
> -done
> -if test "${ac_cv_search_dlgetmodinfo+set}" = set; then :
>  
> +
> +
> +  # See if the user specified whether he wants zlib support or not.
> +
> +# Check whether --with-zlib was given.
> +if test "${with_zlib+set}" = set; then :
> +  withval=$with_zlib;
>  else
> -  ac_cv_search_dlgetmodinfo=no
> -fi
> -rm conftest.$ac_ext
> -LIBS=$ac_func_search_save_LIBS
> +  with_zlib=auto
>  fi
> -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_dlgetmodinfo" >&5
> -$as_echo "$ac_cv_search_dlgetmodinfo" >&6; }
> -ac_res=$ac_cv_search_dlgetmodinfo
> -if test "$ac_res" != no; then :
> -  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
>  
> -fi
>  
> +  if test "$with_zlib" != "no"; then
>  
>  
>  
>  
> -# Check whether --with-libiconv-prefix was given.
> -if test "${with_libiconv_prefix+set}" = set; then :
> -  withval=$with_libiconv_prefix;
> -    for dir in `echo "$withval" | tr : ' '`; do
> -      if test -d $dir/include; then LIBICONV_INCLUDE="-I$dir/include"; fi
> -      if test -d $dir/lib; then LIBICONV_LIBDIR="-L$dir/lib"; fi
> -    done
>  
> -fi
>  
>  
> -  BUILD_LIBICONV_LIBDIRS="../libiconv/lib/.libs ../libiconv/lib/_libs"
> +
> +    use_additional=yes
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +
> +    eval additional_includedir=\"$includedir\"
> +    eval additional_libdir=\"$libdir\"
> +
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +
> +# Check whether --with-libz-prefix was given.
> +if test "${with_libz_prefix+set}" = set; then :
> +  withval=$with_libz_prefix;
> +    if test "X$withval" = "Xno"; then
> +      use_additional=no
> +    else
> +      if test "X$withval" = "X"; then
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +
> +          eval additional_includedir=\"$includedir\"
> +          eval additional_libdir=\"$libdir\"
> +
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +      else
> +        additional_includedir="$withval/include"
> +        additional_libdir="$withval/lib"
> +      fi
> +    fi
> +
> +fi
> +
> +      LIBZ=
> +  LTLIBZ=
> +  INCZ=
> +  rpathdirs=
> +  ltrpathdirs=
> +  names_already_handled=
> +  names_next_round='z '
> +  while test -n "$names_next_round"; do
> +    names_this_round="$names_next_round"
> +    names_next_round=
> +    for name in $names_this_round; do
> +      already_handled=
> +      for n in $names_already_handled; do
> +        if test "$n" = "$name"; then
> +          already_handled=yes
> +          break
> +        fi
> +      done
> +      if test -z "$already_handled"; then
> +        names_already_handled="$names_already_handled $name"
> +                        uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
> +        eval value=\"\$HAVE_LIB$uppername\"
> +        if test -n "$value"; then
> +          if test "$value" = yes; then
> +            eval value=\"\$LIB$uppername\"
> +            test -z "$value" || LIBZ="${LIBZ}${LIBZ:+ }$value"
> +            eval value=\"\$LTLIB$uppername\"
> +            test -z "$value" || LTLIBZ="${LTLIBZ}${LTLIBZ:+ }$value"
> +          else
> +                                    :
> +          fi
> +        else
> +                              found_dir=
> +          found_la=
> +          found_so=
> +          found_a=
> +          if test $use_additional = yes; then
> +            if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then
> +              found_dir="$additional_libdir"
> +              found_so="$additional_libdir/lib$name.$shlibext"
> +              if test -f "$additional_libdir/lib$name.la"; then
> +                found_la="$additional_libdir/lib$name.la"
> +              fi
> +            else
> +              if test -f "$additional_libdir/lib$name.$libext"; then
> +                found_dir="$additional_libdir"
> +                found_a="$additional_libdir/lib$name.$libext"
> +                if test -f "$additional_libdir/lib$name.la"; then
> +                  found_la="$additional_libdir/lib$name.la"
> +                fi
> +              fi
> +            fi
> +          fi
> +          if test "X$found_dir" = "X"; then
> +            for x in $LDFLAGS $LTLIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +              case "$x" in
> +                -L*)
> +                  dir=`echo "X$x" | sed -e 's/^X-L//'`
> +                  if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then
> +                    found_dir="$dir"
> +                    found_so="$dir/lib$name.$shlibext"
> +                    if test -f "$dir/lib$name.la"; then
> +                      found_la="$dir/lib$name.la"
> +                    fi
> +                  else
> +                    if test -f "$dir/lib$name.$libext"; then
> +                      found_dir="$dir"
> +                      found_a="$dir/lib$name.$libext"
> +                      if test -f "$dir/lib$name.la"; then
> +                        found_la="$dir/lib$name.la"
> +                      fi
> +                    fi
> +                  fi
> +                  ;;
> +              esac
> +              if test "X$found_dir" != "X"; then
> +                break
> +              fi
> +            done
> +          fi
> +          if test "X$found_dir" != "X"; then
> +                        LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-L$found_dir -l$name"
> +            if test "X$found_so" != "X"; then
> +                                                        if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then
> +                                LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +              else
> +                                                                                haveit=
> +                for x in $ltrpathdirs; do
> +                  if test "X$x" = "X$found_dir"; then
> +                    haveit=yes
> +                    break
> +                  fi
> +                done
> +                if test -z "$haveit"; then
> +                  ltrpathdirs="$ltrpathdirs $found_dir"
> +                fi
> +                                if test "$hardcode_direct" = yes; then
> +                                                      LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +                else
> +                  if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then
> +                                                            LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +                                                            haveit=
> +                    for x in $rpathdirs; do
> +                      if test "X$x" = "X$found_dir"; then
> +                        haveit=yes
> +                        break
> +                      fi
> +                    done
> +                    if test -z "$haveit"; then
> +                      rpathdirs="$rpathdirs $found_dir"
> +                    fi
> +                  else
> +                                                                                haveit=
> +                    for x in $LDFLAGS $LIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                      if test "X$x" = "X-L$found_dir"; then
> +                        haveit=yes
> +                        break
> +                      fi
> +                    done
> +                    if test -z "$haveit"; then
> +                      LIBZ="${LIBZ}${LIBZ:+ }-L$found_dir"
> +                    fi
> +                    if test "$hardcode_minus_L" != no; then
> +                                                                                        LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +                    else
> +                                                                                                                                                                                LIBZ="${LIBZ}${LIBZ:+ }-l$name"
> +                    fi
> +                  fi
> +                fi
> +              fi
> +            else
> +              if test "X$found_a" != "X"; then
> +                                LIBZ="${LIBZ}${LIBZ:+ }$found_a"
> +              else
> +                                                LIBZ="${LIBZ}${LIBZ:+ }-L$found_dir -l$name"
> +              fi
> +            fi
> +                        additional_includedir=
> +            case "$found_dir" in
> +              */lib | */lib/)
> +                basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'`
> +                additional_includedir="$basedir/include"
> +                ;;
> +            esac
> +            if test "X$additional_includedir" != "X"; then
> +                                                                                                                if test "X$additional_includedir" != "X/usr/include"; then
> +                haveit=
> +                if test "X$additional_includedir" = "X/usr/local/include"; then
> +                  if test -n "$GCC"; then
> +                    case $host_os in
> +                      linux*) haveit=yes;;
> +                    esac
> +                  fi
> +                fi
> +                if test -z "$haveit"; then
> +                  for x in $CPPFLAGS $INCZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                    if test "X$x" = "X-I$additional_includedir"; then
> +                      haveit=yes
> +                      break
> +                    fi
> +                  done
> +                  if test -z "$haveit"; then
> +                    if test -d "$additional_includedir"; then
> +                                            INCZ="${INCZ}${INCZ:+ }-I$additional_includedir"
> +                    fi
> +                  fi
> +                fi
> +              fi
> +            fi
> +                        if test -n "$found_la"; then
> +                                                        save_libdir="$libdir"
> +              case "$found_la" in
> +                */* | *\\*) . "$found_la" ;;
> +                *) . "./$found_la" ;;
> +              esac
> +              libdir="$save_libdir"
> +                            for dep in $dependency_libs; do
> +                case "$dep" in
> +                  -L*)
> +                    additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
> +                                                                                                                                                                if test "X$additional_libdir" != "X/usr/lib"; then
> +                      haveit=
> +                      if test "X$additional_libdir" = "X/usr/local/lib"; then
> +                        if test -n "$GCC"; then
> +                          case $host_os in
> +                            linux*) haveit=yes;;
> +                          esac
> +                        fi
> +                      fi
> +                      if test -z "$haveit"; then
> +                        haveit=
> +                        for x in $LDFLAGS $LIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                          if test "X$x" = "X-L$additional_libdir"; then
> +                            haveit=yes
> +                            break
> +                          fi
> +                        done
> +                        if test -z "$haveit"; then
> +                          if test -d "$additional_libdir"; then
> +                                                        LIBZ="${LIBZ}${LIBZ:+ }-L$additional_libdir"
> +                          fi
> +                        fi
> +                        haveit=
> +                        for x in $LDFLAGS $LTLIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                          if test "X$x" = "X-L$additional_libdir"; then
> +                            haveit=yes
> +                            break
> +                          fi
> +                        done
> +                        if test -z "$haveit"; then
> +                          if test -d "$additional_libdir"; then
> +                                                        LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-L$additional_libdir"
> +                          fi
> +                        fi
> +                      fi
> +                    fi
> +                    ;;
> +                  -R*)
> +                    dir=`echo "X$dep" | sed -e 's/^X-R//'`
> +                    if test "$enable_rpath" != no; then
> +                                                                  haveit=
> +                      for x in $rpathdirs; do
> +                        if test "X$x" = "X$dir"; then
> +                          haveit=yes
> +                          break
> +                        fi
> +                      done
> +                      if test -z "$haveit"; then
> +                        rpathdirs="$rpathdirs $dir"
> +                      fi
> +                                                                  haveit=
> +                      for x in $ltrpathdirs; do
> +                        if test "X$x" = "X$dir"; then
> +                          haveit=yes
> +                          break
> +                        fi
> +                      done
> +                      if test -z "$haveit"; then
> +                        ltrpathdirs="$ltrpathdirs $dir"
> +                      fi
> +                    fi
> +                    ;;
> +                  -l*)
> +                                        names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
> +                    ;;
> +                  *.la)
> +                                                                                names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
> +                    ;;
> +                  *)
> +                                        LIBZ="${LIBZ}${LIBZ:+ }$dep"
> +                    LTLIBZ="${LTLIBZ}${LTLIBZ:+ }$dep"
> +                    ;;
> +                esac
> +              done
> +            fi
> +          else
> +                                                            LIBZ="${LIBZ}${LIBZ:+ }-l$name"
> +            LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-l$name"
> +          fi
> +        fi
> +      fi
> +    done
> +  done
> +  if test "X$rpathdirs" != "X"; then
> +    if test -n "$hardcode_libdir_separator"; then
> +                        alldirs=
> +      for found_dir in $rpathdirs; do
> +        alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir"
> +      done
> +            acl_save_libdir="$libdir"
> +      libdir="$alldirs"
> +      eval flag=\"$hardcode_libdir_flag_spec\"
> +      libdir="$acl_save_libdir"
> +      LIBZ="${LIBZ}${LIBZ:+ }$flag"
> +    else
> +            for found_dir in $rpathdirs; do
> +        acl_save_libdir="$libdir"
> +        libdir="$found_dir"
> +        eval flag=\"$hardcode_libdir_flag_spec\"
> +        libdir="$acl_save_libdir"
> +        LIBZ="${LIBZ}${LIBZ:+ }$flag"
> +      done
> +    fi
> +  fi
> +  if test "X$ltrpathdirs" != "X"; then
> +            for found_dir in $ltrpathdirs; do
> +      LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-R$found_dir"
> +    done
> +  fi
> +
> +
> +        ac_save_CPPFLAGS="$CPPFLAGS"
> +
> +  for element in $INCZ; do
> +    haveit=
> +    for x in $CPPFLAGS; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +      if test "X$x" = "X$element"; then
> +        haveit=yes
> +        break
> +      fi
> +    done
> +    if test -z "$haveit"; then
> +      CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element"
> +    fi
> +  done
> +
> +
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libz" >&5
> +$as_echo_n "checking for libz... " >&6; }
> +if test "${ac_cv_libz+set}" = set; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +
> +    ac_save_LIBS="$LIBS"
> +    LIBS="$LIBS $LIBZ"
> +    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> +/* end confdefs.h.  */
> +#include "zlib.h";
> +int
> +main ()
> +{
> +int ret = deflateInit(NULL, 1);
> +  ;
> +  return 0;
> +}
> +_ACEOF
> +if ac_fn_c_try_link "$LINENO"; then :
> +  ac_cv_libz=yes
> +else
> +  ac_cv_libz=no
> +fi
> +rm -f core conftest.err conftest.$ac_objext \
> +    conftest$ac_exeext conftest.$ac_ext
> +    LIBS="$ac_save_LIBS"
> +
> +fi
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_libz" >&5
> +$as_echo "$ac_cv_libz" >&6; }
> +  if test "$ac_cv_libz" = yes; then
> +    HAVE_LIBZ=yes
> +
> +$as_echo "#define HAVE_LIBZ 1" >>confdefs.h
> +
> +    { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libz" >&5
> +$as_echo_n "checking how to link with libz... " >&6; }
> +    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBZ" >&5
> +$as_echo "$LIBZ" >&6; }
> +  else
> +    HAVE_LIBZ=no
> +            CPPFLAGS="$ac_save_CPPFLAGS"
> +    LIBZ=
> +    LTLIBZ=
> +  fi
> +
> +
> +
> +
> +
> +
> +    if test "$HAVE_LIBZ" = "yes"; then
> +      # Make sure HAVE_ZLIB_H gets defined.  Some code uses that over
> +      # HAVE_LIBZ, since initially we were only defining HAVE_ZLIB_H.
> +      for ac_header in zlib.h
> +do :
> +  ac_fn_c_check_header_mongrel "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default"
> +if test "x$ac_cv_header_zlib_h" = x""yes; then :
> +  cat >>confdefs.h <<_ACEOF
> +#define HAVE_ZLIB_H 1
> +_ACEOF
> +
> +fi
> +
> +done
> +
> +      LIBS="$LIBS $LIBZ"
> +    fi
> +    if test "$with_zlib" = "yes" -a "$HAVE_LIBZ" != "yes"; then
> +      as_fn_error "zlib (libz) library was explicitly requested but not found" "$LINENO" 5
> +    fi
> +  fi
> +
> +
> +# On HP/UX we may need libxpdl for dlgetmodinfo (used by solib-pa64.c).
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing dlgetmodinfo" >&5
> +$as_echo_n "checking for library containing dlgetmodinfo... " >&6; }
> +if test "${ac_cv_search_dlgetmodinfo+set}" = set; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +  ac_func_search_save_LIBS=$LIBS
> +cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> +/* end confdefs.h.  */
> +
> +/* Override any GCC internal prototype to avoid an error.
> +   Use char because int might match the return type of a GCC
> +   builtin and then its argument prototype would still apply.  */
> +#ifdef __cplusplus
> +extern "C"
> +#endif
> +char dlgetmodinfo ();
> +int
> +main ()
> +{
> +return dlgetmodinfo ();
> +  ;
> +  return 0;
> +}
> +_ACEOF
> +for ac_lib in '' dl xpdl; do
> +  if test -z "$ac_lib"; then
> +    ac_res="none required"
> +  else
> +    ac_res=-l$ac_lib
> +    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
> +  fi
> +  if ac_fn_c_try_link "$LINENO"; then :
> +  ac_cv_search_dlgetmodinfo=$ac_res
> +fi
> +rm -f core conftest.err conftest.$ac_objext \
> +    conftest$ac_exeext
> +  if test "${ac_cv_search_dlgetmodinfo+set}" = set; then :
> +  break
> +fi
> +done
> +if test "${ac_cv_search_dlgetmodinfo+set}" = set; then :
> +
> +else
> +  ac_cv_search_dlgetmodinfo=no
> +fi
> +rm conftest.$ac_ext
> +LIBS=$ac_func_search_save_LIBS
> +fi
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_dlgetmodinfo" >&5
> +$as_echo "$ac_cv_search_dlgetmodinfo" >&6; }
> +ac_res=$ac_cv_search_dlgetmodinfo
> +if test "$ac_res" != no; then :
> +  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
> +
> +fi
> +
> +
> +
> +
> +
> +# Check whether --with-libiconv-prefix was given.
> +if test "${with_libiconv_prefix+set}" = set; then :
> +  withval=$with_libiconv_prefix;
> +    for dir in `echo "$withval" | tr : ' '`; do
> +      if test -d $dir/include; then LIBICONV_INCLUDE="-I$dir/include"; fi
> +      if test -d $dir/lib; then LIBICONV_LIBDIR="-L$dir/lib"; fi
> +    done
> +
> +fi
> +
> +
> +  BUILD_LIBICONV_LIBDIRS="../libiconv/lib/.libs ../libiconv/lib/_libs"
>    BUILD_LIBICONV_INCLUDE="-I../libiconv/include"
>  
>    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for iconv" >&5
> @@ -7519,164 +8095,6 @@ $as_echo "$as_me: WARNING: expat support disabled; some features may be unavaila
>    HAVE_LIBEXPAT=no
>  else
>  
> -      if test "X$prefix" = "XNONE"; then
> -    acl_final_prefix="$ac_default_prefix"
> -  else
> -    acl_final_prefix="$prefix"
> -  fi
> -  if test "X$exec_prefix" = "XNONE"; then
> -    acl_final_exec_prefix='${prefix}'
> -  else
> -    acl_final_exec_prefix="$exec_prefix"
> -  fi
> -  acl_save_prefix="$prefix"
> -  prefix="$acl_final_prefix"
> -  eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
> -  prefix="$acl_save_prefix"
> -
> -
> -# Check whether --with-gnu-ld was given.
> -if test "${with_gnu_ld+set}" = set; then :
> -  withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
> -else
> -  with_gnu_ld=no
> -fi
> -
> -# Prepare PATH_SEPARATOR.
> -# The user is always right.
> -if test "${PATH_SEPARATOR+set}" != set; then
> -  echo "#! /bin/sh" >conf$$.sh
> -  echo  "exit 0"   >>conf$$.sh
> -  chmod +x conf$$.sh
> -  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
> -    PATH_SEPARATOR=';'
> -  else
> -    PATH_SEPARATOR=:
> -  fi
> -  rm -f conf$$.sh
> -fi
> -ac_prog=ld
> -if test "$GCC" = yes; then
> -  # Check if gcc -print-prog-name=ld gives a path.
> -  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by GCC" >&5
> -$as_echo_n "checking for ld used by GCC... " >&6; }
> -  case $host in
> -  *-*-mingw*)
> -    # gcc leaves a trailing carriage return which upsets mingw
> -    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
> -  *)
> -    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
> -  esac
> -  case $ac_prog in
> -    # Accept absolute paths.
> -    [\\/]* | [A-Za-z]:[\\/]*)
> -      re_direlt='/[^/][^/]*/\.\./'
> -      # Canonicalize the path of ld
> -      ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
> -      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
> -	ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
> -      done
> -      test -z "$LD" && LD="$ac_prog"
> -      ;;
> -  "")
> -    # If it fails, then pretend we aren't using GCC.
> -    ac_prog=ld
> -    ;;
> -  *)
> -    # If it is relative, then search for the first ld in PATH.
> -    with_gnu_ld=unknown
> -    ;;
> -  esac
> -elif test "$with_gnu_ld" = yes; then
> -  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
> -$as_echo_n "checking for GNU ld... " >&6; }
> -else
> -  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
> -$as_echo_n "checking for non-GNU ld... " >&6; }
> -fi
> -if test "${acl_cv_path_LD+set}" = set; then :
> -  $as_echo_n "(cached) " >&6
> -else
> -  if test -z "$LD"; then
> -  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
> -  for ac_dir in $PATH; do
> -    test -z "$ac_dir" && ac_dir=.
> -    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
> -      acl_cv_path_LD="$ac_dir/$ac_prog"
> -      # Check to see if the program is GNU ld.  I'd rather use --version,
> -      # but apparently some GNU ld's only accept -v.
> -      # Break only if it was the GNU/non-GNU ld that we prefer.
> -      if "$acl_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
> -	test "$with_gnu_ld" != no && break
> -      else
> -	test "$with_gnu_ld" != yes && break
> -      fi
> -    fi
> -  done
> -  IFS="$ac_save_ifs"
> -else
> -  acl_cv_path_LD="$LD" # Let the user override the test with a path.
> -fi
> -fi
> -
> -LD="$acl_cv_path_LD"
> -if test -n "$LD"; then
> -  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
> -$as_echo "$LD" >&6; }
> -else
> -  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
> -$as_echo "no" >&6; }
> -fi
> -test -z "$LD" && as_fn_error "no acceptable ld found in \$PATH" "$LINENO" 5
> -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
> -$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; }
> -if test "${acl_cv_prog_gnu_ld+set}" = set; then :
> -  $as_echo_n "(cached) " >&6
> -else
> -  # I'd rather use --version here, but apparently some GNU ld's only accept -v.
> -if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
> -  acl_cv_prog_gnu_ld=yes
> -else
> -  acl_cv_prog_gnu_ld=no
> -fi
> -fi
> -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_prog_gnu_ld" >&5
> -$as_echo "$acl_cv_prog_gnu_ld" >&6; }
> -with_gnu_ld=$acl_cv_prog_gnu_ld
> -
> -
> -
> -                                                { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5
> -$as_echo_n "checking for shared library run path origin... " >&6; }
> -if test "${acl_cv_rpath+set}" = set; then :
> -  $as_echo_n "(cached) " >&6
> -else
> -
> -    CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
> -    ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
> -    . ./conftest.sh
> -    rm -f ./conftest.sh
> -    acl_cv_rpath=done
> -
> -fi
> -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_rpath" >&5
> -$as_echo "$acl_cv_rpath" >&6; }
> -  wl="$acl_cv_wl"
> -  libext="$acl_cv_libext"
> -  shlibext="$acl_cv_shlibext"
> -  hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
> -  hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
> -  hardcode_direct="$acl_cv_hardcode_direct"
> -  hardcode_minus_L="$acl_cv_hardcode_minus_L"
> -    # Check whether --enable-rpath was given.
> -if test "${enable_rpath+set}" = set; then :
> -  enableval=$enable_rpath; :
> -else
> -  enable_rpath=yes
> -fi
> -
> -
> -
>  
>  
>  
> diff --git a/gold/Makefile.in b/gold/Makefile.in
> index cd4d165..01a7fee 100644
> --- a/gold/Makefile.in
> +++ b/gold/Makefile.in
> @@ -78,6 +78,9 @@ am__aclocal_m4_deps = $(top_srcdir)/../config/depstand.m4 \
>  	$(top_srcdir)/../config/gettext-sister.m4 \
>  	$(top_srcdir)/../config/lcmessage.m4 \
>  	$(top_srcdir)/../config/lead-dot.m4 \
> +	$(top_srcdir)/../config/lib-ld.m4 \
> +	$(top_srcdir)/../config/lib-link.m4 \
> +	$(top_srcdir)/../config/lib-prefix.m4 \
>  	$(top_srcdir)/../config/nls.m4 \
>  	$(top_srcdir)/../config/override.m4 \
>  	$(top_srcdir)/../config/po.m4 \
> @@ -301,6 +304,7 @@ GMSGFMT = @GMSGFMT@
>  GOLD_LDADD = @GOLD_LDADD@
>  GOLD_LDFLAGS = @GOLD_LDFLAGS@
>  GREP = @GREP@
> +HAVE_LIBZ = @HAVE_LIBZ@
>  INCINTL = @INCINTL@
>  INSTALL = @INSTALL@
>  INSTALL_DATA = @INSTALL_DATA@
> @@ -314,8 +318,10 @@ LIBINTL = @LIBINTL@
>  LIBINTL_DEP = @LIBINTL_DEP@
>  LIBOBJS = @LIBOBJS@
>  LIBS = @LIBS@
> +LIBZ = @LIBZ@
>  LN_S = @LN_S@
>  LTLIBOBJS = @LTLIBOBJS@
> +LTLIBZ = @LTLIBZ@
>  MAINT = @MAINT@
>  MAKEINFO = @MAKEINFO@
>  MERGE_CONSTANTS_FLAG = @MERGE_CONSTANTS_FLAG@
> diff --git a/gold/aclocal.m4 b/gold/aclocal.m4
> index 8321894..8444d1d 100644
> --- a/gold/aclocal.m4
> +++ b/gold/aclocal.m4
> @@ -984,6 +984,9 @@ m4_include([../config/depstand.m4])
>  m4_include([../config/gettext-sister.m4])
>  m4_include([../config/lcmessage.m4])
>  m4_include([../config/lead-dot.m4])
> +m4_include([../config/lib-ld.m4])
> +m4_include([../config/lib-link.m4])
> +m4_include([../config/lib-prefix.m4])
>  m4_include([../config/nls.m4])
>  m4_include([../config/override.m4])
>  m4_include([../config/po.m4])
> diff --git a/gold/config.in b/gold/config.in
> index be77810..1871eb5 100644
> --- a/gold/config.in
> +++ b/gold/config.in
> @@ -97,6 +97,9 @@
>  /* Define if your <locale.h> file defines LC_MESSAGES. */
>  #undef HAVE_LC_MESSAGES
>  
> +/* Define if you have the z library. */
> +#undef HAVE_LIBZ
> +
>  /* Define to 1 if you have the <locale.h> header file. */
>  #undef HAVE_LOCALE_H
>  
> diff --git a/gold/configure b/gold/configure
> index 23e4735..66554cd 100755
> --- a/gold/configure
> +++ b/gold/configure
> @@ -602,6 +602,9 @@ HAVE_PUBNAMES_FALSE
>  HAVE_PUBNAMES_TRUE
>  HAVE_ZLIB_FALSE
>  HAVE_ZLIB_TRUE
> +LTLIBZ
> +LIBZ
> +HAVE_LIBZ
>  LIBOBJS
>  LFS_CFLAGS
>  GOLD_LDADD
> @@ -797,6 +800,9 @@ enable_build_warnings
>  with_gold_ldflags
>  with_gold_ldadd
>  with_zlib
> +with_gnu_ld
> +enable_rpath
> +with_libz_prefix
>  enable_maintainer_mode
>  '
>        ac_precious_vars='build_alias
> @@ -1443,6 +1449,7 @@ Optional Features:
>    --disable-nls           do not use Native Language Support
>    --enable-werror         treat compile warnings as errors
>    --enable-build-warnings enable build-time compiler warnings
> +  --disable-rpath         do not hardcode runtime library paths
>    --enable-maintainer-mode  enable make rules and dependencies not useful
>  			  (and sometimes confusing) to the casual installer
>  
> @@ -1454,6 +1461,9 @@ Optional Packages:
>    --with-gold-ldflags=FLAGS  additional link flags for gold
>    --with-gold-ldadd=LIBS     additional libraries for gold
>    --with-zlib             include zlib support (auto/yes/no) default=auto
> +  --with-gnu-ld           assume the C compiler uses GNU ld default=no
> +  --with-libz-prefix[=DIR]  search for libz in DIR/include and DIR/lib
> +  --without-libz-prefix     don't search for libz in includedir and libdir
>  
>  Some influential environment variables:
>    CC          C compiler command
> @@ -6874,6 +6884,164 @@ fi
>  
>  # Link in zlib if we can.  This allows us to write compressed sections.
>  
> +      if test "X$prefix" = "XNONE"; then
> +    acl_final_prefix="$ac_default_prefix"
> +  else
> +    acl_final_prefix="$prefix"
> +  fi
> +  if test "X$exec_prefix" = "XNONE"; then
> +    acl_final_exec_prefix='${prefix}'
> +  else
> +    acl_final_exec_prefix="$exec_prefix"
> +  fi
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
> +  prefix="$acl_save_prefix"
> +
> +
> +# Check whether --with-gnu-ld was given.
> +if test "${with_gnu_ld+set}" = set; then :
> +  withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
> +else
> +  with_gnu_ld=no
> +fi
> +
> +# Prepare PATH_SEPARATOR.
> +# The user is always right.
> +if test "${PATH_SEPARATOR+set}" != set; then
> +  echo "#! /bin/sh" >conf$$.sh
> +  echo  "exit 0"   >>conf$$.sh
> +  chmod +x conf$$.sh
> +  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
> +    PATH_SEPARATOR=';'
> +  else
> +    PATH_SEPARATOR=:
> +  fi
> +  rm -f conf$$.sh
> +fi
> +ac_prog=ld
> +if test "$GCC" = yes; then
> +  # Check if gcc -print-prog-name=ld gives a path.
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by GCC" >&5
> +$as_echo_n "checking for ld used by GCC... " >&6; }
> +  case $host in
> +  *-*-mingw*)
> +    # gcc leaves a trailing carriage return which upsets mingw
> +    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
> +  *)
> +    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
> +  esac
> +  case $ac_prog in
> +    # Accept absolute paths.
> +    [\\/]* | [A-Za-z]:[\\/]*)
> +      re_direlt='/[^/][^/]*/\.\./'
> +      # Canonicalize the path of ld
> +      ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
> +      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
> +	ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
> +      done
> +      test -z "$LD" && LD="$ac_prog"
> +      ;;
> +  "")
> +    # If it fails, then pretend we aren't using GCC.
> +    ac_prog=ld
> +    ;;
> +  *)
> +    # If it is relative, then search for the first ld in PATH.
> +    with_gnu_ld=unknown
> +    ;;
> +  esac
> +elif test "$with_gnu_ld" = yes; then
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
> +$as_echo_n "checking for GNU ld... " >&6; }
> +else
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
> +$as_echo_n "checking for non-GNU ld... " >&6; }
> +fi
> +if test "${acl_cv_path_LD+set}" = set; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +  if test -z "$LD"; then
> +  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
> +  for ac_dir in $PATH; do
> +    test -z "$ac_dir" && ac_dir=.
> +    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
> +      acl_cv_path_LD="$ac_dir/$ac_prog"
> +      # Check to see if the program is GNU ld.  I'd rather use --version,
> +      # but apparently some GNU ld's only accept -v.
> +      # Break only if it was the GNU/non-GNU ld that we prefer.
> +      if "$acl_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
> +	test "$with_gnu_ld" != no && break
> +      else
> +	test "$with_gnu_ld" != yes && break
> +      fi
> +    fi
> +  done
> +  IFS="$ac_save_ifs"
> +else
> +  acl_cv_path_LD="$LD" # Let the user override the test with a path.
> +fi
> +fi
> +
> +LD="$acl_cv_path_LD"
> +if test -n "$LD"; then
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
> +$as_echo "$LD" >&6; }
> +else
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
> +$as_echo "no" >&6; }
> +fi
> +test -z "$LD" && as_fn_error "no acceptable ld found in \$PATH" "$LINENO" 5
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
> +$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; }
> +if test "${acl_cv_prog_gnu_ld+set}" = set; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +  # I'd rather use --version here, but apparently some GNU ld's only accept -v.
> +if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
> +  acl_cv_prog_gnu_ld=yes
> +else
> +  acl_cv_prog_gnu_ld=no
> +fi
> +fi
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_prog_gnu_ld" >&5
> +$as_echo "$acl_cv_prog_gnu_ld" >&6; }
> +with_gnu_ld=$acl_cv_prog_gnu_ld
> +
> +
> +
> +                                                { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5
> +$as_echo_n "checking for shared library run path origin... " >&6; }
> +if test "${acl_cv_rpath+set}" = set; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +
> +    CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
> +    ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
> +    . ./conftest.sh
> +    rm -f ./conftest.sh
> +    acl_cv_rpath=done
> +
> +fi
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_rpath" >&5
> +$as_echo "$acl_cv_rpath" >&6; }
> +  wl="$acl_cv_wl"
> +  libext="$acl_cv_libext"
> +  shlibext="$acl_cv_shlibext"
> +  hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
> +  hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
> +  hardcode_direct="$acl_cv_hardcode_direct"
> +  hardcode_minus_L="$acl_cv_hardcode_minus_L"
> +    # Check whether --enable-rpath was given.
> +if test "${enable_rpath+set}" = set; then :
> +  enableval=$enable_rpath; :
> +else
> +  enable_rpath=yes
> +fi
> +
> +
> +
>    # See if the user specified whether he wants zlib support or not.
>  
>  # Check whether --with-zlib was given.
> @@ -6885,60 +7053,472 @@ fi
>  
>  
>    if test "$with_zlib" != "no"; then
> -    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing zlibVersion" >&5
> -$as_echo_n "checking for library containing zlibVersion... " >&6; }
> -if test "${ac_cv_search_zlibVersion+set}" = set; then :
> +
> +
> +
> +
> +
> +
> +
> +
> +    use_additional=yes
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +
> +    eval additional_includedir=\"$includedir\"
> +    eval additional_libdir=\"$libdir\"
> +
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +
> +# Check whether --with-libz-prefix was given.
> +if test "${with_libz_prefix+set}" = set; then :
> +  withval=$with_libz_prefix;
> +    if test "X$withval" = "Xno"; then
> +      use_additional=no
> +    else
> +      if test "X$withval" = "X"; then
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +
> +          eval additional_includedir=\"$includedir\"
> +          eval additional_libdir=\"$libdir\"
> +
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +      else
> +        additional_includedir="$withval/include"
> +        additional_libdir="$withval/lib"
> +      fi
> +    fi
> +
> +fi
> +
> +      LIBZ=
> +  LTLIBZ=
> +  INCZ=
> +  rpathdirs=
> +  ltrpathdirs=
> +  names_already_handled=
> +  names_next_round='z '
> +  while test -n "$names_next_round"; do
> +    names_this_round="$names_next_round"
> +    names_next_round=
> +    for name in $names_this_round; do
> +      already_handled=
> +      for n in $names_already_handled; do
> +        if test "$n" = "$name"; then
> +          already_handled=yes
> +          break
> +        fi
> +      done
> +      if test -z "$already_handled"; then
> +        names_already_handled="$names_already_handled $name"
> +                        uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
> +        eval value=\"\$HAVE_LIB$uppername\"
> +        if test -n "$value"; then
> +          if test "$value" = yes; then
> +            eval value=\"\$LIB$uppername\"
> +            test -z "$value" || LIBZ="${LIBZ}${LIBZ:+ }$value"
> +            eval value=\"\$LTLIB$uppername\"
> +            test -z "$value" || LTLIBZ="${LTLIBZ}${LTLIBZ:+ }$value"
> +          else
> +                                    :
> +          fi
> +        else
> +                              found_dir=
> +          found_la=
> +          found_so=
> +          found_a=
> +          if test $use_additional = yes; then
> +            if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then
> +              found_dir="$additional_libdir"
> +              found_so="$additional_libdir/lib$name.$shlibext"
> +              if test -f "$additional_libdir/lib$name.la"; then
> +                found_la="$additional_libdir/lib$name.la"
> +              fi
> +            else
> +              if test -f "$additional_libdir/lib$name.$libext"; then
> +                found_dir="$additional_libdir"
> +                found_a="$additional_libdir/lib$name.$libext"
> +                if test -f "$additional_libdir/lib$name.la"; then
> +                  found_la="$additional_libdir/lib$name.la"
> +                fi
> +              fi
> +            fi
> +          fi
> +          if test "X$found_dir" = "X"; then
> +            for x in $LDFLAGS $LTLIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +              case "$x" in
> +                -L*)
> +                  dir=`echo "X$x" | sed -e 's/^X-L//'`
> +                  if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then
> +                    found_dir="$dir"
> +                    found_so="$dir/lib$name.$shlibext"
> +                    if test -f "$dir/lib$name.la"; then
> +                      found_la="$dir/lib$name.la"
> +                    fi
> +                  else
> +                    if test -f "$dir/lib$name.$libext"; then
> +                      found_dir="$dir"
> +                      found_a="$dir/lib$name.$libext"
> +                      if test -f "$dir/lib$name.la"; then
> +                        found_la="$dir/lib$name.la"
> +                      fi
> +                    fi
> +                  fi
> +                  ;;
> +              esac
> +              if test "X$found_dir" != "X"; then
> +                break
> +              fi
> +            done
> +          fi
> +          if test "X$found_dir" != "X"; then
> +                        LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-L$found_dir -l$name"
> +            if test "X$found_so" != "X"; then
> +                                                        if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then
> +                                LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +              else
> +                                                                                haveit=
> +                for x in $ltrpathdirs; do
> +                  if test "X$x" = "X$found_dir"; then
> +                    haveit=yes
> +                    break
> +                  fi
> +                done
> +                if test -z "$haveit"; then
> +                  ltrpathdirs="$ltrpathdirs $found_dir"
> +                fi
> +                                if test "$hardcode_direct" = yes; then
> +                                                      LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +                else
> +                  if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then
> +                                                            LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +                                                            haveit=
> +                    for x in $rpathdirs; do
> +                      if test "X$x" = "X$found_dir"; then
> +                        haveit=yes
> +                        break
> +                      fi
> +                    done
> +                    if test -z "$haveit"; then
> +                      rpathdirs="$rpathdirs $found_dir"
> +                    fi
> +                  else
> +                                                                                haveit=
> +                    for x in $LDFLAGS $LIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                      if test "X$x" = "X-L$found_dir"; then
> +                        haveit=yes
> +                        break
> +                      fi
> +                    done
> +                    if test -z "$haveit"; then
> +                      LIBZ="${LIBZ}${LIBZ:+ }-L$found_dir"
> +                    fi
> +                    if test "$hardcode_minus_L" != no; then
> +                                                                                        LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +                    else
> +                                                                                                                                                                                LIBZ="${LIBZ}${LIBZ:+ }-l$name"
> +                    fi
> +                  fi
> +                fi
> +              fi
> +            else
> +              if test "X$found_a" != "X"; then
> +                                LIBZ="${LIBZ}${LIBZ:+ }$found_a"
> +              else
> +                                                LIBZ="${LIBZ}${LIBZ:+ }-L$found_dir -l$name"
> +              fi
> +            fi
> +                        additional_includedir=
> +            case "$found_dir" in
> +              */lib | */lib/)
> +                basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'`
> +                additional_includedir="$basedir/include"
> +                ;;
> +            esac
> +            if test "X$additional_includedir" != "X"; then
> +                                                                                                                if test "X$additional_includedir" != "X/usr/include"; then
> +                haveit=
> +                if test "X$additional_includedir" = "X/usr/local/include"; then
> +                  if test -n "$GCC"; then
> +                    case $host_os in
> +                      linux*) haveit=yes;;
> +                    esac
> +                  fi
> +                fi
> +                if test -z "$haveit"; then
> +                  for x in $CPPFLAGS $INCZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                    if test "X$x" = "X-I$additional_includedir"; then
> +                      haveit=yes
> +                      break
> +                    fi
> +                  done
> +                  if test -z "$haveit"; then
> +                    if test -d "$additional_includedir"; then
> +                                            INCZ="${INCZ}${INCZ:+ }-I$additional_includedir"
> +                    fi
> +                  fi
> +                fi
> +              fi
> +            fi
> +                        if test -n "$found_la"; then
> +                                                        save_libdir="$libdir"
> +              case "$found_la" in
> +                */* | *\\*) . "$found_la" ;;
> +                *) . "./$found_la" ;;
> +              esac
> +              libdir="$save_libdir"
> +                            for dep in $dependency_libs; do
> +                case "$dep" in
> +                  -L*)
> +                    additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
> +                                                                                                                                                                if test "X$additional_libdir" != "X/usr/lib"; then
> +                      haveit=
> +                      if test "X$additional_libdir" = "X/usr/local/lib"; then
> +                        if test -n "$GCC"; then
> +                          case $host_os in
> +                            linux*) haveit=yes;;
> +                          esac
> +                        fi
> +                      fi
> +                      if test -z "$haveit"; then
> +                        haveit=
> +                        for x in $LDFLAGS $LIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                          if test "X$x" = "X-L$additional_libdir"; then
> +                            haveit=yes
> +                            break
> +                          fi
> +                        done
> +                        if test -z "$haveit"; then
> +                          if test -d "$additional_libdir"; then
> +                                                        LIBZ="${LIBZ}${LIBZ:+ }-L$additional_libdir"
> +                          fi
> +                        fi
> +                        haveit=
> +                        for x in $LDFLAGS $LTLIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                          if test "X$x" = "X-L$additional_libdir"; then
> +                            haveit=yes
> +                            break
> +                          fi
> +                        done
> +                        if test -z "$haveit"; then
> +                          if test -d "$additional_libdir"; then
> +                                                        LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-L$additional_libdir"
> +                          fi
> +                        fi
> +                      fi
> +                    fi
> +                    ;;
> +                  -R*)
> +                    dir=`echo "X$dep" | sed -e 's/^X-R//'`
> +                    if test "$enable_rpath" != no; then
> +                                                                  haveit=
> +                      for x in $rpathdirs; do
> +                        if test "X$x" = "X$dir"; then
> +                          haveit=yes
> +                          break
> +                        fi
> +                      done
> +                      if test -z "$haveit"; then
> +                        rpathdirs="$rpathdirs $dir"
> +                      fi
> +                                                                  haveit=
> +                      for x in $ltrpathdirs; do
> +                        if test "X$x" = "X$dir"; then
> +                          haveit=yes
> +                          break
> +                        fi
> +                      done
> +                      if test -z "$haveit"; then
> +                        ltrpathdirs="$ltrpathdirs $dir"
> +                      fi
> +                    fi
> +                    ;;
> +                  -l*)
> +                                        names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
> +                    ;;
> +                  *.la)
> +                                                                                names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
> +                    ;;
> +                  *)
> +                                        LIBZ="${LIBZ}${LIBZ:+ }$dep"
> +                    LTLIBZ="${LTLIBZ}${LTLIBZ:+ }$dep"
> +                    ;;
> +                esac
> +              done
> +            fi
> +          else
> +                                                            LIBZ="${LIBZ}${LIBZ:+ }-l$name"
> +            LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-l$name"
> +          fi
> +        fi
> +      fi
> +    done
> +  done
> +  if test "X$rpathdirs" != "X"; then
> +    if test -n "$hardcode_libdir_separator"; then
> +                        alldirs=
> +      for found_dir in $rpathdirs; do
> +        alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir"
> +      done
> +            acl_save_libdir="$libdir"
> +      libdir="$alldirs"
> +      eval flag=\"$hardcode_libdir_flag_spec\"
> +      libdir="$acl_save_libdir"
> +      LIBZ="${LIBZ}${LIBZ:+ }$flag"
> +    else
> +            for found_dir in $rpathdirs; do
> +        acl_save_libdir="$libdir"
> +        libdir="$found_dir"
> +        eval flag=\"$hardcode_libdir_flag_spec\"
> +        libdir="$acl_save_libdir"
> +        LIBZ="${LIBZ}${LIBZ:+ }$flag"
> +      done
> +    fi
> +  fi
> +  if test "X$ltrpathdirs" != "X"; then
> +            for found_dir in $ltrpathdirs; do
> +      LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-R$found_dir"
> +    done
> +  fi
> +
> +
> +        ac_save_CPPFLAGS="$CPPFLAGS"
> +
> +  for element in $INCZ; do
> +    haveit=
> +    for x in $CPPFLAGS; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +      if test "X$x" = "X$element"; then
> +        haveit=yes
> +        break
> +      fi
> +    done
> +    if test -z "$haveit"; then
> +      CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element"
> +    fi
> +  done
> +
> +
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libz" >&5
> +$as_echo_n "checking for libz... " >&6; }
> +if test "${ac_cv_libz+set}" = set; then :
>    $as_echo_n "(cached) " >&6
>  else
> -  ac_func_search_save_LIBS=$LIBS
> -cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> -/* end confdefs.h.  */
>  
> -/* Override any GCC internal prototype to avoid an error.
> -   Use char because int might match the return type of a GCC
> -   builtin and then its argument prototype would still apply.  */
> -#ifdef __cplusplus
> -extern "C"
> -#endif
> -char zlibVersion ();
> +    ac_save_LIBS="$LIBS"
> +    LIBS="$LIBS $LIBZ"
> +    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> +/* end confdefs.h.  */
> +#include "zlib.h";
>  int
>  main ()
>  {
> -return zlibVersion ();
> +int ret = deflateInit(NULL, 1);
>    ;
>    return 0;
>  }
>  _ACEOF
> -for ac_lib in '' z; do
> -  if test -z "$ac_lib"; then
> -    ac_res="none required"
> -  else
> -    ac_res=-l$ac_lib
> -    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
> -  fi
> -  if ac_fn_c_try_link "$LINENO"; then :
> -  ac_cv_search_zlibVersion=$ac_res
> +if ac_fn_c_try_link "$LINENO"; then :
> +  ac_cv_libz=yes
> +else
> +  ac_cv_libz=no
>  fi
>  rm -f core conftest.err conftest.$ac_objext \
> -    conftest$ac_exeext
> -  if test "${ac_cv_search_zlibVersion+set}" = set; then :
> -  break
> -fi
> -done
> -if test "${ac_cv_search_zlibVersion+set}" = set; then :
> +    conftest$ac_exeext conftest.$ac_ext
> +    LIBS="$ac_save_LIBS"
>  
> -else
> -  ac_cv_search_zlibVersion=no
>  fi
> -rm conftest.$ac_ext
> -LIBS=$ac_func_search_save_LIBS
> -fi
> -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_zlibVersion" >&5
> -$as_echo "$ac_cv_search_zlibVersion" >&6; }
> -ac_res=$ac_cv_search_zlibVersion
> -if test "$ac_res" != no; then :
> -  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
> -  for ac_header in zlib.h
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_libz" >&5
> +$as_echo "$ac_cv_libz" >&6; }
> +  if test "$ac_cv_libz" = yes; then
> +    HAVE_LIBZ=yes
> +
> +$as_echo "#define HAVE_LIBZ 1" >>confdefs.h
> +
> +    { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libz" >&5
> +$as_echo_n "checking how to link with libz... " >&6; }
> +    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBZ" >&5
> +$as_echo "$LIBZ" >&6; }
> +  else
> +    HAVE_LIBZ=no
> +            CPPFLAGS="$ac_save_CPPFLAGS"
> +    LIBZ=
> +    LTLIBZ=
> +  fi
> +
> +
> +
> +
> +
> +
> +    if test "$HAVE_LIBZ" = "yes"; then
> +      # Make sure HAVE_ZLIB_H gets defined.  Some code uses that over
> +      # HAVE_LIBZ, since initially we were only defining HAVE_ZLIB_H.
> +      for ac_header in zlib.h
>  do :
>    ac_fn_c_check_header_mongrel "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default"
>  if test "x$ac_cv_header_zlib_h" = x""yes; then :
> @@ -6950,9 +7530,9 @@ fi
>  
>  done
>  
> -fi
> -
> -    if test "$with_zlib" = "yes" -a "$ac_cv_header_zlib_h" != "yes"; then
> +      LIBS="$LIBS $LIBZ"
> +    fi
> +    if test "$with_zlib" = "yes" -a "$HAVE_LIBZ" != "yes"; then
>        as_fn_error "zlib (libz) library was explicitly requested but not found" "$LINENO" 5
>      fi
>    fi
> diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in
> index d818570..14aa076 100644
> --- a/gold/testsuite/Makefile.in
> +++ b/gold/testsuite/Makefile.in
> @@ -756,6 +756,9 @@ am__aclocal_m4_deps = $(top_srcdir)/../config/depstand.m4 \
>  	$(top_srcdir)/../config/gettext-sister.m4 \
>  	$(top_srcdir)/../config/lcmessage.m4 \
>  	$(top_srcdir)/../config/lead-dot.m4 \
> +	$(top_srcdir)/../config/lib-ld.m4 \
> +	$(top_srcdir)/../config/lib-link.m4 \
> +	$(top_srcdir)/../config/lib-prefix.m4 \
>  	$(top_srcdir)/../config/nls.m4 \
>  	$(top_srcdir)/../config/override.m4 \
>  	$(top_srcdir)/../config/po.m4 \
> @@ -2055,6 +2058,7 @@ GMSGFMT = @GMSGFMT@
>  GOLD_LDADD = @GOLD_LDADD@
>  GOLD_LDFLAGS = @GOLD_LDFLAGS@
>  GREP = @GREP@
> +HAVE_LIBZ = @HAVE_LIBZ@
>  INCINTL = @INCINTL@
>  INSTALL = @INSTALL@
>  INSTALL_DATA = @INSTALL_DATA@
> @@ -2068,8 +2072,10 @@ LIBINTL = @LIBINTL@
>  LIBINTL_DEP = @LIBINTL_DEP@
>  LIBOBJS = @LIBOBJS@
>  LIBS = @LIBS@
> +LIBZ = @LIBZ@
>  LN_S = @LN_S@
>  LTLIBOBJS = @LTLIBOBJS@
> +LTLIBZ = @LTLIBZ@
>  MAINT = @MAINT@
>  MAKEINFO = @MAKEINFO@
>  MERGE_CONSTANTS_FLAG = @MERGE_CONSTANTS_FLAG@
> diff --git a/ld/Makefile.in b/ld/Makefile.in
> index 311452d..a54bc97 100644
> --- a/ld/Makefile.in
> +++ b/ld/Makefile.in
> @@ -75,6 +75,9 @@ am__aclocal_m4_deps = $(top_srcdir)/../bfd/acinclude.m4 \
>  	$(top_srcdir)/../config/largefile.m4 \
>  	$(top_srcdir)/../config/lcmessage.m4 \
>  	$(top_srcdir)/../config/lead-dot.m4 \
> +	$(top_srcdir)/../config/lib-ld.m4 \
> +	$(top_srcdir)/../config/lib-link.m4 \
> +	$(top_srcdir)/../config/lib-prefix.m4 \
>  	$(top_srcdir)/../config/nls.m4 \
>  	$(top_srcdir)/../config/override.m4 \
>  	$(top_srcdir)/../config/plugins.m4 \
> @@ -226,6 +229,7 @@ FGREP = @FGREP@
>  GENCAT = @GENCAT@
>  GMSGFMT = @GMSGFMT@
>  GREP = @GREP@
> +HAVE_LIBZ = @HAVE_LIBZ@
>  HDEFINES = @HDEFINES@
>  
>  #stuff for self hosting (can be overridden in config file).
> @@ -250,6 +254,7 @@ LIBINTL_DEP = @LIBINTL_DEP@
>  LIBOBJS = @LIBOBJS@
>  LIBS = @LIBS@
>  LIBTOOL = @LIBTOOL@
> +LIBZ = @LIBZ@
>  
>  # Search path to override the default search path for -lfoo libraries.
>  # If LIB_PATH is empty, the ones in the script (if any) are left alone.
> @@ -262,6 +267,7 @@ LIB_PATH = @LIB_PATH@
>  LIPO = @LIPO@
>  LN_S = @LN_S@
>  LTLIBOBJS = @LTLIBOBJS@
> +LTLIBZ = @LTLIBZ@
>  MAINT = @MAINT@
>  MAKEINFO = @MAKEINFO@
>  MKDIR_P = @MKDIR_P@
> diff --git a/ld/aclocal.m4 b/ld/aclocal.m4
> index 6585160..fed7950 100644
> --- a/ld/aclocal.m4
> +++ b/ld/aclocal.m4
> @@ -997,6 +997,9 @@ m4_include([../config/gettext-sister.m4])
>  m4_include([../config/largefile.m4])
>  m4_include([../config/lcmessage.m4])
>  m4_include([../config/lead-dot.m4])
> +m4_include([../config/lib-ld.m4])
> +m4_include([../config/lib-link.m4])
> +m4_include([../config/lib-prefix.m4])
>  m4_include([../config/nls.m4])
>  m4_include([../config/override.m4])
>  m4_include([../config/plugins.m4])
> diff --git a/ld/config.in b/ld/config.in
> index 2ab4844..226009e 100644
> --- a/ld/config.in
> +++ b/ld/config.in
> @@ -68,6 +68,9 @@
>  /* Define if your <locale.h> file defines LC_MESSAGES. */
>  #undef HAVE_LC_MESSAGES
>  
> +/* Define if you have the z library. */
> +#undef HAVE_LIBZ
> +
>  /* Define to 1 if you have the <limits.h> header file. */
>  #undef HAVE_LIMITS_H
>  
> diff --git a/ld/configure b/ld/configure
> index 8a7bd20..a0078da 100755
> --- a/ld/configure
> +++ b/ld/configure
> @@ -609,6 +609,9 @@ EMUL_EXTRA_OFILES
>  EMULATION_OFILES
>  EMUL
>  STRINGIFY
> +LTLIBZ
> +LIBZ
> +HAVE_LIBZ
>  enable_initfini_array
>  ENABLE_PLUGINS_FALSE
>  ENABLE_PLUGINS_TRUE
> @@ -790,6 +793,8 @@ enable_build_warnings
>  enable_nls
>  enable_initfini_array
>  with_zlib
> +enable_rpath
> +with_libz_prefix
>  '
>        ac_precious_vars='build_alias
>  host_alias
> @@ -1446,6 +1451,7 @@ Optional Features:
>    --enable-build-warnings enable build-time compiler warnings
>    --disable-nls           do not use Native Language Support
>    --enable-initfini-array	use .init_array/.fini_array sections
> +  --disable-rpath         do not hardcode runtime library paths
>  
>  Optional Packages:
>    --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
> @@ -1456,6 +1462,9 @@ Optional Packages:
>    --with-lib-path=dir1:dir2...  set default LIB_PATH
>    --with-sysroot=DIR Search for usr/lib et al within DIR.
>    --with-zlib             include zlib support (auto/yes/no) default=auto
> +  --with-gnu-ld           assume the C compiler uses GNU ld default=no
> +  --with-libz-prefix[=DIR]  search for libz in DIR/include and DIR/lib
> +  --without-libz-prefix     don't search for libz in includedir and libdir
>  
>  Some influential environment variables:
>    CC          C compiler command
> @@ -11712,7 +11721,7 @@ else
>    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>    lt_status=$lt_dlunknown
>    cat > conftest.$ac_ext <<_LT_EOF
> -#line 11715 "configure"
> +#line 11724 "configure"
>  #include "confdefs.h"
>  
>  #if HAVE_DLFCN_H
> @@ -11818,7 +11827,7 @@ else
>    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>    lt_status=$lt_dlunknown
>    cat > conftest.$ac_ext <<_LT_EOF
> -#line 11821 "configure"
> +#line 11830 "configure"
>  #include "confdefs.h"
>  
>  #if HAVE_DLFCN_H
> @@ -16757,6 +16766,164 @@ _ACEOF
>  # Link in zlib if we can.  This is needed only for the bootstrap tests
>  # right now, since those tests use libbfd, which depends on zlib.
>  
> +      if test "X$prefix" = "XNONE"; then
> +    acl_final_prefix="$ac_default_prefix"
> +  else
> +    acl_final_prefix="$prefix"
> +  fi
> +  if test "X$exec_prefix" = "XNONE"; then
> +    acl_final_exec_prefix='${prefix}'
> +  else
> +    acl_final_exec_prefix="$exec_prefix"
> +  fi
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
> +  prefix="$acl_save_prefix"
> +
> +
> +# Check whether --with-gnu-ld was given.
> +if test "${with_gnu_ld+set}" = set; then :
> +  withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
> +else
> +  with_gnu_ld=no
> +fi
> +
> +# Prepare PATH_SEPARATOR.
> +# The user is always right.
> +if test "${PATH_SEPARATOR+set}" != set; then
> +  echo "#! /bin/sh" >conf$$.sh
> +  echo  "exit 0"   >>conf$$.sh
> +  chmod +x conf$$.sh
> +  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
> +    PATH_SEPARATOR=';'
> +  else
> +    PATH_SEPARATOR=:
> +  fi
> +  rm -f conf$$.sh
> +fi
> +ac_prog=ld
> +if test "$GCC" = yes; then
> +  # Check if gcc -print-prog-name=ld gives a path.
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by GCC" >&5
> +$as_echo_n "checking for ld used by GCC... " >&6; }
> +  case $host in
> +  *-*-mingw*)
> +    # gcc leaves a trailing carriage return which upsets mingw
> +    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
> +  *)
> +    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
> +  esac
> +  case $ac_prog in
> +    # Accept absolute paths.
> +    [\\/]* | [A-Za-z]:[\\/]*)
> +      re_direlt='/[^/][^/]*/\.\./'
> +      # Canonicalize the path of ld
> +      ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
> +      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
> +	ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
> +      done
> +      test -z "$LD" && LD="$ac_prog"
> +      ;;
> +  "")
> +    # If it fails, then pretend we aren't using GCC.
> +    ac_prog=ld
> +    ;;
> +  *)
> +    # If it is relative, then search for the first ld in PATH.
> +    with_gnu_ld=unknown
> +    ;;
> +  esac
> +elif test "$with_gnu_ld" = yes; then
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
> +$as_echo_n "checking for GNU ld... " >&6; }
> +else
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
> +$as_echo_n "checking for non-GNU ld... " >&6; }
> +fi
> +if test "${acl_cv_path_LD+set}" = set; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +  if test -z "$LD"; then
> +  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
> +  for ac_dir in $PATH; do
> +    test -z "$ac_dir" && ac_dir=.
> +    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
> +      acl_cv_path_LD="$ac_dir/$ac_prog"
> +      # Check to see if the program is GNU ld.  I'd rather use --version,
> +      # but apparently some GNU ld's only accept -v.
> +      # Break only if it was the GNU/non-GNU ld that we prefer.
> +      if "$acl_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
> +	test "$with_gnu_ld" != no && break
> +      else
> +	test "$with_gnu_ld" != yes && break
> +      fi
> +    fi
> +  done
> +  IFS="$ac_save_ifs"
> +else
> +  acl_cv_path_LD="$LD" # Let the user override the test with a path.
> +fi
> +fi
> +
> +LD="$acl_cv_path_LD"
> +if test -n "$LD"; then
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
> +$as_echo "$LD" >&6; }
> +else
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
> +$as_echo "no" >&6; }
> +fi
> +test -z "$LD" && as_fn_error "no acceptable ld found in \$PATH" "$LINENO" 5
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
> +$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; }
> +if test "${acl_cv_prog_gnu_ld+set}" = set; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +  # I'd rather use --version here, but apparently some GNU ld's only accept -v.
> +if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
> +  acl_cv_prog_gnu_ld=yes
> +else
> +  acl_cv_prog_gnu_ld=no
> +fi
> +fi
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_prog_gnu_ld" >&5
> +$as_echo "$acl_cv_prog_gnu_ld" >&6; }
> +with_gnu_ld=$acl_cv_prog_gnu_ld
> +
> +
> +
> +                                                { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5
> +$as_echo_n "checking for shared library run path origin... " >&6; }
> +if test "${acl_cv_rpath+set}" = set; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +
> +    CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
> +    ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
> +    . ./conftest.sh
> +    rm -f ./conftest.sh
> +    acl_cv_rpath=done
> +
> +fi
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_rpath" >&5
> +$as_echo "$acl_cv_rpath" >&6; }
> +  wl="$acl_cv_wl"
> +  libext="$acl_cv_libext"
> +  shlibext="$acl_cv_shlibext"
> +  hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
> +  hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
> +  hardcode_direct="$acl_cv_hardcode_direct"
> +  hardcode_minus_L="$acl_cv_hardcode_minus_L"
> +    # Check whether --enable-rpath was given.
> +if test "${enable_rpath+set}" = set; then :
> +  enableval=$enable_rpath; :
> +else
> +  enable_rpath=yes
> +fi
> +
> +
> +
>    # See if the user specified whether he wants zlib support or not.
>  
>  # Check whether --with-zlib was given.
> @@ -16768,60 +16935,472 @@ fi
>  
>  
>    if test "$with_zlib" != "no"; then
> -    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing zlibVersion" >&5
> -$as_echo_n "checking for library containing zlibVersion... " >&6; }
> -if test "${ac_cv_search_zlibVersion+set}" = set; then :
> +
> +
> +
> +
> +
> +
> +
> +
> +    use_additional=yes
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +
> +    eval additional_includedir=\"$includedir\"
> +    eval additional_libdir=\"$libdir\"
> +
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +
> +# Check whether --with-libz-prefix was given.
> +if test "${with_libz_prefix+set}" = set; then :
> +  withval=$with_libz_prefix;
> +    if test "X$withval" = "Xno"; then
> +      use_additional=no
> +    else
> +      if test "X$withval" = "X"; then
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +
> +          eval additional_includedir=\"$includedir\"
> +          eval additional_libdir=\"$libdir\"
> +
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +      else
> +        additional_includedir="$withval/include"
> +        additional_libdir="$withval/lib"
> +      fi
> +    fi
> +
> +fi
> +
> +      LIBZ=
> +  LTLIBZ=
> +  INCZ=
> +  rpathdirs=
> +  ltrpathdirs=
> +  names_already_handled=
> +  names_next_round='z '
> +  while test -n "$names_next_round"; do
> +    names_this_round="$names_next_round"
> +    names_next_round=
> +    for name in $names_this_round; do
> +      already_handled=
> +      for n in $names_already_handled; do
> +        if test "$n" = "$name"; then
> +          already_handled=yes
> +          break
> +        fi
> +      done
> +      if test -z "$already_handled"; then
> +        names_already_handled="$names_already_handled $name"
> +                        uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
> +        eval value=\"\$HAVE_LIB$uppername\"
> +        if test -n "$value"; then
> +          if test "$value" = yes; then
> +            eval value=\"\$LIB$uppername\"
> +            test -z "$value" || LIBZ="${LIBZ}${LIBZ:+ }$value"
> +            eval value=\"\$LTLIB$uppername\"
> +            test -z "$value" || LTLIBZ="${LTLIBZ}${LTLIBZ:+ }$value"
> +          else
> +                                    :
> +          fi
> +        else
> +                              found_dir=
> +          found_la=
> +          found_so=
> +          found_a=
> +          if test $use_additional = yes; then
> +            if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then
> +              found_dir="$additional_libdir"
> +              found_so="$additional_libdir/lib$name.$shlibext"
> +              if test -f "$additional_libdir/lib$name.la"; then
> +                found_la="$additional_libdir/lib$name.la"
> +              fi
> +            else
> +              if test -f "$additional_libdir/lib$name.$libext"; then
> +                found_dir="$additional_libdir"
> +                found_a="$additional_libdir/lib$name.$libext"
> +                if test -f "$additional_libdir/lib$name.la"; then
> +                  found_la="$additional_libdir/lib$name.la"
> +                fi
> +              fi
> +            fi
> +          fi
> +          if test "X$found_dir" = "X"; then
> +            for x in $LDFLAGS $LTLIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +              case "$x" in
> +                -L*)
> +                  dir=`echo "X$x" | sed -e 's/^X-L//'`
> +                  if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then
> +                    found_dir="$dir"
> +                    found_so="$dir/lib$name.$shlibext"
> +                    if test -f "$dir/lib$name.la"; then
> +                      found_la="$dir/lib$name.la"
> +                    fi
> +                  else
> +                    if test -f "$dir/lib$name.$libext"; then
> +                      found_dir="$dir"
> +                      found_a="$dir/lib$name.$libext"
> +                      if test -f "$dir/lib$name.la"; then
> +                        found_la="$dir/lib$name.la"
> +                      fi
> +                    fi
> +                  fi
> +                  ;;
> +              esac
> +              if test "X$found_dir" != "X"; then
> +                break
> +              fi
> +            done
> +          fi
> +          if test "X$found_dir" != "X"; then
> +                        LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-L$found_dir -l$name"
> +            if test "X$found_so" != "X"; then
> +                                                        if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then
> +                                LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +              else
> +                                                                                haveit=
> +                for x in $ltrpathdirs; do
> +                  if test "X$x" = "X$found_dir"; then
> +                    haveit=yes
> +                    break
> +                  fi
> +                done
> +                if test -z "$haveit"; then
> +                  ltrpathdirs="$ltrpathdirs $found_dir"
> +                fi
> +                                if test "$hardcode_direct" = yes; then
> +                                                      LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +                else
> +                  if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then
> +                                                            LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +                                                            haveit=
> +                    for x in $rpathdirs; do
> +                      if test "X$x" = "X$found_dir"; then
> +                        haveit=yes
> +                        break
> +                      fi
> +                    done
> +                    if test -z "$haveit"; then
> +                      rpathdirs="$rpathdirs $found_dir"
> +                    fi
> +                  else
> +                                                                                haveit=
> +                    for x in $LDFLAGS $LIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                      if test "X$x" = "X-L$found_dir"; then
> +                        haveit=yes
> +                        break
> +                      fi
> +                    done
> +                    if test -z "$haveit"; then
> +                      LIBZ="${LIBZ}${LIBZ:+ }-L$found_dir"
> +                    fi
> +                    if test "$hardcode_minus_L" != no; then
> +                                                                                        LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +                    else
> +                                                                                                                                                                                LIBZ="${LIBZ}${LIBZ:+ }-l$name"
> +                    fi
> +                  fi
> +                fi
> +              fi
> +            else
> +              if test "X$found_a" != "X"; then
> +                                LIBZ="${LIBZ}${LIBZ:+ }$found_a"
> +              else
> +                                                LIBZ="${LIBZ}${LIBZ:+ }-L$found_dir -l$name"
> +              fi
> +            fi
> +                        additional_includedir=
> +            case "$found_dir" in
> +              */lib | */lib/)
> +                basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'`
> +                additional_includedir="$basedir/include"
> +                ;;
> +            esac
> +            if test "X$additional_includedir" != "X"; then
> +                                                                                                                if test "X$additional_includedir" != "X/usr/include"; then
> +                haveit=
> +                if test "X$additional_includedir" = "X/usr/local/include"; then
> +                  if test -n "$GCC"; then
> +                    case $host_os in
> +                      linux*) haveit=yes;;
> +                    esac
> +                  fi
> +                fi
> +                if test -z "$haveit"; then
> +                  for x in $CPPFLAGS $INCZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                    if test "X$x" = "X-I$additional_includedir"; then
> +                      haveit=yes
> +                      break
> +                    fi
> +                  done
> +                  if test -z "$haveit"; then
> +                    if test -d "$additional_includedir"; then
> +                                            INCZ="${INCZ}${INCZ:+ }-I$additional_includedir"
> +                    fi
> +                  fi
> +                fi
> +              fi
> +            fi
> +                        if test -n "$found_la"; then
> +                                                        save_libdir="$libdir"
> +              case "$found_la" in
> +                */* | *\\*) . "$found_la" ;;
> +                *) . "./$found_la" ;;
> +              esac
> +              libdir="$save_libdir"
> +                            for dep in $dependency_libs; do
> +                case "$dep" in
> +                  -L*)
> +                    additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
> +                                                                                                                                                                if test "X$additional_libdir" != "X/usr/lib"; then
> +                      haveit=
> +                      if test "X$additional_libdir" = "X/usr/local/lib"; then
> +                        if test -n "$GCC"; then
> +                          case $host_os in
> +                            linux*) haveit=yes;;
> +                          esac
> +                        fi
> +                      fi
> +                      if test -z "$haveit"; then
> +                        haveit=
> +                        for x in $LDFLAGS $LIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                          if test "X$x" = "X-L$additional_libdir"; then
> +                            haveit=yes
> +                            break
> +                          fi
> +                        done
> +                        if test -z "$haveit"; then
> +                          if test -d "$additional_libdir"; then
> +                                                        LIBZ="${LIBZ}${LIBZ:+ }-L$additional_libdir"
> +                          fi
> +                        fi
> +                        haveit=
> +                        for x in $LDFLAGS $LTLIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                          if test "X$x" = "X-L$additional_libdir"; then
> +                            haveit=yes
> +                            break
> +                          fi
> +                        done
> +                        if test -z "$haveit"; then
> +                          if test -d "$additional_libdir"; then
> +                                                        LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-L$additional_libdir"
> +                          fi
> +                        fi
> +                      fi
> +                    fi
> +                    ;;
> +                  -R*)
> +                    dir=`echo "X$dep" | sed -e 's/^X-R//'`
> +                    if test "$enable_rpath" != no; then
> +                                                                  haveit=
> +                      for x in $rpathdirs; do
> +                        if test "X$x" = "X$dir"; then
> +                          haveit=yes
> +                          break
> +                        fi
> +                      done
> +                      if test -z "$haveit"; then
> +                        rpathdirs="$rpathdirs $dir"
> +                      fi
> +                                                                  haveit=
> +                      for x in $ltrpathdirs; do
> +                        if test "X$x" = "X$dir"; then
> +                          haveit=yes
> +                          break
> +                        fi
> +                      done
> +                      if test -z "$haveit"; then
> +                        ltrpathdirs="$ltrpathdirs $dir"
> +                      fi
> +                    fi
> +                    ;;
> +                  -l*)
> +                                        names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
> +                    ;;
> +                  *.la)
> +                                                                                names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
> +                    ;;
> +                  *)
> +                                        LIBZ="${LIBZ}${LIBZ:+ }$dep"
> +                    LTLIBZ="${LTLIBZ}${LTLIBZ:+ }$dep"
> +                    ;;
> +                esac
> +              done
> +            fi
> +          else
> +                                                            LIBZ="${LIBZ}${LIBZ:+ }-l$name"
> +            LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-l$name"
> +          fi
> +        fi
> +      fi
> +    done
> +  done
> +  if test "X$rpathdirs" != "X"; then
> +    if test -n "$hardcode_libdir_separator"; then
> +                        alldirs=
> +      for found_dir in $rpathdirs; do
> +        alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir"
> +      done
> +            acl_save_libdir="$libdir"
> +      libdir="$alldirs"
> +      eval flag=\"$hardcode_libdir_flag_spec\"
> +      libdir="$acl_save_libdir"
> +      LIBZ="${LIBZ}${LIBZ:+ }$flag"
> +    else
> +            for found_dir in $rpathdirs; do
> +        acl_save_libdir="$libdir"
> +        libdir="$found_dir"
> +        eval flag=\"$hardcode_libdir_flag_spec\"
> +        libdir="$acl_save_libdir"
> +        LIBZ="${LIBZ}${LIBZ:+ }$flag"
> +      done
> +    fi
> +  fi
> +  if test "X$ltrpathdirs" != "X"; then
> +            for found_dir in $ltrpathdirs; do
> +      LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-R$found_dir"
> +    done
> +  fi
> +
> +
> +        ac_save_CPPFLAGS="$CPPFLAGS"
> +
> +  for element in $INCZ; do
> +    haveit=
> +    for x in $CPPFLAGS; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +      if test "X$x" = "X$element"; then
> +        haveit=yes
> +        break
> +      fi
> +    done
> +    if test -z "$haveit"; then
> +      CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element"
> +    fi
> +  done
> +
> +
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libz" >&5
> +$as_echo_n "checking for libz... " >&6; }
> +if test "${ac_cv_libz+set}" = set; then :
>    $as_echo_n "(cached) " >&6
>  else
> -  ac_func_search_save_LIBS=$LIBS
> -cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> -/* end confdefs.h.  */
>  
> -/* Override any GCC internal prototype to avoid an error.
> -   Use char because int might match the return type of a GCC
> -   builtin and then its argument prototype would still apply.  */
> -#ifdef __cplusplus
> -extern "C"
> -#endif
> -char zlibVersion ();
> +    ac_save_LIBS="$LIBS"
> +    LIBS="$LIBS $LIBZ"
> +    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> +/* end confdefs.h.  */
> +#include "zlib.h";
>  int
>  main ()
>  {
> -return zlibVersion ();
> +int ret = deflateInit(NULL, 1);
>    ;
>    return 0;
>  }
>  _ACEOF
> -for ac_lib in '' z; do
> -  if test -z "$ac_lib"; then
> -    ac_res="none required"
> -  else
> -    ac_res=-l$ac_lib
> -    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
> -  fi
> -  if ac_fn_c_try_link "$LINENO"; then :
> -  ac_cv_search_zlibVersion=$ac_res
> +if ac_fn_c_try_link "$LINENO"; then :
> +  ac_cv_libz=yes
> +else
> +  ac_cv_libz=no
>  fi
>  rm -f core conftest.err conftest.$ac_objext \
> -    conftest$ac_exeext
> -  if test "${ac_cv_search_zlibVersion+set}" = set; then :
> -  break
> -fi
> -done
> -if test "${ac_cv_search_zlibVersion+set}" = set; then :
> +    conftest$ac_exeext conftest.$ac_ext
> +    LIBS="$ac_save_LIBS"
>  
> -else
> -  ac_cv_search_zlibVersion=no
>  fi
> -rm conftest.$ac_ext
> -LIBS=$ac_func_search_save_LIBS
> -fi
> -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_zlibVersion" >&5
> -$as_echo "$ac_cv_search_zlibVersion" >&6; }
> -ac_res=$ac_cv_search_zlibVersion
> -if test "$ac_res" != no; then :
> -  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
> -  for ac_header in zlib.h
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_libz" >&5
> +$as_echo "$ac_cv_libz" >&6; }
> +  if test "$ac_cv_libz" = yes; then
> +    HAVE_LIBZ=yes
> +
> +$as_echo "#define HAVE_LIBZ 1" >>confdefs.h
> +
> +    { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libz" >&5
> +$as_echo_n "checking how to link with libz... " >&6; }
> +    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBZ" >&5
> +$as_echo "$LIBZ" >&6; }
> +  else
> +    HAVE_LIBZ=no
> +            CPPFLAGS="$ac_save_CPPFLAGS"
> +    LIBZ=
> +    LTLIBZ=
> +  fi
> +
> +
> +
> +
> +
> +
> +    if test "$HAVE_LIBZ" = "yes"; then
> +      # Make sure HAVE_ZLIB_H gets defined.  Some code uses that over
> +      # HAVE_LIBZ, since initially we were only defining HAVE_ZLIB_H.
> +      for ac_header in zlib.h
>  do :
>    ac_fn_c_check_header_mongrel "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default"
>  if test "x$ac_cv_header_zlib_h" = x""yes; then :
> @@ -16833,9 +17412,9 @@ fi
>  
>  done
>  
> -fi
> -
> -    if test "$with_zlib" = "yes" -a "$ac_cv_header_zlib_h" != "yes"; then
> +      LIBS="$LIBS $LIBZ"
> +    fi
> +    if test "$with_zlib" = "yes" -a "$HAVE_LIBZ" != "yes"; then
>        as_fn_error "zlib (libz) library was explicitly requested but not found" "$LINENO" 5
>      fi
>    fi
> diff --git a/sim/common/acinclude.m4 b/sim/common/acinclude.m4
> index f96ec35..430ae0e 100644
> --- a/sim/common/acinclude.m4
> +++ b/sim/common/acinclude.m4
> @@ -20,6 +20,9 @@
>  
>  # Include global overrides and fixes for Autoconf.
>  m4_include(../../config/override.m4)
> +m4_include([../../config/lib-ld.m4])
> +m4_include([../../config/lib-link.m4])
> +m4_include([../../config/lib-prefix.m4])
>  sinclude([../../config/zlib.m4])
>  m4_include([../../config/plugins.m4])
>  m4_include([../../libtool.m4])
> diff --git a/sim/common/config.in b/sim/common/config.in
> index 5b8ebd8..d6d595e 100644
> --- a/sim/common/config.in
> +++ b/sim/common/config.in
> @@ -31,6 +31,9 @@
>  /* Define to 1 if you have the `socket' library (-lsocket). */
>  #undef HAVE_LIBSOCKET
>  
> +/* Define if you have the z library. */
> +#undef HAVE_LIBZ
> +
>  /* Define to 1 if you have the `lstat' function. */
>  #undef HAVE_LSTAT
>  
> diff --git a/sim/common/configure b/sim/common/configure
> index add4c0f..16f6f28 100755
> --- a/sim/common/configure
> +++ b/sim/common/configure
> @@ -633,6 +633,9 @@ SED
>  LIBTOOL
>  PLUGINS_FALSE
>  PLUGINS_TRUE
> +LTLIBZ
> +LIBZ
> +HAVE_LIBZ
>  CATOBJEXT
>  GENCAT
>  INSTOBJEXT
> @@ -744,12 +747,14 @@ ac_subst_files=''
>  ac_user_opts='
>  enable_option_checking
>  with_zlib
> +with_gnu_ld
> +enable_rpath
> +with_libz_prefix
>  enable_plugins
>  enable_shared
>  enable_static
>  with_pic
>  enable_fast_install
> -with_gnu_ld
>  enable_libtool_lock
>  enable_maintainer_mode
>  enable_sim_bswap
> @@ -1388,6 +1393,7 @@ Optional Features:
>    --disable-option-checking  ignore unrecognized --enable/--with options
>    --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
>    --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
> +  --disable-rpath         do not hardcode runtime library paths
>    --enable-plugins        Enable support for plugins
>    --enable-shared[=PKGS]  build shared libraries [default=yes]
>    --enable-static[=PKGS]  build static libraries [default=yes]
> @@ -1407,6 +1413,9 @@ Optional Packages:
>    --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
>    --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
>    --with-zlib             include zlib support (auto/yes/no) default=auto
> +  --with-gnu-ld           assume the C compiler uses GNU ld default=no
> +  --with-libz-prefix[=DIR]  search for libz in DIR/include and DIR/lib
> +  --without-libz-prefix     don't search for libz in includedir and libdir
>    --with-pic              try to use only PIC/non-PIC objects [default=use
>                            both]
>    --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
> @@ -3788,6 +3797,164 @@ rmdir .tst 2>/dev/null
>  
>  DEPDIR="${am__leading_dot}deps"
>  
> +
> +      if test "X$prefix" = "XNONE"; then
> +    acl_final_prefix="$ac_default_prefix"
> +  else
> +    acl_final_prefix="$prefix"
> +  fi
> +  if test "X$exec_prefix" = "XNONE"; then
> +    acl_final_exec_prefix='${prefix}'
> +  else
> +    acl_final_exec_prefix="$exec_prefix"
> +  fi
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
> +  prefix="$acl_save_prefix"
> +
> +
> +# Check whether --with-gnu-ld was given.
> +if test "${with_gnu_ld+set}" = set; then :
> +  withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
> +else
> +  with_gnu_ld=no
> +fi
> +
> +# Prepare PATH_SEPARATOR.
> +# The user is always right.
> +if test "${PATH_SEPARATOR+set}" != set; then
> +  echo "#! /bin/sh" >conf$$.sh
> +  echo  "exit 0"   >>conf$$.sh
> +  chmod +x conf$$.sh
> +  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
> +    PATH_SEPARATOR=';'
> +  else
> +    PATH_SEPARATOR=:
> +  fi
> +  rm -f conf$$.sh
> +fi
> +ac_prog=ld
> +if test "$GCC" = yes; then
> +  # Check if gcc -print-prog-name=ld gives a path.
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by GCC" >&5
> +$as_echo_n "checking for ld used by GCC... " >&6; }
> +  case $host in
> +  *-*-mingw*)
> +    # gcc leaves a trailing carriage return which upsets mingw
> +    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
> +  *)
> +    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
> +  esac
> +  case $ac_prog in
> +    # Accept absolute paths.
> +    [\\/]* | [A-Za-z]:[\\/]*)
> +      re_direlt='/[^/][^/]*/\.\./'
> +      # Canonicalize the path of ld
> +      ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
> +      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
> +	ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
> +      done
> +      test -z "$LD" && LD="$ac_prog"
> +      ;;
> +  "")
> +    # If it fails, then pretend we aren't using GCC.
> +    ac_prog=ld
> +    ;;
> +  *)
> +    # If it is relative, then search for the first ld in PATH.
> +    with_gnu_ld=unknown
> +    ;;
> +  esac
> +elif test "$with_gnu_ld" = yes; then
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
> +$as_echo_n "checking for GNU ld... " >&6; }
> +else
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
> +$as_echo_n "checking for non-GNU ld... " >&6; }
> +fi
> +if test "${acl_cv_path_LD+set}" = set; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +  if test -z "$LD"; then
> +  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
> +  for ac_dir in $PATH; do
> +    test -z "$ac_dir" && ac_dir=.
> +    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
> +      acl_cv_path_LD="$ac_dir/$ac_prog"
> +      # Check to see if the program is GNU ld.  I'd rather use --version,
> +      # but apparently some GNU ld's only accept -v.
> +      # Break only if it was the GNU/non-GNU ld that we prefer.
> +      if "$acl_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
> +	test "$with_gnu_ld" != no && break
> +      else
> +	test "$with_gnu_ld" != yes && break
> +      fi
> +    fi
> +  done
> +  IFS="$ac_save_ifs"
> +else
> +  acl_cv_path_LD="$LD" # Let the user override the test with a path.
> +fi
> +fi
> +
> +LD="$acl_cv_path_LD"
> +if test -n "$LD"; then
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
> +$as_echo "$LD" >&6; }
> +else
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
> +$as_echo "no" >&6; }
> +fi
> +test -z "$LD" && as_fn_error "no acceptable ld found in \$PATH" "$LINENO" 5
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
> +$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; }
> +if test "${acl_cv_prog_gnu_ld+set}" = set; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +  # I'd rather use --version here, but apparently some GNU ld's only accept -v.
> +if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
> +  acl_cv_prog_gnu_ld=yes
> +else
> +  acl_cv_prog_gnu_ld=no
> +fi
> +fi
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_prog_gnu_ld" >&5
> +$as_echo "$acl_cv_prog_gnu_ld" >&6; }
> +with_gnu_ld=$acl_cv_prog_gnu_ld
> +
> +
> +
> +                                                { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5
> +$as_echo_n "checking for shared library run path origin... " >&6; }
> +if test "${acl_cv_rpath+set}" = set; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +
> +    CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
> +    ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
> +    . ./conftest.sh
> +    rm -f ./conftest.sh
> +    acl_cv_rpath=done
> +
> +fi
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_rpath" >&5
> +$as_echo "$acl_cv_rpath" >&6; }
> +  wl="$acl_cv_wl"
> +  libext="$acl_cv_libext"
> +  shlibext="$acl_cv_shlibext"
> +  hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
> +  hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
> +  hardcode_direct="$acl_cv_hardcode_direct"
> +  hardcode_minus_L="$acl_cv_hardcode_minus_L"
> +    # Check whether --enable-rpath was given.
> +if test "${enable_rpath+set}" = set; then :
> +  enableval=$enable_rpath; :
> +else
> +  enable_rpath=yes
> +fi
> +
> +
>  case `pwd` in
>    *\ * | *\	*)
>      { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5
> @@ -6962,60 +7129,472 @@ fi
>  
>  
>    if test "$with_zlib" != "no"; then
> -    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing zlibVersion" >&5
> -$as_echo_n "checking for library containing zlibVersion... " >&6; }
> -if test "${ac_cv_search_zlibVersion+set}" = set; then :
> +
> +
> +
> +
> +
> +
> +
> +
> +    use_additional=yes
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +
> +    eval additional_includedir=\"$includedir\"
> +    eval additional_libdir=\"$libdir\"
> +
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +
> +# Check whether --with-libz-prefix was given.
> +if test "${with_libz_prefix+set}" = set; then :
> +  withval=$with_libz_prefix;
> +    if test "X$withval" = "Xno"; then
> +      use_additional=no
> +    else
> +      if test "X$withval" = "X"; then
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +
> +          eval additional_includedir=\"$includedir\"
> +          eval additional_libdir=\"$libdir\"
> +
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +      else
> +        additional_includedir="$withval/include"
> +        additional_libdir="$withval/lib"
> +      fi
> +    fi
> +
> +fi
> +
> +      LIBZ=
> +  LTLIBZ=
> +  INCZ=
> +  rpathdirs=
> +  ltrpathdirs=
> +  names_already_handled=
> +  names_next_round='z '
> +  while test -n "$names_next_round"; do
> +    names_this_round="$names_next_round"
> +    names_next_round=
> +    for name in $names_this_round; do
> +      already_handled=
> +      for n in $names_already_handled; do
> +        if test "$n" = "$name"; then
> +          already_handled=yes
> +          break
> +        fi
> +      done
> +      if test -z "$already_handled"; then
> +        names_already_handled="$names_already_handled $name"
> +                        uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
> +        eval value=\"\$HAVE_LIB$uppername\"
> +        if test -n "$value"; then
> +          if test "$value" = yes; then
> +            eval value=\"\$LIB$uppername\"
> +            test -z "$value" || LIBZ="${LIBZ}${LIBZ:+ }$value"
> +            eval value=\"\$LTLIB$uppername\"
> +            test -z "$value" || LTLIBZ="${LTLIBZ}${LTLIBZ:+ }$value"
> +          else
> +                                    :
> +          fi
> +        else
> +                              found_dir=
> +          found_la=
> +          found_so=
> +          found_a=
> +          if test $use_additional = yes; then
> +            if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then
> +              found_dir="$additional_libdir"
> +              found_so="$additional_libdir/lib$name.$shlibext"
> +              if test -f "$additional_libdir/lib$name.la"; then
> +                found_la="$additional_libdir/lib$name.la"
> +              fi
> +            else
> +              if test -f "$additional_libdir/lib$name.$libext"; then
> +                found_dir="$additional_libdir"
> +                found_a="$additional_libdir/lib$name.$libext"
> +                if test -f "$additional_libdir/lib$name.la"; then
> +                  found_la="$additional_libdir/lib$name.la"
> +                fi
> +              fi
> +            fi
> +          fi
> +          if test "X$found_dir" = "X"; then
> +            for x in $LDFLAGS $LTLIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +              case "$x" in
> +                -L*)
> +                  dir=`echo "X$x" | sed -e 's/^X-L//'`
> +                  if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then
> +                    found_dir="$dir"
> +                    found_so="$dir/lib$name.$shlibext"
> +                    if test -f "$dir/lib$name.la"; then
> +                      found_la="$dir/lib$name.la"
> +                    fi
> +                  else
> +                    if test -f "$dir/lib$name.$libext"; then
> +                      found_dir="$dir"
> +                      found_a="$dir/lib$name.$libext"
> +                      if test -f "$dir/lib$name.la"; then
> +                        found_la="$dir/lib$name.la"
> +                      fi
> +                    fi
> +                  fi
> +                  ;;
> +              esac
> +              if test "X$found_dir" != "X"; then
> +                break
> +              fi
> +            done
> +          fi
> +          if test "X$found_dir" != "X"; then
> +                        LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-L$found_dir -l$name"
> +            if test "X$found_so" != "X"; then
> +                                                        if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then
> +                                LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +              else
> +                                                                                haveit=
> +                for x in $ltrpathdirs; do
> +                  if test "X$x" = "X$found_dir"; then
> +                    haveit=yes
> +                    break
> +                  fi
> +                done
> +                if test -z "$haveit"; then
> +                  ltrpathdirs="$ltrpathdirs $found_dir"
> +                fi
> +                                if test "$hardcode_direct" = yes; then
> +                                                      LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +                else
> +                  if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then
> +                                                            LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +                                                            haveit=
> +                    for x in $rpathdirs; do
> +                      if test "X$x" = "X$found_dir"; then
> +                        haveit=yes
> +                        break
> +                      fi
> +                    done
> +                    if test -z "$haveit"; then
> +                      rpathdirs="$rpathdirs $found_dir"
> +                    fi
> +                  else
> +                                                                                haveit=
> +                    for x in $LDFLAGS $LIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                      if test "X$x" = "X-L$found_dir"; then
> +                        haveit=yes
> +                        break
> +                      fi
> +                    done
> +                    if test -z "$haveit"; then
> +                      LIBZ="${LIBZ}${LIBZ:+ }-L$found_dir"
> +                    fi
> +                    if test "$hardcode_minus_L" != no; then
> +                                                                                        LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +                    else
> +                                                                                                                                                                                LIBZ="${LIBZ}${LIBZ:+ }-l$name"
> +                    fi
> +                  fi
> +                fi
> +              fi
> +            else
> +              if test "X$found_a" != "X"; then
> +                                LIBZ="${LIBZ}${LIBZ:+ }$found_a"
> +              else
> +                                                LIBZ="${LIBZ}${LIBZ:+ }-L$found_dir -l$name"
> +              fi
> +            fi
> +                        additional_includedir=
> +            case "$found_dir" in
> +              */lib | */lib/)
> +                basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'`
> +                additional_includedir="$basedir/include"
> +                ;;
> +            esac
> +            if test "X$additional_includedir" != "X"; then
> +                                                                                                                if test "X$additional_includedir" != "X/usr/include"; then
> +                haveit=
> +                if test "X$additional_includedir" = "X/usr/local/include"; then
> +                  if test -n "$GCC"; then
> +                    case $host_os in
> +                      linux*) haveit=yes;;
> +                    esac
> +                  fi
> +                fi
> +                if test -z "$haveit"; then
> +                  for x in $CPPFLAGS $INCZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                    if test "X$x" = "X-I$additional_includedir"; then
> +                      haveit=yes
> +                      break
> +                    fi
> +                  done
> +                  if test -z "$haveit"; then
> +                    if test -d "$additional_includedir"; then
> +                                            INCZ="${INCZ}${INCZ:+ }-I$additional_includedir"
> +                    fi
> +                  fi
> +                fi
> +              fi
> +            fi
> +                        if test -n "$found_la"; then
> +                                                        save_libdir="$libdir"
> +              case "$found_la" in
> +                */* | *\\*) . "$found_la" ;;
> +                *) . "./$found_la" ;;
> +              esac
> +              libdir="$save_libdir"
> +                            for dep in $dependency_libs; do
> +                case "$dep" in
> +                  -L*)
> +                    additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
> +                                                                                                                                                                if test "X$additional_libdir" != "X/usr/lib"; then
> +                      haveit=
> +                      if test "X$additional_libdir" = "X/usr/local/lib"; then
> +                        if test -n "$GCC"; then
> +                          case $host_os in
> +                            linux*) haveit=yes;;
> +                          esac
> +                        fi
> +                      fi
> +                      if test -z "$haveit"; then
> +                        haveit=
> +                        for x in $LDFLAGS $LIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                          if test "X$x" = "X-L$additional_libdir"; then
> +                            haveit=yes
> +                            break
> +                          fi
> +                        done
> +                        if test -z "$haveit"; then
> +                          if test -d "$additional_libdir"; then
> +                                                        LIBZ="${LIBZ}${LIBZ:+ }-L$additional_libdir"
> +                          fi
> +                        fi
> +                        haveit=
> +                        for x in $LDFLAGS $LTLIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                          if test "X$x" = "X-L$additional_libdir"; then
> +                            haveit=yes
> +                            break
> +                          fi
> +                        done
> +                        if test -z "$haveit"; then
> +                          if test -d "$additional_libdir"; then
> +                                                        LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-L$additional_libdir"
> +                          fi
> +                        fi
> +                      fi
> +                    fi
> +                    ;;
> +                  -R*)
> +                    dir=`echo "X$dep" | sed -e 's/^X-R//'`
> +                    if test "$enable_rpath" != no; then
> +                                                                  haveit=
> +                      for x in $rpathdirs; do
> +                        if test "X$x" = "X$dir"; then
> +                          haveit=yes
> +                          break
> +                        fi
> +                      done
> +                      if test -z "$haveit"; then
> +                        rpathdirs="$rpathdirs $dir"
> +                      fi
> +                                                                  haveit=
> +                      for x in $ltrpathdirs; do
> +                        if test "X$x" = "X$dir"; then
> +                          haveit=yes
> +                          break
> +                        fi
> +                      done
> +                      if test -z "$haveit"; then
> +                        ltrpathdirs="$ltrpathdirs $dir"
> +                      fi
> +                    fi
> +                    ;;
> +                  -l*)
> +                                        names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
> +                    ;;
> +                  *.la)
> +                                                                                names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
> +                    ;;
> +                  *)
> +                                        LIBZ="${LIBZ}${LIBZ:+ }$dep"
> +                    LTLIBZ="${LTLIBZ}${LTLIBZ:+ }$dep"
> +                    ;;
> +                esac
> +              done
> +            fi
> +          else
> +                                                            LIBZ="${LIBZ}${LIBZ:+ }-l$name"
> +            LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-l$name"
> +          fi
> +        fi
> +      fi
> +    done
> +  done
> +  if test "X$rpathdirs" != "X"; then
> +    if test -n "$hardcode_libdir_separator"; then
> +                        alldirs=
> +      for found_dir in $rpathdirs; do
> +        alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir"
> +      done
> +            acl_save_libdir="$libdir"
> +      libdir="$alldirs"
> +      eval flag=\"$hardcode_libdir_flag_spec\"
> +      libdir="$acl_save_libdir"
> +      LIBZ="${LIBZ}${LIBZ:+ }$flag"
> +    else
> +            for found_dir in $rpathdirs; do
> +        acl_save_libdir="$libdir"
> +        libdir="$found_dir"
> +        eval flag=\"$hardcode_libdir_flag_spec\"
> +        libdir="$acl_save_libdir"
> +        LIBZ="${LIBZ}${LIBZ:+ }$flag"
> +      done
> +    fi
> +  fi
> +  if test "X$ltrpathdirs" != "X"; then
> +            for found_dir in $ltrpathdirs; do
> +      LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-R$found_dir"
> +    done
> +  fi
> +
> +
> +        ac_save_CPPFLAGS="$CPPFLAGS"
> +
> +  for element in $INCZ; do
> +    haveit=
> +    for x in $CPPFLAGS; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +      if test "X$x" = "X$element"; then
> +        haveit=yes
> +        break
> +      fi
> +    done
> +    if test -z "$haveit"; then
> +      CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element"
> +    fi
> +  done
> +
> +
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libz" >&5
> +$as_echo_n "checking for libz... " >&6; }
> +if test "${ac_cv_libz+set}" = set; then :
>    $as_echo_n "(cached) " >&6
>  else
> -  ac_func_search_save_LIBS=$LIBS
> -cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> -/* end confdefs.h.  */
>  
> -/* Override any GCC internal prototype to avoid an error.
> -   Use char because int might match the return type of a GCC
> -   builtin and then its argument prototype would still apply.  */
> -#ifdef __cplusplus
> -extern "C"
> -#endif
> -char zlibVersion ();
> +    ac_save_LIBS="$LIBS"
> +    LIBS="$LIBS $LIBZ"
> +    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> +/* end confdefs.h.  */
> +#include "zlib.h";
>  int
>  main ()
>  {
> -return zlibVersion ();
> +int ret = deflateInit(NULL, 1);
>    ;
>    return 0;
>  }
>  _ACEOF
> -for ac_lib in '' z; do
> -  if test -z "$ac_lib"; then
> -    ac_res="none required"
> -  else
> -    ac_res=-l$ac_lib
> -    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
> -  fi
> -  if ac_fn_c_try_link "$LINENO"; then :
> -  ac_cv_search_zlibVersion=$ac_res
> +if ac_fn_c_try_link "$LINENO"; then :
> +  ac_cv_libz=yes
> +else
> +  ac_cv_libz=no
>  fi
>  rm -f core conftest.err conftest.$ac_objext \
> -    conftest$ac_exeext
> -  if test "${ac_cv_search_zlibVersion+set}" = set; then :
> -  break
> -fi
> -done
> -if test "${ac_cv_search_zlibVersion+set}" = set; then :
> +    conftest$ac_exeext conftest.$ac_ext
> +    LIBS="$ac_save_LIBS"
>  
> -else
> -  ac_cv_search_zlibVersion=no
> -fi
> -rm conftest.$ac_ext
> -LIBS=$ac_func_search_save_LIBS
>  fi
> -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_zlibVersion" >&5
> -$as_echo "$ac_cv_search_zlibVersion" >&6; }
> -ac_res=$ac_cv_search_zlibVersion
> -if test "$ac_res" != no; then :
> -  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
> -  for ac_header in zlib.h
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_libz" >&5
> +$as_echo "$ac_cv_libz" >&6; }
> +  if test "$ac_cv_libz" = yes; then
> +    HAVE_LIBZ=yes
> +
> +$as_echo "#define HAVE_LIBZ 1" >>confdefs.h
> +
> +    { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libz" >&5
> +$as_echo_n "checking how to link with libz... " >&6; }
> +    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBZ" >&5
> +$as_echo "$LIBZ" >&6; }
> +  else
> +    HAVE_LIBZ=no
> +            CPPFLAGS="$ac_save_CPPFLAGS"
> +    LIBZ=
> +    LTLIBZ=
> +  fi
> +
> +
> +
> +
> +
> +
> +    if test "$HAVE_LIBZ" = "yes"; then
> +      # Make sure HAVE_ZLIB_H gets defined.  Some code uses that over
> +      # HAVE_LIBZ, since initially we were only defining HAVE_ZLIB_H.
> +      for ac_header in zlib.h
>  do :
>    ac_fn_c_check_header_mongrel "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default"
>  if test "x$ac_cv_header_zlib_h" = x""yes; then :
> @@ -7027,9 +7606,9 @@ fi
>  
>  done
>  
> -fi
> -
> -    if test "$with_zlib" = "yes" -a "$ac_cv_header_zlib_h" != "yes"; then
> +      LIBS="$LIBS $LIBZ"
> +    fi
> +    if test "$with_zlib" = "yes" -a "$HAVE_LIBZ" != "yes"; then
>        as_fn_error "zlib (libz) library was explicitly requested but not found" "$LINENO" 5
>      fi
>    fi
> @@ -10623,7 +11202,7 @@ else
>    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>    lt_status=$lt_dlunknown
>    cat > conftest.$ac_ext <<_LT_EOF
> -#line 10626 "configure"
> +#line 11205 "configure"
>  #include "confdefs.h"
>  
>  #if HAVE_DLFCN_H
> @@ -10729,7 +11308,7 @@ else
>    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>    lt_status=$lt_dlunknown
>    cat > conftest.$ac_ext <<_LT_EOF
> -#line 10732 "configure"
> +#line 11311 "configure"
>  #include "confdefs.h"
>  
>  #if HAVE_DLFCN_H
> diff --git a/sim/ppc/config.in b/sim/ppc/config.in
> index b0c9e6f..32605bc 100644
> --- a/sim/ppc/config.in
> +++ b/sim/ppc/config.in
> @@ -106,6 +106,9 @@
>  /* Define to 1 if you have the `kill' function. */
>  #undef HAVE_KILL
>  
> +/* Define if you have the z library. */
> +#undef HAVE_LIBZ
> +
>  /* Define to 1 if you have the `link' function. */
>  #undef HAVE_LINK
>  
> diff --git a/sim/ppc/configure b/sim/ppc/configure
> index 5044383..6ec0fd0 100755
> --- a/sim/ppc/configure
> +++ b/sim/ppc/configure
> @@ -627,6 +627,9 @@ HDEFINES
>  CFLAGS_FOR_BUILD
>  CC_FOR_BUILD
>  LIBOBJS
> +LTLIBZ
> +LIBZ
> +HAVE_LIBZ
>  target_os
>  target_vendor
>  target_cpu
> @@ -767,6 +770,9 @@ enable_sim_xor_endian
>  with_pkgversion
>  with_bugurl
>  with_zlib
> +with_gnu_ld
> +enable_rpath
> +with_libz_prefix
>  enable_plugins
>  '
>        ac_precious_vars='build_alias
> @@ -1431,6 +1437,7 @@ Optional Features:
>    --enable-sim-trace			Specify whether tracing is supported.
>    --enable-sim-warnings=opts		Extra CFLAGS for turning on compiler warnings except for idecode.o, semantics.o and psim.o
>    --enable-sim-xor-endian=n		Specify number bytes involved in PowerPC XOR bi-endian mode (default 8).
> +  --disable-rpath         do not hardcode runtime library paths
>    --enable-plugins        Enable support for plugins
>  
>  Optional Packages:
> @@ -1439,6 +1446,9 @@ Optional Packages:
>    --with-pkgversion=PKG   Use PKG in the version string in place of "GDB"
>    --with-bugurl=URL       Direct users to URL to report a bug
>    --with-zlib             include zlib support (auto/yes/no) default=auto
> +  --with-gnu-ld           assume the C compiler uses GNU ld default=no
> +  --with-libz-prefix[=DIR]  search for libz in DIR/include and DIR/lib
> +  --without-libz-prefix     don't search for libz in includedir and libdir
>  
>  Some influential environment variables:
>    CC          C compiler command
> @@ -2448,6 +2458,37 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
>  
>  
>  
> +# lib-ld.m4 serial 2 (gettext-0.12)
> +
> +
> +
> +
> +
> +
> +# lib-link.m4 serial 4 (gettext-0.12)
> +
> +
> +
> +
> +
> +
> +
> +
> +
> +
> +
> +
> +# lib-prefix.m4 serial 2 (gettext-0.12)
> +
> +
> +
> +
> +
> +
> +
> +
> +
> +
>  
>  
>  
> @@ -6817,6 +6858,164 @@ program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"`
>  # BFD conditionally uses zlib, so we must link it in if libbfd does, by
>  # using the same condition.
>  
> +      if test "X$prefix" = "XNONE"; then
> +    acl_final_prefix="$ac_default_prefix"
> +  else
> +    acl_final_prefix="$prefix"
> +  fi
> +  if test "X$exec_prefix" = "XNONE"; then
> +    acl_final_exec_prefix='${prefix}'
> +  else
> +    acl_final_exec_prefix="$exec_prefix"
> +  fi
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
> +  prefix="$acl_save_prefix"
> +
> +
> +# Check whether --with-gnu-ld was given.
> +if test "${with_gnu_ld+set}" = set; then :
> +  withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
> +else
> +  with_gnu_ld=no
> +fi
> +
> +# Prepare PATH_SEPARATOR.
> +# The user is always right.
> +if test "${PATH_SEPARATOR+set}" != set; then
> +  echo "#! /bin/sh" >conf$$.sh
> +  echo  "exit 0"   >>conf$$.sh
> +  chmod +x conf$$.sh
> +  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
> +    PATH_SEPARATOR=';'
> +  else
> +    PATH_SEPARATOR=:
> +  fi
> +  rm -f conf$$.sh
> +fi
> +ac_prog=ld
> +if test "$GCC" = yes; then
> +  # Check if gcc -print-prog-name=ld gives a path.
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by GCC" >&5
> +$as_echo_n "checking for ld used by GCC... " >&6; }
> +  case $host in
> +  *-*-mingw*)
> +    # gcc leaves a trailing carriage return which upsets mingw
> +    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
> +  *)
> +    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
> +  esac
> +  case $ac_prog in
> +    # Accept absolute paths.
> +    [\\/]* | [A-Za-z]:[\\/]*)
> +      re_direlt='/[^/][^/]*/\.\./'
> +      # Canonicalize the path of ld
> +      ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
> +      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
> +	ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
> +      done
> +      test -z "$LD" && LD="$ac_prog"
> +      ;;
> +  "")
> +    # If it fails, then pretend we aren't using GCC.
> +    ac_prog=ld
> +    ;;
> +  *)
> +    # If it is relative, then search for the first ld in PATH.
> +    with_gnu_ld=unknown
> +    ;;
> +  esac
> +elif test "$with_gnu_ld" = yes; then
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
> +$as_echo_n "checking for GNU ld... " >&6; }
> +else
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
> +$as_echo_n "checking for non-GNU ld... " >&6; }
> +fi
> +if test "${acl_cv_path_LD+set}" = set; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +  if test -z "$LD"; then
> +  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
> +  for ac_dir in $PATH; do
> +    test -z "$ac_dir" && ac_dir=.
> +    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
> +      acl_cv_path_LD="$ac_dir/$ac_prog"
> +      # Check to see if the program is GNU ld.  I'd rather use --version,
> +      # but apparently some GNU ld's only accept -v.
> +      # Break only if it was the GNU/non-GNU ld that we prefer.
> +      if "$acl_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
> +	test "$with_gnu_ld" != no && break
> +      else
> +	test "$with_gnu_ld" != yes && break
> +      fi
> +    fi
> +  done
> +  IFS="$ac_save_ifs"
> +else
> +  acl_cv_path_LD="$LD" # Let the user override the test with a path.
> +fi
> +fi
> +
> +LD="$acl_cv_path_LD"
> +if test -n "$LD"; then
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
> +$as_echo "$LD" >&6; }
> +else
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
> +$as_echo "no" >&6; }
> +fi
> +test -z "$LD" && as_fn_error "no acceptable ld found in \$PATH" "$LINENO" 5
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
> +$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; }
> +if test "${acl_cv_prog_gnu_ld+set}" = set; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +  # I'd rather use --version here, but apparently some GNU ld's only accept -v.
> +if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
> +  acl_cv_prog_gnu_ld=yes
> +else
> +  acl_cv_prog_gnu_ld=no
> +fi
> +fi
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_prog_gnu_ld" >&5
> +$as_echo "$acl_cv_prog_gnu_ld" >&6; }
> +with_gnu_ld=$acl_cv_prog_gnu_ld
> +
> +
> +
> +                                                { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5
> +$as_echo_n "checking for shared library run path origin... " >&6; }
> +if test "${acl_cv_rpath+set}" = set; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +
> +    CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
> +    ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
> +    . ./conftest.sh
> +    rm -f ./conftest.sh
> +    acl_cv_rpath=done
> +
> +fi
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_rpath" >&5
> +$as_echo "$acl_cv_rpath" >&6; }
> +  wl="$acl_cv_wl"
> +  libext="$acl_cv_libext"
> +  shlibext="$acl_cv_shlibext"
> +  hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
> +  hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
> +  hardcode_direct="$acl_cv_hardcode_direct"
> +  hardcode_minus_L="$acl_cv_hardcode_minus_L"
> +    # Check whether --enable-rpath was given.
> +if test "${enable_rpath+set}" = set; then :
> +  enableval=$enable_rpath; :
> +else
> +  enable_rpath=yes
> +fi
> +
> +
> +
>    # See if the user specified whether he wants zlib support or not.
>  
>  # Check whether --with-zlib was given.
> @@ -6828,60 +7027,472 @@ fi
>  
>  
>    if test "$with_zlib" != "no"; then
> -    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing zlibVersion" >&5
> -$as_echo_n "checking for library containing zlibVersion... " >&6; }
> -if test "${ac_cv_search_zlibVersion+set}" = set; then :
> +
> +
> +
> +
> +
> +
> +
> +
> +    use_additional=yes
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +
> +    eval additional_includedir=\"$includedir\"
> +    eval additional_libdir=\"$libdir\"
> +
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +
> +# Check whether --with-libz-prefix was given.
> +if test "${with_libz_prefix+set}" = set; then :
> +  withval=$with_libz_prefix;
> +    if test "X$withval" = "Xno"; then
> +      use_additional=no
> +    else
> +      if test "X$withval" = "X"; then
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +
> +          eval additional_includedir=\"$includedir\"
> +          eval additional_libdir=\"$libdir\"
> +
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +      else
> +        additional_includedir="$withval/include"
> +        additional_libdir="$withval/lib"
> +      fi
> +    fi
> +
> +fi
> +
> +      LIBZ=
> +  LTLIBZ=
> +  INCZ=
> +  rpathdirs=
> +  ltrpathdirs=
> +  names_already_handled=
> +  names_next_round='z '
> +  while test -n "$names_next_round"; do
> +    names_this_round="$names_next_round"
> +    names_next_round=
> +    for name in $names_this_round; do
> +      already_handled=
> +      for n in $names_already_handled; do
> +        if test "$n" = "$name"; then
> +          already_handled=yes
> +          break
> +        fi
> +      done
> +      if test -z "$already_handled"; then
> +        names_already_handled="$names_already_handled $name"
> +                        uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
> +        eval value=\"\$HAVE_LIB$uppername\"
> +        if test -n "$value"; then
> +          if test "$value" = yes; then
> +            eval value=\"\$LIB$uppername\"
> +            test -z "$value" || LIBZ="${LIBZ}${LIBZ:+ }$value"
> +            eval value=\"\$LTLIB$uppername\"
> +            test -z "$value" || LTLIBZ="${LTLIBZ}${LTLIBZ:+ }$value"
> +          else
> +                                    :
> +          fi
> +        else
> +                              found_dir=
> +          found_la=
> +          found_so=
> +          found_a=
> +          if test $use_additional = yes; then
> +            if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then
> +              found_dir="$additional_libdir"
> +              found_so="$additional_libdir/lib$name.$shlibext"
> +              if test -f "$additional_libdir/lib$name.la"; then
> +                found_la="$additional_libdir/lib$name.la"
> +              fi
> +            else
> +              if test -f "$additional_libdir/lib$name.$libext"; then
> +                found_dir="$additional_libdir"
> +                found_a="$additional_libdir/lib$name.$libext"
> +                if test -f "$additional_libdir/lib$name.la"; then
> +                  found_la="$additional_libdir/lib$name.la"
> +                fi
> +              fi
> +            fi
> +          fi
> +          if test "X$found_dir" = "X"; then
> +            for x in $LDFLAGS $LTLIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +              case "$x" in
> +                -L*)
> +                  dir=`echo "X$x" | sed -e 's/^X-L//'`
> +                  if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then
> +                    found_dir="$dir"
> +                    found_so="$dir/lib$name.$shlibext"
> +                    if test -f "$dir/lib$name.la"; then
> +                      found_la="$dir/lib$name.la"
> +                    fi
> +                  else
> +                    if test -f "$dir/lib$name.$libext"; then
> +                      found_dir="$dir"
> +                      found_a="$dir/lib$name.$libext"
> +                      if test -f "$dir/lib$name.la"; then
> +                        found_la="$dir/lib$name.la"
> +                      fi
> +                    fi
> +                  fi
> +                  ;;
> +              esac
> +              if test "X$found_dir" != "X"; then
> +                break
> +              fi
> +            done
> +          fi
> +          if test "X$found_dir" != "X"; then
> +                        LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-L$found_dir -l$name"
> +            if test "X$found_so" != "X"; then
> +                                                        if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then
> +                                LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +              else
> +                                                                                haveit=
> +                for x in $ltrpathdirs; do
> +                  if test "X$x" = "X$found_dir"; then
> +                    haveit=yes
> +                    break
> +                  fi
> +                done
> +                if test -z "$haveit"; then
> +                  ltrpathdirs="$ltrpathdirs $found_dir"
> +                fi
> +                                if test "$hardcode_direct" = yes; then
> +                                                      LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +                else
> +                  if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then
> +                                                            LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +                                                            haveit=
> +                    for x in $rpathdirs; do
> +                      if test "X$x" = "X$found_dir"; then
> +                        haveit=yes
> +                        break
> +                      fi
> +                    done
> +                    if test -z "$haveit"; then
> +                      rpathdirs="$rpathdirs $found_dir"
> +                    fi
> +                  else
> +                                                                                haveit=
> +                    for x in $LDFLAGS $LIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                      if test "X$x" = "X-L$found_dir"; then
> +                        haveit=yes
> +                        break
> +                      fi
> +                    done
> +                    if test -z "$haveit"; then
> +                      LIBZ="${LIBZ}${LIBZ:+ }-L$found_dir"
> +                    fi
> +                    if test "$hardcode_minus_L" != no; then
> +                                                                                        LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +                    else
> +                                                                                                                                                                                LIBZ="${LIBZ}${LIBZ:+ }-l$name"
> +                    fi
> +                  fi
> +                fi
> +              fi
> +            else
> +              if test "X$found_a" != "X"; then
> +                                LIBZ="${LIBZ}${LIBZ:+ }$found_a"
> +              else
> +                                                LIBZ="${LIBZ}${LIBZ:+ }-L$found_dir -l$name"
> +              fi
> +            fi
> +                        additional_includedir=
> +            case "$found_dir" in
> +              */lib | */lib/)
> +                basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'`
> +                additional_includedir="$basedir/include"
> +                ;;
> +            esac
> +            if test "X$additional_includedir" != "X"; then
> +                                                                                                                if test "X$additional_includedir" != "X/usr/include"; then
> +                haveit=
> +                if test "X$additional_includedir" = "X/usr/local/include"; then
> +                  if test -n "$GCC"; then
> +                    case $host_os in
> +                      linux*) haveit=yes;;
> +                    esac
> +                  fi
> +                fi
> +                if test -z "$haveit"; then
> +                  for x in $CPPFLAGS $INCZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                    if test "X$x" = "X-I$additional_includedir"; then
> +                      haveit=yes
> +                      break
> +                    fi
> +                  done
> +                  if test -z "$haveit"; then
> +                    if test -d "$additional_includedir"; then
> +                                            INCZ="${INCZ}${INCZ:+ }-I$additional_includedir"
> +                    fi
> +                  fi
> +                fi
> +              fi
> +            fi
> +                        if test -n "$found_la"; then
> +                                                        save_libdir="$libdir"
> +              case "$found_la" in
> +                */* | *\\*) . "$found_la" ;;
> +                *) . "./$found_la" ;;
> +              esac
> +              libdir="$save_libdir"
> +                            for dep in $dependency_libs; do
> +                case "$dep" in
> +                  -L*)
> +                    additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
> +                                                                                                                                                                if test "X$additional_libdir" != "X/usr/lib"; then
> +                      haveit=
> +                      if test "X$additional_libdir" = "X/usr/local/lib"; then
> +                        if test -n "$GCC"; then
> +                          case $host_os in
> +                            linux*) haveit=yes;;
> +                          esac
> +                        fi
> +                      fi
> +                      if test -z "$haveit"; then
> +                        haveit=
> +                        for x in $LDFLAGS $LIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                          if test "X$x" = "X-L$additional_libdir"; then
> +                            haveit=yes
> +                            break
> +                          fi
> +                        done
> +                        if test -z "$haveit"; then
> +                          if test -d "$additional_libdir"; then
> +                                                        LIBZ="${LIBZ}${LIBZ:+ }-L$additional_libdir"
> +                          fi
> +                        fi
> +                        haveit=
> +                        for x in $LDFLAGS $LTLIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                          if test "X$x" = "X-L$additional_libdir"; then
> +                            haveit=yes
> +                            break
> +                          fi
> +                        done
> +                        if test -z "$haveit"; then
> +                          if test -d "$additional_libdir"; then
> +                                                        LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-L$additional_libdir"
> +                          fi
> +                        fi
> +                      fi
> +                    fi
> +                    ;;
> +                  -R*)
> +                    dir=`echo "X$dep" | sed -e 's/^X-R//'`
> +                    if test "$enable_rpath" != no; then
> +                                                                  haveit=
> +                      for x in $rpathdirs; do
> +                        if test "X$x" = "X$dir"; then
> +                          haveit=yes
> +                          break
> +                        fi
> +                      done
> +                      if test -z "$haveit"; then
> +                        rpathdirs="$rpathdirs $dir"
> +                      fi
> +                                                                  haveit=
> +                      for x in $ltrpathdirs; do
> +                        if test "X$x" = "X$dir"; then
> +                          haveit=yes
> +                          break
> +                        fi
> +                      done
> +                      if test -z "$haveit"; then
> +                        ltrpathdirs="$ltrpathdirs $dir"
> +                      fi
> +                    fi
> +                    ;;
> +                  -l*)
> +                                        names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
> +                    ;;
> +                  *.la)
> +                                                                                names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
> +                    ;;
> +                  *)
> +                                        LIBZ="${LIBZ}${LIBZ:+ }$dep"
> +                    LTLIBZ="${LTLIBZ}${LTLIBZ:+ }$dep"
> +                    ;;
> +                esac
> +              done
> +            fi
> +          else
> +                                                            LIBZ="${LIBZ}${LIBZ:+ }-l$name"
> +            LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-l$name"
> +          fi
> +        fi
> +      fi
> +    done
> +  done
> +  if test "X$rpathdirs" != "X"; then
> +    if test -n "$hardcode_libdir_separator"; then
> +                        alldirs=
> +      for found_dir in $rpathdirs; do
> +        alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir"
> +      done
> +            acl_save_libdir="$libdir"
> +      libdir="$alldirs"
> +      eval flag=\"$hardcode_libdir_flag_spec\"
> +      libdir="$acl_save_libdir"
> +      LIBZ="${LIBZ}${LIBZ:+ }$flag"
> +    else
> +            for found_dir in $rpathdirs; do
> +        acl_save_libdir="$libdir"
> +        libdir="$found_dir"
> +        eval flag=\"$hardcode_libdir_flag_spec\"
> +        libdir="$acl_save_libdir"
> +        LIBZ="${LIBZ}${LIBZ:+ }$flag"
> +      done
> +    fi
> +  fi
> +  if test "X$ltrpathdirs" != "X"; then
> +            for found_dir in $ltrpathdirs; do
> +      LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-R$found_dir"
> +    done
> +  fi
> +
> +
> +        ac_save_CPPFLAGS="$CPPFLAGS"
> +
> +  for element in $INCZ; do
> +    haveit=
> +    for x in $CPPFLAGS; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +      if test "X$x" = "X$element"; then
> +        haveit=yes
> +        break
> +      fi
> +    done
> +    if test -z "$haveit"; then
> +      CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element"
> +    fi
> +  done
> +
> +
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libz" >&5
> +$as_echo_n "checking for libz... " >&6; }
> +if test "${ac_cv_libz+set}" = set; then :
>    $as_echo_n "(cached) " >&6
>  else
> -  ac_func_search_save_LIBS=$LIBS
> -cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> -/* end confdefs.h.  */
>  
> -/* Override any GCC internal prototype to avoid an error.
> -   Use char because int might match the return type of a GCC
> -   builtin and then its argument prototype would still apply.  */
> -#ifdef __cplusplus
> -extern "C"
> -#endif
> -char zlibVersion ();
> +    ac_save_LIBS="$LIBS"
> +    LIBS="$LIBS $LIBZ"
> +    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> +/* end confdefs.h.  */
> +#include "zlib.h";
>  int
>  main ()
>  {
> -return zlibVersion ();
> +int ret = deflateInit(NULL, 1);
>    ;
>    return 0;
>  }
>  _ACEOF
> -for ac_lib in '' z; do
> -  if test -z "$ac_lib"; then
> -    ac_res="none required"
> -  else
> -    ac_res=-l$ac_lib
> -    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
> -  fi
> -  if ac_fn_c_try_link "$LINENO"; then :
> -  ac_cv_search_zlibVersion=$ac_res
> +if ac_fn_c_try_link "$LINENO"; then :
> +  ac_cv_libz=yes
> +else
> +  ac_cv_libz=no
>  fi
>  rm -f core conftest.err conftest.$ac_objext \
> -    conftest$ac_exeext
> -  if test "${ac_cv_search_zlibVersion+set}" = set; then :
> -  break
> -fi
> -done
> -if test "${ac_cv_search_zlibVersion+set}" = set; then :
> +    conftest$ac_exeext conftest.$ac_ext
> +    LIBS="$ac_save_LIBS"
>  
> -else
> -  ac_cv_search_zlibVersion=no
> -fi
> -rm conftest.$ac_ext
> -LIBS=$ac_func_search_save_LIBS
>  fi
> -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_zlibVersion" >&5
> -$as_echo "$ac_cv_search_zlibVersion" >&6; }
> -ac_res=$ac_cv_search_zlibVersion
> -if test "$ac_res" != no; then :
> -  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
> -  for ac_header in zlib.h
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_libz" >&5
> +$as_echo "$ac_cv_libz" >&6; }
> +  if test "$ac_cv_libz" = yes; then
> +    HAVE_LIBZ=yes
> +
> +$as_echo "#define HAVE_LIBZ 1" >>confdefs.h
> +
> +    { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libz" >&5
> +$as_echo_n "checking how to link with libz... " >&6; }
> +    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBZ" >&5
> +$as_echo "$LIBZ" >&6; }
> +  else
> +    HAVE_LIBZ=no
> +            CPPFLAGS="$ac_save_CPPFLAGS"
> +    LIBZ=
> +    LTLIBZ=
> +  fi
> +
> +
> +
> +
> +
> +
> +    if test "$HAVE_LIBZ" = "yes"; then
> +      # Make sure HAVE_ZLIB_H gets defined.  Some code uses that over
> +      # HAVE_LIBZ, since initially we were only defining HAVE_ZLIB_H.
> +      for ac_header in zlib.h
>  do :
>    ac_fn_c_check_header_mongrel "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default"
>  if test "x$ac_cv_header_zlib_h" = x""yes; then :
> @@ -6893,9 +7504,9 @@ fi
>  
>  done
>  
> -fi
> -
> -    if test "$with_zlib" = "yes" -a "$ac_cv_header_zlib_h" != "yes"; then
> +      LIBS="$LIBS $LIBZ"
> +    fi
> +    if test "$with_zlib" = "yes" -a "$HAVE_LIBZ" != "yes"; then
>        as_fn_error "zlib (libz) library was explicitly requested but not found" "$LINENO" 5
>      fi
>    fi
> -- 
> 1.9.1
>
  
Tristan Gingold Jan. 21, 2015, 8:21 a.m. UTC | #4
> On 21 Jan 2015, at 08:47, Joel Brobecker <brobecker@adacore.com> wrote:
> 
> Thank you! :)

What is the rational for having --with-zlib but --with-libz-prefix
(ie zlib vs libz) ?  Looks not very consistent.

Tristan.

> 
> On Wed, Jan 07, 2015 at 06:45:48PM +0400, Joel Brobecker wrote:
>> Hello,
>> 
>> This patch enhances config/zlib.m4 to introduce an extra option
>> --with-libz-prefix which allows us to provide the location of
>> the zlib library we want to use during the build.
>> 
>> config/ChangeLog:
>> 
>>        * zlib.m4 (AM_ZLIB): Add --with-libz-prefix option support.
>> 
>> I didn't see any file in the GCC project that uses this macro,
>> so for the GCC repository, the change to zlib.m4 is it. But
>> I am also attaching to this email a copy of the patch that
>> will be applied to the binutils-gdb.git repository, with all
>> configury using this macro being re-generated - mostly for info,
>> also as a heads-up to both binutils and GDB.
>> 
>> This was tested by regenerating all autoconf/automake files in
>> the binutils-gdb project, and rebuilding GDB, using the following
>> combinations:
>> 
>>  --with-zlib (system zlib used)
>>  --with-libz-prefix=/zlib/prefix (specific zlib linked in)
>>  --with-zlib --with-libz-prefix=/zlib/prefix (specific zlib linked in)
>> 
>>  --without-zlib (zlib support turned off)
>>  --without-zlib --with-zlib-prefix (zlib support turned off)
>> 
>>  --with-zlib (no system zlib available, configure fails with expected error)
>>  --with-zlib --with-libz-prefix=/invalid/zlib/prefix
>>              (no system zlib, configure fails with same error)
  
Joel Brobecker Jan. 21, 2015, 8:33 a.m. UTC | #5
> What is the rational for having --with-zlib but --with-libz-prefix
> (ie zlib vs libz) ?  Looks not very consistent.

I agree it's unfortunate, but it is unavoidable if I want to keep the
current option as it is (compatibility), and reuse AC_LIB_HAVE_LINKFLAGS
(which is a fairly complex function).
  
Joel Brobecker Feb. 4, 2015, 3:57 a.m. UTC | #6
Ping #2

It's been nearly a month since I submitted the patch. There has been
questions about the name of the command-line option, which I've been
answering. But no feedback from any of the maintainers, so I do not
know if changes are needed or not.

Thank you,
  
Joel Brobecker Feb. 18, 2015, 12:08 p.m. UTC | #7
Yay? Nay?

Thank you.

On Wed, Jan 07, 2015 at 06:45:48PM +0400, Joel Brobecker wrote:
> Hello,
> 
> This patch enhances config/zlib.m4 to introduce an extra option
> --with-libz-prefix which allows us to provide the location of
> the zlib library we want to use during the build.
> 
> config/ChangeLog:
> 
>         * zlib.m4 (AM_ZLIB): Add --with-libz-prefix option support.
> 
> I didn't see any file in the GCC project that uses this macro,
> so for the GCC repository, the change to zlib.m4 is it. But
> I am also attaching to this email a copy of the patch that
> will be applied to the binutils-gdb.git repository, with all
> configury using this macro being re-generated - mostly for info,
> also as a heads-up to both binutils and GDB.
> 
> This was tested by regenerating all autoconf/automake files in
> the binutils-gdb project, and rebuilding GDB, using the following
> combinations:
> 
>   --with-zlib (system zlib used)
>   --with-libz-prefix=/zlib/prefix (specific zlib linked in)
>   --with-zlib --with-libz-prefix=/zlib/prefix (specific zlib linked in)
> 
>   --without-zlib (zlib support turned off)
>   --without-zlib --with-zlib-prefix (zlib support turned off)
> 
>   --with-zlib (no system zlib available, configure fails with expected error)
>   --with-zlib --with-libz-prefix=/invalid/zlib/prefix
>               (no system zlib, configure fails with same error)
> 
> OK to commit?
> 
> Thank you!
> -- 
> Joel
> 
> ---
>  config/zlib.m4 | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/config/zlib.m4 b/config/zlib.m4
> index b017499..1581124 100644
> --- a/config/zlib.m4
> +++ b/config/zlib.m4
> @@ -9,8 +9,15 @@ AC_DEFUN([AM_ZLIB],
>      [], [with_zlib=auto])
>  
>    if test "$with_zlib" != "no"; then
> -    AC_SEARCH_LIBS(zlibVersion, z, [AC_CHECK_HEADERS(zlib.h)])
> -    if test "$with_zlib" = "yes" -a "$ac_cv_header_zlib_h" != "yes"; then
> +    AC_LIB_HAVE_LINKFLAGS([z], [], [#include "zlib.h";],
> +                          [int ret = deflateInit(NULL, 1);])
> +    if test "$HAVE_LIBZ" = "yes"; then
> +      # Make sure HAVE_ZLIB_H gets defined.  Some code uses that over
> +      # HAVE_LIBZ, since initially we were only defining HAVE_ZLIB_H.
> +      AC_CHECK_HEADERS(zlib.h)
> +      LIBS="$LIBS $LIBZ"
> +    fi
> +    if test "$with_zlib" = "yes" -a "$HAVE_LIBZ" != "yes"; then
>        AC_MSG_ERROR([zlib (libz) library was explicitly requested but not found])
>      fi
>    fi
> -- 
> 1.9.1

> >From 9dfb8ddb97c6dc56a5e1482e7029120d07dc07c8 Mon Sep 17 00:00:00 2001
> From: Joel Brobecker <brobecker@adacore.com>
> Date: Wed, 7 Jan 2015 14:47:51 +0400
> Subject: [PATCH] config/zlib.m4: Add support for --with-libz-prefix
> 
> This patch enhances config/zlib.m4 to introduce an extra option
> --with-libz-prefix which allows us to provide the location of
> the zlib library we want to use during the build.
> 
> config/ChangeLog:
> 
>         * zlib.m4 (AM_ZLIB): Add --with-libz-prefix option support.
> 
> bfd/ChangeLog:
> 
>         * Makefile.in, aclocal.m4, config.in, configure: Regenerate.
> 
> bfd/doc/ChangeLog:
> 
>         * doc/Makefile.in: Regenerate.
> 
> binutils/ChangeLog:
> 
>         * Makefile.in, config.in, configure: Regenerate.
> 
> binutils/doc/ChangeLog:
> 
>         * Makefile.in: Regenerate.
> 
> gas/ChangeLog:
> 
>         * Makefile.in, aclocal.m4, config.in, configure, doc/Makefile.in:
>         Regenerate.
> 
> gdb/ChangeLog:
> 
>         * config.in, configure: Regenerate.
> 
> gold/ChangeLog:
> 
>         * Makefile.in, aclocal.m4, config.in, configure,
>         testsuite/Makefile.in: Regenerate.
> 
> ld/ChangeLog:
> 
>         * Makefile.in, aclocal.m4, config.in, configure: Regenerate.
> 
> sim/common/ChangeLog:
> 
>         * acinclude.m4, config.in, configure: Regenerate.
> 
> sim/ppc/ChangeLog:
> 
>         * config.in, configure: Regenerate.
> 
> This was tested by regenerating all autoconf/automake files in
> the binutils-gdb project, and rebuilding GDB, using the following
> combinations:
> 
>   --with-zlib (system zlib used)
>   --with-libz-prefix=/zlib/prefix (specific zlib linked in)
>   --with-zlib --with-libz-prefix=/zlib/prefix (specific zlib linked in)
> 
>   --without-zlib (zlib support turned off)
>   --without-zlib --with-zlib-prefix (zlib support turned off)
> 
>   --with-zlib (no system zlib available, configure fails with expected error)
>       --with-zlib --with-libz-prefix=/invalid/zlib/prefix
>                   (no system zlib, configure fails with same error)
> ---
>  bfd/Makefile.in            |   6 +
>  bfd/aclocal.m4             |   3 +
>  bfd/config.in              |   3 +
>  bfd/configure              | 669 +++++++++++++++++++++++++++---
>  bfd/doc/Makefile.in        |   6 +
>  binutils/Makefile.in       |   3 +
>  binutils/config.in         |   3 +
>  binutils/configure         | 652 ++++++++++++++++++++++++------
>  binutils/doc/Makefile.in   |   3 +
>  config/zlib.m4             |  11 +-
>  gas/Makefile.in            |   6 +
>  gas/aclocal.m4             |   3 +
>  gas/config.in              |   3 +
>  gas/configure              | 669 +++++++++++++++++++++++++++---
>  gas/doc/Makefile.in        |   6 +
>  gdb/config.in              |   3 +
>  gdb/configure              | 986 ++++++++++++++++++++++++++++++++-------------
>  gold/Makefile.in           |   6 +
>  gold/aclocal.m4            |   3 +
>  gold/config.in             |   3 +
>  gold/configure             | 666 ++++++++++++++++++++++++++++--
>  gold/testsuite/Makefile.in |   6 +
>  ld/Makefile.in             |   6 +
>  ld/aclocal.m4              |   3 +
>  ld/config.in               |   3 +
>  ld/configure               | 669 +++++++++++++++++++++++++++---
>  sim/common/acinclude.m4    |   3 +
>  sim/common/config.in       |   3 +
>  sim/common/configure       | 671 +++++++++++++++++++++++++++---
>  sim/ppc/config.in          |   3 +
>  sim/ppc/configure          | 697 ++++++++++++++++++++++++++++++--
>  31 files changed, 5107 insertions(+), 670 deletions(-)
> 
> diff --git a/bfd/Makefile.in b/bfd/Makefile.in
> index 2c9435c..934d62a 100644
> --- a/bfd/Makefile.in
> +++ b/bfd/Makefile.in
> @@ -70,6 +70,9 @@ am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
>  	$(top_srcdir)/../config/gettext-sister.m4 \
>  	$(top_srcdir)/../config/largefile.m4 \
>  	$(top_srcdir)/../config/lead-dot.m4 \
> +	$(top_srcdir)/../config/lib-ld.m4 \
> +	$(top_srcdir)/../config/lib-link.m4 \
> +	$(top_srcdir)/../config/lib-prefix.m4 \
>  	$(top_srcdir)/../config/nls.m4 \
>  	$(top_srcdir)/../config/override.m4 \
>  	$(top_srcdir)/../config/plugins.m4 \
> @@ -204,6 +207,7 @@ FGREP = @FGREP@
>  GENCAT = @GENCAT@
>  GMSGFMT = @GMSGFMT@
>  GREP = @GREP@
> +HAVE_LIBZ = @HAVE_LIBZ@
>  HDEFINES = @HDEFINES@
>  INCINTL = @INCINTL@
>  INSTALL = @INSTALL@
> @@ -220,9 +224,11 @@ LIBM = @LIBM@
>  LIBOBJS = @LIBOBJS@
>  LIBS = @LIBS@
>  LIBTOOL = @LIBTOOL@
> +LIBZ = @LIBZ@
>  LIPO = @LIPO@
>  LN_S = @LN_S@
>  LTLIBOBJS = @LTLIBOBJS@
> +LTLIBZ = @LTLIBZ@
>  MAINT = @MAINT@
>  MAKEINFO = @MAKEINFO@
>  MKDIR_P = @MKDIR_P@
> diff --git a/bfd/aclocal.m4 b/bfd/aclocal.m4
> index d9e743e..358fe09 100644
> --- a/bfd/aclocal.m4
> +++ b/bfd/aclocal.m4
> @@ -973,6 +973,9 @@ m4_include([../config/depstand.m4])
>  m4_include([../config/gettext-sister.m4])
>  m4_include([../config/largefile.m4])
>  m4_include([../config/lead-dot.m4])
> +m4_include([../config/lib-ld.m4])
> +m4_include([../config/lib-link.m4])
> +m4_include([../config/lib-prefix.m4])
>  m4_include([../config/nls.m4])
>  m4_include([../config/override.m4])
>  m4_include([../config/plugins.m4])
> diff --git a/bfd/config.in b/bfd/config.in
> index b911bf6..cf1a97a 100644
> --- a/bfd/config.in
> +++ b/bfd/config.in
> @@ -125,6 +125,9 @@
>  /* Define to 1 if you have the <inttypes.h> header file. */
>  #undef HAVE_INTTYPES_H
>  
> +/* Define if you have the z library. */
> +#undef HAVE_LIBZ
> +
>  /* Define if <sys/procfs.h> has lwpstatus_t. */
>  #undef HAVE_LWPSTATUS_T
>  
> diff --git a/bfd/configure b/bfd/configure
> index f7a9e81..8c92742 100755
> --- a/bfd/configure
> +++ b/bfd/configure
> @@ -620,6 +620,9 @@ SHARED_LDFLAGS
>  LIBM
>  COREFLAG
>  COREFILE
> +LTLIBZ
> +LIBZ
> +HAVE_LIBZ
>  EXEEXT_FOR_BUILD
>  CC_FOR_BUILD
>  BFD_HOSTPTR_T
> @@ -798,6 +801,8 @@ enable_maintainer_mode
>  enable_install_libbfd
>  enable_nls
>  with_zlib
> +enable_rpath
> +with_libz_prefix
>  '
>        ac_precious_vars='build_alias
>  host_alias
> @@ -1449,6 +1454,7 @@ Optional Features:
>  			  (and sometimes confusing) to the casual installer
>    --enable-install-libbfd controls installation of libbfd and related headers
>    --disable-nls           do not use Native Language Support
> +  --disable-rpath         do not hardcode runtime library paths
>  
>  Optional Packages:
>    --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
> @@ -1464,6 +1470,9 @@ Optional Packages:
>                            Binutils"
>    --with-bugurl=URL       Direct users to URL to report a bug
>    --with-zlib             include zlib support (auto/yes/no) default=auto
> +  --with-gnu-ld           assume the C compiler uses GNU ld default=no
> +  --with-libz-prefix[=DIR]  search for libz in DIR/include and DIR/lib
> +  --without-libz-prefix     don't search for libz in includedir and libdir
>  
>  Some influential environment variables:
>    CC          C compiler command
> @@ -11421,7 +11430,7 @@ else
>    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>    lt_status=$lt_dlunknown
>    cat > conftest.$ac_ext <<_LT_EOF
> -#line 11424 "configure"
> +#line 11433 "configure"
>  #include "confdefs.h"
>  
>  #if HAVE_DLFCN_H
> @@ -11527,7 +11536,7 @@ else
>    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>    lt_status=$lt_dlunknown
>    cat > conftest.$ac_ext <<_LT_EOF
> -#line 11530 "configure"
> +#line 11539 "configure"
>  #include "confdefs.h"
>  
>  #if HAVE_DLFCN_H
> @@ -13854,6 +13863,164 @@ _ACEOF
>  # Link in zlib if we can.  This allows us to read compressed debug sections.
>  # This is used only by compress.c.
>  
> +      if test "X$prefix" = "XNONE"; then
> +    acl_final_prefix="$ac_default_prefix"
> +  else
> +    acl_final_prefix="$prefix"
> +  fi
> +  if test "X$exec_prefix" = "XNONE"; then
> +    acl_final_exec_prefix='${prefix}'
> +  else
> +    acl_final_exec_prefix="$exec_prefix"
> +  fi
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
> +  prefix="$acl_save_prefix"
> +
> +
> +# Check whether --with-gnu-ld was given.
> +if test "${with_gnu_ld+set}" = set; then :
> +  withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
> +else
> +  with_gnu_ld=no
> +fi
> +
> +# Prepare PATH_SEPARATOR.
> +# The user is always right.
> +if test "${PATH_SEPARATOR+set}" != set; then
> +  echo "#! /bin/sh" >conf$$.sh
> +  echo  "exit 0"   >>conf$$.sh
> +  chmod +x conf$$.sh
> +  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
> +    PATH_SEPARATOR=';'
> +  else
> +    PATH_SEPARATOR=:
> +  fi
> +  rm -f conf$$.sh
> +fi
> +ac_prog=ld
> +if test "$GCC" = yes; then
> +  # Check if gcc -print-prog-name=ld gives a path.
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by GCC" >&5
> +$as_echo_n "checking for ld used by GCC... " >&6; }
> +  case $host in
> +  *-*-mingw*)
> +    # gcc leaves a trailing carriage return which upsets mingw
> +    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
> +  *)
> +    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
> +  esac
> +  case $ac_prog in
> +    # Accept absolute paths.
> +    [\\/]* | [A-Za-z]:[\\/]*)
> +      re_direlt='/[^/][^/]*/\.\./'
> +      # Canonicalize the path of ld
> +      ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
> +      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
> +	ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
> +      done
> +      test -z "$LD" && LD="$ac_prog"
> +      ;;
> +  "")
> +    # If it fails, then pretend we aren't using GCC.
> +    ac_prog=ld
> +    ;;
> +  *)
> +    # If it is relative, then search for the first ld in PATH.
> +    with_gnu_ld=unknown
> +    ;;
> +  esac
> +elif test "$with_gnu_ld" = yes; then
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
> +$as_echo_n "checking for GNU ld... " >&6; }
> +else
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
> +$as_echo_n "checking for non-GNU ld... " >&6; }
> +fi
> +if test "${acl_cv_path_LD+set}" = set; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +  if test -z "$LD"; then
> +  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
> +  for ac_dir in $PATH; do
> +    test -z "$ac_dir" && ac_dir=.
> +    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
> +      acl_cv_path_LD="$ac_dir/$ac_prog"
> +      # Check to see if the program is GNU ld.  I'd rather use --version,
> +      # but apparently some GNU ld's only accept -v.
> +      # Break only if it was the GNU/non-GNU ld that we prefer.
> +      if "$acl_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
> +	test "$with_gnu_ld" != no && break
> +      else
> +	test "$with_gnu_ld" != yes && break
> +      fi
> +    fi
> +  done
> +  IFS="$ac_save_ifs"
> +else
> +  acl_cv_path_LD="$LD" # Let the user override the test with a path.
> +fi
> +fi
> +
> +LD="$acl_cv_path_LD"
> +if test -n "$LD"; then
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
> +$as_echo "$LD" >&6; }
> +else
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
> +$as_echo "no" >&6; }
> +fi
> +test -z "$LD" && as_fn_error "no acceptable ld found in \$PATH" "$LINENO" 5
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
> +$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; }
> +if test "${acl_cv_prog_gnu_ld+set}" = set; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +  # I'd rather use --version here, but apparently some GNU ld's only accept -v.
> +if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
> +  acl_cv_prog_gnu_ld=yes
> +else
> +  acl_cv_prog_gnu_ld=no
> +fi
> +fi
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_prog_gnu_ld" >&5
> +$as_echo "$acl_cv_prog_gnu_ld" >&6; }
> +with_gnu_ld=$acl_cv_prog_gnu_ld
> +
> +
> +
> +                                                { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5
> +$as_echo_n "checking for shared library run path origin... " >&6; }
> +if test "${acl_cv_rpath+set}" = set; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +
> +    CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
> +    ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
> +    . ./conftest.sh
> +    rm -f ./conftest.sh
> +    acl_cv_rpath=done
> +
> +fi
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_rpath" >&5
> +$as_echo "$acl_cv_rpath" >&6; }
> +  wl="$acl_cv_wl"
> +  libext="$acl_cv_libext"
> +  shlibext="$acl_cv_shlibext"
> +  hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
> +  hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
> +  hardcode_direct="$acl_cv_hardcode_direct"
> +  hardcode_minus_L="$acl_cv_hardcode_minus_L"
> +    # Check whether --enable-rpath was given.
> +if test "${enable_rpath+set}" = set; then :
> +  enableval=$enable_rpath; :
> +else
> +  enable_rpath=yes
> +fi
> +
> +
> +
>    # See if the user specified whether he wants zlib support or not.
>  
>  # Check whether --with-zlib was given.
> @@ -13865,60 +14032,472 @@ fi
>  
>  
>    if test "$with_zlib" != "no"; then
> -    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing zlibVersion" >&5
> -$as_echo_n "checking for library containing zlibVersion... " >&6; }
> -if test "${ac_cv_search_zlibVersion+set}" = set; then :
> +
> +
> +
> +
> +
> +
> +
> +
> +    use_additional=yes
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +
> +    eval additional_includedir=\"$includedir\"
> +    eval additional_libdir=\"$libdir\"
> +
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +
> +# Check whether --with-libz-prefix was given.
> +if test "${with_libz_prefix+set}" = set; then :
> +  withval=$with_libz_prefix;
> +    if test "X$withval" = "Xno"; then
> +      use_additional=no
> +    else
> +      if test "X$withval" = "X"; then
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +
> +          eval additional_includedir=\"$includedir\"
> +          eval additional_libdir=\"$libdir\"
> +
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +      else
> +        additional_includedir="$withval/include"
> +        additional_libdir="$withval/lib"
> +      fi
> +    fi
> +
> +fi
> +
> +      LIBZ=
> +  LTLIBZ=
> +  INCZ=
> +  rpathdirs=
> +  ltrpathdirs=
> +  names_already_handled=
> +  names_next_round='z '
> +  while test -n "$names_next_round"; do
> +    names_this_round="$names_next_round"
> +    names_next_round=
> +    for name in $names_this_round; do
> +      already_handled=
> +      for n in $names_already_handled; do
> +        if test "$n" = "$name"; then
> +          already_handled=yes
> +          break
> +        fi
> +      done
> +      if test -z "$already_handled"; then
> +        names_already_handled="$names_already_handled $name"
> +                        uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
> +        eval value=\"\$HAVE_LIB$uppername\"
> +        if test -n "$value"; then
> +          if test "$value" = yes; then
> +            eval value=\"\$LIB$uppername\"
> +            test -z "$value" || LIBZ="${LIBZ}${LIBZ:+ }$value"
> +            eval value=\"\$LTLIB$uppername\"
> +            test -z "$value" || LTLIBZ="${LTLIBZ}${LTLIBZ:+ }$value"
> +          else
> +                                    :
> +          fi
> +        else
> +                              found_dir=
> +          found_la=
> +          found_so=
> +          found_a=
> +          if test $use_additional = yes; then
> +            if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then
> +              found_dir="$additional_libdir"
> +              found_so="$additional_libdir/lib$name.$shlibext"
> +              if test -f "$additional_libdir/lib$name.la"; then
> +                found_la="$additional_libdir/lib$name.la"
> +              fi
> +            else
> +              if test -f "$additional_libdir/lib$name.$libext"; then
> +                found_dir="$additional_libdir"
> +                found_a="$additional_libdir/lib$name.$libext"
> +                if test -f "$additional_libdir/lib$name.la"; then
> +                  found_la="$additional_libdir/lib$name.la"
> +                fi
> +              fi
> +            fi
> +          fi
> +          if test "X$found_dir" = "X"; then
> +            for x in $LDFLAGS $LTLIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +              case "$x" in
> +                -L*)
> +                  dir=`echo "X$x" | sed -e 's/^X-L//'`
> +                  if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then
> +                    found_dir="$dir"
> +                    found_so="$dir/lib$name.$shlibext"
> +                    if test -f "$dir/lib$name.la"; then
> +                      found_la="$dir/lib$name.la"
> +                    fi
> +                  else
> +                    if test -f "$dir/lib$name.$libext"; then
> +                      found_dir="$dir"
> +                      found_a="$dir/lib$name.$libext"
> +                      if test -f "$dir/lib$name.la"; then
> +                        found_la="$dir/lib$name.la"
> +                      fi
> +                    fi
> +                  fi
> +                  ;;
> +              esac
> +              if test "X$found_dir" != "X"; then
> +                break
> +              fi
> +            done
> +          fi
> +          if test "X$found_dir" != "X"; then
> +                        LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-L$found_dir -l$name"
> +            if test "X$found_so" != "X"; then
> +                                                        if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then
> +                                LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +              else
> +                                                                                haveit=
> +                for x in $ltrpathdirs; do
> +                  if test "X$x" = "X$found_dir"; then
> +                    haveit=yes
> +                    break
> +                  fi
> +                done
> +                if test -z "$haveit"; then
> +                  ltrpathdirs="$ltrpathdirs $found_dir"
> +                fi
> +                                if test "$hardcode_direct" = yes; then
> +                                                      LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +                else
> +                  if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then
> +                                                            LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +                                                            haveit=
> +                    for x in $rpathdirs; do
> +                      if test "X$x" = "X$found_dir"; then
> +                        haveit=yes
> +                        break
> +                      fi
> +                    done
> +                    if test -z "$haveit"; then
> +                      rpathdirs="$rpathdirs $found_dir"
> +                    fi
> +                  else
> +                                                                                haveit=
> +                    for x in $LDFLAGS $LIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                      if test "X$x" = "X-L$found_dir"; then
> +                        haveit=yes
> +                        break
> +                      fi
> +                    done
> +                    if test -z "$haveit"; then
> +                      LIBZ="${LIBZ}${LIBZ:+ }-L$found_dir"
> +                    fi
> +                    if test "$hardcode_minus_L" != no; then
> +                                                                                        LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +                    else
> +                                                                                                                                                                                LIBZ="${LIBZ}${LIBZ:+ }-l$name"
> +                    fi
> +                  fi
> +                fi
> +              fi
> +            else
> +              if test "X$found_a" != "X"; then
> +                                LIBZ="${LIBZ}${LIBZ:+ }$found_a"
> +              else
> +                                                LIBZ="${LIBZ}${LIBZ:+ }-L$found_dir -l$name"
> +              fi
> +            fi
> +                        additional_includedir=
> +            case "$found_dir" in
> +              */lib | */lib/)
> +                basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'`
> +                additional_includedir="$basedir/include"
> +                ;;
> +            esac
> +            if test "X$additional_includedir" != "X"; then
> +                                                                                                                if test "X$additional_includedir" != "X/usr/include"; then
> +                haveit=
> +                if test "X$additional_includedir" = "X/usr/local/include"; then
> +                  if test -n "$GCC"; then
> +                    case $host_os in
> +                      linux*) haveit=yes;;
> +                    esac
> +                  fi
> +                fi
> +                if test -z "$haveit"; then
> +                  for x in $CPPFLAGS $INCZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                    if test "X$x" = "X-I$additional_includedir"; then
> +                      haveit=yes
> +                      break
> +                    fi
> +                  done
> +                  if test -z "$haveit"; then
> +                    if test -d "$additional_includedir"; then
> +                                            INCZ="${INCZ}${INCZ:+ }-I$additional_includedir"
> +                    fi
> +                  fi
> +                fi
> +              fi
> +            fi
> +                        if test -n "$found_la"; then
> +                                                        save_libdir="$libdir"
> +              case "$found_la" in
> +                */* | *\\*) . "$found_la" ;;
> +                *) . "./$found_la" ;;
> +              esac
> +              libdir="$save_libdir"
> +                            for dep in $dependency_libs; do
> +                case "$dep" in
> +                  -L*)
> +                    additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
> +                                                                                                                                                                if test "X$additional_libdir" != "X/usr/lib"; then
> +                      haveit=
> +                      if test "X$additional_libdir" = "X/usr/local/lib"; then
> +                        if test -n "$GCC"; then
> +                          case $host_os in
> +                            linux*) haveit=yes;;
> +                          esac
> +                        fi
> +                      fi
> +                      if test -z "$haveit"; then
> +                        haveit=
> +                        for x in $LDFLAGS $LIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                          if test "X$x" = "X-L$additional_libdir"; then
> +                            haveit=yes
> +                            break
> +                          fi
> +                        done
> +                        if test -z "$haveit"; then
> +                          if test -d "$additional_libdir"; then
> +                                                        LIBZ="${LIBZ}${LIBZ:+ }-L$additional_libdir"
> +                          fi
> +                        fi
> +                        haveit=
> +                        for x in $LDFLAGS $LTLIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                          if test "X$x" = "X-L$additional_libdir"; then
> +                            haveit=yes
> +                            break
> +                          fi
> +                        done
> +                        if test -z "$haveit"; then
> +                          if test -d "$additional_libdir"; then
> +                                                        LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-L$additional_libdir"
> +                          fi
> +                        fi
> +                      fi
> +                    fi
> +                    ;;
> +                  -R*)
> +                    dir=`echo "X$dep" | sed -e 's/^X-R//'`
> +                    if test "$enable_rpath" != no; then
> +                                                                  haveit=
> +                      for x in $rpathdirs; do
> +                        if test "X$x" = "X$dir"; then
> +                          haveit=yes
> +                          break
> +                        fi
> +                      done
> +                      if test -z "$haveit"; then
> +                        rpathdirs="$rpathdirs $dir"
> +                      fi
> +                                                                  haveit=
> +                      for x in $ltrpathdirs; do
> +                        if test "X$x" = "X$dir"; then
> +                          haveit=yes
> +                          break
> +                        fi
> +                      done
> +                      if test -z "$haveit"; then
> +                        ltrpathdirs="$ltrpathdirs $dir"
> +                      fi
> +                    fi
> +                    ;;
> +                  -l*)
> +                                        names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
> +                    ;;
> +                  *.la)
> +                                                                                names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
> +                    ;;
> +                  *)
> +                                        LIBZ="${LIBZ}${LIBZ:+ }$dep"
> +                    LTLIBZ="${LTLIBZ}${LTLIBZ:+ }$dep"
> +                    ;;
> +                esac
> +              done
> +            fi
> +          else
> +                                                            LIBZ="${LIBZ}${LIBZ:+ }-l$name"
> +            LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-l$name"
> +          fi
> +        fi
> +      fi
> +    done
> +  done
> +  if test "X$rpathdirs" != "X"; then
> +    if test -n "$hardcode_libdir_separator"; then
> +                        alldirs=
> +      for found_dir in $rpathdirs; do
> +        alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir"
> +      done
> +            acl_save_libdir="$libdir"
> +      libdir="$alldirs"
> +      eval flag=\"$hardcode_libdir_flag_spec\"
> +      libdir="$acl_save_libdir"
> +      LIBZ="${LIBZ}${LIBZ:+ }$flag"
> +    else
> +            for found_dir in $rpathdirs; do
> +        acl_save_libdir="$libdir"
> +        libdir="$found_dir"
> +        eval flag=\"$hardcode_libdir_flag_spec\"
> +        libdir="$acl_save_libdir"
> +        LIBZ="${LIBZ}${LIBZ:+ }$flag"
> +      done
> +    fi
> +  fi
> +  if test "X$ltrpathdirs" != "X"; then
> +            for found_dir in $ltrpathdirs; do
> +      LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-R$found_dir"
> +    done
> +  fi
> +
> +
> +        ac_save_CPPFLAGS="$CPPFLAGS"
> +
> +  for element in $INCZ; do
> +    haveit=
> +    for x in $CPPFLAGS; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +      if test "X$x" = "X$element"; then
> +        haveit=yes
> +        break
> +      fi
> +    done
> +    if test -z "$haveit"; then
> +      CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element"
> +    fi
> +  done
> +
> +
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libz" >&5
> +$as_echo_n "checking for libz... " >&6; }
> +if test "${ac_cv_libz+set}" = set; then :
>    $as_echo_n "(cached) " >&6
>  else
> -  ac_func_search_save_LIBS=$LIBS
> -cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> -/* end confdefs.h.  */
>  
> -/* Override any GCC internal prototype to avoid an error.
> -   Use char because int might match the return type of a GCC
> -   builtin and then its argument prototype would still apply.  */
> -#ifdef __cplusplus
> -extern "C"
> -#endif
> -char zlibVersion ();
> +    ac_save_LIBS="$LIBS"
> +    LIBS="$LIBS $LIBZ"
> +    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> +/* end confdefs.h.  */
> +#include "zlib.h";
>  int
>  main ()
>  {
> -return zlibVersion ();
> +int ret = deflateInit(NULL, 1);
>    ;
>    return 0;
>  }
>  _ACEOF
> -for ac_lib in '' z; do
> -  if test -z "$ac_lib"; then
> -    ac_res="none required"
> -  else
> -    ac_res=-l$ac_lib
> -    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
> -  fi
> -  if ac_fn_c_try_link "$LINENO"; then :
> -  ac_cv_search_zlibVersion=$ac_res
> +if ac_fn_c_try_link "$LINENO"; then :
> +  ac_cv_libz=yes
> +else
> +  ac_cv_libz=no
>  fi
>  rm -f core conftest.err conftest.$ac_objext \
> -    conftest$ac_exeext
> -  if test "${ac_cv_search_zlibVersion+set}" = set; then :
> -  break
> -fi
> -done
> -if test "${ac_cv_search_zlibVersion+set}" = set; then :
> +    conftest$ac_exeext conftest.$ac_ext
> +    LIBS="$ac_save_LIBS"
>  
> -else
> -  ac_cv_search_zlibVersion=no
>  fi
> -rm conftest.$ac_ext
> -LIBS=$ac_func_search_save_LIBS
> -fi
> -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_zlibVersion" >&5
> -$as_echo "$ac_cv_search_zlibVersion" >&6; }
> -ac_res=$ac_cv_search_zlibVersion
> -if test "$ac_res" != no; then :
> -  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
> -  for ac_header in zlib.h
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_libz" >&5
> +$as_echo "$ac_cv_libz" >&6; }
> +  if test "$ac_cv_libz" = yes; then
> +    HAVE_LIBZ=yes
> +
> +$as_echo "#define HAVE_LIBZ 1" >>confdefs.h
> +
> +    { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libz" >&5
> +$as_echo_n "checking how to link with libz... " >&6; }
> +    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBZ" >&5
> +$as_echo "$LIBZ" >&6; }
> +  else
> +    HAVE_LIBZ=no
> +            CPPFLAGS="$ac_save_CPPFLAGS"
> +    LIBZ=
> +    LTLIBZ=
> +  fi
> +
> +
> +
> +
> +
> +
> +    if test "$HAVE_LIBZ" = "yes"; then
> +      # Make sure HAVE_ZLIB_H gets defined.  Some code uses that over
> +      # HAVE_LIBZ, since initially we were only defining HAVE_ZLIB_H.
> +      for ac_header in zlib.h
>  do :
>    ac_fn_c_check_header_mongrel "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default"
>  if test "x$ac_cv_header_zlib_h" = x""yes; then :
> @@ -13930,9 +14509,9 @@ fi
>  
>  done
>  
> -fi
> -
> -    if test "$with_zlib" = "yes" -a "$ac_cv_header_zlib_h" != "yes"; then
> +      LIBS="$LIBS $LIBZ"
> +    fi
> +    if test "$with_zlib" = "yes" -a "$HAVE_LIBZ" != "yes"; then
>        as_fn_error "zlib (libz) library was explicitly requested but not found" "$LINENO" 5
>      fi
>    fi
> diff --git a/bfd/doc/Makefile.in b/bfd/doc/Makefile.in
> index 3be6a5e..7257ed9 100644
> --- a/bfd/doc/Makefile.in
> +++ b/bfd/doc/Makefile.in
> @@ -66,6 +66,9 @@ am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
>  	$(top_srcdir)/../config/gettext-sister.m4 \
>  	$(top_srcdir)/../config/largefile.m4 \
>  	$(top_srcdir)/../config/lead-dot.m4 \
> +	$(top_srcdir)/../config/lib-ld.m4 \
> +	$(top_srcdir)/../config/lib-link.m4 \
> +	$(top_srcdir)/../config/lib-prefix.m4 \
>  	$(top_srcdir)/../config/nls.m4 \
>  	$(top_srcdir)/../config/override.m4 \
>  	$(top_srcdir)/../config/plugins.m4 \
> @@ -164,6 +167,7 @@ FGREP = @FGREP@
>  GENCAT = @GENCAT@
>  GMSGFMT = @GMSGFMT@
>  GREP = @GREP@
> +HAVE_LIBZ = @HAVE_LIBZ@
>  HDEFINES = @HDEFINES@
>  INCINTL = @INCINTL@
>  INSTALL = @INSTALL@
> @@ -180,9 +184,11 @@ LIBM = @LIBM@
>  LIBOBJS = @LIBOBJS@
>  LIBS = @LIBS@
>  LIBTOOL = @LIBTOOL@
> +LIBZ = @LIBZ@
>  LIPO = @LIPO@
>  LN_S = @LN_S@
>  LTLIBOBJS = @LTLIBOBJS@
> +LTLIBZ = @LTLIBZ@
>  MAINT = @MAINT@
>  MAKEINFO = @MAKEINFO@
>  MKDIR_P = @MKDIR_P@
> diff --git a/binutils/Makefile.in b/binutils/Makefile.in
> index aaf4d51..05fb968 100644
> --- a/binutils/Makefile.in
> +++ b/binutils/Makefile.in
> @@ -316,6 +316,7 @@ FGREP = @FGREP@
>  GENCAT = @GENCAT@
>  GMSGFMT = @GMSGFMT@
>  GREP = @GREP@
> +HAVE_LIBZ = @HAVE_LIBZ@
>  HDEFINES = @HDEFINES@
>  INCINTL = @INCINTL@
>  INSTALL = @INSTALL@
> @@ -335,10 +336,12 @@ LIBINTL_DEP = @LIBINTL_DEP@
>  LIBOBJS = @LIBOBJS@
>  LIBS = @LIBS@
>  LIBTOOL = @LIBTOOL@
> +LIBZ = @LIBZ@
>  LIPO = @LIPO@
>  LN_S = @LN_S@
>  LTLIBICONV = @LTLIBICONV@
>  LTLIBOBJS = @LTLIBOBJS@
> +LTLIBZ = @LTLIBZ@
>  MAINT = @MAINT@
>  MAKEINFO = @MAKEINFO@
>  MKDIR_P = @MKDIR_P@
> diff --git a/binutils/config.in b/binutils/config.in
> index a0ed034..dd7d832 100644
> --- a/binutils/config.in
> +++ b/binutils/config.in
> @@ -102,6 +102,9 @@
>  /* Define if your <locale.h> file defines LC_MESSAGES. */
>  #undef HAVE_LC_MESSAGES
>  
> +/* Define if you have the z library. */
> +#undef HAVE_LIBZ
> +
>  /* Define to 1 if you have the <limits.h> header file. */
>  #undef HAVE_LIMITS_H
>  
> diff --git a/binutils/configure b/binutils/configure
> index b960c19..8280dd8 100755
> --- a/binutils/configure
> +++ b/binutils/configure
> @@ -618,6 +618,9 @@ BUILD_NLMCONV
>  NLMCONV_DEFS
>  LTLIBICONV
>  LIBICONV
> +LTLIBZ
> +LIBZ
> +HAVE_LIBZ
>  ALLOCA
>  DEMANGLER_NAME
>  EXEEXT_FOR_BUILD
> @@ -779,6 +782,7 @@ enable_nls
>  enable_maintainer_mode
>  with_zlib
>  enable_rpath
> +with_libz_prefix
>  with_libiconv_prefix
>  '
>        ac_precious_vars='build_alias
> @@ -1441,6 +1445,8 @@ Optional Packages:
>    --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
>    --with-zlib             include zlib support (auto/yes/no) default=auto
>    --with-gnu-ld           assume the C compiler uses GNU ld default=no
> +  --with-libz-prefix[=DIR]  search for libz in DIR/include and DIR/lib
> +  --without-libz-prefix     don't search for libz in includedir and libdir
>    --with-libiconv-prefix[=DIR]  search for libiconv in DIR/include and DIR/lib
>    --without-libiconv-prefix     don't search for libiconv in includedir and libdir
>  
> @@ -11219,7 +11225,7 @@ else
>    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>    lt_status=$lt_dlunknown
>    cat > conftest.$ac_ext <<_LT_EOF
> -#line 11222 "configure"
> +#line 11228 "configure"
>  #include "confdefs.h"
>  
>  #if HAVE_DLFCN_H
> @@ -11325,7 +11331,7 @@ else
>    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>    lt_status=$lt_dlunknown
>    cat > conftest.$ac_ext <<_LT_EOF
> -#line 11328 "configure"
> +#line 11334 "configure"
>  #include "confdefs.h"
>  
>  #if HAVE_DLFCN_H
> @@ -13540,121 +13546,6 @@ _ACEOF
>  # sections.  This is used only by readelf.c (objdump uses bfd for
>  # reading compressed sections).
>  
> -  # See if the user specified whether he wants zlib support or not.
> -
> -# Check whether --with-zlib was given.
> -if test "${with_zlib+set}" = set; then :
> -  withval=$with_zlib;
> -else
> -  with_zlib=auto
> -fi
> -
> -
> -  if test "$with_zlib" != "no"; then
> -    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing zlibVersion" >&5
> -$as_echo_n "checking for library containing zlibVersion... " >&6; }
> -if test "${ac_cv_search_zlibVersion+set}" = set; then :
> -  $as_echo_n "(cached) " >&6
> -else
> -  ac_func_search_save_LIBS=$LIBS
> -cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> -/* end confdefs.h.  */
> -
> -/* Override any GCC internal prototype to avoid an error.
> -   Use char because int might match the return type of a GCC
> -   builtin and then its argument prototype would still apply.  */
> -#ifdef __cplusplus
> -extern "C"
> -#endif
> -char zlibVersion ();
> -int
> -main ()
> -{
> -return zlibVersion ();
> -  ;
> -  return 0;
> -}
> -_ACEOF
> -for ac_lib in '' z; do
> -  if test -z "$ac_lib"; then
> -    ac_res="none required"
> -  else
> -    ac_res=-l$ac_lib
> -    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
> -  fi
> -  if ac_fn_c_try_link "$LINENO"; then :
> -  ac_cv_search_zlibVersion=$ac_res
> -fi
> -rm -f core conftest.err conftest.$ac_objext \
> -    conftest$ac_exeext
> -  if test "${ac_cv_search_zlibVersion+set}" = set; then :
> -  break
> -fi
> -done
> -if test "${ac_cv_search_zlibVersion+set}" = set; then :
> -
> -else
> -  ac_cv_search_zlibVersion=no
> -fi
> -rm conftest.$ac_ext
> -LIBS=$ac_func_search_save_LIBS
> -fi
> -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_zlibVersion" >&5
> -$as_echo "$ac_cv_search_zlibVersion" >&6; }
> -ac_res=$ac_cv_search_zlibVersion
> -if test "$ac_res" != no; then :
> -  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
> -  for ac_header in zlib.h
> -do :
> -  ac_fn_c_check_header_mongrel "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default"
> -if test "x$ac_cv_header_zlib_h" = x""yes; then :
> -  cat >>confdefs.h <<_ACEOF
> -#define HAVE_ZLIB_H 1
> -_ACEOF
> -
> -fi
> -
> -done
> -
> -fi
> -
> -    if test "$with_zlib" = "yes" -a "$ac_cv_header_zlib_h" != "yes"; then
> -      as_fn_error "zlib (libz) library was explicitly requested but not found" "$LINENO" 5
> -    fi
> -  fi
> -
> -
> -
> -case "${host}" in
> -*-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows*)
> -
> -$as_echo "#define USE_BINARY_FOPEN 1" >>confdefs.h
> - ;;
> -esac
> -
> -# target-specific stuff:
> -
> -# Canonicalize the secondary target names.
> -if test -n "$enable_targets"; then
> -    for targ in `echo $enable_targets | sed 's/,/ /g'`
> -    do
> -	result=`$ac_config_sub $targ 2>/dev/null`
> -	if test -n "$result"; then
> -	    canon_targets="$canon_targets $result"
> -	else
> -	    # Allow targets that config.sub doesn't recognize, like "all".
> -	    canon_targets="$canon_targets $targ"
> -	fi
> -    done
> -fi
> -
> -ac_fn_c_check_header_mongrel "$LINENO" "iconv.h" "ac_cv_header_iconv_h" "$ac_includes_default"
> -if test "x$ac_cv_header_iconv_h" = x""yes; then :
> -
> -fi
> -
> -
> -
>        if test "X$prefix" = "XNONE"; then
>      acl_final_prefix="$ac_default_prefix"
>    else
> @@ -13813,6 +13704,533 @@ fi
>  
>  
>  
> +  # See if the user specified whether he wants zlib support or not.
> +
> +# Check whether --with-zlib was given.
> +if test "${with_zlib+set}" = set; then :
> +  withval=$with_zlib;
> +else
> +  with_zlib=auto
> +fi
> +
> +
> +  if test "$with_zlib" != "no"; then
> +
> +
> +
> +
> +
> +
> +
> +
> +    use_additional=yes
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +
> +    eval additional_includedir=\"$includedir\"
> +    eval additional_libdir=\"$libdir\"
> +
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +
> +# Check whether --with-libz-prefix was given.
> +if test "${with_libz_prefix+set}" = set; then :
> +  withval=$with_libz_prefix;
> +    if test "X$withval" = "Xno"; then
> +      use_additional=no
> +    else
> +      if test "X$withval" = "X"; then
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +
> +          eval additional_includedir=\"$includedir\"
> +          eval additional_libdir=\"$libdir\"
> +
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +      else
> +        additional_includedir="$withval/include"
> +        additional_libdir="$withval/lib"
> +      fi
> +    fi
> +
> +fi
> +
> +      LIBZ=
> +  LTLIBZ=
> +  INCZ=
> +  rpathdirs=
> +  ltrpathdirs=
> +  names_already_handled=
> +  names_next_round='z '
> +  while test -n "$names_next_round"; do
> +    names_this_round="$names_next_round"
> +    names_next_round=
> +    for name in $names_this_round; do
> +      already_handled=
> +      for n in $names_already_handled; do
> +        if test "$n" = "$name"; then
> +          already_handled=yes
> +          break
> +        fi
> +      done
> +      if test -z "$already_handled"; then
> +        names_already_handled="$names_already_handled $name"
> +                        uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
> +        eval value=\"\$HAVE_LIB$uppername\"
> +        if test -n "$value"; then
> +          if test "$value" = yes; then
> +            eval value=\"\$LIB$uppername\"
> +            test -z "$value" || LIBZ="${LIBZ}${LIBZ:+ }$value"
> +            eval value=\"\$LTLIB$uppername\"
> +            test -z "$value" || LTLIBZ="${LTLIBZ}${LTLIBZ:+ }$value"
> +          else
> +                                    :
> +          fi
> +        else
> +                              found_dir=
> +          found_la=
> +          found_so=
> +          found_a=
> +          if test $use_additional = yes; then
> +            if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then
> +              found_dir="$additional_libdir"
> +              found_so="$additional_libdir/lib$name.$shlibext"
> +              if test -f "$additional_libdir/lib$name.la"; then
> +                found_la="$additional_libdir/lib$name.la"
> +              fi
> +            else
> +              if test -f "$additional_libdir/lib$name.$libext"; then
> +                found_dir="$additional_libdir"
> +                found_a="$additional_libdir/lib$name.$libext"
> +                if test -f "$additional_libdir/lib$name.la"; then
> +                  found_la="$additional_libdir/lib$name.la"
> +                fi
> +              fi
> +            fi
> +          fi
> +          if test "X$found_dir" = "X"; then
> +            for x in $LDFLAGS $LTLIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +              case "$x" in
> +                -L*)
> +                  dir=`echo "X$x" | sed -e 's/^X-L//'`
> +                  if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then
> +                    found_dir="$dir"
> +                    found_so="$dir/lib$name.$shlibext"
> +                    if test -f "$dir/lib$name.la"; then
> +                      found_la="$dir/lib$name.la"
> +                    fi
> +                  else
> +                    if test -f "$dir/lib$name.$libext"; then
> +                      found_dir="$dir"
> +                      found_a="$dir/lib$name.$libext"
> +                      if test -f "$dir/lib$name.la"; then
> +                        found_la="$dir/lib$name.la"
> +                      fi
> +                    fi
> +                  fi
> +                  ;;
> +              esac
> +              if test "X$found_dir" != "X"; then
> +                break
> +              fi
> +            done
> +          fi
> +          if test "X$found_dir" != "X"; then
> +                        LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-L$found_dir -l$name"
> +            if test "X$found_so" != "X"; then
> +                                                        if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then
> +                                LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +              else
> +                                                                                haveit=
> +                for x in $ltrpathdirs; do
> +                  if test "X$x" = "X$found_dir"; then
> +                    haveit=yes
> +                    break
> +                  fi
> +                done
> +                if test -z "$haveit"; then
> +                  ltrpathdirs="$ltrpathdirs $found_dir"
> +                fi
> +                                if test "$hardcode_direct" = yes; then
> +                                                      LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +                else
> +                  if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then
> +                                                            LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +                                                            haveit=
> +                    for x in $rpathdirs; do
> +                      if test "X$x" = "X$found_dir"; then
> +                        haveit=yes
> +                        break
> +                      fi
> +                    done
> +                    if test -z "$haveit"; then
> +                      rpathdirs="$rpathdirs $found_dir"
> +                    fi
> +                  else
> +                                                                                haveit=
> +                    for x in $LDFLAGS $LIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                      if test "X$x" = "X-L$found_dir"; then
> +                        haveit=yes
> +                        break
> +                      fi
> +                    done
> +                    if test -z "$haveit"; then
> +                      LIBZ="${LIBZ}${LIBZ:+ }-L$found_dir"
> +                    fi
> +                    if test "$hardcode_minus_L" != no; then
> +                                                                                        LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +                    else
> +                                                                                                                                                                                LIBZ="${LIBZ}${LIBZ:+ }-l$name"
> +                    fi
> +                  fi
> +                fi
> +              fi
> +            else
> +              if test "X$found_a" != "X"; then
> +                                LIBZ="${LIBZ}${LIBZ:+ }$found_a"
> +              else
> +                                                LIBZ="${LIBZ}${LIBZ:+ }-L$found_dir -l$name"
> +              fi
> +            fi
> +                        additional_includedir=
> +            case "$found_dir" in
> +              */lib | */lib/)
> +                basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'`
> +                additional_includedir="$basedir/include"
> +                ;;
> +            esac
> +            if test "X$additional_includedir" != "X"; then
> +                                                                                                                if test "X$additional_includedir" != "X/usr/include"; then
> +                haveit=
> +                if test "X$additional_includedir" = "X/usr/local/include"; then
> +                  if test -n "$GCC"; then
> +                    case $host_os in
> +                      linux*) haveit=yes;;
> +                    esac
> +                  fi
> +                fi
> +                if test -z "$haveit"; then
> +                  for x in $CPPFLAGS $INCZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                    if test "X$x" = "X-I$additional_includedir"; then
> +                      haveit=yes
> +                      break
> +                    fi
> +                  done
> +                  if test -z "$haveit"; then
> +                    if test -d "$additional_includedir"; then
> +                                            INCZ="${INCZ}${INCZ:+ }-I$additional_includedir"
> +                    fi
> +                  fi
> +                fi
> +              fi
> +            fi
> +                        if test -n "$found_la"; then
> +                                                        save_libdir="$libdir"
> +              case "$found_la" in
> +                */* | *\\*) . "$found_la" ;;
> +                *) . "./$found_la" ;;
> +              esac
> +              libdir="$save_libdir"
> +                            for dep in $dependency_libs; do
> +                case "$dep" in
> +                  -L*)
> +                    additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
> +                                                                                                                                                                if test "X$additional_libdir" != "X/usr/lib"; then
> +                      haveit=
> +                      if test "X$additional_libdir" = "X/usr/local/lib"; then
> +                        if test -n "$GCC"; then
> +                          case $host_os in
> +                            linux*) haveit=yes;;
> +                          esac
> +                        fi
> +                      fi
> +                      if test -z "$haveit"; then
> +                        haveit=
> +                        for x in $LDFLAGS $LIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                          if test "X$x" = "X-L$additional_libdir"; then
> +                            haveit=yes
> +                            break
> +                          fi
> +                        done
> +                        if test -z "$haveit"; then
> +                          if test -d "$additional_libdir"; then
> +                                                        LIBZ="${LIBZ}${LIBZ:+ }-L$additional_libdir"
> +                          fi
> +                        fi
> +                        haveit=
> +                        for x in $LDFLAGS $LTLIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                          if test "X$x" = "X-L$additional_libdir"; then
> +                            haveit=yes
> +                            break
> +                          fi
> +                        done
> +                        if test -z "$haveit"; then
> +                          if test -d "$additional_libdir"; then
> +                                                        LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-L$additional_libdir"
> +                          fi
> +                        fi
> +                      fi
> +                    fi
> +                    ;;
> +                  -R*)
> +                    dir=`echo "X$dep" | sed -e 's/^X-R//'`
> +                    if test "$enable_rpath" != no; then
> +                                                                  haveit=
> +                      for x in $rpathdirs; do
> +                        if test "X$x" = "X$dir"; then
> +                          haveit=yes
> +                          break
> +                        fi
> +                      done
> +                      if test -z "$haveit"; then
> +                        rpathdirs="$rpathdirs $dir"
> +                      fi
> +                                                                  haveit=
> +                      for x in $ltrpathdirs; do
> +                        if test "X$x" = "X$dir"; then
> +                          haveit=yes
> +                          break
> +                        fi
> +                      done
> +                      if test -z "$haveit"; then
> +                        ltrpathdirs="$ltrpathdirs $dir"
> +                      fi
> +                    fi
> +                    ;;
> +                  -l*)
> +                                        names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
> +                    ;;
> +                  *.la)
> +                                                                                names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
> +                    ;;
> +                  *)
> +                                        LIBZ="${LIBZ}${LIBZ:+ }$dep"
> +                    LTLIBZ="${LTLIBZ}${LTLIBZ:+ }$dep"
> +                    ;;
> +                esac
> +              done
> +            fi
> +          else
> +                                                            LIBZ="${LIBZ}${LIBZ:+ }-l$name"
> +            LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-l$name"
> +          fi
> +        fi
> +      fi
> +    done
> +  done
> +  if test "X$rpathdirs" != "X"; then
> +    if test -n "$hardcode_libdir_separator"; then
> +                        alldirs=
> +      for found_dir in $rpathdirs; do
> +        alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir"
> +      done
> +            acl_save_libdir="$libdir"
> +      libdir="$alldirs"
> +      eval flag=\"$hardcode_libdir_flag_spec\"
> +      libdir="$acl_save_libdir"
> +      LIBZ="${LIBZ}${LIBZ:+ }$flag"
> +    else
> +            for found_dir in $rpathdirs; do
> +        acl_save_libdir="$libdir"
> +        libdir="$found_dir"
> +        eval flag=\"$hardcode_libdir_flag_spec\"
> +        libdir="$acl_save_libdir"
> +        LIBZ="${LIBZ}${LIBZ:+ }$flag"
> +      done
> +    fi
> +  fi
> +  if test "X$ltrpathdirs" != "X"; then
> +            for found_dir in $ltrpathdirs; do
> +      LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-R$found_dir"
> +    done
> +  fi
> +
> +
> +        ac_save_CPPFLAGS="$CPPFLAGS"
> +
> +  for element in $INCZ; do
> +    haveit=
> +    for x in $CPPFLAGS; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +      if test "X$x" = "X$element"; then
> +        haveit=yes
> +        break
> +      fi
> +    done
> +    if test -z "$haveit"; then
> +      CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element"
> +    fi
> +  done
> +
> +
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libz" >&5
> +$as_echo_n "checking for libz... " >&6; }
> +if test "${ac_cv_libz+set}" = set; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +
> +    ac_save_LIBS="$LIBS"
> +    LIBS="$LIBS $LIBZ"
> +    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> +/* end confdefs.h.  */
> +#include "zlib.h";
> +int
> +main ()
> +{
> +int ret = deflateInit(NULL, 1);
> +  ;
> +  return 0;
> +}
> +_ACEOF
> +if ac_fn_c_try_link "$LINENO"; then :
> +  ac_cv_libz=yes
> +else
> +  ac_cv_libz=no
> +fi
> +rm -f core conftest.err conftest.$ac_objext \
> +    conftest$ac_exeext conftest.$ac_ext
> +    LIBS="$ac_save_LIBS"
> +
> +fi
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_libz" >&5
> +$as_echo "$ac_cv_libz" >&6; }
> +  if test "$ac_cv_libz" = yes; then
> +    HAVE_LIBZ=yes
> +
> +$as_echo "#define HAVE_LIBZ 1" >>confdefs.h
> +
> +    { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libz" >&5
> +$as_echo_n "checking how to link with libz... " >&6; }
> +    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBZ" >&5
> +$as_echo "$LIBZ" >&6; }
> +  else
> +    HAVE_LIBZ=no
> +            CPPFLAGS="$ac_save_CPPFLAGS"
> +    LIBZ=
> +    LTLIBZ=
> +  fi
> +
> +
> +
> +
> +
> +
> +    if test "$HAVE_LIBZ" = "yes"; then
> +      # Make sure HAVE_ZLIB_H gets defined.  Some code uses that over
> +      # HAVE_LIBZ, since initially we were only defining HAVE_ZLIB_H.
> +      for ac_header in zlib.h
> +do :
> +  ac_fn_c_check_header_mongrel "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default"
> +if test "x$ac_cv_header_zlib_h" = x""yes; then :
> +  cat >>confdefs.h <<_ACEOF
> +#define HAVE_ZLIB_H 1
> +_ACEOF
> +
> +fi
> +
> +done
> +
> +      LIBS="$LIBS $LIBZ"
> +    fi
> +    if test "$with_zlib" = "yes" -a "$HAVE_LIBZ" != "yes"; then
> +      as_fn_error "zlib (libz) library was explicitly requested but not found" "$LINENO" 5
> +    fi
> +  fi
> +
> +
> +
> +case "${host}" in
> +*-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows*)
> +
> +$as_echo "#define USE_BINARY_FOPEN 1" >>confdefs.h
> + ;;
> +esac
> +
> +# target-specific stuff:
> +
> +# Canonicalize the secondary target names.
> +if test -n "$enable_targets"; then
> +    for targ in `echo $enable_targets | sed 's/,/ /g'`
> +    do
> +	result=`$ac_config_sub $targ 2>/dev/null`
> +	if test -n "$result"; then
> +	    canon_targets="$canon_targets $result"
> +	else
> +	    # Allow targets that config.sub doesn't recognize, like "all".
> +	    canon_targets="$canon_targets $targ"
> +	fi
> +    done
> +fi
> +
> +ac_fn_c_check_header_mongrel "$LINENO" "iconv.h" "ac_cv_header_iconv_h" "$ac_includes_default"
> +if test "x$ac_cv_header_iconv_h" = x""yes; then :
> +
> +fi
> +
> +
> +
>  
>  
>  
> diff --git a/binutils/doc/Makefile.in b/binutils/doc/Makefile.in
> index c828aae..96657ed 100644
> --- a/binutils/doc/Makefile.in
> +++ b/binutils/doc/Makefile.in
> @@ -166,6 +166,7 @@ FGREP = @FGREP@
>  GENCAT = @GENCAT@
>  GMSGFMT = @GMSGFMT@
>  GREP = @GREP@
> +HAVE_LIBZ = @HAVE_LIBZ@
>  HDEFINES = @HDEFINES@
>  INCINTL = @INCINTL@
>  INSTALL = @INSTALL@
> @@ -185,10 +186,12 @@ LIBINTL_DEP = @LIBINTL_DEP@
>  LIBOBJS = @LIBOBJS@
>  LIBS = @LIBS@
>  LIBTOOL = @LIBTOOL@
> +LIBZ = @LIBZ@
>  LIPO = @LIPO@
>  LN_S = @LN_S@
>  LTLIBICONV = @LTLIBICONV@
>  LTLIBOBJS = @LTLIBOBJS@
> +LTLIBZ = @LTLIBZ@
>  MAINT = @MAINT@
>  MAKEINFO = @MAKEINFO@
>  MKDIR_P = @MKDIR_P@
> diff --git a/config/zlib.m4 b/config/zlib.m4
> index b017499..1581124 100644
> --- a/config/zlib.m4
> +++ b/config/zlib.m4
> @@ -9,8 +9,15 @@ AC_DEFUN([AM_ZLIB],
>      [], [with_zlib=auto])
>  
>    if test "$with_zlib" != "no"; then
> -    AC_SEARCH_LIBS(zlibVersion, z, [AC_CHECK_HEADERS(zlib.h)])
> -    if test "$with_zlib" = "yes" -a "$ac_cv_header_zlib_h" != "yes"; then
> +    AC_LIB_HAVE_LINKFLAGS([z], [], [#include "zlib.h";],
> +                          [int ret = deflateInit(NULL, 1);])
> +    if test "$HAVE_LIBZ" = "yes"; then
> +      # Make sure HAVE_ZLIB_H gets defined.  Some code uses that over
> +      # HAVE_LIBZ, since initially we were only defining HAVE_ZLIB_H.
> +      AC_CHECK_HEADERS(zlib.h)
> +      LIBS="$LIBS $LIBZ"
> +    fi
> +    if test "$with_zlib" = "yes" -a "$HAVE_LIBZ" != "yes"; then
>        AC_MSG_ERROR([zlib (libz) library was explicitly requested but not found])
>      fi
>    fi
> diff --git a/gas/Makefile.in b/gas/Makefile.in
> index f190714..dd21288 100644
> --- a/gas/Makefile.in
> +++ b/gas/Makefile.in
> @@ -73,6 +73,9 @@ am__aclocal_m4_deps = $(top_srcdir)/../bfd/acinclude.m4 \
>  	$(top_srcdir)/../config/largefile.m4 \
>  	$(top_srcdir)/../config/lcmessage.m4 \
>  	$(top_srcdir)/../config/lead-dot.m4 \
> +	$(top_srcdir)/../config/lib-ld.m4 \
> +	$(top_srcdir)/../config/lib-link.m4 \
> +	$(top_srcdir)/../config/lib-prefix.m4 \
>  	$(top_srcdir)/../config/nls.m4 \
>  	$(top_srcdir)/../config/override.m4 \
>  	$(top_srcdir)/../config/plugins.m4 \
> @@ -181,6 +184,7 @@ GDBINIT = @GDBINIT@
>  GENCAT = @GENCAT@
>  GMSGFMT = @GMSGFMT@
>  GREP = @GREP@
> +HAVE_LIBZ = @HAVE_LIBZ@
>  INCINTL = @INCINTL@
>  INSTALL = @INSTALL@
>  INSTALL_DATA = @INSTALL_DATA@
> @@ -199,9 +203,11 @@ LIBM = @LIBM@
>  LIBOBJS = @LIBOBJS@
>  LIBS = @LIBS@
>  LIBTOOL = @LIBTOOL@
> +LIBZ = @LIBZ@
>  LIPO = @LIPO@
>  LN_S = @LN_S@
>  LTLIBOBJS = @LTLIBOBJS@
> +LTLIBZ = @LTLIBZ@
>  MAINT = @MAINT@
>  MAKEINFO = @MAKEINFO@
>  MKDIR_P = @MKDIR_P@
> diff --git a/gas/aclocal.m4 b/gas/aclocal.m4
> index ea731ac..3d9deaf 100644
> --- a/gas/aclocal.m4
> +++ b/gas/aclocal.m4
> @@ -997,6 +997,9 @@ m4_include([../config/gettext-sister.m4])
>  m4_include([../config/largefile.m4])
>  m4_include([../config/lcmessage.m4])
>  m4_include([../config/lead-dot.m4])
> +m4_include([../config/lib-ld.m4])
> +m4_include([../config/lib-link.m4])
> +m4_include([../config/lib-prefix.m4])
>  m4_include([../config/nls.m4])
>  m4_include([../config/override.m4])
>  m4_include([../config/plugins.m4])
> diff --git a/gas/config.in b/gas/config.in
> index fef16ee..c326c74 100644
> --- a/gas/config.in
> +++ b/gas/config.in
> @@ -100,6 +100,9 @@
>  /* Define if your <locale.h> file defines LC_MESSAGES. */
>  #undef HAVE_LC_MESSAGES
>  
> +/* Define if you have the z library. */
> +#undef HAVE_LIBZ
> +
>  /* Define to 1 if you have the <limits.h> header file. */
>  #undef HAVE_LIMITS_H
>  
> diff --git a/gas/configure b/gas/configure
> index 75d8a52..7ebd36a 100755
> --- a/gas/configure
> +++ b/gas/configure
> @@ -602,6 +602,9 @@ ac_subst_vars='am__EXEEXT_FALSE
>  am__EXEEXT_TRUE
>  LTLIBOBJS
>  LIBOBJS
> +LTLIBZ
> +LIBZ
> +HAVE_LIBZ
>  LIBM
>  ALLOCA
>  GENINSRC_NEVER_FALSE
> @@ -767,6 +770,8 @@ enable_build_warnings
>  enable_nls
>  enable_maintainer_mode
>  with_zlib
> +enable_rpath
> +with_libz_prefix
>  '
>        ac_precious_vars='build_alias
>  host_alias
> @@ -1415,6 +1420,7 @@ Optional Features:
>    --disable-nls           do not use Native Language Support
>    --enable-maintainer-mode  enable make rules and dependencies not useful
>  			  (and sometimes confusing) to the casual installer
> +  --disable-rpath         do not hardcode runtime library paths
>  
>  Optional Packages:
>    --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
> @@ -1423,6 +1429,9 @@ Optional Packages:
>                            both]
>    --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
>    --with-zlib             include zlib support (auto/yes/no) default=auto
> +  --with-gnu-ld           assume the C compiler uses GNU ld default=no
> +  --with-libz-prefix[=DIR]  search for libz in DIR/include and DIR/lib
> +  --without-libz-prefix     don't search for libz in includedir and libdir
>  
>  Some influential environment variables:
>    CC          C compiler command
> @@ -10967,7 +10976,7 @@ else
>    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>    lt_status=$lt_dlunknown
>    cat > conftest.$ac_ext <<_LT_EOF
> -#line 10970 "configure"
> +#line 10979 "configure"
>  #include "confdefs.h"
>  
>  #if HAVE_DLFCN_H
> @@ -11073,7 +11082,7 @@ else
>    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>    lt_status=$lt_dlunknown
>    cat > conftest.$ac_ext <<_LT_EOF
> -#line 11076 "configure"
> +#line 11085 "configure"
>  #include "confdefs.h"
>  
>  #if HAVE_DLFCN_H
> @@ -14321,6 +14330,164 @@ esac
>  
>  # Link in zlib if we can.  This allows us to write compressed debug sections.
>  
> +      if test "X$prefix" = "XNONE"; then
> +    acl_final_prefix="$ac_default_prefix"
> +  else
> +    acl_final_prefix="$prefix"
> +  fi
> +  if test "X$exec_prefix" = "XNONE"; then
> +    acl_final_exec_prefix='${prefix}'
> +  else
> +    acl_final_exec_prefix="$exec_prefix"
> +  fi
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
> +  prefix="$acl_save_prefix"
> +
> +
> +# Check whether --with-gnu-ld was given.
> +if test "${with_gnu_ld+set}" = set; then :
> +  withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
> +else
> +  with_gnu_ld=no
> +fi
> +
> +# Prepare PATH_SEPARATOR.
> +# The user is always right.
> +if test "${PATH_SEPARATOR+set}" != set; then
> +  echo "#! /bin/sh" >conf$$.sh
> +  echo  "exit 0"   >>conf$$.sh
> +  chmod +x conf$$.sh
> +  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
> +    PATH_SEPARATOR=';'
> +  else
> +    PATH_SEPARATOR=:
> +  fi
> +  rm -f conf$$.sh
> +fi
> +ac_prog=ld
> +if test "$GCC" = yes; then
> +  # Check if gcc -print-prog-name=ld gives a path.
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by GCC" >&5
> +$as_echo_n "checking for ld used by GCC... " >&6; }
> +  case $host in
> +  *-*-mingw*)
> +    # gcc leaves a trailing carriage return which upsets mingw
> +    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
> +  *)
> +    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
> +  esac
> +  case $ac_prog in
> +    # Accept absolute paths.
> +    [\\/]* | [A-Za-z]:[\\/]*)
> +      re_direlt='/[^/][^/]*/\.\./'
> +      # Canonicalize the path of ld
> +      ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
> +      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
> +	ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
> +      done
> +      test -z "$LD" && LD="$ac_prog"
> +      ;;
> +  "")
> +    # If it fails, then pretend we aren't using GCC.
> +    ac_prog=ld
> +    ;;
> +  *)
> +    # If it is relative, then search for the first ld in PATH.
> +    with_gnu_ld=unknown
> +    ;;
> +  esac
> +elif test "$with_gnu_ld" = yes; then
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
> +$as_echo_n "checking for GNU ld... " >&6; }
> +else
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
> +$as_echo_n "checking for non-GNU ld... " >&6; }
> +fi
> +if test "${acl_cv_path_LD+set}" = set; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +  if test -z "$LD"; then
> +  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
> +  for ac_dir in $PATH; do
> +    test -z "$ac_dir" && ac_dir=.
> +    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
> +      acl_cv_path_LD="$ac_dir/$ac_prog"
> +      # Check to see if the program is GNU ld.  I'd rather use --version,
> +      # but apparently some GNU ld's only accept -v.
> +      # Break only if it was the GNU/non-GNU ld that we prefer.
> +      if "$acl_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
> +	test "$with_gnu_ld" != no && break
> +      else
> +	test "$with_gnu_ld" != yes && break
> +      fi
> +    fi
> +  done
> +  IFS="$ac_save_ifs"
> +else
> +  acl_cv_path_LD="$LD" # Let the user override the test with a path.
> +fi
> +fi
> +
> +LD="$acl_cv_path_LD"
> +if test -n "$LD"; then
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
> +$as_echo "$LD" >&6; }
> +else
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
> +$as_echo "no" >&6; }
> +fi
> +test -z "$LD" && as_fn_error "no acceptable ld found in \$PATH" "$LINENO" 5
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
> +$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; }
> +if test "${acl_cv_prog_gnu_ld+set}" = set; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +  # I'd rather use --version here, but apparently some GNU ld's only accept -v.
> +if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
> +  acl_cv_prog_gnu_ld=yes
> +else
> +  acl_cv_prog_gnu_ld=no
> +fi
> +fi
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_prog_gnu_ld" >&5
> +$as_echo "$acl_cv_prog_gnu_ld" >&6; }
> +with_gnu_ld=$acl_cv_prog_gnu_ld
> +
> +
> +
> +                                                { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5
> +$as_echo_n "checking for shared library run path origin... " >&6; }
> +if test "${acl_cv_rpath+set}" = set; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +
> +    CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
> +    ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
> +    . ./conftest.sh
> +    rm -f ./conftest.sh
> +    acl_cv_rpath=done
> +
> +fi
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_rpath" >&5
> +$as_echo "$acl_cv_rpath" >&6; }
> +  wl="$acl_cv_wl"
> +  libext="$acl_cv_libext"
> +  shlibext="$acl_cv_shlibext"
> +  hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
> +  hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
> +  hardcode_direct="$acl_cv_hardcode_direct"
> +  hardcode_minus_L="$acl_cv_hardcode_minus_L"
> +    # Check whether --enable-rpath was given.
> +if test "${enable_rpath+set}" = set; then :
> +  enableval=$enable_rpath; :
> +else
> +  enable_rpath=yes
> +fi
> +
> +
> +
>    # See if the user specified whether he wants zlib support or not.
>  
>  # Check whether --with-zlib was given.
> @@ -14332,60 +14499,472 @@ fi
>  
>  
>    if test "$with_zlib" != "no"; then
> -    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing zlibVersion" >&5
> -$as_echo_n "checking for library containing zlibVersion... " >&6; }
> -if test "${ac_cv_search_zlibVersion+set}" = set; then :
> +
> +
> +
> +
> +
> +
> +
> +
> +    use_additional=yes
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +
> +    eval additional_includedir=\"$includedir\"
> +    eval additional_libdir=\"$libdir\"
> +
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +
> +# Check whether --with-libz-prefix was given.
> +if test "${with_libz_prefix+set}" = set; then :
> +  withval=$with_libz_prefix;
> +    if test "X$withval" = "Xno"; then
> +      use_additional=no
> +    else
> +      if test "X$withval" = "X"; then
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +
> +          eval additional_includedir=\"$includedir\"
> +          eval additional_libdir=\"$libdir\"
> +
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +      else
> +        additional_includedir="$withval/include"
> +        additional_libdir="$withval/lib"
> +      fi
> +    fi
> +
> +fi
> +
> +      LIBZ=
> +  LTLIBZ=
> +  INCZ=
> +  rpathdirs=
> +  ltrpathdirs=
> +  names_already_handled=
> +  names_next_round='z '
> +  while test -n "$names_next_round"; do
> +    names_this_round="$names_next_round"
> +    names_next_round=
> +    for name in $names_this_round; do
> +      already_handled=
> +      for n in $names_already_handled; do
> +        if test "$n" = "$name"; then
> +          already_handled=yes
> +          break
> +        fi
> +      done
> +      if test -z "$already_handled"; then
> +        names_already_handled="$names_already_handled $name"
> +                        uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
> +        eval value=\"\$HAVE_LIB$uppername\"
> +        if test -n "$value"; then
> +          if test "$value" = yes; then
> +            eval value=\"\$LIB$uppername\"
> +            test -z "$value" || LIBZ="${LIBZ}${LIBZ:+ }$value"
> +            eval value=\"\$LTLIB$uppername\"
> +            test -z "$value" || LTLIBZ="${LTLIBZ}${LTLIBZ:+ }$value"
> +          else
> +                                    :
> +          fi
> +        else
> +                              found_dir=
> +          found_la=
> +          found_so=
> +          found_a=
> +          if test $use_additional = yes; then
> +            if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then
> +              found_dir="$additional_libdir"
> +              found_so="$additional_libdir/lib$name.$shlibext"
> +              if test -f "$additional_libdir/lib$name.la"; then
> +                found_la="$additional_libdir/lib$name.la"
> +              fi
> +            else
> +              if test -f "$additional_libdir/lib$name.$libext"; then
> +                found_dir="$additional_libdir"
> +                found_a="$additional_libdir/lib$name.$libext"
> +                if test -f "$additional_libdir/lib$name.la"; then
> +                  found_la="$additional_libdir/lib$name.la"
> +                fi
> +              fi
> +            fi
> +          fi
> +          if test "X$found_dir" = "X"; then
> +            for x in $LDFLAGS $LTLIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +              case "$x" in
> +                -L*)
> +                  dir=`echo "X$x" | sed -e 's/^X-L//'`
> +                  if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then
> +                    found_dir="$dir"
> +                    found_so="$dir/lib$name.$shlibext"
> +                    if test -f "$dir/lib$name.la"; then
> +                      found_la="$dir/lib$name.la"
> +                    fi
> +                  else
> +                    if test -f "$dir/lib$name.$libext"; then
> +                      found_dir="$dir"
> +                      found_a="$dir/lib$name.$libext"
> +                      if test -f "$dir/lib$name.la"; then
> +                        found_la="$dir/lib$name.la"
> +                      fi
> +                    fi
> +                  fi
> +                  ;;
> +              esac
> +              if test "X$found_dir" != "X"; then
> +                break
> +              fi
> +            done
> +          fi
> +          if test "X$found_dir" != "X"; then
> +                        LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-L$found_dir -l$name"
> +            if test "X$found_so" != "X"; then
> +                                                        if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then
> +                                LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +              else
> +                                                                                haveit=
> +                for x in $ltrpathdirs; do
> +                  if test "X$x" = "X$found_dir"; then
> +                    haveit=yes
> +                    break
> +                  fi
> +                done
> +                if test -z "$haveit"; then
> +                  ltrpathdirs="$ltrpathdirs $found_dir"
> +                fi
> +                                if test "$hardcode_direct" = yes; then
> +                                                      LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +                else
> +                  if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then
> +                                                            LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +                                                            haveit=
> +                    for x in $rpathdirs; do
> +                      if test "X$x" = "X$found_dir"; then
> +                        haveit=yes
> +                        break
> +                      fi
> +                    done
> +                    if test -z "$haveit"; then
> +                      rpathdirs="$rpathdirs $found_dir"
> +                    fi
> +                  else
> +                                                                                haveit=
> +                    for x in $LDFLAGS $LIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                      if test "X$x" = "X-L$found_dir"; then
> +                        haveit=yes
> +                        break
> +                      fi
> +                    done
> +                    if test -z "$haveit"; then
> +                      LIBZ="${LIBZ}${LIBZ:+ }-L$found_dir"
> +                    fi
> +                    if test "$hardcode_minus_L" != no; then
> +                                                                                        LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +                    else
> +                                                                                                                                                                                LIBZ="${LIBZ}${LIBZ:+ }-l$name"
> +                    fi
> +                  fi
> +                fi
> +              fi
> +            else
> +              if test "X$found_a" != "X"; then
> +                                LIBZ="${LIBZ}${LIBZ:+ }$found_a"
> +              else
> +                                                LIBZ="${LIBZ}${LIBZ:+ }-L$found_dir -l$name"
> +              fi
> +            fi
> +                        additional_includedir=
> +            case "$found_dir" in
> +              */lib | */lib/)
> +                basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'`
> +                additional_includedir="$basedir/include"
> +                ;;
> +            esac
> +            if test "X$additional_includedir" != "X"; then
> +                                                                                                                if test "X$additional_includedir" != "X/usr/include"; then
> +                haveit=
> +                if test "X$additional_includedir" = "X/usr/local/include"; then
> +                  if test -n "$GCC"; then
> +                    case $host_os in
> +                      linux*) haveit=yes;;
> +                    esac
> +                  fi
> +                fi
> +                if test -z "$haveit"; then
> +                  for x in $CPPFLAGS $INCZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                    if test "X$x" = "X-I$additional_includedir"; then
> +                      haveit=yes
> +                      break
> +                    fi
> +                  done
> +                  if test -z "$haveit"; then
> +                    if test -d "$additional_includedir"; then
> +                                            INCZ="${INCZ}${INCZ:+ }-I$additional_includedir"
> +                    fi
> +                  fi
> +                fi
> +              fi
> +            fi
> +                        if test -n "$found_la"; then
> +                                                        save_libdir="$libdir"
> +              case "$found_la" in
> +                */* | *\\*) . "$found_la" ;;
> +                *) . "./$found_la" ;;
> +              esac
> +              libdir="$save_libdir"
> +                            for dep in $dependency_libs; do
> +                case "$dep" in
> +                  -L*)
> +                    additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
> +                                                                                                                                                                if test "X$additional_libdir" != "X/usr/lib"; then
> +                      haveit=
> +                      if test "X$additional_libdir" = "X/usr/local/lib"; then
> +                        if test -n "$GCC"; then
> +                          case $host_os in
> +                            linux*) haveit=yes;;
> +                          esac
> +                        fi
> +                      fi
> +                      if test -z "$haveit"; then
> +                        haveit=
> +                        for x in $LDFLAGS $LIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                          if test "X$x" = "X-L$additional_libdir"; then
> +                            haveit=yes
> +                            break
> +                          fi
> +                        done
> +                        if test -z "$haveit"; then
> +                          if test -d "$additional_libdir"; then
> +                                                        LIBZ="${LIBZ}${LIBZ:+ }-L$additional_libdir"
> +                          fi
> +                        fi
> +                        haveit=
> +                        for x in $LDFLAGS $LTLIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                          if test "X$x" = "X-L$additional_libdir"; then
> +                            haveit=yes
> +                            break
> +                          fi
> +                        done
> +                        if test -z "$haveit"; then
> +                          if test -d "$additional_libdir"; then
> +                                                        LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-L$additional_libdir"
> +                          fi
> +                        fi
> +                      fi
> +                    fi
> +                    ;;
> +                  -R*)
> +                    dir=`echo "X$dep" | sed -e 's/^X-R//'`
> +                    if test "$enable_rpath" != no; then
> +                                                                  haveit=
> +                      for x in $rpathdirs; do
> +                        if test "X$x" = "X$dir"; then
> +                          haveit=yes
> +                          break
> +                        fi
> +                      done
> +                      if test -z "$haveit"; then
> +                        rpathdirs="$rpathdirs $dir"
> +                      fi
> +                                                                  haveit=
> +                      for x in $ltrpathdirs; do
> +                        if test "X$x" = "X$dir"; then
> +                          haveit=yes
> +                          break
> +                        fi
> +                      done
> +                      if test -z "$haveit"; then
> +                        ltrpathdirs="$ltrpathdirs $dir"
> +                      fi
> +                    fi
> +                    ;;
> +                  -l*)
> +                                        names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
> +                    ;;
> +                  *.la)
> +                                                                                names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
> +                    ;;
> +                  *)
> +                                        LIBZ="${LIBZ}${LIBZ:+ }$dep"
> +                    LTLIBZ="${LTLIBZ}${LTLIBZ:+ }$dep"
> +                    ;;
> +                esac
> +              done
> +            fi
> +          else
> +                                                            LIBZ="${LIBZ}${LIBZ:+ }-l$name"
> +            LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-l$name"
> +          fi
> +        fi
> +      fi
> +    done
> +  done
> +  if test "X$rpathdirs" != "X"; then
> +    if test -n "$hardcode_libdir_separator"; then
> +                        alldirs=
> +      for found_dir in $rpathdirs; do
> +        alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir"
> +      done
> +            acl_save_libdir="$libdir"
> +      libdir="$alldirs"
> +      eval flag=\"$hardcode_libdir_flag_spec\"
> +      libdir="$acl_save_libdir"
> +      LIBZ="${LIBZ}${LIBZ:+ }$flag"
> +    else
> +            for found_dir in $rpathdirs; do
> +        acl_save_libdir="$libdir"
> +        libdir="$found_dir"
> +        eval flag=\"$hardcode_libdir_flag_spec\"
> +        libdir="$acl_save_libdir"
> +        LIBZ="${LIBZ}${LIBZ:+ }$flag"
> +      done
> +    fi
> +  fi
> +  if test "X$ltrpathdirs" != "X"; then
> +            for found_dir in $ltrpathdirs; do
> +      LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-R$found_dir"
> +    done
> +  fi
> +
> +
> +        ac_save_CPPFLAGS="$CPPFLAGS"
> +
> +  for element in $INCZ; do
> +    haveit=
> +    for x in $CPPFLAGS; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +      if test "X$x" = "X$element"; then
> +        haveit=yes
> +        break
> +      fi
> +    done
> +    if test -z "$haveit"; then
> +      CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element"
> +    fi
> +  done
> +
> +
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libz" >&5
> +$as_echo_n "checking for libz... " >&6; }
> +if test "${ac_cv_libz+set}" = set; then :
>    $as_echo_n "(cached) " >&6
>  else
> -  ac_func_search_save_LIBS=$LIBS
> -cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> -/* end confdefs.h.  */
>  
> -/* Override any GCC internal prototype to avoid an error.
> -   Use char because int might match the return type of a GCC
> -   builtin and then its argument prototype would still apply.  */
> -#ifdef __cplusplus
> -extern "C"
> -#endif
> -char zlibVersion ();
> +    ac_save_LIBS="$LIBS"
> +    LIBS="$LIBS $LIBZ"
> +    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> +/* end confdefs.h.  */
> +#include "zlib.h";
>  int
>  main ()
>  {
> -return zlibVersion ();
> +int ret = deflateInit(NULL, 1);
>    ;
>    return 0;
>  }
>  _ACEOF
> -for ac_lib in '' z; do
> -  if test -z "$ac_lib"; then
> -    ac_res="none required"
> -  else
> -    ac_res=-l$ac_lib
> -    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
> -  fi
> -  if ac_fn_c_try_link "$LINENO"; then :
> -  ac_cv_search_zlibVersion=$ac_res
> +if ac_fn_c_try_link "$LINENO"; then :
> +  ac_cv_libz=yes
> +else
> +  ac_cv_libz=no
>  fi
>  rm -f core conftest.err conftest.$ac_objext \
> -    conftest$ac_exeext
> -  if test "${ac_cv_search_zlibVersion+set}" = set; then :
> -  break
> -fi
> -done
> -if test "${ac_cv_search_zlibVersion+set}" = set; then :
> +    conftest$ac_exeext conftest.$ac_ext
> +    LIBS="$ac_save_LIBS"
>  
> -else
> -  ac_cv_search_zlibVersion=no
>  fi
> -rm conftest.$ac_ext
> -LIBS=$ac_func_search_save_LIBS
> -fi
> -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_zlibVersion" >&5
> -$as_echo "$ac_cv_search_zlibVersion" >&6; }
> -ac_res=$ac_cv_search_zlibVersion
> -if test "$ac_res" != no; then :
> -  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
> -  for ac_header in zlib.h
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_libz" >&5
> +$as_echo "$ac_cv_libz" >&6; }
> +  if test "$ac_cv_libz" = yes; then
> +    HAVE_LIBZ=yes
> +
> +$as_echo "#define HAVE_LIBZ 1" >>confdefs.h
> +
> +    { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libz" >&5
> +$as_echo_n "checking how to link with libz... " >&6; }
> +    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBZ" >&5
> +$as_echo "$LIBZ" >&6; }
> +  else
> +    HAVE_LIBZ=no
> +            CPPFLAGS="$ac_save_CPPFLAGS"
> +    LIBZ=
> +    LTLIBZ=
> +  fi
> +
> +
> +
> +
> +
> +
> +    if test "$HAVE_LIBZ" = "yes"; then
> +      # Make sure HAVE_ZLIB_H gets defined.  Some code uses that over
> +      # HAVE_LIBZ, since initially we were only defining HAVE_ZLIB_H.
> +      for ac_header in zlib.h
>  do :
>    ac_fn_c_check_header_mongrel "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default"
>  if test "x$ac_cv_header_zlib_h" = x""yes; then :
> @@ -14397,9 +14976,9 @@ fi
>  
>  done
>  
> -fi
> -
> -    if test "$with_zlib" = "yes" -a "$ac_cv_header_zlib_h" != "yes"; then
> +      LIBS="$LIBS $LIBZ"
> +    fi
> +    if test "$with_zlib" = "yes" -a "$HAVE_LIBZ" != "yes"; then
>        as_fn_error "zlib (libz) library was explicitly requested but not found" "$LINENO" 5
>      fi
>    fi
> diff --git a/gas/doc/Makefile.in b/gas/doc/Makefile.in
> index 02841d9..86d5a5d 100644
> --- a/gas/doc/Makefile.in
> +++ b/gas/doc/Makefile.in
> @@ -64,6 +64,9 @@ am__aclocal_m4_deps = $(top_srcdir)/../bfd/acinclude.m4 \
>  	$(top_srcdir)/../config/largefile.m4 \
>  	$(top_srcdir)/../config/lcmessage.m4 \
>  	$(top_srcdir)/../config/lead-dot.m4 \
> +	$(top_srcdir)/../config/lib-ld.m4 \
> +	$(top_srcdir)/../config/lib-link.m4 \
> +	$(top_srcdir)/../config/lib-prefix.m4 \
>  	$(top_srcdir)/../config/nls.m4 \
>  	$(top_srcdir)/../config/override.m4 \
>  	$(top_srcdir)/../config/plugins.m4 \
> @@ -150,6 +153,7 @@ GDBINIT = @GDBINIT@
>  GENCAT = @GENCAT@
>  GMSGFMT = @GMSGFMT@
>  GREP = @GREP@
> +HAVE_LIBZ = @HAVE_LIBZ@
>  INCINTL = @INCINTL@
>  INSTALL = @INSTALL@
>  INSTALL_DATA = @INSTALL_DATA@
> @@ -168,9 +172,11 @@ LIBM = @LIBM@
>  LIBOBJS = @LIBOBJS@
>  LIBS = @LIBS@
>  LIBTOOL = @LIBTOOL@
> +LIBZ = @LIBZ@
>  LIPO = @LIPO@
>  LN_S = @LN_S@
>  LTLIBOBJS = @LTLIBOBJS@
> +LTLIBZ = @LTLIBZ@
>  MAINT = @MAINT@
>  MAKEINFO = @MAKEINFO@
>  MKDIR_P = @MKDIR_P@
> diff --git a/gdb/config.in b/gdb/config.in
> index 9d3f32d..9b04c29 100644
> --- a/gdb/config.in
> +++ b/gdb/config.in
> @@ -213,6 +213,9 @@
>  /* Define to 1 if you have the `w' library (-lw). */
>  #undef HAVE_LIBW
>  
> +/* Define if you have the z library. */
> +#undef HAVE_LIBZ
> +
>  /* Define to 1 if you have the <linux/perf_event.h> header file. */
>  #undef HAVE_LINUX_PERF_EVENT_H
>  
> diff --git a/gdb/configure b/gdb/configure
> index 7ff74ba..0ae5c79 100755
> --- a/gdb/configure
> +++ b/gdb/configure
> @@ -680,6 +680,9 @@ READLINE_TEXI_INCFLAG
>  READLINE_CFLAGS
>  READLINE_DEPS
>  READLINE
> +LTLIBZ
> +LIBZ
> +HAVE_LIBZ
>  MIG
>  WINDRES
>  DLLTOOL
> @@ -813,13 +816,14 @@ enable_profiling
>  with_pkgversion
>  with_bugurl
>  with_zlib
> +with_gnu_ld
> +enable_rpath
> +with_libz_prefix
>  with_libiconv_prefix
>  with_iconv_bin
>  with_system_readline
>  with_jit_reader_dir
>  with_expat
> -with_gnu_ld
> -enable_rpath
>  with_libexpat_prefix
>  with_python
>  with_guile
> @@ -1528,6 +1532,9 @@ Optional Packages:
>    --with-pkgversion=PKG   Use PKG in the version string in place of "GDB"
>    --with-bugurl=URL       Direct users to URL to report a bug
>    --with-zlib             include zlib support (auto/yes/no) default=auto
> +  --with-gnu-ld           assume the C compiler uses GNU ld default=no
> +  --with-libz-prefix[=DIR]  search for libz in DIR/include and DIR/lib
> +  --without-libz-prefix     don't search for libz in includedir and libdir
>    --with-libiconv-prefix=DIR
>                            search for libiconv in DIR/include and DIR/lib
>    --with-iconv-bin=PATH   specify where to find the iconv program
> @@ -1535,7 +1542,6 @@ Optional Packages:
>    --with-jit-reader-dir=PATH
>                            directory to load the JIT readers from
>    --with-expat            include expat support (auto/yes/no)
> -  --with-gnu-ld           assume the C compiler uses GNU ld default=no
>    --with-libexpat-prefix[=DIR]  search for libexpat in DIR/include and DIR/lib
>    --without-libexpat-prefix     don't search for libexpat in includedir and libdir
>    --with-python[=PYTHON]  include python support
> @@ -6682,163 +6688,733 @@ fi
>  
>  # Link in zlib if we can.  This allows us to read compressed debug sections.
>  
> -  # See if the user specified whether he wants zlib support or not.
> -
> -# Check whether --with-zlib was given.
> -if test "${with_zlib+set}" = set; then :
> -  withval=$with_zlib;
> -else
> -  with_zlib=auto
> -fi
> +      if test "X$prefix" = "XNONE"; then
> +    acl_final_prefix="$ac_default_prefix"
> +  else
> +    acl_final_prefix="$prefix"
> +  fi
> +  if test "X$exec_prefix" = "XNONE"; then
> +    acl_final_exec_prefix='${prefix}'
> +  else
> +    acl_final_exec_prefix="$exec_prefix"
> +  fi
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
> +  prefix="$acl_save_prefix"
>  
>  
> -  if test "$with_zlib" != "no"; then
> -    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing zlibVersion" >&5
> -$as_echo_n "checking for library containing zlibVersion... " >&6; }
> -if test "${ac_cv_search_zlibVersion+set}" = set; then :
> -  $as_echo_n "(cached) " >&6
> +# Check whether --with-gnu-ld was given.
> +if test "${with_gnu_ld+set}" = set; then :
> +  withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
>  else
> -  ac_func_search_save_LIBS=$LIBS
> -cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> -/* end confdefs.h.  */
> +  with_gnu_ld=no
> +fi
>  
> -/* Override any GCC internal prototype to avoid an error.
> -   Use char because int might match the return type of a GCC
> -   builtin and then its argument prototype would still apply.  */
> -#ifdef __cplusplus
> -extern "C"
> -#endif
> -char zlibVersion ();
> -int
> -main ()
> -{
> -return zlibVersion ();
> -  ;
> -  return 0;
> -}
> -_ACEOF
> -for ac_lib in '' z; do
> -  if test -z "$ac_lib"; then
> -    ac_res="none required"
> +# Prepare PATH_SEPARATOR.
> +# The user is always right.
> +if test "${PATH_SEPARATOR+set}" != set; then
> +  echo "#! /bin/sh" >conf$$.sh
> +  echo  "exit 0"   >>conf$$.sh
> +  chmod +x conf$$.sh
> +  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
> +    PATH_SEPARATOR=';'
>    else
> -    ac_res=-l$ac_lib
> -    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
> +    PATH_SEPARATOR=:
>    fi
> -  if ac_fn_c_try_link "$LINENO"; then :
> -  ac_cv_search_zlibVersion=$ac_res
> +  rm -f conf$$.sh
>  fi
> -rm -f core conftest.err conftest.$ac_objext \
> -    conftest$ac_exeext
> -  if test "${ac_cv_search_zlibVersion+set}" = set; then :
> -  break
> +ac_prog=ld
> +if test "$GCC" = yes; then
> +  # Check if gcc -print-prog-name=ld gives a path.
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by GCC" >&5
> +$as_echo_n "checking for ld used by GCC... " >&6; }
> +  case $host in
> +  *-*-mingw*)
> +    # gcc leaves a trailing carriage return which upsets mingw
> +    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
> +  *)
> +    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
> +  esac
> +  case $ac_prog in
> +    # Accept absolute paths.
> +    [\\/]* | [A-Za-z]:[\\/]*)
> +      re_direlt='/[^/][^/]*/\.\./'
> +      # Canonicalize the path of ld
> +      ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
> +      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
> +	ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
> +      done
> +      test -z "$LD" && LD="$ac_prog"
> +      ;;
> +  "")
> +    # If it fails, then pretend we aren't using GCC.
> +    ac_prog=ld
> +    ;;
> +  *)
> +    # If it is relative, then search for the first ld in PATH.
> +    with_gnu_ld=unknown
> +    ;;
> +  esac
> +elif test "$with_gnu_ld" = yes; then
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
> +$as_echo_n "checking for GNU ld... " >&6; }
> +else
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
> +$as_echo_n "checking for non-GNU ld... " >&6; }
>  fi
> -done
> -if test "${ac_cv_search_zlibVersion+set}" = set; then :
> -
> +if test "${acl_cv_path_LD+set}" = set; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +  if test -z "$LD"; then
> +  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
> +  for ac_dir in $PATH; do
> +    test -z "$ac_dir" && ac_dir=.
> +    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
> +      acl_cv_path_LD="$ac_dir/$ac_prog"
> +      # Check to see if the program is GNU ld.  I'd rather use --version,
> +      # but apparently some GNU ld's only accept -v.
> +      # Break only if it was the GNU/non-GNU ld that we prefer.
> +      if "$acl_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
> +	test "$with_gnu_ld" != no && break
> +      else
> +	test "$with_gnu_ld" != yes && break
> +      fi
> +    fi
> +  done
> +  IFS="$ac_save_ifs"
>  else
> -  ac_cv_search_zlibVersion=no
> +  acl_cv_path_LD="$LD" # Let the user override the test with a path.
>  fi
> -rm conftest.$ac_ext
> -LIBS=$ac_func_search_save_LIBS
>  fi
> -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_zlibVersion" >&5
> -$as_echo "$ac_cv_search_zlibVersion" >&6; }
> -ac_res=$ac_cv_search_zlibVersion
> -if test "$ac_res" != no; then :
> -  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
> -  for ac_header in zlib.h
> -do :
> -  ac_fn_c_check_header_mongrel "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default"
> -if test "x$ac_cv_header_zlib_h" = x""yes; then :
> -  cat >>confdefs.h <<_ACEOF
> -#define HAVE_ZLIB_H 1
> -_ACEOF
>  
> +LD="$acl_cv_path_LD"
> +if test -n "$LD"; then
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
> +$as_echo "$LD" >&6; }
> +else
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
> +$as_echo "no" >&6; }
> +fi
> +test -z "$LD" && as_fn_error "no acceptable ld found in \$PATH" "$LINENO" 5
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
> +$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; }
> +if test "${acl_cv_prog_gnu_ld+set}" = set; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +  # I'd rather use --version here, but apparently some GNU ld's only accept -v.
> +if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
> +  acl_cv_prog_gnu_ld=yes
> +else
> +  acl_cv_prog_gnu_ld=no
>  fi
> -
> -done
> -
>  fi
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_prog_gnu_ld" >&5
> +$as_echo "$acl_cv_prog_gnu_ld" >&6; }
> +with_gnu_ld=$acl_cv_prog_gnu_ld
>  
> -    if test "$with_zlib" = "yes" -a "$ac_cv_header_zlib_h" != "yes"; then
> -      as_fn_error "zlib (libz) library was explicitly requested but not found" "$LINENO" 5
> -    fi
> -  fi
>  
>  
> -# On HP/UX we may need libxpdl for dlgetmodinfo (used by solib-pa64.c).
> -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing dlgetmodinfo" >&5
> -$as_echo_n "checking for library containing dlgetmodinfo... " >&6; }
> -if test "${ac_cv_search_dlgetmodinfo+set}" = set; then :
> +                                                { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5
> +$as_echo_n "checking for shared library run path origin... " >&6; }
> +if test "${acl_cv_rpath+set}" = set; then :
>    $as_echo_n "(cached) " >&6
>  else
> -  ac_func_search_save_LIBS=$LIBS
> -cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> -/* end confdefs.h.  */
>  
> -/* Override any GCC internal prototype to avoid an error.
> -   Use char because int might match the return type of a GCC
> -   builtin and then its argument prototype would still apply.  */
> -#ifdef __cplusplus
> -extern "C"
> -#endif
> -char dlgetmodinfo ();
> -int
> -main ()
> -{
> -return dlgetmodinfo ();
> -  ;
> -  return 0;
> -}
> -_ACEOF
> -for ac_lib in '' dl xpdl; do
> -  if test -z "$ac_lib"; then
> -    ac_res="none required"
> -  else
> -    ac_res=-l$ac_lib
> -    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
> -  fi
> -  if ac_fn_c_try_link "$LINENO"; then :
> -  ac_cv_search_dlgetmodinfo=$ac_res
> +    CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
> +    ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
> +    . ./conftest.sh
> +    rm -f ./conftest.sh
> +    acl_cv_rpath=done
> +
>  fi
> -rm -f core conftest.err conftest.$ac_objext \
> -    conftest$ac_exeext
> -  if test "${ac_cv_search_dlgetmodinfo+set}" = set; then :
> -  break
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_rpath" >&5
> +$as_echo "$acl_cv_rpath" >&6; }
> +  wl="$acl_cv_wl"
> +  libext="$acl_cv_libext"
> +  shlibext="$acl_cv_shlibext"
> +  hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
> +  hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
> +  hardcode_direct="$acl_cv_hardcode_direct"
> +  hardcode_minus_L="$acl_cv_hardcode_minus_L"
> +    # Check whether --enable-rpath was given.
> +if test "${enable_rpath+set}" = set; then :
> +  enableval=$enable_rpath; :
> +else
> +  enable_rpath=yes
>  fi
> -done
> -if test "${ac_cv_search_dlgetmodinfo+set}" = set; then :
>  
> +
> +
> +  # See if the user specified whether he wants zlib support or not.
> +
> +# Check whether --with-zlib was given.
> +if test "${with_zlib+set}" = set; then :
> +  withval=$with_zlib;
>  else
> -  ac_cv_search_dlgetmodinfo=no
> -fi
> -rm conftest.$ac_ext
> -LIBS=$ac_func_search_save_LIBS
> +  with_zlib=auto
>  fi
> -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_dlgetmodinfo" >&5
> -$as_echo "$ac_cv_search_dlgetmodinfo" >&6; }
> -ac_res=$ac_cv_search_dlgetmodinfo
> -if test "$ac_res" != no; then :
> -  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
>  
> -fi
>  
> +  if test "$with_zlib" != "no"; then
>  
>  
>  
>  
> -# Check whether --with-libiconv-prefix was given.
> -if test "${with_libiconv_prefix+set}" = set; then :
> -  withval=$with_libiconv_prefix;
> -    for dir in `echo "$withval" | tr : ' '`; do
> -      if test -d $dir/include; then LIBICONV_INCLUDE="-I$dir/include"; fi
> -      if test -d $dir/lib; then LIBICONV_LIBDIR="-L$dir/lib"; fi
> -    done
>  
> -fi
>  
>  
> -  BUILD_LIBICONV_LIBDIRS="../libiconv/lib/.libs ../libiconv/lib/_libs"
> +
> +    use_additional=yes
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +
> +    eval additional_includedir=\"$includedir\"
> +    eval additional_libdir=\"$libdir\"
> +
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +
> +# Check whether --with-libz-prefix was given.
> +if test "${with_libz_prefix+set}" = set; then :
> +  withval=$with_libz_prefix;
> +    if test "X$withval" = "Xno"; then
> +      use_additional=no
> +    else
> +      if test "X$withval" = "X"; then
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +
> +          eval additional_includedir=\"$includedir\"
> +          eval additional_libdir=\"$libdir\"
> +
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +      else
> +        additional_includedir="$withval/include"
> +        additional_libdir="$withval/lib"
> +      fi
> +    fi
> +
> +fi
> +
> +      LIBZ=
> +  LTLIBZ=
> +  INCZ=
> +  rpathdirs=
> +  ltrpathdirs=
> +  names_already_handled=
> +  names_next_round='z '
> +  while test -n "$names_next_round"; do
> +    names_this_round="$names_next_round"
> +    names_next_round=
> +    for name in $names_this_round; do
> +      already_handled=
> +      for n in $names_already_handled; do
> +        if test "$n" = "$name"; then
> +          already_handled=yes
> +          break
> +        fi
> +      done
> +      if test -z "$already_handled"; then
> +        names_already_handled="$names_already_handled $name"
> +                        uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
> +        eval value=\"\$HAVE_LIB$uppername\"
> +        if test -n "$value"; then
> +          if test "$value" = yes; then
> +            eval value=\"\$LIB$uppername\"
> +            test -z "$value" || LIBZ="${LIBZ}${LIBZ:+ }$value"
> +            eval value=\"\$LTLIB$uppername\"
> +            test -z "$value" || LTLIBZ="${LTLIBZ}${LTLIBZ:+ }$value"
> +          else
> +                                    :
> +          fi
> +        else
> +                              found_dir=
> +          found_la=
> +          found_so=
> +          found_a=
> +          if test $use_additional = yes; then
> +            if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then
> +              found_dir="$additional_libdir"
> +              found_so="$additional_libdir/lib$name.$shlibext"
> +              if test -f "$additional_libdir/lib$name.la"; then
> +                found_la="$additional_libdir/lib$name.la"
> +              fi
> +            else
> +              if test -f "$additional_libdir/lib$name.$libext"; then
> +                found_dir="$additional_libdir"
> +                found_a="$additional_libdir/lib$name.$libext"
> +                if test -f "$additional_libdir/lib$name.la"; then
> +                  found_la="$additional_libdir/lib$name.la"
> +                fi
> +              fi
> +            fi
> +          fi
> +          if test "X$found_dir" = "X"; then
> +            for x in $LDFLAGS $LTLIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +              case "$x" in
> +                -L*)
> +                  dir=`echo "X$x" | sed -e 's/^X-L//'`
> +                  if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then
> +                    found_dir="$dir"
> +                    found_so="$dir/lib$name.$shlibext"
> +                    if test -f "$dir/lib$name.la"; then
> +                      found_la="$dir/lib$name.la"
> +                    fi
> +                  else
> +                    if test -f "$dir/lib$name.$libext"; then
> +                      found_dir="$dir"
> +                      found_a="$dir/lib$name.$libext"
> +                      if test -f "$dir/lib$name.la"; then
> +                        found_la="$dir/lib$name.la"
> +                      fi
> +                    fi
> +                  fi
> +                  ;;
> +              esac
> +              if test "X$found_dir" != "X"; then
> +                break
> +              fi
> +            done
> +          fi
> +          if test "X$found_dir" != "X"; then
> +                        LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-L$found_dir -l$name"
> +            if test "X$found_so" != "X"; then
> +                                                        if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then
> +                                LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +              else
> +                                                                                haveit=
> +                for x in $ltrpathdirs; do
> +                  if test "X$x" = "X$found_dir"; then
> +                    haveit=yes
> +                    break
> +                  fi
> +                done
> +                if test -z "$haveit"; then
> +                  ltrpathdirs="$ltrpathdirs $found_dir"
> +                fi
> +                                if test "$hardcode_direct" = yes; then
> +                                                      LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +                else
> +                  if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then
> +                                                            LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +                                                            haveit=
> +                    for x in $rpathdirs; do
> +                      if test "X$x" = "X$found_dir"; then
> +                        haveit=yes
> +                        break
> +                      fi
> +                    done
> +                    if test -z "$haveit"; then
> +                      rpathdirs="$rpathdirs $found_dir"
> +                    fi
> +                  else
> +                                                                                haveit=
> +                    for x in $LDFLAGS $LIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                      if test "X$x" = "X-L$found_dir"; then
> +                        haveit=yes
> +                        break
> +                      fi
> +                    done
> +                    if test -z "$haveit"; then
> +                      LIBZ="${LIBZ}${LIBZ:+ }-L$found_dir"
> +                    fi
> +                    if test "$hardcode_minus_L" != no; then
> +                                                                                        LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +                    else
> +                                                                                                                                                                                LIBZ="${LIBZ}${LIBZ:+ }-l$name"
> +                    fi
> +                  fi
> +                fi
> +              fi
> +            else
> +              if test "X$found_a" != "X"; then
> +                                LIBZ="${LIBZ}${LIBZ:+ }$found_a"
> +              else
> +                                                LIBZ="${LIBZ}${LIBZ:+ }-L$found_dir -l$name"
> +              fi
> +            fi
> +                        additional_includedir=
> +            case "$found_dir" in
> +              */lib | */lib/)
> +                basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'`
> +                additional_includedir="$basedir/include"
> +                ;;
> +            esac
> +            if test "X$additional_includedir" != "X"; then
> +                                                                                                                if test "X$additional_includedir" != "X/usr/include"; then
> +                haveit=
> +                if test "X$additional_includedir" = "X/usr/local/include"; then
> +                  if test -n "$GCC"; then
> +                    case $host_os in
> +                      linux*) haveit=yes;;
> +                    esac
> +                  fi
> +                fi
> +                if test -z "$haveit"; then
> +                  for x in $CPPFLAGS $INCZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                    if test "X$x" = "X-I$additional_includedir"; then
> +                      haveit=yes
> +                      break
> +                    fi
> +                  done
> +                  if test -z "$haveit"; then
> +                    if test -d "$additional_includedir"; then
> +                                            INCZ="${INCZ}${INCZ:+ }-I$additional_includedir"
> +                    fi
> +                  fi
> +                fi
> +              fi
> +            fi
> +                        if test -n "$found_la"; then
> +                                                        save_libdir="$libdir"
> +              case "$found_la" in
> +                */* | *\\*) . "$found_la" ;;
> +                *) . "./$found_la" ;;
> +              esac
> +              libdir="$save_libdir"
> +                            for dep in $dependency_libs; do
> +                case "$dep" in
> +                  -L*)
> +                    additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
> +                                                                                                                                                                if test "X$additional_libdir" != "X/usr/lib"; then
> +                      haveit=
> +                      if test "X$additional_libdir" = "X/usr/local/lib"; then
> +                        if test -n "$GCC"; then
> +                          case $host_os in
> +                            linux*) haveit=yes;;
> +                          esac
> +                        fi
> +                      fi
> +                      if test -z "$haveit"; then
> +                        haveit=
> +                        for x in $LDFLAGS $LIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                          if test "X$x" = "X-L$additional_libdir"; then
> +                            haveit=yes
> +                            break
> +                          fi
> +                        done
> +                        if test -z "$haveit"; then
> +                          if test -d "$additional_libdir"; then
> +                                                        LIBZ="${LIBZ}${LIBZ:+ }-L$additional_libdir"
> +                          fi
> +                        fi
> +                        haveit=
> +                        for x in $LDFLAGS $LTLIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                          if test "X$x" = "X-L$additional_libdir"; then
> +                            haveit=yes
> +                            break
> +                          fi
> +                        done
> +                        if test -z "$haveit"; then
> +                          if test -d "$additional_libdir"; then
> +                                                        LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-L$additional_libdir"
> +                          fi
> +                        fi
> +                      fi
> +                    fi
> +                    ;;
> +                  -R*)
> +                    dir=`echo "X$dep" | sed -e 's/^X-R//'`
> +                    if test "$enable_rpath" != no; then
> +                                                                  haveit=
> +                      for x in $rpathdirs; do
> +                        if test "X$x" = "X$dir"; then
> +                          haveit=yes
> +                          break
> +                        fi
> +                      done
> +                      if test -z "$haveit"; then
> +                        rpathdirs="$rpathdirs $dir"
> +                      fi
> +                                                                  haveit=
> +                      for x in $ltrpathdirs; do
> +                        if test "X$x" = "X$dir"; then
> +                          haveit=yes
> +                          break
> +                        fi
> +                      done
> +                      if test -z "$haveit"; then
> +                        ltrpathdirs="$ltrpathdirs $dir"
> +                      fi
> +                    fi
> +                    ;;
> +                  -l*)
> +                                        names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
> +                    ;;
> +                  *.la)
> +                                                                                names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
> +                    ;;
> +                  *)
> +                                        LIBZ="${LIBZ}${LIBZ:+ }$dep"
> +                    LTLIBZ="${LTLIBZ}${LTLIBZ:+ }$dep"
> +                    ;;
> +                esac
> +              done
> +            fi
> +          else
> +                                                            LIBZ="${LIBZ}${LIBZ:+ }-l$name"
> +            LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-l$name"
> +          fi
> +        fi
> +      fi
> +    done
> +  done
> +  if test "X$rpathdirs" != "X"; then
> +    if test -n "$hardcode_libdir_separator"; then
> +                        alldirs=
> +      for found_dir in $rpathdirs; do
> +        alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir"
> +      done
> +            acl_save_libdir="$libdir"
> +      libdir="$alldirs"
> +      eval flag=\"$hardcode_libdir_flag_spec\"
> +      libdir="$acl_save_libdir"
> +      LIBZ="${LIBZ}${LIBZ:+ }$flag"
> +    else
> +            for found_dir in $rpathdirs; do
> +        acl_save_libdir="$libdir"
> +        libdir="$found_dir"
> +        eval flag=\"$hardcode_libdir_flag_spec\"
> +        libdir="$acl_save_libdir"
> +        LIBZ="${LIBZ}${LIBZ:+ }$flag"
> +      done
> +    fi
> +  fi
> +  if test "X$ltrpathdirs" != "X"; then
> +            for found_dir in $ltrpathdirs; do
> +      LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-R$found_dir"
> +    done
> +  fi
> +
> +
> +        ac_save_CPPFLAGS="$CPPFLAGS"
> +
> +  for element in $INCZ; do
> +    haveit=
> +    for x in $CPPFLAGS; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +      if test "X$x" = "X$element"; then
> +        haveit=yes
> +        break
> +      fi
> +    done
> +    if test -z "$haveit"; then
> +      CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element"
> +    fi
> +  done
> +
> +
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libz" >&5
> +$as_echo_n "checking for libz... " >&6; }
> +if test "${ac_cv_libz+set}" = set; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +
> +    ac_save_LIBS="$LIBS"
> +    LIBS="$LIBS $LIBZ"
> +    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> +/* end confdefs.h.  */
> +#include "zlib.h";
> +int
> +main ()
> +{
> +int ret = deflateInit(NULL, 1);
> +  ;
> +  return 0;
> +}
> +_ACEOF
> +if ac_fn_c_try_link "$LINENO"; then :
> +  ac_cv_libz=yes
> +else
> +  ac_cv_libz=no
> +fi
> +rm -f core conftest.err conftest.$ac_objext \
> +    conftest$ac_exeext conftest.$ac_ext
> +    LIBS="$ac_save_LIBS"
> +
> +fi
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_libz" >&5
> +$as_echo "$ac_cv_libz" >&6; }
> +  if test "$ac_cv_libz" = yes; then
> +    HAVE_LIBZ=yes
> +
> +$as_echo "#define HAVE_LIBZ 1" >>confdefs.h
> +
> +    { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libz" >&5
> +$as_echo_n "checking how to link with libz... " >&6; }
> +    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBZ" >&5
> +$as_echo "$LIBZ" >&6; }
> +  else
> +    HAVE_LIBZ=no
> +            CPPFLAGS="$ac_save_CPPFLAGS"
> +    LIBZ=
> +    LTLIBZ=
> +  fi
> +
> +
> +
> +
> +
> +
> +    if test "$HAVE_LIBZ" = "yes"; then
> +      # Make sure HAVE_ZLIB_H gets defined.  Some code uses that over
> +      # HAVE_LIBZ, since initially we were only defining HAVE_ZLIB_H.
> +      for ac_header in zlib.h
> +do :
> +  ac_fn_c_check_header_mongrel "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default"
> +if test "x$ac_cv_header_zlib_h" = x""yes; then :
> +  cat >>confdefs.h <<_ACEOF
> +#define HAVE_ZLIB_H 1
> +_ACEOF
> +
> +fi
> +
> +done
> +
> +      LIBS="$LIBS $LIBZ"
> +    fi
> +    if test "$with_zlib" = "yes" -a "$HAVE_LIBZ" != "yes"; then
> +      as_fn_error "zlib (libz) library was explicitly requested but not found" "$LINENO" 5
> +    fi
> +  fi
> +
> +
> +# On HP/UX we may need libxpdl for dlgetmodinfo (used by solib-pa64.c).
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing dlgetmodinfo" >&5
> +$as_echo_n "checking for library containing dlgetmodinfo... " >&6; }
> +if test "${ac_cv_search_dlgetmodinfo+set}" = set; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +  ac_func_search_save_LIBS=$LIBS
> +cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> +/* end confdefs.h.  */
> +
> +/* Override any GCC internal prototype to avoid an error.
> +   Use char because int might match the return type of a GCC
> +   builtin and then its argument prototype would still apply.  */
> +#ifdef __cplusplus
> +extern "C"
> +#endif
> +char dlgetmodinfo ();
> +int
> +main ()
> +{
> +return dlgetmodinfo ();
> +  ;
> +  return 0;
> +}
> +_ACEOF
> +for ac_lib in '' dl xpdl; do
> +  if test -z "$ac_lib"; then
> +    ac_res="none required"
> +  else
> +    ac_res=-l$ac_lib
> +    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
> +  fi
> +  if ac_fn_c_try_link "$LINENO"; then :
> +  ac_cv_search_dlgetmodinfo=$ac_res
> +fi
> +rm -f core conftest.err conftest.$ac_objext \
> +    conftest$ac_exeext
> +  if test "${ac_cv_search_dlgetmodinfo+set}" = set; then :
> +  break
> +fi
> +done
> +if test "${ac_cv_search_dlgetmodinfo+set}" = set; then :
> +
> +else
> +  ac_cv_search_dlgetmodinfo=no
> +fi
> +rm conftest.$ac_ext
> +LIBS=$ac_func_search_save_LIBS
> +fi
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_dlgetmodinfo" >&5
> +$as_echo "$ac_cv_search_dlgetmodinfo" >&6; }
> +ac_res=$ac_cv_search_dlgetmodinfo
> +if test "$ac_res" != no; then :
> +  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
> +
> +fi
> +
> +
> +
> +
> +
> +# Check whether --with-libiconv-prefix was given.
> +if test "${with_libiconv_prefix+set}" = set; then :
> +  withval=$with_libiconv_prefix;
> +    for dir in `echo "$withval" | tr : ' '`; do
> +      if test -d $dir/include; then LIBICONV_INCLUDE="-I$dir/include"; fi
> +      if test -d $dir/lib; then LIBICONV_LIBDIR="-L$dir/lib"; fi
> +    done
> +
> +fi
> +
> +
> +  BUILD_LIBICONV_LIBDIRS="../libiconv/lib/.libs ../libiconv/lib/_libs"
>    BUILD_LIBICONV_INCLUDE="-I../libiconv/include"
>  
>    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for iconv" >&5
> @@ -7519,164 +8095,6 @@ $as_echo "$as_me: WARNING: expat support disabled; some features may be unavaila
>    HAVE_LIBEXPAT=no
>  else
>  
> -      if test "X$prefix" = "XNONE"; then
> -    acl_final_prefix="$ac_default_prefix"
> -  else
> -    acl_final_prefix="$prefix"
> -  fi
> -  if test "X$exec_prefix" = "XNONE"; then
> -    acl_final_exec_prefix='${prefix}'
> -  else
> -    acl_final_exec_prefix="$exec_prefix"
> -  fi
> -  acl_save_prefix="$prefix"
> -  prefix="$acl_final_prefix"
> -  eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
> -  prefix="$acl_save_prefix"
> -
> -
> -# Check whether --with-gnu-ld was given.
> -if test "${with_gnu_ld+set}" = set; then :
> -  withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
> -else
> -  with_gnu_ld=no
> -fi
> -
> -# Prepare PATH_SEPARATOR.
> -# The user is always right.
> -if test "${PATH_SEPARATOR+set}" != set; then
> -  echo "#! /bin/sh" >conf$$.sh
> -  echo  "exit 0"   >>conf$$.sh
> -  chmod +x conf$$.sh
> -  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
> -    PATH_SEPARATOR=';'
> -  else
> -    PATH_SEPARATOR=:
> -  fi
> -  rm -f conf$$.sh
> -fi
> -ac_prog=ld
> -if test "$GCC" = yes; then
> -  # Check if gcc -print-prog-name=ld gives a path.
> -  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by GCC" >&5
> -$as_echo_n "checking for ld used by GCC... " >&6; }
> -  case $host in
> -  *-*-mingw*)
> -    # gcc leaves a trailing carriage return which upsets mingw
> -    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
> -  *)
> -    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
> -  esac
> -  case $ac_prog in
> -    # Accept absolute paths.
> -    [\\/]* | [A-Za-z]:[\\/]*)
> -      re_direlt='/[^/][^/]*/\.\./'
> -      # Canonicalize the path of ld
> -      ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
> -      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
> -	ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
> -      done
> -      test -z "$LD" && LD="$ac_prog"
> -      ;;
> -  "")
> -    # If it fails, then pretend we aren't using GCC.
> -    ac_prog=ld
> -    ;;
> -  *)
> -    # If it is relative, then search for the first ld in PATH.
> -    with_gnu_ld=unknown
> -    ;;
> -  esac
> -elif test "$with_gnu_ld" = yes; then
> -  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
> -$as_echo_n "checking for GNU ld... " >&6; }
> -else
> -  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
> -$as_echo_n "checking for non-GNU ld... " >&6; }
> -fi
> -if test "${acl_cv_path_LD+set}" = set; then :
> -  $as_echo_n "(cached) " >&6
> -else
> -  if test -z "$LD"; then
> -  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
> -  for ac_dir in $PATH; do
> -    test -z "$ac_dir" && ac_dir=.
> -    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
> -      acl_cv_path_LD="$ac_dir/$ac_prog"
> -      # Check to see if the program is GNU ld.  I'd rather use --version,
> -      # but apparently some GNU ld's only accept -v.
> -      # Break only if it was the GNU/non-GNU ld that we prefer.
> -      if "$acl_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
> -	test "$with_gnu_ld" != no && break
> -      else
> -	test "$with_gnu_ld" != yes && break
> -      fi
> -    fi
> -  done
> -  IFS="$ac_save_ifs"
> -else
> -  acl_cv_path_LD="$LD" # Let the user override the test with a path.
> -fi
> -fi
> -
> -LD="$acl_cv_path_LD"
> -if test -n "$LD"; then
> -  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
> -$as_echo "$LD" >&6; }
> -else
> -  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
> -$as_echo "no" >&6; }
> -fi
> -test -z "$LD" && as_fn_error "no acceptable ld found in \$PATH" "$LINENO" 5
> -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
> -$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; }
> -if test "${acl_cv_prog_gnu_ld+set}" = set; then :
> -  $as_echo_n "(cached) " >&6
> -else
> -  # I'd rather use --version here, but apparently some GNU ld's only accept -v.
> -if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
> -  acl_cv_prog_gnu_ld=yes
> -else
> -  acl_cv_prog_gnu_ld=no
> -fi
> -fi
> -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_prog_gnu_ld" >&5
> -$as_echo "$acl_cv_prog_gnu_ld" >&6; }
> -with_gnu_ld=$acl_cv_prog_gnu_ld
> -
> -
> -
> -                                                { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5
> -$as_echo_n "checking for shared library run path origin... " >&6; }
> -if test "${acl_cv_rpath+set}" = set; then :
> -  $as_echo_n "(cached) " >&6
> -else
> -
> -    CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
> -    ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
> -    . ./conftest.sh
> -    rm -f ./conftest.sh
> -    acl_cv_rpath=done
> -
> -fi
> -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_rpath" >&5
> -$as_echo "$acl_cv_rpath" >&6; }
> -  wl="$acl_cv_wl"
> -  libext="$acl_cv_libext"
> -  shlibext="$acl_cv_shlibext"
> -  hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
> -  hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
> -  hardcode_direct="$acl_cv_hardcode_direct"
> -  hardcode_minus_L="$acl_cv_hardcode_minus_L"
> -    # Check whether --enable-rpath was given.
> -if test "${enable_rpath+set}" = set; then :
> -  enableval=$enable_rpath; :
> -else
> -  enable_rpath=yes
> -fi
> -
> -
> -
>  
>  
>  
> diff --git a/gold/Makefile.in b/gold/Makefile.in
> index cd4d165..01a7fee 100644
> --- a/gold/Makefile.in
> +++ b/gold/Makefile.in
> @@ -78,6 +78,9 @@ am__aclocal_m4_deps = $(top_srcdir)/../config/depstand.m4 \
>  	$(top_srcdir)/../config/gettext-sister.m4 \
>  	$(top_srcdir)/../config/lcmessage.m4 \
>  	$(top_srcdir)/../config/lead-dot.m4 \
> +	$(top_srcdir)/../config/lib-ld.m4 \
> +	$(top_srcdir)/../config/lib-link.m4 \
> +	$(top_srcdir)/../config/lib-prefix.m4 \
>  	$(top_srcdir)/../config/nls.m4 \
>  	$(top_srcdir)/../config/override.m4 \
>  	$(top_srcdir)/../config/po.m4 \
> @@ -301,6 +304,7 @@ GMSGFMT = @GMSGFMT@
>  GOLD_LDADD = @GOLD_LDADD@
>  GOLD_LDFLAGS = @GOLD_LDFLAGS@
>  GREP = @GREP@
> +HAVE_LIBZ = @HAVE_LIBZ@
>  INCINTL = @INCINTL@
>  INSTALL = @INSTALL@
>  INSTALL_DATA = @INSTALL_DATA@
> @@ -314,8 +318,10 @@ LIBINTL = @LIBINTL@
>  LIBINTL_DEP = @LIBINTL_DEP@
>  LIBOBJS = @LIBOBJS@
>  LIBS = @LIBS@
> +LIBZ = @LIBZ@
>  LN_S = @LN_S@
>  LTLIBOBJS = @LTLIBOBJS@
> +LTLIBZ = @LTLIBZ@
>  MAINT = @MAINT@
>  MAKEINFO = @MAKEINFO@
>  MERGE_CONSTANTS_FLAG = @MERGE_CONSTANTS_FLAG@
> diff --git a/gold/aclocal.m4 b/gold/aclocal.m4
> index 8321894..8444d1d 100644
> --- a/gold/aclocal.m4
> +++ b/gold/aclocal.m4
> @@ -984,6 +984,9 @@ m4_include([../config/depstand.m4])
>  m4_include([../config/gettext-sister.m4])
>  m4_include([../config/lcmessage.m4])
>  m4_include([../config/lead-dot.m4])
> +m4_include([../config/lib-ld.m4])
> +m4_include([../config/lib-link.m4])
> +m4_include([../config/lib-prefix.m4])
>  m4_include([../config/nls.m4])
>  m4_include([../config/override.m4])
>  m4_include([../config/po.m4])
> diff --git a/gold/config.in b/gold/config.in
> index be77810..1871eb5 100644
> --- a/gold/config.in
> +++ b/gold/config.in
> @@ -97,6 +97,9 @@
>  /* Define if your <locale.h> file defines LC_MESSAGES. */
>  #undef HAVE_LC_MESSAGES
>  
> +/* Define if you have the z library. */
> +#undef HAVE_LIBZ
> +
>  /* Define to 1 if you have the <locale.h> header file. */
>  #undef HAVE_LOCALE_H
>  
> diff --git a/gold/configure b/gold/configure
> index 23e4735..66554cd 100755
> --- a/gold/configure
> +++ b/gold/configure
> @@ -602,6 +602,9 @@ HAVE_PUBNAMES_FALSE
>  HAVE_PUBNAMES_TRUE
>  HAVE_ZLIB_FALSE
>  HAVE_ZLIB_TRUE
> +LTLIBZ
> +LIBZ
> +HAVE_LIBZ
>  LIBOBJS
>  LFS_CFLAGS
>  GOLD_LDADD
> @@ -797,6 +800,9 @@ enable_build_warnings
>  with_gold_ldflags
>  with_gold_ldadd
>  with_zlib
> +with_gnu_ld
> +enable_rpath
> +with_libz_prefix
>  enable_maintainer_mode
>  '
>        ac_precious_vars='build_alias
> @@ -1443,6 +1449,7 @@ Optional Features:
>    --disable-nls           do not use Native Language Support
>    --enable-werror         treat compile warnings as errors
>    --enable-build-warnings enable build-time compiler warnings
> +  --disable-rpath         do not hardcode runtime library paths
>    --enable-maintainer-mode  enable make rules and dependencies not useful
>  			  (and sometimes confusing) to the casual installer
>  
> @@ -1454,6 +1461,9 @@ Optional Packages:
>    --with-gold-ldflags=FLAGS  additional link flags for gold
>    --with-gold-ldadd=LIBS     additional libraries for gold
>    --with-zlib             include zlib support (auto/yes/no) default=auto
> +  --with-gnu-ld           assume the C compiler uses GNU ld default=no
> +  --with-libz-prefix[=DIR]  search for libz in DIR/include and DIR/lib
> +  --without-libz-prefix     don't search for libz in includedir and libdir
>  
>  Some influential environment variables:
>    CC          C compiler command
> @@ -6874,6 +6884,164 @@ fi
>  
>  # Link in zlib if we can.  This allows us to write compressed sections.
>  
> +      if test "X$prefix" = "XNONE"; then
> +    acl_final_prefix="$ac_default_prefix"
> +  else
> +    acl_final_prefix="$prefix"
> +  fi
> +  if test "X$exec_prefix" = "XNONE"; then
> +    acl_final_exec_prefix='${prefix}'
> +  else
> +    acl_final_exec_prefix="$exec_prefix"
> +  fi
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
> +  prefix="$acl_save_prefix"
> +
> +
> +# Check whether --with-gnu-ld was given.
> +if test "${with_gnu_ld+set}" = set; then :
> +  withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
> +else
> +  with_gnu_ld=no
> +fi
> +
> +# Prepare PATH_SEPARATOR.
> +# The user is always right.
> +if test "${PATH_SEPARATOR+set}" != set; then
> +  echo "#! /bin/sh" >conf$$.sh
> +  echo  "exit 0"   >>conf$$.sh
> +  chmod +x conf$$.sh
> +  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
> +    PATH_SEPARATOR=';'
> +  else
> +    PATH_SEPARATOR=:
> +  fi
> +  rm -f conf$$.sh
> +fi
> +ac_prog=ld
> +if test "$GCC" = yes; then
> +  # Check if gcc -print-prog-name=ld gives a path.
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by GCC" >&5
> +$as_echo_n "checking for ld used by GCC... " >&6; }
> +  case $host in
> +  *-*-mingw*)
> +    # gcc leaves a trailing carriage return which upsets mingw
> +    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
> +  *)
> +    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
> +  esac
> +  case $ac_prog in
> +    # Accept absolute paths.
> +    [\\/]* | [A-Za-z]:[\\/]*)
> +      re_direlt='/[^/][^/]*/\.\./'
> +      # Canonicalize the path of ld
> +      ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
> +      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
> +	ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
> +      done
> +      test -z "$LD" && LD="$ac_prog"
> +      ;;
> +  "")
> +    # If it fails, then pretend we aren't using GCC.
> +    ac_prog=ld
> +    ;;
> +  *)
> +    # If it is relative, then search for the first ld in PATH.
> +    with_gnu_ld=unknown
> +    ;;
> +  esac
> +elif test "$with_gnu_ld" = yes; then
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
> +$as_echo_n "checking for GNU ld... " >&6; }
> +else
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
> +$as_echo_n "checking for non-GNU ld... " >&6; }
> +fi
> +if test "${acl_cv_path_LD+set}" = set; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +  if test -z "$LD"; then
> +  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
> +  for ac_dir in $PATH; do
> +    test -z "$ac_dir" && ac_dir=.
> +    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
> +      acl_cv_path_LD="$ac_dir/$ac_prog"
> +      # Check to see if the program is GNU ld.  I'd rather use --version,
> +      # but apparently some GNU ld's only accept -v.
> +      # Break only if it was the GNU/non-GNU ld that we prefer.
> +      if "$acl_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
> +	test "$with_gnu_ld" != no && break
> +      else
> +	test "$with_gnu_ld" != yes && break
> +      fi
> +    fi
> +  done
> +  IFS="$ac_save_ifs"
> +else
> +  acl_cv_path_LD="$LD" # Let the user override the test with a path.
> +fi
> +fi
> +
> +LD="$acl_cv_path_LD"
> +if test -n "$LD"; then
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
> +$as_echo "$LD" >&6; }
> +else
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
> +$as_echo "no" >&6; }
> +fi
> +test -z "$LD" && as_fn_error "no acceptable ld found in \$PATH" "$LINENO" 5
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
> +$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; }
> +if test "${acl_cv_prog_gnu_ld+set}" = set; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +  # I'd rather use --version here, but apparently some GNU ld's only accept -v.
> +if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
> +  acl_cv_prog_gnu_ld=yes
> +else
> +  acl_cv_prog_gnu_ld=no
> +fi
> +fi
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_prog_gnu_ld" >&5
> +$as_echo "$acl_cv_prog_gnu_ld" >&6; }
> +with_gnu_ld=$acl_cv_prog_gnu_ld
> +
> +
> +
> +                                                { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5
> +$as_echo_n "checking for shared library run path origin... " >&6; }
> +if test "${acl_cv_rpath+set}" = set; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +
> +    CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
> +    ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
> +    . ./conftest.sh
> +    rm -f ./conftest.sh
> +    acl_cv_rpath=done
> +
> +fi
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_rpath" >&5
> +$as_echo "$acl_cv_rpath" >&6; }
> +  wl="$acl_cv_wl"
> +  libext="$acl_cv_libext"
> +  shlibext="$acl_cv_shlibext"
> +  hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
> +  hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
> +  hardcode_direct="$acl_cv_hardcode_direct"
> +  hardcode_minus_L="$acl_cv_hardcode_minus_L"
> +    # Check whether --enable-rpath was given.
> +if test "${enable_rpath+set}" = set; then :
> +  enableval=$enable_rpath; :
> +else
> +  enable_rpath=yes
> +fi
> +
> +
> +
>    # See if the user specified whether he wants zlib support or not.
>  
>  # Check whether --with-zlib was given.
> @@ -6885,60 +7053,472 @@ fi
>  
>  
>    if test "$with_zlib" != "no"; then
> -    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing zlibVersion" >&5
> -$as_echo_n "checking for library containing zlibVersion... " >&6; }
> -if test "${ac_cv_search_zlibVersion+set}" = set; then :
> +
> +
> +
> +
> +
> +
> +
> +
> +    use_additional=yes
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +
> +    eval additional_includedir=\"$includedir\"
> +    eval additional_libdir=\"$libdir\"
> +
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +
> +# Check whether --with-libz-prefix was given.
> +if test "${with_libz_prefix+set}" = set; then :
> +  withval=$with_libz_prefix;
> +    if test "X$withval" = "Xno"; then
> +      use_additional=no
> +    else
> +      if test "X$withval" = "X"; then
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +
> +          eval additional_includedir=\"$includedir\"
> +          eval additional_libdir=\"$libdir\"
> +
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +      else
> +        additional_includedir="$withval/include"
> +        additional_libdir="$withval/lib"
> +      fi
> +    fi
> +
> +fi
> +
> +      LIBZ=
> +  LTLIBZ=
> +  INCZ=
> +  rpathdirs=
> +  ltrpathdirs=
> +  names_already_handled=
> +  names_next_round='z '
> +  while test -n "$names_next_round"; do
> +    names_this_round="$names_next_round"
> +    names_next_round=
> +    for name in $names_this_round; do
> +      already_handled=
> +      for n in $names_already_handled; do
> +        if test "$n" = "$name"; then
> +          already_handled=yes
> +          break
> +        fi
> +      done
> +      if test -z "$already_handled"; then
> +        names_already_handled="$names_already_handled $name"
> +                        uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
> +        eval value=\"\$HAVE_LIB$uppername\"
> +        if test -n "$value"; then
> +          if test "$value" = yes; then
> +            eval value=\"\$LIB$uppername\"
> +            test -z "$value" || LIBZ="${LIBZ}${LIBZ:+ }$value"
> +            eval value=\"\$LTLIB$uppername\"
> +            test -z "$value" || LTLIBZ="${LTLIBZ}${LTLIBZ:+ }$value"
> +          else
> +                                    :
> +          fi
> +        else
> +                              found_dir=
> +          found_la=
> +          found_so=
> +          found_a=
> +          if test $use_additional = yes; then
> +            if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then
> +              found_dir="$additional_libdir"
> +              found_so="$additional_libdir/lib$name.$shlibext"
> +              if test -f "$additional_libdir/lib$name.la"; then
> +                found_la="$additional_libdir/lib$name.la"
> +              fi
> +            else
> +              if test -f "$additional_libdir/lib$name.$libext"; then
> +                found_dir="$additional_libdir"
> +                found_a="$additional_libdir/lib$name.$libext"
> +                if test -f "$additional_libdir/lib$name.la"; then
> +                  found_la="$additional_libdir/lib$name.la"
> +                fi
> +              fi
> +            fi
> +          fi
> +          if test "X$found_dir" = "X"; then
> +            for x in $LDFLAGS $LTLIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +              case "$x" in
> +                -L*)
> +                  dir=`echo "X$x" | sed -e 's/^X-L//'`
> +                  if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then
> +                    found_dir="$dir"
> +                    found_so="$dir/lib$name.$shlibext"
> +                    if test -f "$dir/lib$name.la"; then
> +                      found_la="$dir/lib$name.la"
> +                    fi
> +                  else
> +                    if test -f "$dir/lib$name.$libext"; then
> +                      found_dir="$dir"
> +                      found_a="$dir/lib$name.$libext"
> +                      if test -f "$dir/lib$name.la"; then
> +                        found_la="$dir/lib$name.la"
> +                      fi
> +                    fi
> +                  fi
> +                  ;;
> +              esac
> +              if test "X$found_dir" != "X"; then
> +                break
> +              fi
> +            done
> +          fi
> +          if test "X$found_dir" != "X"; then
> +                        LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-L$found_dir -l$name"
> +            if test "X$found_so" != "X"; then
> +                                                        if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then
> +                                LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +              else
> +                                                                                haveit=
> +                for x in $ltrpathdirs; do
> +                  if test "X$x" = "X$found_dir"; then
> +                    haveit=yes
> +                    break
> +                  fi
> +                done
> +                if test -z "$haveit"; then
> +                  ltrpathdirs="$ltrpathdirs $found_dir"
> +                fi
> +                                if test "$hardcode_direct" = yes; then
> +                                                      LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +                else
> +                  if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then
> +                                                            LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +                                                            haveit=
> +                    for x in $rpathdirs; do
> +                      if test "X$x" = "X$found_dir"; then
> +                        haveit=yes
> +                        break
> +                      fi
> +                    done
> +                    if test -z "$haveit"; then
> +                      rpathdirs="$rpathdirs $found_dir"
> +                    fi
> +                  else
> +                                                                                haveit=
> +                    for x in $LDFLAGS $LIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                      if test "X$x" = "X-L$found_dir"; then
> +                        haveit=yes
> +                        break
> +                      fi
> +                    done
> +                    if test -z "$haveit"; then
> +                      LIBZ="${LIBZ}${LIBZ:+ }-L$found_dir"
> +                    fi
> +                    if test "$hardcode_minus_L" != no; then
> +                                                                                        LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +                    else
> +                                                                                                                                                                                LIBZ="${LIBZ}${LIBZ:+ }-l$name"
> +                    fi
> +                  fi
> +                fi
> +              fi
> +            else
> +              if test "X$found_a" != "X"; then
> +                                LIBZ="${LIBZ}${LIBZ:+ }$found_a"
> +              else
> +                                                LIBZ="${LIBZ}${LIBZ:+ }-L$found_dir -l$name"
> +              fi
> +            fi
> +                        additional_includedir=
> +            case "$found_dir" in
> +              */lib | */lib/)
> +                basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'`
> +                additional_includedir="$basedir/include"
> +                ;;
> +            esac
> +            if test "X$additional_includedir" != "X"; then
> +                                                                                                                if test "X$additional_includedir" != "X/usr/include"; then
> +                haveit=
> +                if test "X$additional_includedir" = "X/usr/local/include"; then
> +                  if test -n "$GCC"; then
> +                    case $host_os in
> +                      linux*) haveit=yes;;
> +                    esac
> +                  fi
> +                fi
> +                if test -z "$haveit"; then
> +                  for x in $CPPFLAGS $INCZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                    if test "X$x" = "X-I$additional_includedir"; then
> +                      haveit=yes
> +                      break
> +                    fi
> +                  done
> +                  if test -z "$haveit"; then
> +                    if test -d "$additional_includedir"; then
> +                                            INCZ="${INCZ}${INCZ:+ }-I$additional_includedir"
> +                    fi
> +                  fi
> +                fi
> +              fi
> +            fi
> +                        if test -n "$found_la"; then
> +                                                        save_libdir="$libdir"
> +              case "$found_la" in
> +                */* | *\\*) . "$found_la" ;;
> +                *) . "./$found_la" ;;
> +              esac
> +              libdir="$save_libdir"
> +                            for dep in $dependency_libs; do
> +                case "$dep" in
> +                  -L*)
> +                    additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
> +                                                                                                                                                                if test "X$additional_libdir" != "X/usr/lib"; then
> +                      haveit=
> +                      if test "X$additional_libdir" = "X/usr/local/lib"; then
> +                        if test -n "$GCC"; then
> +                          case $host_os in
> +                            linux*) haveit=yes;;
> +                          esac
> +                        fi
> +                      fi
> +                      if test -z "$haveit"; then
> +                        haveit=
> +                        for x in $LDFLAGS $LIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                          if test "X$x" = "X-L$additional_libdir"; then
> +                            haveit=yes
> +                            break
> +                          fi
> +                        done
> +                        if test -z "$haveit"; then
> +                          if test -d "$additional_libdir"; then
> +                                                        LIBZ="${LIBZ}${LIBZ:+ }-L$additional_libdir"
> +                          fi
> +                        fi
> +                        haveit=
> +                        for x in $LDFLAGS $LTLIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                          if test "X$x" = "X-L$additional_libdir"; then
> +                            haveit=yes
> +                            break
> +                          fi
> +                        done
> +                        if test -z "$haveit"; then
> +                          if test -d "$additional_libdir"; then
> +                                                        LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-L$additional_libdir"
> +                          fi
> +                        fi
> +                      fi
> +                    fi
> +                    ;;
> +                  -R*)
> +                    dir=`echo "X$dep" | sed -e 's/^X-R//'`
> +                    if test "$enable_rpath" != no; then
> +                                                                  haveit=
> +                      for x in $rpathdirs; do
> +                        if test "X$x" = "X$dir"; then
> +                          haveit=yes
> +                          break
> +                        fi
> +                      done
> +                      if test -z "$haveit"; then
> +                        rpathdirs="$rpathdirs $dir"
> +                      fi
> +                                                                  haveit=
> +                      for x in $ltrpathdirs; do
> +                        if test "X$x" = "X$dir"; then
> +                          haveit=yes
> +                          break
> +                        fi
> +                      done
> +                      if test -z "$haveit"; then
> +                        ltrpathdirs="$ltrpathdirs $dir"
> +                      fi
> +                    fi
> +                    ;;
> +                  -l*)
> +                                        names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
> +                    ;;
> +                  *.la)
> +                                                                                names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
> +                    ;;
> +                  *)
> +                                        LIBZ="${LIBZ}${LIBZ:+ }$dep"
> +                    LTLIBZ="${LTLIBZ}${LTLIBZ:+ }$dep"
> +                    ;;
> +                esac
> +              done
> +            fi
> +          else
> +                                                            LIBZ="${LIBZ}${LIBZ:+ }-l$name"
> +            LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-l$name"
> +          fi
> +        fi
> +      fi
> +    done
> +  done
> +  if test "X$rpathdirs" != "X"; then
> +    if test -n "$hardcode_libdir_separator"; then
> +                        alldirs=
> +      for found_dir in $rpathdirs; do
> +        alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir"
> +      done
> +            acl_save_libdir="$libdir"
> +      libdir="$alldirs"
> +      eval flag=\"$hardcode_libdir_flag_spec\"
> +      libdir="$acl_save_libdir"
> +      LIBZ="${LIBZ}${LIBZ:+ }$flag"
> +    else
> +            for found_dir in $rpathdirs; do
> +        acl_save_libdir="$libdir"
> +        libdir="$found_dir"
> +        eval flag=\"$hardcode_libdir_flag_spec\"
> +        libdir="$acl_save_libdir"
> +        LIBZ="${LIBZ}${LIBZ:+ }$flag"
> +      done
> +    fi
> +  fi
> +  if test "X$ltrpathdirs" != "X"; then
> +            for found_dir in $ltrpathdirs; do
> +      LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-R$found_dir"
> +    done
> +  fi
> +
> +
> +        ac_save_CPPFLAGS="$CPPFLAGS"
> +
> +  for element in $INCZ; do
> +    haveit=
> +    for x in $CPPFLAGS; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +      if test "X$x" = "X$element"; then
> +        haveit=yes
> +        break
> +      fi
> +    done
> +    if test -z "$haveit"; then
> +      CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element"
> +    fi
> +  done
> +
> +
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libz" >&5
> +$as_echo_n "checking for libz... " >&6; }
> +if test "${ac_cv_libz+set}" = set; then :
>    $as_echo_n "(cached) " >&6
>  else
> -  ac_func_search_save_LIBS=$LIBS
> -cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> -/* end confdefs.h.  */
>  
> -/* Override any GCC internal prototype to avoid an error.
> -   Use char because int might match the return type of a GCC
> -   builtin and then its argument prototype would still apply.  */
> -#ifdef __cplusplus
> -extern "C"
> -#endif
> -char zlibVersion ();
> +    ac_save_LIBS="$LIBS"
> +    LIBS="$LIBS $LIBZ"
> +    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> +/* end confdefs.h.  */
> +#include "zlib.h";
>  int
>  main ()
>  {
> -return zlibVersion ();
> +int ret = deflateInit(NULL, 1);
>    ;
>    return 0;
>  }
>  _ACEOF
> -for ac_lib in '' z; do
> -  if test -z "$ac_lib"; then
> -    ac_res="none required"
> -  else
> -    ac_res=-l$ac_lib
> -    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
> -  fi
> -  if ac_fn_c_try_link "$LINENO"; then :
> -  ac_cv_search_zlibVersion=$ac_res
> +if ac_fn_c_try_link "$LINENO"; then :
> +  ac_cv_libz=yes
> +else
> +  ac_cv_libz=no
>  fi
>  rm -f core conftest.err conftest.$ac_objext \
> -    conftest$ac_exeext
> -  if test "${ac_cv_search_zlibVersion+set}" = set; then :
> -  break
> -fi
> -done
> -if test "${ac_cv_search_zlibVersion+set}" = set; then :
> +    conftest$ac_exeext conftest.$ac_ext
> +    LIBS="$ac_save_LIBS"
>  
> -else
> -  ac_cv_search_zlibVersion=no
>  fi
> -rm conftest.$ac_ext
> -LIBS=$ac_func_search_save_LIBS
> -fi
> -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_zlibVersion" >&5
> -$as_echo "$ac_cv_search_zlibVersion" >&6; }
> -ac_res=$ac_cv_search_zlibVersion
> -if test "$ac_res" != no; then :
> -  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
> -  for ac_header in zlib.h
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_libz" >&5
> +$as_echo "$ac_cv_libz" >&6; }
> +  if test "$ac_cv_libz" = yes; then
> +    HAVE_LIBZ=yes
> +
> +$as_echo "#define HAVE_LIBZ 1" >>confdefs.h
> +
> +    { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libz" >&5
> +$as_echo_n "checking how to link with libz... " >&6; }
> +    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBZ" >&5
> +$as_echo "$LIBZ" >&6; }
> +  else
> +    HAVE_LIBZ=no
> +            CPPFLAGS="$ac_save_CPPFLAGS"
> +    LIBZ=
> +    LTLIBZ=
> +  fi
> +
> +
> +
> +
> +
> +
> +    if test "$HAVE_LIBZ" = "yes"; then
> +      # Make sure HAVE_ZLIB_H gets defined.  Some code uses that over
> +      # HAVE_LIBZ, since initially we were only defining HAVE_ZLIB_H.
> +      for ac_header in zlib.h
>  do :
>    ac_fn_c_check_header_mongrel "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default"
>  if test "x$ac_cv_header_zlib_h" = x""yes; then :
> @@ -6950,9 +7530,9 @@ fi
>  
>  done
>  
> -fi
> -
> -    if test "$with_zlib" = "yes" -a "$ac_cv_header_zlib_h" != "yes"; then
> +      LIBS="$LIBS $LIBZ"
> +    fi
> +    if test "$with_zlib" = "yes" -a "$HAVE_LIBZ" != "yes"; then
>        as_fn_error "zlib (libz) library was explicitly requested but not found" "$LINENO" 5
>      fi
>    fi
> diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in
> index d818570..14aa076 100644
> --- a/gold/testsuite/Makefile.in
> +++ b/gold/testsuite/Makefile.in
> @@ -756,6 +756,9 @@ am__aclocal_m4_deps = $(top_srcdir)/../config/depstand.m4 \
>  	$(top_srcdir)/../config/gettext-sister.m4 \
>  	$(top_srcdir)/../config/lcmessage.m4 \
>  	$(top_srcdir)/../config/lead-dot.m4 \
> +	$(top_srcdir)/../config/lib-ld.m4 \
> +	$(top_srcdir)/../config/lib-link.m4 \
> +	$(top_srcdir)/../config/lib-prefix.m4 \
>  	$(top_srcdir)/../config/nls.m4 \
>  	$(top_srcdir)/../config/override.m4 \
>  	$(top_srcdir)/../config/po.m4 \
> @@ -2055,6 +2058,7 @@ GMSGFMT = @GMSGFMT@
>  GOLD_LDADD = @GOLD_LDADD@
>  GOLD_LDFLAGS = @GOLD_LDFLAGS@
>  GREP = @GREP@
> +HAVE_LIBZ = @HAVE_LIBZ@
>  INCINTL = @INCINTL@
>  INSTALL = @INSTALL@
>  INSTALL_DATA = @INSTALL_DATA@
> @@ -2068,8 +2072,10 @@ LIBINTL = @LIBINTL@
>  LIBINTL_DEP = @LIBINTL_DEP@
>  LIBOBJS = @LIBOBJS@
>  LIBS = @LIBS@
> +LIBZ = @LIBZ@
>  LN_S = @LN_S@
>  LTLIBOBJS = @LTLIBOBJS@
> +LTLIBZ = @LTLIBZ@
>  MAINT = @MAINT@
>  MAKEINFO = @MAKEINFO@
>  MERGE_CONSTANTS_FLAG = @MERGE_CONSTANTS_FLAG@
> diff --git a/ld/Makefile.in b/ld/Makefile.in
> index 311452d..a54bc97 100644
> --- a/ld/Makefile.in
> +++ b/ld/Makefile.in
> @@ -75,6 +75,9 @@ am__aclocal_m4_deps = $(top_srcdir)/../bfd/acinclude.m4 \
>  	$(top_srcdir)/../config/largefile.m4 \
>  	$(top_srcdir)/../config/lcmessage.m4 \
>  	$(top_srcdir)/../config/lead-dot.m4 \
> +	$(top_srcdir)/../config/lib-ld.m4 \
> +	$(top_srcdir)/../config/lib-link.m4 \
> +	$(top_srcdir)/../config/lib-prefix.m4 \
>  	$(top_srcdir)/../config/nls.m4 \
>  	$(top_srcdir)/../config/override.m4 \
>  	$(top_srcdir)/../config/plugins.m4 \
> @@ -226,6 +229,7 @@ FGREP = @FGREP@
>  GENCAT = @GENCAT@
>  GMSGFMT = @GMSGFMT@
>  GREP = @GREP@
> +HAVE_LIBZ = @HAVE_LIBZ@
>  HDEFINES = @HDEFINES@
>  
>  #stuff for self hosting (can be overridden in config file).
> @@ -250,6 +254,7 @@ LIBINTL_DEP = @LIBINTL_DEP@
>  LIBOBJS = @LIBOBJS@
>  LIBS = @LIBS@
>  LIBTOOL = @LIBTOOL@
> +LIBZ = @LIBZ@
>  
>  # Search path to override the default search path for -lfoo libraries.
>  # If LIB_PATH is empty, the ones in the script (if any) are left alone.
> @@ -262,6 +267,7 @@ LIB_PATH = @LIB_PATH@
>  LIPO = @LIPO@
>  LN_S = @LN_S@
>  LTLIBOBJS = @LTLIBOBJS@
> +LTLIBZ = @LTLIBZ@
>  MAINT = @MAINT@
>  MAKEINFO = @MAKEINFO@
>  MKDIR_P = @MKDIR_P@
> diff --git a/ld/aclocal.m4 b/ld/aclocal.m4
> index 6585160..fed7950 100644
> --- a/ld/aclocal.m4
> +++ b/ld/aclocal.m4
> @@ -997,6 +997,9 @@ m4_include([../config/gettext-sister.m4])
>  m4_include([../config/largefile.m4])
>  m4_include([../config/lcmessage.m4])
>  m4_include([../config/lead-dot.m4])
> +m4_include([../config/lib-ld.m4])
> +m4_include([../config/lib-link.m4])
> +m4_include([../config/lib-prefix.m4])
>  m4_include([../config/nls.m4])
>  m4_include([../config/override.m4])
>  m4_include([../config/plugins.m4])
> diff --git a/ld/config.in b/ld/config.in
> index 2ab4844..226009e 100644
> --- a/ld/config.in
> +++ b/ld/config.in
> @@ -68,6 +68,9 @@
>  /* Define if your <locale.h> file defines LC_MESSAGES. */
>  #undef HAVE_LC_MESSAGES
>  
> +/* Define if you have the z library. */
> +#undef HAVE_LIBZ
> +
>  /* Define to 1 if you have the <limits.h> header file. */
>  #undef HAVE_LIMITS_H
>  
> diff --git a/ld/configure b/ld/configure
> index 8a7bd20..a0078da 100755
> --- a/ld/configure
> +++ b/ld/configure
> @@ -609,6 +609,9 @@ EMUL_EXTRA_OFILES
>  EMULATION_OFILES
>  EMUL
>  STRINGIFY
> +LTLIBZ
> +LIBZ
> +HAVE_LIBZ
>  enable_initfini_array
>  ENABLE_PLUGINS_FALSE
>  ENABLE_PLUGINS_TRUE
> @@ -790,6 +793,8 @@ enable_build_warnings
>  enable_nls
>  enable_initfini_array
>  with_zlib
> +enable_rpath
> +with_libz_prefix
>  '
>        ac_precious_vars='build_alias
>  host_alias
> @@ -1446,6 +1451,7 @@ Optional Features:
>    --enable-build-warnings enable build-time compiler warnings
>    --disable-nls           do not use Native Language Support
>    --enable-initfini-array	use .init_array/.fini_array sections
> +  --disable-rpath         do not hardcode runtime library paths
>  
>  Optional Packages:
>    --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
> @@ -1456,6 +1462,9 @@ Optional Packages:
>    --with-lib-path=dir1:dir2...  set default LIB_PATH
>    --with-sysroot=DIR Search for usr/lib et al within DIR.
>    --with-zlib             include zlib support (auto/yes/no) default=auto
> +  --with-gnu-ld           assume the C compiler uses GNU ld default=no
> +  --with-libz-prefix[=DIR]  search for libz in DIR/include and DIR/lib
> +  --without-libz-prefix     don't search for libz in includedir and libdir
>  
>  Some influential environment variables:
>    CC          C compiler command
> @@ -11712,7 +11721,7 @@ else
>    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>    lt_status=$lt_dlunknown
>    cat > conftest.$ac_ext <<_LT_EOF
> -#line 11715 "configure"
> +#line 11724 "configure"
>  #include "confdefs.h"
>  
>  #if HAVE_DLFCN_H
> @@ -11818,7 +11827,7 @@ else
>    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>    lt_status=$lt_dlunknown
>    cat > conftest.$ac_ext <<_LT_EOF
> -#line 11821 "configure"
> +#line 11830 "configure"
>  #include "confdefs.h"
>  
>  #if HAVE_DLFCN_H
> @@ -16757,6 +16766,164 @@ _ACEOF
>  # Link in zlib if we can.  This is needed only for the bootstrap tests
>  # right now, since those tests use libbfd, which depends on zlib.
>  
> +      if test "X$prefix" = "XNONE"; then
> +    acl_final_prefix="$ac_default_prefix"
> +  else
> +    acl_final_prefix="$prefix"
> +  fi
> +  if test "X$exec_prefix" = "XNONE"; then
> +    acl_final_exec_prefix='${prefix}'
> +  else
> +    acl_final_exec_prefix="$exec_prefix"
> +  fi
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
> +  prefix="$acl_save_prefix"
> +
> +
> +# Check whether --with-gnu-ld was given.
> +if test "${with_gnu_ld+set}" = set; then :
> +  withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
> +else
> +  with_gnu_ld=no
> +fi
> +
> +# Prepare PATH_SEPARATOR.
> +# The user is always right.
> +if test "${PATH_SEPARATOR+set}" != set; then
> +  echo "#! /bin/sh" >conf$$.sh
> +  echo  "exit 0"   >>conf$$.sh
> +  chmod +x conf$$.sh
> +  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
> +    PATH_SEPARATOR=';'
> +  else
> +    PATH_SEPARATOR=:
> +  fi
> +  rm -f conf$$.sh
> +fi
> +ac_prog=ld
> +if test "$GCC" = yes; then
> +  # Check if gcc -print-prog-name=ld gives a path.
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by GCC" >&5
> +$as_echo_n "checking for ld used by GCC... " >&6; }
> +  case $host in
> +  *-*-mingw*)
> +    # gcc leaves a trailing carriage return which upsets mingw
> +    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
> +  *)
> +    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
> +  esac
> +  case $ac_prog in
> +    # Accept absolute paths.
> +    [\\/]* | [A-Za-z]:[\\/]*)
> +      re_direlt='/[^/][^/]*/\.\./'
> +      # Canonicalize the path of ld
> +      ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
> +      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
> +	ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
> +      done
> +      test -z "$LD" && LD="$ac_prog"
> +      ;;
> +  "")
> +    # If it fails, then pretend we aren't using GCC.
> +    ac_prog=ld
> +    ;;
> +  *)
> +    # If it is relative, then search for the first ld in PATH.
> +    with_gnu_ld=unknown
> +    ;;
> +  esac
> +elif test "$with_gnu_ld" = yes; then
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
> +$as_echo_n "checking for GNU ld... " >&6; }
> +else
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
> +$as_echo_n "checking for non-GNU ld... " >&6; }
> +fi
> +if test "${acl_cv_path_LD+set}" = set; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +  if test -z "$LD"; then
> +  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
> +  for ac_dir in $PATH; do
> +    test -z "$ac_dir" && ac_dir=.
> +    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
> +      acl_cv_path_LD="$ac_dir/$ac_prog"
> +      # Check to see if the program is GNU ld.  I'd rather use --version,
> +      # but apparently some GNU ld's only accept -v.
> +      # Break only if it was the GNU/non-GNU ld that we prefer.
> +      if "$acl_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
> +	test "$with_gnu_ld" != no && break
> +      else
> +	test "$with_gnu_ld" != yes && break
> +      fi
> +    fi
> +  done
> +  IFS="$ac_save_ifs"
> +else
> +  acl_cv_path_LD="$LD" # Let the user override the test with a path.
> +fi
> +fi
> +
> +LD="$acl_cv_path_LD"
> +if test -n "$LD"; then
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
> +$as_echo "$LD" >&6; }
> +else
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
> +$as_echo "no" >&6; }
> +fi
> +test -z "$LD" && as_fn_error "no acceptable ld found in \$PATH" "$LINENO" 5
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
> +$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; }
> +if test "${acl_cv_prog_gnu_ld+set}" = set; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +  # I'd rather use --version here, but apparently some GNU ld's only accept -v.
> +if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
> +  acl_cv_prog_gnu_ld=yes
> +else
> +  acl_cv_prog_gnu_ld=no
> +fi
> +fi
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_prog_gnu_ld" >&5
> +$as_echo "$acl_cv_prog_gnu_ld" >&6; }
> +with_gnu_ld=$acl_cv_prog_gnu_ld
> +
> +
> +
> +                                                { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5
> +$as_echo_n "checking for shared library run path origin... " >&6; }
> +if test "${acl_cv_rpath+set}" = set; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +
> +    CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
> +    ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
> +    . ./conftest.sh
> +    rm -f ./conftest.sh
> +    acl_cv_rpath=done
> +
> +fi
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_rpath" >&5
> +$as_echo "$acl_cv_rpath" >&6; }
> +  wl="$acl_cv_wl"
> +  libext="$acl_cv_libext"
> +  shlibext="$acl_cv_shlibext"
> +  hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
> +  hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
> +  hardcode_direct="$acl_cv_hardcode_direct"
> +  hardcode_minus_L="$acl_cv_hardcode_minus_L"
> +    # Check whether --enable-rpath was given.
> +if test "${enable_rpath+set}" = set; then :
> +  enableval=$enable_rpath; :
> +else
> +  enable_rpath=yes
> +fi
> +
> +
> +
>    # See if the user specified whether he wants zlib support or not.
>  
>  # Check whether --with-zlib was given.
> @@ -16768,60 +16935,472 @@ fi
>  
>  
>    if test "$with_zlib" != "no"; then
> -    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing zlibVersion" >&5
> -$as_echo_n "checking for library containing zlibVersion... " >&6; }
> -if test "${ac_cv_search_zlibVersion+set}" = set; then :
> +
> +
> +
> +
> +
> +
> +
> +
> +    use_additional=yes
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +
> +    eval additional_includedir=\"$includedir\"
> +    eval additional_libdir=\"$libdir\"
> +
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +
> +# Check whether --with-libz-prefix was given.
> +if test "${with_libz_prefix+set}" = set; then :
> +  withval=$with_libz_prefix;
> +    if test "X$withval" = "Xno"; then
> +      use_additional=no
> +    else
> +      if test "X$withval" = "X"; then
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +
> +          eval additional_includedir=\"$includedir\"
> +          eval additional_libdir=\"$libdir\"
> +
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +      else
> +        additional_includedir="$withval/include"
> +        additional_libdir="$withval/lib"
> +      fi
> +    fi
> +
> +fi
> +
> +      LIBZ=
> +  LTLIBZ=
> +  INCZ=
> +  rpathdirs=
> +  ltrpathdirs=
> +  names_already_handled=
> +  names_next_round='z '
> +  while test -n "$names_next_round"; do
> +    names_this_round="$names_next_round"
> +    names_next_round=
> +    for name in $names_this_round; do
> +      already_handled=
> +      for n in $names_already_handled; do
> +        if test "$n" = "$name"; then
> +          already_handled=yes
> +          break
> +        fi
> +      done
> +      if test -z "$already_handled"; then
> +        names_already_handled="$names_already_handled $name"
> +                        uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
> +        eval value=\"\$HAVE_LIB$uppername\"
> +        if test -n "$value"; then
> +          if test "$value" = yes; then
> +            eval value=\"\$LIB$uppername\"
> +            test -z "$value" || LIBZ="${LIBZ}${LIBZ:+ }$value"
> +            eval value=\"\$LTLIB$uppername\"
> +            test -z "$value" || LTLIBZ="${LTLIBZ}${LTLIBZ:+ }$value"
> +          else
> +                                    :
> +          fi
> +        else
> +                              found_dir=
> +          found_la=
> +          found_so=
> +          found_a=
> +          if test $use_additional = yes; then
> +            if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then
> +              found_dir="$additional_libdir"
> +              found_so="$additional_libdir/lib$name.$shlibext"
> +              if test -f "$additional_libdir/lib$name.la"; then
> +                found_la="$additional_libdir/lib$name.la"
> +              fi
> +            else
> +              if test -f "$additional_libdir/lib$name.$libext"; then
> +                found_dir="$additional_libdir"
> +                found_a="$additional_libdir/lib$name.$libext"
> +                if test -f "$additional_libdir/lib$name.la"; then
> +                  found_la="$additional_libdir/lib$name.la"
> +                fi
> +              fi
> +            fi
> +          fi
> +          if test "X$found_dir" = "X"; then
> +            for x in $LDFLAGS $LTLIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +              case "$x" in
> +                -L*)
> +                  dir=`echo "X$x" | sed -e 's/^X-L//'`
> +                  if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then
> +                    found_dir="$dir"
> +                    found_so="$dir/lib$name.$shlibext"
> +                    if test -f "$dir/lib$name.la"; then
> +                      found_la="$dir/lib$name.la"
> +                    fi
> +                  else
> +                    if test -f "$dir/lib$name.$libext"; then
> +                      found_dir="$dir"
> +                      found_a="$dir/lib$name.$libext"
> +                      if test -f "$dir/lib$name.la"; then
> +                        found_la="$dir/lib$name.la"
> +                      fi
> +                    fi
> +                  fi
> +                  ;;
> +              esac
> +              if test "X$found_dir" != "X"; then
> +                break
> +              fi
> +            done
> +          fi
> +          if test "X$found_dir" != "X"; then
> +                        LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-L$found_dir -l$name"
> +            if test "X$found_so" != "X"; then
> +                                                        if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then
> +                                LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +              else
> +                                                                                haveit=
> +                for x in $ltrpathdirs; do
> +                  if test "X$x" = "X$found_dir"; then
> +                    haveit=yes
> +                    break
> +                  fi
> +                done
> +                if test -z "$haveit"; then
> +                  ltrpathdirs="$ltrpathdirs $found_dir"
> +                fi
> +                                if test "$hardcode_direct" = yes; then
> +                                                      LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +                else
> +                  if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then
> +                                                            LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +                                                            haveit=
> +                    for x in $rpathdirs; do
> +                      if test "X$x" = "X$found_dir"; then
> +                        haveit=yes
> +                        break
> +                      fi
> +                    done
> +                    if test -z "$haveit"; then
> +                      rpathdirs="$rpathdirs $found_dir"
> +                    fi
> +                  else
> +                                                                                haveit=
> +                    for x in $LDFLAGS $LIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                      if test "X$x" = "X-L$found_dir"; then
> +                        haveit=yes
> +                        break
> +                      fi
> +                    done
> +                    if test -z "$haveit"; then
> +                      LIBZ="${LIBZ}${LIBZ:+ }-L$found_dir"
> +                    fi
> +                    if test "$hardcode_minus_L" != no; then
> +                                                                                        LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +                    else
> +                                                                                                                                                                                LIBZ="${LIBZ}${LIBZ:+ }-l$name"
> +                    fi
> +                  fi
> +                fi
> +              fi
> +            else
> +              if test "X$found_a" != "X"; then
> +                                LIBZ="${LIBZ}${LIBZ:+ }$found_a"
> +              else
> +                                                LIBZ="${LIBZ}${LIBZ:+ }-L$found_dir -l$name"
> +              fi
> +            fi
> +                        additional_includedir=
> +            case "$found_dir" in
> +              */lib | */lib/)
> +                basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'`
> +                additional_includedir="$basedir/include"
> +                ;;
> +            esac
> +            if test "X$additional_includedir" != "X"; then
> +                                                                                                                if test "X$additional_includedir" != "X/usr/include"; then
> +                haveit=
> +                if test "X$additional_includedir" = "X/usr/local/include"; then
> +                  if test -n "$GCC"; then
> +                    case $host_os in
> +                      linux*) haveit=yes;;
> +                    esac
> +                  fi
> +                fi
> +                if test -z "$haveit"; then
> +                  for x in $CPPFLAGS $INCZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                    if test "X$x" = "X-I$additional_includedir"; then
> +                      haveit=yes
> +                      break
> +                    fi
> +                  done
> +                  if test -z "$haveit"; then
> +                    if test -d "$additional_includedir"; then
> +                                            INCZ="${INCZ}${INCZ:+ }-I$additional_includedir"
> +                    fi
> +                  fi
> +                fi
> +              fi
> +            fi
> +                        if test -n "$found_la"; then
> +                                                        save_libdir="$libdir"
> +              case "$found_la" in
> +                */* | *\\*) . "$found_la" ;;
> +                *) . "./$found_la" ;;
> +              esac
> +              libdir="$save_libdir"
> +                            for dep in $dependency_libs; do
> +                case "$dep" in
> +                  -L*)
> +                    additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
> +                                                                                                                                                                if test "X$additional_libdir" != "X/usr/lib"; then
> +                      haveit=
> +                      if test "X$additional_libdir" = "X/usr/local/lib"; then
> +                        if test -n "$GCC"; then
> +                          case $host_os in
> +                            linux*) haveit=yes;;
> +                          esac
> +                        fi
> +                      fi
> +                      if test -z "$haveit"; then
> +                        haveit=
> +                        for x in $LDFLAGS $LIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                          if test "X$x" = "X-L$additional_libdir"; then
> +                            haveit=yes
> +                            break
> +                          fi
> +                        done
> +                        if test -z "$haveit"; then
> +                          if test -d "$additional_libdir"; then
> +                                                        LIBZ="${LIBZ}${LIBZ:+ }-L$additional_libdir"
> +                          fi
> +                        fi
> +                        haveit=
> +                        for x in $LDFLAGS $LTLIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                          if test "X$x" = "X-L$additional_libdir"; then
> +                            haveit=yes
> +                            break
> +                          fi
> +                        done
> +                        if test -z "$haveit"; then
> +                          if test -d "$additional_libdir"; then
> +                                                        LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-L$additional_libdir"
> +                          fi
> +                        fi
> +                      fi
> +                    fi
> +                    ;;
> +                  -R*)
> +                    dir=`echo "X$dep" | sed -e 's/^X-R//'`
> +                    if test "$enable_rpath" != no; then
> +                                                                  haveit=
> +                      for x in $rpathdirs; do
> +                        if test "X$x" = "X$dir"; then
> +                          haveit=yes
> +                          break
> +                        fi
> +                      done
> +                      if test -z "$haveit"; then
> +                        rpathdirs="$rpathdirs $dir"
> +                      fi
> +                                                                  haveit=
> +                      for x in $ltrpathdirs; do
> +                        if test "X$x" = "X$dir"; then
> +                          haveit=yes
> +                          break
> +                        fi
> +                      done
> +                      if test -z "$haveit"; then
> +                        ltrpathdirs="$ltrpathdirs $dir"
> +                      fi
> +                    fi
> +                    ;;
> +                  -l*)
> +                                        names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
> +                    ;;
> +                  *.la)
> +                                                                                names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
> +                    ;;
> +                  *)
> +                                        LIBZ="${LIBZ}${LIBZ:+ }$dep"
> +                    LTLIBZ="${LTLIBZ}${LTLIBZ:+ }$dep"
> +                    ;;
> +                esac
> +              done
> +            fi
> +          else
> +                                                            LIBZ="${LIBZ}${LIBZ:+ }-l$name"
> +            LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-l$name"
> +          fi
> +        fi
> +      fi
> +    done
> +  done
> +  if test "X$rpathdirs" != "X"; then
> +    if test -n "$hardcode_libdir_separator"; then
> +                        alldirs=
> +      for found_dir in $rpathdirs; do
> +        alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir"
> +      done
> +            acl_save_libdir="$libdir"
> +      libdir="$alldirs"
> +      eval flag=\"$hardcode_libdir_flag_spec\"
> +      libdir="$acl_save_libdir"
> +      LIBZ="${LIBZ}${LIBZ:+ }$flag"
> +    else
> +            for found_dir in $rpathdirs; do
> +        acl_save_libdir="$libdir"
> +        libdir="$found_dir"
> +        eval flag=\"$hardcode_libdir_flag_spec\"
> +        libdir="$acl_save_libdir"
> +        LIBZ="${LIBZ}${LIBZ:+ }$flag"
> +      done
> +    fi
> +  fi
> +  if test "X$ltrpathdirs" != "X"; then
> +            for found_dir in $ltrpathdirs; do
> +      LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-R$found_dir"
> +    done
> +  fi
> +
> +
> +        ac_save_CPPFLAGS="$CPPFLAGS"
> +
> +  for element in $INCZ; do
> +    haveit=
> +    for x in $CPPFLAGS; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +      if test "X$x" = "X$element"; then
> +        haveit=yes
> +        break
> +      fi
> +    done
> +    if test -z "$haveit"; then
> +      CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element"
> +    fi
> +  done
> +
> +
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libz" >&5
> +$as_echo_n "checking for libz... " >&6; }
> +if test "${ac_cv_libz+set}" = set; then :
>    $as_echo_n "(cached) " >&6
>  else
> -  ac_func_search_save_LIBS=$LIBS
> -cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> -/* end confdefs.h.  */
>  
> -/* Override any GCC internal prototype to avoid an error.
> -   Use char because int might match the return type of a GCC
> -   builtin and then its argument prototype would still apply.  */
> -#ifdef __cplusplus
> -extern "C"
> -#endif
> -char zlibVersion ();
> +    ac_save_LIBS="$LIBS"
> +    LIBS="$LIBS $LIBZ"
> +    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> +/* end confdefs.h.  */
> +#include "zlib.h";
>  int
>  main ()
>  {
> -return zlibVersion ();
> +int ret = deflateInit(NULL, 1);
>    ;
>    return 0;
>  }
>  _ACEOF
> -for ac_lib in '' z; do
> -  if test -z "$ac_lib"; then
> -    ac_res="none required"
> -  else
> -    ac_res=-l$ac_lib
> -    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
> -  fi
> -  if ac_fn_c_try_link "$LINENO"; then :
> -  ac_cv_search_zlibVersion=$ac_res
> +if ac_fn_c_try_link "$LINENO"; then :
> +  ac_cv_libz=yes
> +else
> +  ac_cv_libz=no
>  fi
>  rm -f core conftest.err conftest.$ac_objext \
> -    conftest$ac_exeext
> -  if test "${ac_cv_search_zlibVersion+set}" = set; then :
> -  break
> -fi
> -done
> -if test "${ac_cv_search_zlibVersion+set}" = set; then :
> +    conftest$ac_exeext conftest.$ac_ext
> +    LIBS="$ac_save_LIBS"
>  
> -else
> -  ac_cv_search_zlibVersion=no
>  fi
> -rm conftest.$ac_ext
> -LIBS=$ac_func_search_save_LIBS
> -fi
> -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_zlibVersion" >&5
> -$as_echo "$ac_cv_search_zlibVersion" >&6; }
> -ac_res=$ac_cv_search_zlibVersion
> -if test "$ac_res" != no; then :
> -  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
> -  for ac_header in zlib.h
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_libz" >&5
> +$as_echo "$ac_cv_libz" >&6; }
> +  if test "$ac_cv_libz" = yes; then
> +    HAVE_LIBZ=yes
> +
> +$as_echo "#define HAVE_LIBZ 1" >>confdefs.h
> +
> +    { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libz" >&5
> +$as_echo_n "checking how to link with libz... " >&6; }
> +    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBZ" >&5
> +$as_echo "$LIBZ" >&6; }
> +  else
> +    HAVE_LIBZ=no
> +            CPPFLAGS="$ac_save_CPPFLAGS"
> +    LIBZ=
> +    LTLIBZ=
> +  fi
> +
> +
> +
> +
> +
> +
> +    if test "$HAVE_LIBZ" = "yes"; then
> +      # Make sure HAVE_ZLIB_H gets defined.  Some code uses that over
> +      # HAVE_LIBZ, since initially we were only defining HAVE_ZLIB_H.
> +      for ac_header in zlib.h
>  do :
>    ac_fn_c_check_header_mongrel "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default"
>  if test "x$ac_cv_header_zlib_h" = x""yes; then :
> @@ -16833,9 +17412,9 @@ fi
>  
>  done
>  
> -fi
> -
> -    if test "$with_zlib" = "yes" -a "$ac_cv_header_zlib_h" != "yes"; then
> +      LIBS="$LIBS $LIBZ"
> +    fi
> +    if test "$with_zlib" = "yes" -a "$HAVE_LIBZ" != "yes"; then
>        as_fn_error "zlib (libz) library was explicitly requested but not found" "$LINENO" 5
>      fi
>    fi
> diff --git a/sim/common/acinclude.m4 b/sim/common/acinclude.m4
> index f96ec35..430ae0e 100644
> --- a/sim/common/acinclude.m4
> +++ b/sim/common/acinclude.m4
> @@ -20,6 +20,9 @@
>  
>  # Include global overrides and fixes for Autoconf.
>  m4_include(../../config/override.m4)
> +m4_include([../../config/lib-ld.m4])
> +m4_include([../../config/lib-link.m4])
> +m4_include([../../config/lib-prefix.m4])
>  sinclude([../../config/zlib.m4])
>  m4_include([../../config/plugins.m4])
>  m4_include([../../libtool.m4])
> diff --git a/sim/common/config.in b/sim/common/config.in
> index 5b8ebd8..d6d595e 100644
> --- a/sim/common/config.in
> +++ b/sim/common/config.in
> @@ -31,6 +31,9 @@
>  /* Define to 1 if you have the `socket' library (-lsocket). */
>  #undef HAVE_LIBSOCKET
>  
> +/* Define if you have the z library. */
> +#undef HAVE_LIBZ
> +
>  /* Define to 1 if you have the `lstat' function. */
>  #undef HAVE_LSTAT
>  
> diff --git a/sim/common/configure b/sim/common/configure
> index add4c0f..16f6f28 100755
> --- a/sim/common/configure
> +++ b/sim/common/configure
> @@ -633,6 +633,9 @@ SED
>  LIBTOOL
>  PLUGINS_FALSE
>  PLUGINS_TRUE
> +LTLIBZ
> +LIBZ
> +HAVE_LIBZ
>  CATOBJEXT
>  GENCAT
>  INSTOBJEXT
> @@ -744,12 +747,14 @@ ac_subst_files=''
>  ac_user_opts='
>  enable_option_checking
>  with_zlib
> +with_gnu_ld
> +enable_rpath
> +with_libz_prefix
>  enable_plugins
>  enable_shared
>  enable_static
>  with_pic
>  enable_fast_install
> -with_gnu_ld
>  enable_libtool_lock
>  enable_maintainer_mode
>  enable_sim_bswap
> @@ -1388,6 +1393,7 @@ Optional Features:
>    --disable-option-checking  ignore unrecognized --enable/--with options
>    --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
>    --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
> +  --disable-rpath         do not hardcode runtime library paths
>    --enable-plugins        Enable support for plugins
>    --enable-shared[=PKGS]  build shared libraries [default=yes]
>    --enable-static[=PKGS]  build static libraries [default=yes]
> @@ -1407,6 +1413,9 @@ Optional Packages:
>    --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
>    --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
>    --with-zlib             include zlib support (auto/yes/no) default=auto
> +  --with-gnu-ld           assume the C compiler uses GNU ld default=no
> +  --with-libz-prefix[=DIR]  search for libz in DIR/include and DIR/lib
> +  --without-libz-prefix     don't search for libz in includedir and libdir
>    --with-pic              try to use only PIC/non-PIC objects [default=use
>                            both]
>    --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
> @@ -3788,6 +3797,164 @@ rmdir .tst 2>/dev/null
>  
>  DEPDIR="${am__leading_dot}deps"
>  
> +
> +      if test "X$prefix" = "XNONE"; then
> +    acl_final_prefix="$ac_default_prefix"
> +  else
> +    acl_final_prefix="$prefix"
> +  fi
> +  if test "X$exec_prefix" = "XNONE"; then
> +    acl_final_exec_prefix='${prefix}'
> +  else
> +    acl_final_exec_prefix="$exec_prefix"
> +  fi
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
> +  prefix="$acl_save_prefix"
> +
> +
> +# Check whether --with-gnu-ld was given.
> +if test "${with_gnu_ld+set}" = set; then :
> +  withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
> +else
> +  with_gnu_ld=no
> +fi
> +
> +# Prepare PATH_SEPARATOR.
> +# The user is always right.
> +if test "${PATH_SEPARATOR+set}" != set; then
> +  echo "#! /bin/sh" >conf$$.sh
> +  echo  "exit 0"   >>conf$$.sh
> +  chmod +x conf$$.sh
> +  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
> +    PATH_SEPARATOR=';'
> +  else
> +    PATH_SEPARATOR=:
> +  fi
> +  rm -f conf$$.sh
> +fi
> +ac_prog=ld
> +if test "$GCC" = yes; then
> +  # Check if gcc -print-prog-name=ld gives a path.
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by GCC" >&5
> +$as_echo_n "checking for ld used by GCC... " >&6; }
> +  case $host in
> +  *-*-mingw*)
> +    # gcc leaves a trailing carriage return which upsets mingw
> +    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
> +  *)
> +    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
> +  esac
> +  case $ac_prog in
> +    # Accept absolute paths.
> +    [\\/]* | [A-Za-z]:[\\/]*)
> +      re_direlt='/[^/][^/]*/\.\./'
> +      # Canonicalize the path of ld
> +      ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
> +      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
> +	ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
> +      done
> +      test -z "$LD" && LD="$ac_prog"
> +      ;;
> +  "")
> +    # If it fails, then pretend we aren't using GCC.
> +    ac_prog=ld
> +    ;;
> +  *)
> +    # If it is relative, then search for the first ld in PATH.
> +    with_gnu_ld=unknown
> +    ;;
> +  esac
> +elif test "$with_gnu_ld" = yes; then
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
> +$as_echo_n "checking for GNU ld... " >&6; }
> +else
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
> +$as_echo_n "checking for non-GNU ld... " >&6; }
> +fi
> +if test "${acl_cv_path_LD+set}" = set; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +  if test -z "$LD"; then
> +  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
> +  for ac_dir in $PATH; do
> +    test -z "$ac_dir" && ac_dir=.
> +    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
> +      acl_cv_path_LD="$ac_dir/$ac_prog"
> +      # Check to see if the program is GNU ld.  I'd rather use --version,
> +      # but apparently some GNU ld's only accept -v.
> +      # Break only if it was the GNU/non-GNU ld that we prefer.
> +      if "$acl_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
> +	test "$with_gnu_ld" != no && break
> +      else
> +	test "$with_gnu_ld" != yes && break
> +      fi
> +    fi
> +  done
> +  IFS="$ac_save_ifs"
> +else
> +  acl_cv_path_LD="$LD" # Let the user override the test with a path.
> +fi
> +fi
> +
> +LD="$acl_cv_path_LD"
> +if test -n "$LD"; then
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
> +$as_echo "$LD" >&6; }
> +else
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
> +$as_echo "no" >&6; }
> +fi
> +test -z "$LD" && as_fn_error "no acceptable ld found in \$PATH" "$LINENO" 5
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
> +$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; }
> +if test "${acl_cv_prog_gnu_ld+set}" = set; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +  # I'd rather use --version here, but apparently some GNU ld's only accept -v.
> +if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
> +  acl_cv_prog_gnu_ld=yes
> +else
> +  acl_cv_prog_gnu_ld=no
> +fi
> +fi
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_prog_gnu_ld" >&5
> +$as_echo "$acl_cv_prog_gnu_ld" >&6; }
> +with_gnu_ld=$acl_cv_prog_gnu_ld
> +
> +
> +
> +                                                { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5
> +$as_echo_n "checking for shared library run path origin... " >&6; }
> +if test "${acl_cv_rpath+set}" = set; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +
> +    CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
> +    ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
> +    . ./conftest.sh
> +    rm -f ./conftest.sh
> +    acl_cv_rpath=done
> +
> +fi
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_rpath" >&5
> +$as_echo "$acl_cv_rpath" >&6; }
> +  wl="$acl_cv_wl"
> +  libext="$acl_cv_libext"
> +  shlibext="$acl_cv_shlibext"
> +  hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
> +  hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
> +  hardcode_direct="$acl_cv_hardcode_direct"
> +  hardcode_minus_L="$acl_cv_hardcode_minus_L"
> +    # Check whether --enable-rpath was given.
> +if test "${enable_rpath+set}" = set; then :
> +  enableval=$enable_rpath; :
> +else
> +  enable_rpath=yes
> +fi
> +
> +
>  case `pwd` in
>    *\ * | *\	*)
>      { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5
> @@ -6962,60 +7129,472 @@ fi
>  
>  
>    if test "$with_zlib" != "no"; then
> -    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing zlibVersion" >&5
> -$as_echo_n "checking for library containing zlibVersion... " >&6; }
> -if test "${ac_cv_search_zlibVersion+set}" = set; then :
> +
> +
> +
> +
> +
> +
> +
> +
> +    use_additional=yes
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +
> +    eval additional_includedir=\"$includedir\"
> +    eval additional_libdir=\"$libdir\"
> +
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +
> +# Check whether --with-libz-prefix was given.
> +if test "${with_libz_prefix+set}" = set; then :
> +  withval=$with_libz_prefix;
> +    if test "X$withval" = "Xno"; then
> +      use_additional=no
> +    else
> +      if test "X$withval" = "X"; then
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +
> +          eval additional_includedir=\"$includedir\"
> +          eval additional_libdir=\"$libdir\"
> +
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +      else
> +        additional_includedir="$withval/include"
> +        additional_libdir="$withval/lib"
> +      fi
> +    fi
> +
> +fi
> +
> +      LIBZ=
> +  LTLIBZ=
> +  INCZ=
> +  rpathdirs=
> +  ltrpathdirs=
> +  names_already_handled=
> +  names_next_round='z '
> +  while test -n "$names_next_round"; do
> +    names_this_round="$names_next_round"
> +    names_next_round=
> +    for name in $names_this_round; do
> +      already_handled=
> +      for n in $names_already_handled; do
> +        if test "$n" = "$name"; then
> +          already_handled=yes
> +          break
> +        fi
> +      done
> +      if test -z "$already_handled"; then
> +        names_already_handled="$names_already_handled $name"
> +                        uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
> +        eval value=\"\$HAVE_LIB$uppername\"
> +        if test -n "$value"; then
> +          if test "$value" = yes; then
> +            eval value=\"\$LIB$uppername\"
> +            test -z "$value" || LIBZ="${LIBZ}${LIBZ:+ }$value"
> +            eval value=\"\$LTLIB$uppername\"
> +            test -z "$value" || LTLIBZ="${LTLIBZ}${LTLIBZ:+ }$value"
> +          else
> +                                    :
> +          fi
> +        else
> +                              found_dir=
> +          found_la=
> +          found_so=
> +          found_a=
> +          if test $use_additional = yes; then
> +            if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then
> +              found_dir="$additional_libdir"
> +              found_so="$additional_libdir/lib$name.$shlibext"
> +              if test -f "$additional_libdir/lib$name.la"; then
> +                found_la="$additional_libdir/lib$name.la"
> +              fi
> +            else
> +              if test -f "$additional_libdir/lib$name.$libext"; then
> +                found_dir="$additional_libdir"
> +                found_a="$additional_libdir/lib$name.$libext"
> +                if test -f "$additional_libdir/lib$name.la"; then
> +                  found_la="$additional_libdir/lib$name.la"
> +                fi
> +              fi
> +            fi
> +          fi
> +          if test "X$found_dir" = "X"; then
> +            for x in $LDFLAGS $LTLIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +              case "$x" in
> +                -L*)
> +                  dir=`echo "X$x" | sed -e 's/^X-L//'`
> +                  if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then
> +                    found_dir="$dir"
> +                    found_so="$dir/lib$name.$shlibext"
> +                    if test -f "$dir/lib$name.la"; then
> +                      found_la="$dir/lib$name.la"
> +                    fi
> +                  else
> +                    if test -f "$dir/lib$name.$libext"; then
> +                      found_dir="$dir"
> +                      found_a="$dir/lib$name.$libext"
> +                      if test -f "$dir/lib$name.la"; then
> +                        found_la="$dir/lib$name.la"
> +                      fi
> +                    fi
> +                  fi
> +                  ;;
> +              esac
> +              if test "X$found_dir" != "X"; then
> +                break
> +              fi
> +            done
> +          fi
> +          if test "X$found_dir" != "X"; then
> +                        LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-L$found_dir -l$name"
> +            if test "X$found_so" != "X"; then
> +                                                        if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then
> +                                LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +              else
> +                                                                                haveit=
> +                for x in $ltrpathdirs; do
> +                  if test "X$x" = "X$found_dir"; then
> +                    haveit=yes
> +                    break
> +                  fi
> +                done
> +                if test -z "$haveit"; then
> +                  ltrpathdirs="$ltrpathdirs $found_dir"
> +                fi
> +                                if test "$hardcode_direct" = yes; then
> +                                                      LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +                else
> +                  if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then
> +                                                            LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +                                                            haveit=
> +                    for x in $rpathdirs; do
> +                      if test "X$x" = "X$found_dir"; then
> +                        haveit=yes
> +                        break
> +                      fi
> +                    done
> +                    if test -z "$haveit"; then
> +                      rpathdirs="$rpathdirs $found_dir"
> +                    fi
> +                  else
> +                                                                                haveit=
> +                    for x in $LDFLAGS $LIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                      if test "X$x" = "X-L$found_dir"; then
> +                        haveit=yes
> +                        break
> +                      fi
> +                    done
> +                    if test -z "$haveit"; then
> +                      LIBZ="${LIBZ}${LIBZ:+ }-L$found_dir"
> +                    fi
> +                    if test "$hardcode_minus_L" != no; then
> +                                                                                        LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +                    else
> +                                                                                                                                                                                LIBZ="${LIBZ}${LIBZ:+ }-l$name"
> +                    fi
> +                  fi
> +                fi
> +              fi
> +            else
> +              if test "X$found_a" != "X"; then
> +                                LIBZ="${LIBZ}${LIBZ:+ }$found_a"
> +              else
> +                                                LIBZ="${LIBZ}${LIBZ:+ }-L$found_dir -l$name"
> +              fi
> +            fi
> +                        additional_includedir=
> +            case "$found_dir" in
> +              */lib | */lib/)
> +                basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'`
> +                additional_includedir="$basedir/include"
> +                ;;
> +            esac
> +            if test "X$additional_includedir" != "X"; then
> +                                                                                                                if test "X$additional_includedir" != "X/usr/include"; then
> +                haveit=
> +                if test "X$additional_includedir" = "X/usr/local/include"; then
> +                  if test -n "$GCC"; then
> +                    case $host_os in
> +                      linux*) haveit=yes;;
> +                    esac
> +                  fi
> +                fi
> +                if test -z "$haveit"; then
> +                  for x in $CPPFLAGS $INCZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                    if test "X$x" = "X-I$additional_includedir"; then
> +                      haveit=yes
> +                      break
> +                    fi
> +                  done
> +                  if test -z "$haveit"; then
> +                    if test -d "$additional_includedir"; then
> +                                            INCZ="${INCZ}${INCZ:+ }-I$additional_includedir"
> +                    fi
> +                  fi
> +                fi
> +              fi
> +            fi
> +                        if test -n "$found_la"; then
> +                                                        save_libdir="$libdir"
> +              case "$found_la" in
> +                */* | *\\*) . "$found_la" ;;
> +                *) . "./$found_la" ;;
> +              esac
> +              libdir="$save_libdir"
> +                            for dep in $dependency_libs; do
> +                case "$dep" in
> +                  -L*)
> +                    additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
> +                                                                                                                                                                if test "X$additional_libdir" != "X/usr/lib"; then
> +                      haveit=
> +                      if test "X$additional_libdir" = "X/usr/local/lib"; then
> +                        if test -n "$GCC"; then
> +                          case $host_os in
> +                            linux*) haveit=yes;;
> +                          esac
> +                        fi
> +                      fi
> +                      if test -z "$haveit"; then
> +                        haveit=
> +                        for x in $LDFLAGS $LIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                          if test "X$x" = "X-L$additional_libdir"; then
> +                            haveit=yes
> +                            break
> +                          fi
> +                        done
> +                        if test -z "$haveit"; then
> +                          if test -d "$additional_libdir"; then
> +                                                        LIBZ="${LIBZ}${LIBZ:+ }-L$additional_libdir"
> +                          fi
> +                        fi
> +                        haveit=
> +                        for x in $LDFLAGS $LTLIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                          if test "X$x" = "X-L$additional_libdir"; then
> +                            haveit=yes
> +                            break
> +                          fi
> +                        done
> +                        if test -z "$haveit"; then
> +                          if test -d "$additional_libdir"; then
> +                                                        LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-L$additional_libdir"
> +                          fi
> +                        fi
> +                      fi
> +                    fi
> +                    ;;
> +                  -R*)
> +                    dir=`echo "X$dep" | sed -e 's/^X-R//'`
> +                    if test "$enable_rpath" != no; then
> +                                                                  haveit=
> +                      for x in $rpathdirs; do
> +                        if test "X$x" = "X$dir"; then
> +                          haveit=yes
> +                          break
> +                        fi
> +                      done
> +                      if test -z "$haveit"; then
> +                        rpathdirs="$rpathdirs $dir"
> +                      fi
> +                                                                  haveit=
> +                      for x in $ltrpathdirs; do
> +                        if test "X$x" = "X$dir"; then
> +                          haveit=yes
> +                          break
> +                        fi
> +                      done
> +                      if test -z "$haveit"; then
> +                        ltrpathdirs="$ltrpathdirs $dir"
> +                      fi
> +                    fi
> +                    ;;
> +                  -l*)
> +                                        names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
> +                    ;;
> +                  *.la)
> +                                                                                names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
> +                    ;;
> +                  *)
> +                                        LIBZ="${LIBZ}${LIBZ:+ }$dep"
> +                    LTLIBZ="${LTLIBZ}${LTLIBZ:+ }$dep"
> +                    ;;
> +                esac
> +              done
> +            fi
> +          else
> +                                                            LIBZ="${LIBZ}${LIBZ:+ }-l$name"
> +            LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-l$name"
> +          fi
> +        fi
> +      fi
> +    done
> +  done
> +  if test "X$rpathdirs" != "X"; then
> +    if test -n "$hardcode_libdir_separator"; then
> +                        alldirs=
> +      for found_dir in $rpathdirs; do
> +        alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir"
> +      done
> +            acl_save_libdir="$libdir"
> +      libdir="$alldirs"
> +      eval flag=\"$hardcode_libdir_flag_spec\"
> +      libdir="$acl_save_libdir"
> +      LIBZ="${LIBZ}${LIBZ:+ }$flag"
> +    else
> +            for found_dir in $rpathdirs; do
> +        acl_save_libdir="$libdir"
> +        libdir="$found_dir"
> +        eval flag=\"$hardcode_libdir_flag_spec\"
> +        libdir="$acl_save_libdir"
> +        LIBZ="${LIBZ}${LIBZ:+ }$flag"
> +      done
> +    fi
> +  fi
> +  if test "X$ltrpathdirs" != "X"; then
> +            for found_dir in $ltrpathdirs; do
> +      LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-R$found_dir"
> +    done
> +  fi
> +
> +
> +        ac_save_CPPFLAGS="$CPPFLAGS"
> +
> +  for element in $INCZ; do
> +    haveit=
> +    for x in $CPPFLAGS; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +      if test "X$x" = "X$element"; then
> +        haveit=yes
> +        break
> +      fi
> +    done
> +    if test -z "$haveit"; then
> +      CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element"
> +    fi
> +  done
> +
> +
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libz" >&5
> +$as_echo_n "checking for libz... " >&6; }
> +if test "${ac_cv_libz+set}" = set; then :
>    $as_echo_n "(cached) " >&6
>  else
> -  ac_func_search_save_LIBS=$LIBS
> -cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> -/* end confdefs.h.  */
>  
> -/* Override any GCC internal prototype to avoid an error.
> -   Use char because int might match the return type of a GCC
> -   builtin and then its argument prototype would still apply.  */
> -#ifdef __cplusplus
> -extern "C"
> -#endif
> -char zlibVersion ();
> +    ac_save_LIBS="$LIBS"
> +    LIBS="$LIBS $LIBZ"
> +    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> +/* end confdefs.h.  */
> +#include "zlib.h";
>  int
>  main ()
>  {
> -return zlibVersion ();
> +int ret = deflateInit(NULL, 1);
>    ;
>    return 0;
>  }
>  _ACEOF
> -for ac_lib in '' z; do
> -  if test -z "$ac_lib"; then
> -    ac_res="none required"
> -  else
> -    ac_res=-l$ac_lib
> -    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
> -  fi
> -  if ac_fn_c_try_link "$LINENO"; then :
> -  ac_cv_search_zlibVersion=$ac_res
> +if ac_fn_c_try_link "$LINENO"; then :
> +  ac_cv_libz=yes
> +else
> +  ac_cv_libz=no
>  fi
>  rm -f core conftest.err conftest.$ac_objext \
> -    conftest$ac_exeext
> -  if test "${ac_cv_search_zlibVersion+set}" = set; then :
> -  break
> -fi
> -done
> -if test "${ac_cv_search_zlibVersion+set}" = set; then :
> +    conftest$ac_exeext conftest.$ac_ext
> +    LIBS="$ac_save_LIBS"
>  
> -else
> -  ac_cv_search_zlibVersion=no
> -fi
> -rm conftest.$ac_ext
> -LIBS=$ac_func_search_save_LIBS
>  fi
> -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_zlibVersion" >&5
> -$as_echo "$ac_cv_search_zlibVersion" >&6; }
> -ac_res=$ac_cv_search_zlibVersion
> -if test "$ac_res" != no; then :
> -  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
> -  for ac_header in zlib.h
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_libz" >&5
> +$as_echo "$ac_cv_libz" >&6; }
> +  if test "$ac_cv_libz" = yes; then
> +    HAVE_LIBZ=yes
> +
> +$as_echo "#define HAVE_LIBZ 1" >>confdefs.h
> +
> +    { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libz" >&5
> +$as_echo_n "checking how to link with libz... " >&6; }
> +    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBZ" >&5
> +$as_echo "$LIBZ" >&6; }
> +  else
> +    HAVE_LIBZ=no
> +            CPPFLAGS="$ac_save_CPPFLAGS"
> +    LIBZ=
> +    LTLIBZ=
> +  fi
> +
> +
> +
> +
> +
> +
> +    if test "$HAVE_LIBZ" = "yes"; then
> +      # Make sure HAVE_ZLIB_H gets defined.  Some code uses that over
> +      # HAVE_LIBZ, since initially we were only defining HAVE_ZLIB_H.
> +      for ac_header in zlib.h
>  do :
>    ac_fn_c_check_header_mongrel "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default"
>  if test "x$ac_cv_header_zlib_h" = x""yes; then :
> @@ -7027,9 +7606,9 @@ fi
>  
>  done
>  
> -fi
> -
> -    if test "$with_zlib" = "yes" -a "$ac_cv_header_zlib_h" != "yes"; then
> +      LIBS="$LIBS $LIBZ"
> +    fi
> +    if test "$with_zlib" = "yes" -a "$HAVE_LIBZ" != "yes"; then
>        as_fn_error "zlib (libz) library was explicitly requested but not found" "$LINENO" 5
>      fi
>    fi
> @@ -10623,7 +11202,7 @@ else
>    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>    lt_status=$lt_dlunknown
>    cat > conftest.$ac_ext <<_LT_EOF
> -#line 10626 "configure"
> +#line 11205 "configure"
>  #include "confdefs.h"
>  
>  #if HAVE_DLFCN_H
> @@ -10729,7 +11308,7 @@ else
>    lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
>    lt_status=$lt_dlunknown
>    cat > conftest.$ac_ext <<_LT_EOF
> -#line 10732 "configure"
> +#line 11311 "configure"
>  #include "confdefs.h"
>  
>  #if HAVE_DLFCN_H
> diff --git a/sim/ppc/config.in b/sim/ppc/config.in
> index b0c9e6f..32605bc 100644
> --- a/sim/ppc/config.in
> +++ b/sim/ppc/config.in
> @@ -106,6 +106,9 @@
>  /* Define to 1 if you have the `kill' function. */
>  #undef HAVE_KILL
>  
> +/* Define if you have the z library. */
> +#undef HAVE_LIBZ
> +
>  /* Define to 1 if you have the `link' function. */
>  #undef HAVE_LINK
>  
> diff --git a/sim/ppc/configure b/sim/ppc/configure
> index 5044383..6ec0fd0 100755
> --- a/sim/ppc/configure
> +++ b/sim/ppc/configure
> @@ -627,6 +627,9 @@ HDEFINES
>  CFLAGS_FOR_BUILD
>  CC_FOR_BUILD
>  LIBOBJS
> +LTLIBZ
> +LIBZ
> +HAVE_LIBZ
>  target_os
>  target_vendor
>  target_cpu
> @@ -767,6 +770,9 @@ enable_sim_xor_endian
>  with_pkgversion
>  with_bugurl
>  with_zlib
> +with_gnu_ld
> +enable_rpath
> +with_libz_prefix
>  enable_plugins
>  '
>        ac_precious_vars='build_alias
> @@ -1431,6 +1437,7 @@ Optional Features:
>    --enable-sim-trace			Specify whether tracing is supported.
>    --enable-sim-warnings=opts		Extra CFLAGS for turning on compiler warnings except for idecode.o, semantics.o and psim.o
>    --enable-sim-xor-endian=n		Specify number bytes involved in PowerPC XOR bi-endian mode (default 8).
> +  --disable-rpath         do not hardcode runtime library paths
>    --enable-plugins        Enable support for plugins
>  
>  Optional Packages:
> @@ -1439,6 +1446,9 @@ Optional Packages:
>    --with-pkgversion=PKG   Use PKG in the version string in place of "GDB"
>    --with-bugurl=URL       Direct users to URL to report a bug
>    --with-zlib             include zlib support (auto/yes/no) default=auto
> +  --with-gnu-ld           assume the C compiler uses GNU ld default=no
> +  --with-libz-prefix[=DIR]  search for libz in DIR/include and DIR/lib
> +  --without-libz-prefix     don't search for libz in includedir and libdir
>  
>  Some influential environment variables:
>    CC          C compiler command
> @@ -2448,6 +2458,37 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
>  
>  
>  
> +# lib-ld.m4 serial 2 (gettext-0.12)
> +
> +
> +
> +
> +
> +
> +# lib-link.m4 serial 4 (gettext-0.12)
> +
> +
> +
> +
> +
> +
> +
> +
> +
> +
> +
> +
> +# lib-prefix.m4 serial 2 (gettext-0.12)
> +
> +
> +
> +
> +
> +
> +
> +
> +
> +
>  
>  
>  
> @@ -6817,6 +6858,164 @@ program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"`
>  # BFD conditionally uses zlib, so we must link it in if libbfd does, by
>  # using the same condition.
>  
> +      if test "X$prefix" = "XNONE"; then
> +    acl_final_prefix="$ac_default_prefix"
> +  else
> +    acl_final_prefix="$prefix"
> +  fi
> +  if test "X$exec_prefix" = "XNONE"; then
> +    acl_final_exec_prefix='${prefix}'
> +  else
> +    acl_final_exec_prefix="$exec_prefix"
> +  fi
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
> +  prefix="$acl_save_prefix"
> +
> +
> +# Check whether --with-gnu-ld was given.
> +if test "${with_gnu_ld+set}" = set; then :
> +  withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
> +else
> +  with_gnu_ld=no
> +fi
> +
> +# Prepare PATH_SEPARATOR.
> +# The user is always right.
> +if test "${PATH_SEPARATOR+set}" != set; then
> +  echo "#! /bin/sh" >conf$$.sh
> +  echo  "exit 0"   >>conf$$.sh
> +  chmod +x conf$$.sh
> +  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
> +    PATH_SEPARATOR=';'
> +  else
> +    PATH_SEPARATOR=:
> +  fi
> +  rm -f conf$$.sh
> +fi
> +ac_prog=ld
> +if test "$GCC" = yes; then
> +  # Check if gcc -print-prog-name=ld gives a path.
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by GCC" >&5
> +$as_echo_n "checking for ld used by GCC... " >&6; }
> +  case $host in
> +  *-*-mingw*)
> +    # gcc leaves a trailing carriage return which upsets mingw
> +    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
> +  *)
> +    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
> +  esac
> +  case $ac_prog in
> +    # Accept absolute paths.
> +    [\\/]* | [A-Za-z]:[\\/]*)
> +      re_direlt='/[^/][^/]*/\.\./'
> +      # Canonicalize the path of ld
> +      ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
> +      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
> +	ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
> +      done
> +      test -z "$LD" && LD="$ac_prog"
> +      ;;
> +  "")
> +    # If it fails, then pretend we aren't using GCC.
> +    ac_prog=ld
> +    ;;
> +  *)
> +    # If it is relative, then search for the first ld in PATH.
> +    with_gnu_ld=unknown
> +    ;;
> +  esac
> +elif test "$with_gnu_ld" = yes; then
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
> +$as_echo_n "checking for GNU ld... " >&6; }
> +else
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
> +$as_echo_n "checking for non-GNU ld... " >&6; }
> +fi
> +if test "${acl_cv_path_LD+set}" = set; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +  if test -z "$LD"; then
> +  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
> +  for ac_dir in $PATH; do
> +    test -z "$ac_dir" && ac_dir=.
> +    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
> +      acl_cv_path_LD="$ac_dir/$ac_prog"
> +      # Check to see if the program is GNU ld.  I'd rather use --version,
> +      # but apparently some GNU ld's only accept -v.
> +      # Break only if it was the GNU/non-GNU ld that we prefer.
> +      if "$acl_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
> +	test "$with_gnu_ld" != no && break
> +      else
> +	test "$with_gnu_ld" != yes && break
> +      fi
> +    fi
> +  done
> +  IFS="$ac_save_ifs"
> +else
> +  acl_cv_path_LD="$LD" # Let the user override the test with a path.
> +fi
> +fi
> +
> +LD="$acl_cv_path_LD"
> +if test -n "$LD"; then
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
> +$as_echo "$LD" >&6; }
> +else
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
> +$as_echo "no" >&6; }
> +fi
> +test -z "$LD" && as_fn_error "no acceptable ld found in \$PATH" "$LINENO" 5
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
> +$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; }
> +if test "${acl_cv_prog_gnu_ld+set}" = set; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +  # I'd rather use --version here, but apparently some GNU ld's only accept -v.
> +if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
> +  acl_cv_prog_gnu_ld=yes
> +else
> +  acl_cv_prog_gnu_ld=no
> +fi
> +fi
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_prog_gnu_ld" >&5
> +$as_echo "$acl_cv_prog_gnu_ld" >&6; }
> +with_gnu_ld=$acl_cv_prog_gnu_ld
> +
> +
> +
> +                                                { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5
> +$as_echo_n "checking for shared library run path origin... " >&6; }
> +if test "${acl_cv_rpath+set}" = set; then :
> +  $as_echo_n "(cached) " >&6
> +else
> +
> +    CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
> +    ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
> +    . ./conftest.sh
> +    rm -f ./conftest.sh
> +    acl_cv_rpath=done
> +
> +fi
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_rpath" >&5
> +$as_echo "$acl_cv_rpath" >&6; }
> +  wl="$acl_cv_wl"
> +  libext="$acl_cv_libext"
> +  shlibext="$acl_cv_shlibext"
> +  hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
> +  hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
> +  hardcode_direct="$acl_cv_hardcode_direct"
> +  hardcode_minus_L="$acl_cv_hardcode_minus_L"
> +    # Check whether --enable-rpath was given.
> +if test "${enable_rpath+set}" = set; then :
> +  enableval=$enable_rpath; :
> +else
> +  enable_rpath=yes
> +fi
> +
> +
> +
>    # See if the user specified whether he wants zlib support or not.
>  
>  # Check whether --with-zlib was given.
> @@ -6828,60 +7027,472 @@ fi
>  
>  
>    if test "$with_zlib" != "no"; then
> -    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing zlibVersion" >&5
> -$as_echo_n "checking for library containing zlibVersion... " >&6; }
> -if test "${ac_cv_search_zlibVersion+set}" = set; then :
> +
> +
> +
> +
> +
> +
> +
> +
> +    use_additional=yes
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +
> +    eval additional_includedir=\"$includedir\"
> +    eval additional_libdir=\"$libdir\"
> +
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +
> +# Check whether --with-libz-prefix was given.
> +if test "${with_libz_prefix+set}" = set; then :
> +  withval=$with_libz_prefix;
> +    if test "X$withval" = "Xno"; then
> +      use_additional=no
> +    else
> +      if test "X$withval" = "X"; then
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +
> +          eval additional_includedir=\"$includedir\"
> +          eval additional_libdir=\"$libdir\"
> +
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +      else
> +        additional_includedir="$withval/include"
> +        additional_libdir="$withval/lib"
> +      fi
> +    fi
> +
> +fi
> +
> +      LIBZ=
> +  LTLIBZ=
> +  INCZ=
> +  rpathdirs=
> +  ltrpathdirs=
> +  names_already_handled=
> +  names_next_round='z '
> +  while test -n "$names_next_round"; do
> +    names_this_round="$names_next_round"
> +    names_next_round=
> +    for name in $names_this_round; do
> +      already_handled=
> +      for n in $names_already_handled; do
> +        if test "$n" = "$name"; then
> +          already_handled=yes
> +          break
> +        fi
> +      done
> +      if test -z "$already_handled"; then
> +        names_already_handled="$names_already_handled $name"
> +                        uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
> +        eval value=\"\$HAVE_LIB$uppername\"
> +        if test -n "$value"; then
> +          if test "$value" = yes; then
> +            eval value=\"\$LIB$uppername\"
> +            test -z "$value" || LIBZ="${LIBZ}${LIBZ:+ }$value"
> +            eval value=\"\$LTLIB$uppername\"
> +            test -z "$value" || LTLIBZ="${LTLIBZ}${LTLIBZ:+ }$value"
> +          else
> +                                    :
> +          fi
> +        else
> +                              found_dir=
> +          found_la=
> +          found_so=
> +          found_a=
> +          if test $use_additional = yes; then
> +            if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then
> +              found_dir="$additional_libdir"
> +              found_so="$additional_libdir/lib$name.$shlibext"
> +              if test -f "$additional_libdir/lib$name.la"; then
> +                found_la="$additional_libdir/lib$name.la"
> +              fi
> +            else
> +              if test -f "$additional_libdir/lib$name.$libext"; then
> +                found_dir="$additional_libdir"
> +                found_a="$additional_libdir/lib$name.$libext"
> +                if test -f "$additional_libdir/lib$name.la"; then
> +                  found_la="$additional_libdir/lib$name.la"
> +                fi
> +              fi
> +            fi
> +          fi
> +          if test "X$found_dir" = "X"; then
> +            for x in $LDFLAGS $LTLIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +              case "$x" in
> +                -L*)
> +                  dir=`echo "X$x" | sed -e 's/^X-L//'`
> +                  if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then
> +                    found_dir="$dir"
> +                    found_so="$dir/lib$name.$shlibext"
> +                    if test -f "$dir/lib$name.la"; then
> +                      found_la="$dir/lib$name.la"
> +                    fi
> +                  else
> +                    if test -f "$dir/lib$name.$libext"; then
> +                      found_dir="$dir"
> +                      found_a="$dir/lib$name.$libext"
> +                      if test -f "$dir/lib$name.la"; then
> +                        found_la="$dir/lib$name.la"
> +                      fi
> +                    fi
> +                  fi
> +                  ;;
> +              esac
> +              if test "X$found_dir" != "X"; then
> +                break
> +              fi
> +            done
> +          fi
> +          if test "X$found_dir" != "X"; then
> +                        LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-L$found_dir -l$name"
> +            if test "X$found_so" != "X"; then
> +                                                        if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then
> +                                LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +              else
> +                                                                                haveit=
> +                for x in $ltrpathdirs; do
> +                  if test "X$x" = "X$found_dir"; then
> +                    haveit=yes
> +                    break
> +                  fi
> +                done
> +                if test -z "$haveit"; then
> +                  ltrpathdirs="$ltrpathdirs $found_dir"
> +                fi
> +                                if test "$hardcode_direct" = yes; then
> +                                                      LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +                else
> +                  if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then
> +                                                            LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +                                                            haveit=
> +                    for x in $rpathdirs; do
> +                      if test "X$x" = "X$found_dir"; then
> +                        haveit=yes
> +                        break
> +                      fi
> +                    done
> +                    if test -z "$haveit"; then
> +                      rpathdirs="$rpathdirs $found_dir"
> +                    fi
> +                  else
> +                                                                                haveit=
> +                    for x in $LDFLAGS $LIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                      if test "X$x" = "X-L$found_dir"; then
> +                        haveit=yes
> +                        break
> +                      fi
> +                    done
> +                    if test -z "$haveit"; then
> +                      LIBZ="${LIBZ}${LIBZ:+ }-L$found_dir"
> +                    fi
> +                    if test "$hardcode_minus_L" != no; then
> +                                                                                        LIBZ="${LIBZ}${LIBZ:+ }$found_so"
> +                    else
> +                                                                                                                                                                                LIBZ="${LIBZ}${LIBZ:+ }-l$name"
> +                    fi
> +                  fi
> +                fi
> +              fi
> +            else
> +              if test "X$found_a" != "X"; then
> +                                LIBZ="${LIBZ}${LIBZ:+ }$found_a"
> +              else
> +                                                LIBZ="${LIBZ}${LIBZ:+ }-L$found_dir -l$name"
> +              fi
> +            fi
> +                        additional_includedir=
> +            case "$found_dir" in
> +              */lib | */lib/)
> +                basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'`
> +                additional_includedir="$basedir/include"
> +                ;;
> +            esac
> +            if test "X$additional_includedir" != "X"; then
> +                                                                                                                if test "X$additional_includedir" != "X/usr/include"; then
> +                haveit=
> +                if test "X$additional_includedir" = "X/usr/local/include"; then
> +                  if test -n "$GCC"; then
> +                    case $host_os in
> +                      linux*) haveit=yes;;
> +                    esac
> +                  fi
> +                fi
> +                if test -z "$haveit"; then
> +                  for x in $CPPFLAGS $INCZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                    if test "X$x" = "X-I$additional_includedir"; then
> +                      haveit=yes
> +                      break
> +                    fi
> +                  done
> +                  if test -z "$haveit"; then
> +                    if test -d "$additional_includedir"; then
> +                                            INCZ="${INCZ}${INCZ:+ }-I$additional_includedir"
> +                    fi
> +                  fi
> +                fi
> +              fi
> +            fi
> +                        if test -n "$found_la"; then
> +                                                        save_libdir="$libdir"
> +              case "$found_la" in
> +                */* | *\\*) . "$found_la" ;;
> +                *) . "./$found_la" ;;
> +              esac
> +              libdir="$save_libdir"
> +                            for dep in $dependency_libs; do
> +                case "$dep" in
> +                  -L*)
> +                    additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
> +                                                                                                                                                                if test "X$additional_libdir" != "X/usr/lib"; then
> +                      haveit=
> +                      if test "X$additional_libdir" = "X/usr/local/lib"; then
> +                        if test -n "$GCC"; then
> +                          case $host_os in
> +                            linux*) haveit=yes;;
> +                          esac
> +                        fi
> +                      fi
> +                      if test -z "$haveit"; then
> +                        haveit=
> +                        for x in $LDFLAGS $LIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                          if test "X$x" = "X-L$additional_libdir"; then
> +                            haveit=yes
> +                            break
> +                          fi
> +                        done
> +                        if test -z "$haveit"; then
> +                          if test -d "$additional_libdir"; then
> +                                                        LIBZ="${LIBZ}${LIBZ:+ }-L$additional_libdir"
> +                          fi
> +                        fi
> +                        haveit=
> +                        for x in $LDFLAGS $LTLIBZ; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +                          if test "X$x" = "X-L$additional_libdir"; then
> +                            haveit=yes
> +                            break
> +                          fi
> +                        done
> +                        if test -z "$haveit"; then
> +                          if test -d "$additional_libdir"; then
> +                                                        LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-L$additional_libdir"
> +                          fi
> +                        fi
> +                      fi
> +                    fi
> +                    ;;
> +                  -R*)
> +                    dir=`echo "X$dep" | sed -e 's/^X-R//'`
> +                    if test "$enable_rpath" != no; then
> +                                                                  haveit=
> +                      for x in $rpathdirs; do
> +                        if test "X$x" = "X$dir"; then
> +                          haveit=yes
> +                          break
> +                        fi
> +                      done
> +                      if test -z "$haveit"; then
> +                        rpathdirs="$rpathdirs $dir"
> +                      fi
> +                                                                  haveit=
> +                      for x in $ltrpathdirs; do
> +                        if test "X$x" = "X$dir"; then
> +                          haveit=yes
> +                          break
> +                        fi
> +                      done
> +                      if test -z "$haveit"; then
> +                        ltrpathdirs="$ltrpathdirs $dir"
> +                      fi
> +                    fi
> +                    ;;
> +                  -l*)
> +                                        names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
> +                    ;;
> +                  *.la)
> +                                                                                names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
> +                    ;;
> +                  *)
> +                                        LIBZ="${LIBZ}${LIBZ:+ }$dep"
> +                    LTLIBZ="${LTLIBZ}${LTLIBZ:+ }$dep"
> +                    ;;
> +                esac
> +              done
> +            fi
> +          else
> +                                                            LIBZ="${LIBZ}${LIBZ:+ }-l$name"
> +            LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-l$name"
> +          fi
> +        fi
> +      fi
> +    done
> +  done
> +  if test "X$rpathdirs" != "X"; then
> +    if test -n "$hardcode_libdir_separator"; then
> +                        alldirs=
> +      for found_dir in $rpathdirs; do
> +        alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir"
> +      done
> +            acl_save_libdir="$libdir"
> +      libdir="$alldirs"
> +      eval flag=\"$hardcode_libdir_flag_spec\"
> +      libdir="$acl_save_libdir"
> +      LIBZ="${LIBZ}${LIBZ:+ }$flag"
> +    else
> +            for found_dir in $rpathdirs; do
> +        acl_save_libdir="$libdir"
> +        libdir="$found_dir"
> +        eval flag=\"$hardcode_libdir_flag_spec\"
> +        libdir="$acl_save_libdir"
> +        LIBZ="${LIBZ}${LIBZ:+ }$flag"
> +      done
> +    fi
> +  fi
> +  if test "X$ltrpathdirs" != "X"; then
> +            for found_dir in $ltrpathdirs; do
> +      LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-R$found_dir"
> +    done
> +  fi
> +
> +
> +        ac_save_CPPFLAGS="$CPPFLAGS"
> +
> +  for element in $INCZ; do
> +    haveit=
> +    for x in $CPPFLAGS; do
> +
> +  acl_save_prefix="$prefix"
> +  prefix="$acl_final_prefix"
> +  acl_save_exec_prefix="$exec_prefix"
> +  exec_prefix="$acl_final_exec_prefix"
> +  eval x=\"$x\"
> +  exec_prefix="$acl_save_exec_prefix"
> +  prefix="$acl_save_prefix"
> +
> +      if test "X$x" = "X$element"; then
> +        haveit=yes
> +        break
> +      fi
> +    done
> +    if test -z "$haveit"; then
> +      CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element"
> +    fi
> +  done
> +
> +
> +  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libz" >&5
> +$as_echo_n "checking for libz... " >&6; }
> +if test "${ac_cv_libz+set}" = set; then :
>    $as_echo_n "(cached) " >&6
>  else
> -  ac_func_search_save_LIBS=$LIBS
> -cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> -/* end confdefs.h.  */
>  
> -/* Override any GCC internal prototype to avoid an error.
> -   Use char because int might match the return type of a GCC
> -   builtin and then its argument prototype would still apply.  */
> -#ifdef __cplusplus
> -extern "C"
> -#endif
> -char zlibVersion ();
> +    ac_save_LIBS="$LIBS"
> +    LIBS="$LIBS $LIBZ"
> +    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
> +/* end confdefs.h.  */
> +#include "zlib.h";
>  int
>  main ()
>  {
> -return zlibVersion ();
> +int ret = deflateInit(NULL, 1);
>    ;
>    return 0;
>  }
>  _ACEOF
> -for ac_lib in '' z; do
> -  if test -z "$ac_lib"; then
> -    ac_res="none required"
> -  else
> -    ac_res=-l$ac_lib
> -    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
> -  fi
> -  if ac_fn_c_try_link "$LINENO"; then :
> -  ac_cv_search_zlibVersion=$ac_res
> +if ac_fn_c_try_link "$LINENO"; then :
> +  ac_cv_libz=yes
> +else
> +  ac_cv_libz=no
>  fi
>  rm -f core conftest.err conftest.$ac_objext \
> -    conftest$ac_exeext
> -  if test "${ac_cv_search_zlibVersion+set}" = set; then :
> -  break
> -fi
> -done
> -if test "${ac_cv_search_zlibVersion+set}" = set; then :
> +    conftest$ac_exeext conftest.$ac_ext
> +    LIBS="$ac_save_LIBS"
>  
> -else
> -  ac_cv_search_zlibVersion=no
> -fi
> -rm conftest.$ac_ext
> -LIBS=$ac_func_search_save_LIBS
>  fi
> -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_zlibVersion" >&5
> -$as_echo "$ac_cv_search_zlibVersion" >&6; }
> -ac_res=$ac_cv_search_zlibVersion
> -if test "$ac_res" != no; then :
> -  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
> -  for ac_header in zlib.h
> +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_libz" >&5
> +$as_echo "$ac_cv_libz" >&6; }
> +  if test "$ac_cv_libz" = yes; then
> +    HAVE_LIBZ=yes
> +
> +$as_echo "#define HAVE_LIBZ 1" >>confdefs.h
> +
> +    { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libz" >&5
> +$as_echo_n "checking how to link with libz... " >&6; }
> +    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBZ" >&5
> +$as_echo "$LIBZ" >&6; }
> +  else
> +    HAVE_LIBZ=no
> +            CPPFLAGS="$ac_save_CPPFLAGS"
> +    LIBZ=
> +    LTLIBZ=
> +  fi
> +
> +
> +
> +
> +
> +
> +    if test "$HAVE_LIBZ" = "yes"; then
> +      # Make sure HAVE_ZLIB_H gets defined.  Some code uses that over
> +      # HAVE_LIBZ, since initially we were only defining HAVE_ZLIB_H.
> +      for ac_header in zlib.h
>  do :
>    ac_fn_c_check_header_mongrel "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default"
>  if test "x$ac_cv_header_zlib_h" = x""yes; then :
> @@ -6893,9 +7504,9 @@ fi
>  
>  done
>  
> -fi
> -
> -    if test "$with_zlib" = "yes" -a "$ac_cv_header_zlib_h" != "yes"; then
> +      LIBS="$LIBS $LIBZ"
> +    fi
> +    if test "$with_zlib" = "yes" -a "$HAVE_LIBZ" != "yes"; then
>        as_fn_error "zlib (libz) library was explicitly requested but not found" "$LINENO" 5
>      fi
>    fi
> -- 
> 1.9.1
>
  
H.J. Lu Feb. 18, 2015, 12:56 p.m. UTC | #8
On Wed, Feb 18, 2015 at 4:08 AM, Joel Brobecker <brobecker@adacore.com> wrote:
> Yay? Nay?
>
> Thank you.
>
> On Wed, Jan 07, 2015 at 06:45:48PM +0400, Joel Brobecker wrote:
>> Hello,
>>
>> This patch enhances config/zlib.m4 to introduce an extra option
>> --with-libz-prefix which allows us to provide the location of
>> the zlib library we want to use during the build.
>>
>> config/ChangeLog:
>>
>>         * zlib.m4 (AM_ZLIB): Add --with-libz-prefix option support.
>>
>> I didn't see any file in the GCC project that uses this macro,
>> so for the GCC repository, the change to zlib.m4 is it. But
>> I am also attaching to this email a copy of the patch that
>> will be applied to the binutils-gdb.git repository, with all
>> configury using this macro being re-generated - mostly for info,
>> also as a heads-up to both binutils and GDB.
>>
>> This was tested by regenerating all autoconf/automake files in
>> the binutils-gdb project, and rebuilding GDB, using the following
>> combinations:
>>
>>   --with-zlib (system zlib used)
>>   --with-libz-prefix=/zlib/prefix (specific zlib linked in)
>>   --with-zlib --with-libz-prefix=/zlib/prefix (specific zlib linked in)
>>
>>   --without-zlib (zlib support turned off)
>>   --without-zlib --with-zlib-prefix (zlib support turned off)
>>
>>   --with-zlib (no system zlib available, configure fails with expected error)
>>   --with-zlib --with-libz-prefix=/invalid/zlib/prefix
>>               (no system zlib, configure fails with same error)
>>
>> OK to commit?

Why do you want to turn off zlib? On Linux/x86,  zlib is required
for assembler.  At least, you should issue an error when --without-libz
is used in binutils for Linux/x86 target.

I guess someone has asked it before.  Why can't zlib be made the
same as

  --with-mpc=PATH         specify prefix directory for installed MPC package.
                          Equivalent to --with-mpc-include=PATH/include plus
                          --with-mpc-lib=PATH/lib
  --with-mpc-include=PATH specify directory for installed MPC include files
  --with-mpc-lib=PATH     specify directory for the installed MPC library

It is more flexible than your patch.  If you have some existing packages
which use your scheme, you can translate the configure command line
options to this one.
  
Mike Frysinger Feb. 18, 2015, 4:54 p.m. UTC | #9
On 18 Feb 2015 04:56, H.J. Lu wrote:
> On Wed, Feb 18, 2015 at 4:08 AM, Joel Brobecker <brobecker@adacore.com> wrote:
> > On Wed, Jan 07, 2015 at 06:45:48PM +0400, Joel Brobecker wrote:
> >> This patch enhances config/zlib.m4 to introduce an extra option
> >> --with-libz-prefix which allows us to provide the location of
> >> the zlib library we want to use during the build.
> >>
> >> config/ChangeLog:
> >>
> >>         * zlib.m4 (AM_ZLIB): Add --with-libz-prefix option support.
> >>
> >> I didn't see any file in the GCC project that uses this macro,
> >> so for the GCC repository, the change to zlib.m4 is it. But
> >> I am also attaching to this email a copy of the patch that
> >> will be applied to the binutils-gdb.git repository, with all
> >> configury using this macro being re-generated - mostly for info,
> >> also as a heads-up to both binutils and GDB.
> >>
> >> This was tested by regenerating all autoconf/automake files in
> >> the binutils-gdb project, and rebuilding GDB, using the following
> >> combinations:
> >>
> >>   --with-zlib (system zlib used)
> >>   --with-libz-prefix=/zlib/prefix (specific zlib linked in)
> >>   --with-zlib --with-libz-prefix=/zlib/prefix (specific zlib linked in)
> >>
> >>   --without-zlib (zlib support turned off)
> >>   --without-zlib --with-zlib-prefix (zlib support turned off)
> >>
> >>   --with-zlib (no system zlib available, configure fails with expected error)
> >>   --with-zlib --with-libz-prefix=/invalid/zlib/prefix
> >>               (no system zlib, configure fails with same error)
> >>
> >> OK to commit?
> 
> Why do you want to turn off zlib? On Linux/x86,  zlib is required
> for assembler.  At least, you should issue an error when --without-libz
> is used in binutils for Linux/x86 target.

err, when did that happen ?  why would zlib be possibly required for an 
assembler ?
-mike
  
H.J. Lu Feb. 18, 2015, 4:58 p.m. UTC | #10
On Wed, Feb 18, 2015 at 8:54 AM, Mike Frysinger <vapier@gentoo.org> wrote:
> On 18 Feb 2015 04:56, H.J. Lu wrote:
>> On Wed, Feb 18, 2015 at 4:08 AM, Joel Brobecker <brobecker@adacore.com> wrote:
>> > On Wed, Jan 07, 2015 at 06:45:48PM +0400, Joel Brobecker wrote:
>> >> This patch enhances config/zlib.m4 to introduce an extra option
>> >> --with-libz-prefix which allows us to provide the location of
>> >> the zlib library we want to use during the build.
>> >>
>> >> config/ChangeLog:
>> >>
>> >>         * zlib.m4 (AM_ZLIB): Add --with-libz-prefix option support.
>> >>
>> >> I didn't see any file in the GCC project that uses this macro,
>> >> so for the GCC repository, the change to zlib.m4 is it. But
>> >> I am also attaching to this email a copy of the patch that
>> >> will be applied to the binutils-gdb.git repository, with all
>> >> configury using this macro being re-generated - mostly for info,
>> >> also as a heads-up to both binutils and GDB.
>> >>
>> >> This was tested by regenerating all autoconf/automake files in
>> >> the binutils-gdb project, and rebuilding GDB, using the following
>> >> combinations:
>> >>
>> >>   --with-zlib (system zlib used)
>> >>   --with-libz-prefix=/zlib/prefix (specific zlib linked in)
>> >>   --with-zlib --with-libz-prefix=/zlib/prefix (specific zlib linked in)
>> >>
>> >>   --without-zlib (zlib support turned off)
>> >>   --without-zlib --with-zlib-prefix (zlib support turned off)
>> >>
>> >>   --with-zlib (no system zlib available, configure fails with expected error)
>> >>   --with-zlib --with-libz-prefix=/invalid/zlib/prefix
>> >>               (no system zlib, configure fails with same error)
>> >>
>> >> OK to commit?
>>
>> Why do you want to turn off zlib? On Linux/x86,  zlib is required
>> for assembler.  At least, you should issue an error when --without-libz
>> is used in binutils for Linux/x86 target.
>
> err, when did that happen ?  why would zlib be possibly required for an
> assembler ?
> -mike

commit 89e7505fcde4bd83948f559f429a0e1eb4262f05
Author: H.J. Lu <hjl.tools@gmail.com>
Date:   Sun Dec 14 06:41:03 2014 -0800

    Compress debug sections for Linux/x86 by default

      * config/tc-i386.c (flag_compress_debug): Default to compress
      debug sections for Linux.
  
Joel Sherrill Feb. 18, 2015, 5 p.m. UTC | #11
On 2/18/2015 10:54 AM, Mike Frysinger wrote:
> On 18 Feb 2015 04:56, H.J. Lu wrote:
>> On Wed, Feb 18, 2015 at 4:08 AM, Joel Brobecker <brobecker@adacore.com> wrote:
>>> On Wed, Jan 07, 2015 at 06:45:48PM +0400, Joel Brobecker wrote:
>>>> This patch enhances config/zlib.m4 to introduce an extra option
>>>> --with-libz-prefix which allows us to provide the location of
>>>> the zlib library we want to use during the build.
>>>>
>>>> config/ChangeLog:
>>>>
>>>>         * zlib.m4 (AM_ZLIB): Add --with-libz-prefix option support.
>>>>
>>>> I didn't see any file in the GCC project that uses this macro,
>>>> so for the GCC repository, the change to zlib.m4 is it. But
>>>> I am also attaching to this email a copy of the patch that
>>>> will be applied to the binutils-gdb.git repository, with all
>>>> configury using this macro being re-generated - mostly for info,
>>>> also as a heads-up to both binutils and GDB.
>>>>
>>>> This was tested by regenerating all autoconf/automake files in
>>>> the binutils-gdb project, and rebuilding GDB, using the following
>>>> combinations:
>>>>
>>>>   --with-zlib (system zlib used)
>>>>   --with-libz-prefix=/zlib/prefix (specific zlib linked in)
>>>>   --with-zlib --with-libz-prefix=/zlib/prefix (specific zlib linked in)
>>>>
>>>>   --without-zlib (zlib support turned off)
>>>>   --without-zlib --with-zlib-prefix (zlib support turned off)
>>>>
>>>>   --with-zlib (no system zlib available, configure fails with expected error)
>>>>   --with-zlib --with-libz-prefix=/invalid/zlib/prefix
>>>>               (no system zlib, configure fails with same error)
>>>>
>>>> OK to commit?
>> Why do you want to turn off zlib? On Linux/x86,  zlib is required
>> for assembler.  At least, you should issue an error when --without-libz
>> is used in binutils for Linux/x86 target.
> err, when did that happen ?  why would zlib be possibly required for an 
> assembler ?

Is there going to be a configure error when the system does not have zlib
and no argument is specified?

This is a common issue for people building tools for RTEMS for the first
time.
> -mike
  
Mike Frysinger Feb. 18, 2015, 7:44 p.m. UTC | #12
On 18 Feb 2015 08:58, H.J. Lu wrote:
> On Wed, Feb 18, 2015 at 8:54 AM, Mike Frysinger wrote:
> > On 18 Feb 2015 04:56, H.J. Lu wrote:
> >> On Wed, Feb 18, 2015 at 4:08 AM, Joel Brobecker wrote:
> >> > On Wed, Jan 07, 2015 at 06:45:48PM +0400, Joel Brobecker wrote:
> >> >> This patch enhances config/zlib.m4 to introduce an extra option
> >> >> --with-libz-prefix which allows us to provide the location of
> >> >> the zlib library we want to use during the build.
> >> >>
> >> >> config/ChangeLog:
> >> >>
> >> >>         * zlib.m4 (AM_ZLIB): Add --with-libz-prefix option support.
> >> >>
> >> >> I didn't see any file in the GCC project that uses this macro,
> >> >> so for the GCC repository, the change to zlib.m4 is it. But
> >> >> I am also attaching to this email a copy of the patch that
> >> >> will be applied to the binutils-gdb.git repository, with all
> >> >> configury using this macro being re-generated - mostly for info,
> >> >> also as a heads-up to both binutils and GDB.
> >> >>
> >> >> This was tested by regenerating all autoconf/automake files in
> >> >> the binutils-gdb project, and rebuilding GDB, using the following
> >> >> combinations:
> >> >>
> >> >>   --with-zlib (system zlib used)
> >> >>   --with-libz-prefix=/zlib/prefix (specific zlib linked in)
> >> >>   --with-zlib --with-libz-prefix=/zlib/prefix (specific zlib linked in)
> >> >>
> >> >>   --without-zlib (zlib support turned off)
> >> >>   --without-zlib --with-zlib-prefix (zlib support turned off)
> >> >>
> >> >>   --with-zlib (no system zlib available, configure fails with expected error)
> >> >>   --with-zlib --with-libz-prefix=/invalid/zlib/prefix
> >> >>               (no system zlib, configure fails with same error)
> >> >>
> >> >> OK to commit?
> >>
> >> Why do you want to turn off zlib? On Linux/x86,  zlib is required
> >> for assembler.  At least, you should issue an error when --without-libz
> >> is used in binutils for Linux/x86 target.
> >
> > err, when did that happen ?  why would zlib be possibly required for an
> > assembler ?
> 
> commit 89e7505fcde4bd83948f559f429a0e1eb4262f05
> Author: H.J. Lu <hjl.tools@gmail.com>
> Date:   Sun Dec 14 06:41:03 2014 -0800
> 
>     Compress debug sections for Linux/x86 by default
> 
>       * config/tc-i386.c (flag_compress_debug): Default to compress
>       debug sections for Linux.

i don't see how that justifies making it a hard requirement
-mike
  
H.J. Lu Feb. 18, 2015, 7:52 p.m. UTC | #13
On Wed, Feb 18, 2015 at 11:44 AM, Mike Frysinger <vapier@gentoo.org> wrote:
> On 18 Feb 2015 08:58, H.J. Lu wrote:
>> On Wed, Feb 18, 2015 at 8:54 AM, Mike Frysinger wrote:
>> > On 18 Feb 2015 04:56, H.J. Lu wrote:
>> >> On Wed, Feb 18, 2015 at 4:08 AM, Joel Brobecker wrote:
>> >> > On Wed, Jan 07, 2015 at 06:45:48PM +0400, Joel Brobecker wrote:
>> >> >> This patch enhances config/zlib.m4 to introduce an extra option
>> >> >> --with-libz-prefix which allows us to provide the location of
>> >> >> the zlib library we want to use during the build.
>> >> >>
>> >> >> config/ChangeLog:
>> >> >>
>> >> >>         * zlib.m4 (AM_ZLIB): Add --with-libz-prefix option support.
>> >> >>
>> >> >> I didn't see any file in the GCC project that uses this macro,
>> >> >> so for the GCC repository, the change to zlib.m4 is it. But
>> >> >> I am also attaching to this email a copy of the patch that
>> >> >> will be applied to the binutils-gdb.git repository, with all
>> >> >> configury using this macro being re-generated - mostly for info,
>> >> >> also as a heads-up to both binutils and GDB.
>> >> >>
>> >> >> This was tested by regenerating all autoconf/automake files in
>> >> >> the binutils-gdb project, and rebuilding GDB, using the following
>> >> >> combinations:
>> >> >>
>> >> >>   --with-zlib (system zlib used)
>> >> >>   --with-libz-prefix=/zlib/prefix (specific zlib linked in)
>> >> >>   --with-zlib --with-libz-prefix=/zlib/prefix (specific zlib linked in)
>> >> >>
>> >> >>   --without-zlib (zlib support turned off)
>> >> >>   --without-zlib --with-zlib-prefix (zlib support turned off)
>> >> >>
>> >> >>   --with-zlib (no system zlib available, configure fails with expected error)
>> >> >>   --with-zlib --with-libz-prefix=/invalid/zlib/prefix
>> >> >>               (no system zlib, configure fails with same error)
>> >> >>
>> >> >> OK to commit?
>> >>
>> >> Why do you want to turn off zlib? On Linux/x86,  zlib is required
>> >> for assembler.  At least, you should issue an error when --without-libz
>> >> is used in binutils for Linux/x86 target.
>> >
>> > err, when did that happen ?  why would zlib be possibly required for an
>> > assembler ?
>>
>> commit 89e7505fcde4bd83948f559f429a0e1eb4262f05
>> Author: H.J. Lu <hjl.tools@gmail.com>
>> Date:   Sun Dec 14 06:41:03 2014 -0800
>>
>>     Compress debug sections for Linux/x86 by default
>>
>>       * config/tc-i386.c (flag_compress_debug): Default to compress
>>       debug sections for Linux.
>
> i don't see how that justifies making it a hard requirement
> -mike

Can you elaborate?
  
Mark Wielaard Feb. 18, 2015, 8:32 p.m. UTC | #14
On Wed, 2015-02-18 at 11:52 -0800, H.J. Lu wrote:
> On Wed, Feb 18, 2015 at 11:44 AM, Mike Frysinger <vapier@gentoo.org> wrote:
> > On 18 Feb 2015 08:58, H.J. Lu wrote:
> >> On Wed, Feb 18, 2015 at 8:54 AM, Mike Frysinger wrote:
> >> >> Why do you want to turn off zlib? On Linux/x86,  zlib is required
> >> >> for assembler.  At least, you should issue an error when --without-libz
> >> >> is used in binutils for Linux/x86 target.
> >> >
> >> > err, when did that happen ?  why would zlib be possibly required for an
> >> > assembler ?
> >>
> >> commit 89e7505fcde4bd83948f559f429a0e1eb4262f05
> >> Author: H.J. Lu <hjl.tools@gmail.com>
> >> Date:   Sun Dec 14 06:41:03 2014 -0800
> >>
> >>     Compress debug sections for Linux/x86 by default
> >>
> >>       * config/tc-i386.c (flag_compress_debug): Default to compress
> >>       debug sections for Linux.
> >
> > i don't see how that justifies making it a hard requirement
> 
> Can you elaborate?

That doesn't seem like a smart default. And why is is Linux/x86 only?
Shouldn't that be something that is done explicitly by a distro
configuring binutils after making sure it actually is beneficial
(debuginfo is often compressed in a different way, on the package/file
level or with dwz). And after making sure all tools actually work with
it? There are various tools that don't handle the .zdebug format like
valgrind. And at least elfutils has trouble with it for ET_REL files,
like kernel modules, because relocations don't actually apply anymore to
the section data as is (but only after the decompression).

Cheers,

Mark
  
Jakub Jelinek Feb. 18, 2015, 8:41 p.m. UTC | #15
On Wed, Feb 18, 2015 at 09:32:21PM +0100, Mark Wielaard wrote:
> > Can you elaborate?
> 
> That doesn't seem like a smart default. And why is is Linux/x86 only?
> Shouldn't that be something that is done explicitly by a distro
> configuring binutils after making sure it actually is beneficial
> (debuginfo is often compressed in a different way, on the package/file
> level or with dwz). And after making sure all tools actually work with

Yeah, dwz doesn't handle those, I think debugedit used by rpm doesn't
either.  When stripping into files, it would seem to be smarter to just
compress the separate debug files rather than compressing individual
sections anyway.

	Jakub
  
H.J. Lu Feb. 18, 2015, 8:53 p.m. UTC | #16
On Wed, Feb 18, 2015 at 12:32 PM, Mark Wielaard <mjw@redhat.com> wrote:
> On Wed, 2015-02-18 at 11:52 -0800, H.J. Lu wrote:
>> On Wed, Feb 18, 2015 at 11:44 AM, Mike Frysinger <vapier@gentoo.org> wrote:
>> > On 18 Feb 2015 08:58, H.J. Lu wrote:
>> >> On Wed, Feb 18, 2015 at 8:54 AM, Mike Frysinger wrote:
>> >> >> Why do you want to turn off zlib? On Linux/x86,  zlib is required
>> >> >> for assembler.  At least, you should issue an error when --without-libz
>> >> >> is used in binutils for Linux/x86 target.
>> >> >
>> >> > err, when did that happen ?  why would zlib be possibly required for an
>> >> > assembler ?
>> >>
>> >> commit 89e7505fcde4bd83948f559f429a0e1eb4262f05
>> >> Author: H.J. Lu <hjl.tools@gmail.com>
>> >> Date:   Sun Dec 14 06:41:03 2014 -0800
>> >>
>> >>     Compress debug sections for Linux/x86 by default
>> >>
>> >>       * config/tc-i386.c (flag_compress_debug): Default to compress
>> >>       debug sections for Linux.
>> >
>> > i don't see how that justifies making it a hard requirement
>>
>> Can you elaborate?
>
> That doesn't seem like a smart default. And why is is Linux/x86 only?
> Shouldn't that be something that is done explicitly by a distro
> configuring binutils after making sure it actually is beneficial
> (debuginfo is often compressed in a different way, on the package/file
> level or with dwz). And after making sure all tools actually work with
> it? There are various tools that don't handle the .zdebug format like
> valgrind. And at least elfutils has trouble with it for ET_REL files,
> like kernel modules, because relocations don't actually apply anymore to
> the section data as is (but only after the decompression).
>

Now it becomes a monthly topic:

https://sourceware.org/ml/binutils/2015-01/msg00089.html
  
Mark Wielaard Feb. 18, 2015, 9:40 p.m. UTC | #17
On Wed, 2015-02-18 at 12:53 -0800, H.J. Lu wrote:
> On Wed, Feb 18, 2015 at 12:32 PM, Mark Wielaard <mjw@redhat.com> wrote:
> > That doesn't seem like a smart default. And why is is Linux/x86 only?
> > Shouldn't that be something that is done explicitly by a distro
> > configuring binutils after making sure it actually is beneficial
> > (debuginfo is often compressed in a different way, on the package/file
> > level or with dwz). And after making sure all tools actually work with
> > it? There are various tools that don't handle the .zdebug format like
> > valgrind. And at least elfutils has trouble with it for ET_REL files,
> > like kernel modules, because relocations don't actually apply anymore to
> > the section data as is (but only after the decompression).
> 
> Now it becomes a monthly topic:
> 
> https://sourceware.org/ml/binutils/2015-01/msg00089.html

Thanks, I hadn't seen that before. Alan Modra makes some good points in
that thread why it is not a good change:
https://sourceware.org/ml/binutils/2015-01/msg00135.html
Do people agree with that? And/Or can the change be reverted for now
till there is agreement it is a desirable default?

Thanks,

Mark
  
H.J. Lu Feb. 18, 2015, 9:54 p.m. UTC | #18
On Wed, Feb 18, 2015 at 1:40 PM, Mark Wielaard <mjw@redhat.com> wrote:
> On Wed, 2015-02-18 at 12:53 -0800, H.J. Lu wrote:
>> On Wed, Feb 18, 2015 at 12:32 PM, Mark Wielaard <mjw@redhat.com> wrote:
>> > That doesn't seem like a smart default. And why is is Linux/x86 only?
>> > Shouldn't that be something that is done explicitly by a distro
>> > configuring binutils after making sure it actually is beneficial
>> > (debuginfo is often compressed in a different way, on the package/file
>> > level or with dwz). And after making sure all tools actually work with
>> > it? There are various tools that don't handle the .zdebug format like
>> > valgrind. And at least elfutils has trouble with it for ET_REL files,
>> > like kernel modules, because relocations don't actually apply anymore to
>> > the section data as is (but only after the decompression).
>>
>> Now it becomes a monthly topic:
>>
>> https://sourceware.org/ml/binutils/2015-01/msg00089.html
>
> Thanks, I hadn't seen that before. Alan Modra makes some good points in
> that thread why it is not a good change:
> https://sourceware.org/ml/binutils/2015-01/msg00135.html
> Do people agree with that? And/Or can the change be reverted for now
> till there is agreement it is a desirable default?
>

It may not be a good idea for all targets.  If you find an issue
on Linux/x86, please file a bug binutils report.

Thanks.
  
Mike Frysinger Feb. 18, 2015, 10:21 p.m. UTC | #19
On 18 Feb 2015 13:54, H.J. Lu wrote:
> On Wed, Feb 18, 2015 at 1:40 PM, Mark Wielaard wrote:
> > On Wed, 2015-02-18 at 12:53 -0800, H.J. Lu wrote:
> >> On Wed, Feb 18, 2015 at 12:32 PM, Mark Wielaard wrote:
> >> > That doesn't seem like a smart default. And why is is Linux/x86 only?
> >> > Shouldn't that be something that is done explicitly by a distro
> >> > configuring binutils after making sure it actually is beneficial
> >> > (debuginfo is often compressed in a different way, on the package/file
> >> > level or with dwz). And after making sure all tools actually work with
> >> > it? There are various tools that don't handle the .zdebug format like
> >> > valgrind. And at least elfutils has trouble with it for ET_REL files,
> >> > like kernel modules, because relocations don't actually apply anymore to
> >> > the section data as is (but only after the decompression).
> >>
> >> Now it becomes a monthly topic:
> >>
> >> https://sourceware.org/ml/binutils/2015-01/msg00089.html
> >
> > Thanks, I hadn't seen that before. Alan Modra makes some good points in
> > that thread why it is not a good change:
> > https://sourceware.org/ml/binutils/2015-01/msg00135.html
> > Do people agree with that? And/Or can the change be reverted for now
> > till there is agreement it is a desirable default?
> 
> It may not be a good idea for all targets.  If you find an issue
> on Linux/x86, please file a bug binutils report.

i think we already have the reports: multiple people don't think it should be 
(1) x86-specific or (2) required.  don't get me wrong -- i think having support 
like this is great.  that doesn't mean we should be forcing it.
-mike
  
H.J. Lu Feb. 18, 2015, 10:24 p.m. UTC | #20
On Wed, Feb 18, 2015 at 2:21 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> On 18 Feb 2015 13:54, H.J. Lu wrote:
>> On Wed, Feb 18, 2015 at 1:40 PM, Mark Wielaard wrote:
>> > On Wed, 2015-02-18 at 12:53 -0800, H.J. Lu wrote:
>> >> On Wed, Feb 18, 2015 at 12:32 PM, Mark Wielaard wrote:
>> >> > That doesn't seem like a smart default. And why is is Linux/x86 only?
>> >> > Shouldn't that be something that is done explicitly by a distro
>> >> > configuring binutils after making sure it actually is beneficial
>> >> > (debuginfo is often compressed in a different way, on the package/file
>> >> > level or with dwz). And after making sure all tools actually work with
>> >> > it? There are various tools that don't handle the .zdebug format like
>> >> > valgrind. And at least elfutils has trouble with it for ET_REL files,
>> >> > like kernel modules, because relocations don't actually apply anymore to
>> >> > the section data as is (but only after the decompression).
>> >>
>> >> Now it becomes a monthly topic:
>> >>
>> >> https://sourceware.org/ml/binutils/2015-01/msg00089.html
>> >
>> > Thanks, I hadn't seen that before. Alan Modra makes some good points in
>> > that thread why it is not a good change:
>> > https://sourceware.org/ml/binutils/2015-01/msg00135.html
>> > Do people agree with that? And/Or can the change be reverted for now
>> > till there is agreement it is a desirable default?
>>
>> It may not be a good idea for all targets.  If you find an issue
>> on Linux/x86, please file a bug binutils report.
>
> i think we already have the reports: multiple people don't think it should be
> (1) x86-specific or (2) required.  don't get me wrong -- i think having support
> like this is great.  that doesn't mean we should be forcing it.
> -mike

Please file a bug report with a testcase.
  
Mike Frysinger Feb. 18, 2015, 11:10 p.m. UTC | #21
On 18 Feb 2015 14:24, H.J. Lu wrote:
> On Wed, Feb 18, 2015 at 2:21 PM, Mike Frysinger wrote:
> > i think we already have the reports: multiple people don't think it should be
> > (1) x86-specific or (2) required.  don't get me wrong -- i think having support
> > like this is great.  that doesn't mean we should be forcing it.
> 
> Please file a bug report with a testcase.

this is getting kafka-esque.  you yourself stated:
  On Linux/x86, zlib is required for assembler.  At least, you should issue an 
  error when --without-libz is used in binutils for Linux/x86 target.
that should not be the case.  making someone open a bug report so you can close 
it with "fixed" and a patch is wasting time.  just fix it now.

all that said, if we look at your actual commit (89e7505fcde4bd83948f559f429a0):
gas/config/tc-i386.c:
  +#ifdef TE_LINUX
  +/* Default to compress debug sections for Linux.  */
  +int flag_compress_debug = 1;
  +#endif

and we look at where that flag is used:
gas/as.c:
  ...
    case OPTION_COMPRESS_DEBUG:
  #ifdef HAVE_ZLIB_H
      flag_compress_debug = 1;
  #else
      as_warn (_("cannot compress debug sections (zlib not installed)"));
  #endif /* HAVE_ZLIB_H */
      break;

    case OPTION_NOCOMPRESS_DEBUG:
      flag_compress_debug = 0;
      break;
  ...

gas/write.c:
  void
  write_object_file (void)
  {
  ...
    if (flag_compress_debug)
      bfd_map_over_sections (stdoutput, compress_debug, (char *) 0);
  ...
  static void
  compress_debug (bfd *abfd, asection *sec, void *xxx ATTRIBUTE_UNUSED)
  {
  ...
    strm = compress_init ();
    if (strm == NULL)
      return;

it turns out the current code does *not* require zlib.  as long as that does not 
change (either issuing a warning or throwing an error), i see no reason why we 
need or should make zlib a requirement in binutils, regardless of target.
-mike
  
Joel Brobecker Feb. 19, 2015, 2:42 a.m. UTC | #22
> Why do you want to turn off zlib? On Linux/x86,  zlib is required
> for assembler.  At least, you should issue an error when --without-libz
> is used in binutils for Linux/x86 target.

I am trying to do the exact opposite, which is to provide an option
to compile WITH zlib, but using an install at a non-standard location.

> I guess someone has asked it before.  Why can't zlib be made the
> same as
> 
>   --with-mpc=PATH         specify prefix directory for installed MPC package.
>                           Equivalent to --with-mpc-include=PATH/include plus
>                           --with-mpc-lib=PATH/lib
>   --with-mpc-include=PATH specify directory for installed MPC include files
>   --with-mpc-lib=PATH     specify directory for the installed MPC library
> 
> It is more flexible than your patch.  If you have some existing packages
> which use your scheme, you can translate the configure command line
> options to this one.

This is fustrating. I already answered that question.
  
Mark Wielaard Feb. 19, 2015, 7:17 a.m. UTC | #23
On Wed, Feb 18, 2015 at 01:54:17PM -0800, H.J. Lu wrote:
> On Wed, Feb 18, 2015 at 1:40 PM, Mark Wielaard <mjw@redhat.com> wrote:
> > On Wed, 2015-02-18 at 12:53 -0800, H.J. Lu wrote:
> >> On Wed, Feb 18, 2015 at 12:32 PM, Mark Wielaard <mjw@redhat.com> wrote:
> >> > That doesn't seem like a smart default. And why is is Linux/x86 only?
> >> > Shouldn't that be something that is done explicitly by a distro
> >> > configuring binutils after making sure it actually is beneficial
> >> > (debuginfo is often compressed in a different way, on the package/file
> >> > level or with dwz). And after making sure all tools actually work with
> >> > it? There are various tools that don't handle the .zdebug format like
> >> > valgrind. And at least elfutils has trouble with it for ET_REL files,
> >> > like kernel modules, because relocations don't actually apply anymore to
> >> > the section data as is (but only after the decompression).
> >>
> >> Now it becomes a monthly topic:
> >>
> >> https://sourceware.org/ml/binutils/2015-01/msg00089.html
> >
> > Thanks, I hadn't seen that before. Alan Modra makes some good points in
> > that thread why it is not a good change:
> > https://sourceware.org/ml/binutils/2015-01/msg00135.html
> > Do people agree with that? And/Or can the change be reverted for now
> > till there is agreement it is a desirable default?
> >
> 
> It may not be a good idea for all targets.  If you find an issue
> on Linux/x86, please file a bug binutils report.

The issue is that this is not something that is target architecture
specific. As others have pointed out this isn't something that is
target architecture-dependent. So please first get agreement on whether
or not to default for the OS (or for all ELF targets or the GNU targets).
Otherwise distros will have to revert on a target by target basis to get
something consistent. Secondly the bug is not directly in binutils (but
there might be an issue between versions compiled with/without zlib
support). If .zdebug sections are left in on disk ET_REL files, like
kernel modules, there is a problem for programs that don't deal with
.zdebug sections (and/or relocations against them) in ET_REL files
like elfutils, systemtap, debugedit, dwz, etc.

Thanks,

Mark
  
Thomas Schwinge Feb. 19, 2015, 7:54 a.m. UTC | #24
Hi!

On Wed, 7 Jan 2015 17:00:59 +0100, Tristan Gingold <gingold@adacore.com> wrote:
> 
> > On 07 Jan 2015, at 15:45, Joel Brobecker <brobecker@adacore.com> wrote:
> > This patch enhances config/zlib.m4 to introduce an extra option
> > --with-libz-prefix which allows us to provide the location of
> > the zlib library we want to use during the build.
> 
> I prefer the gcc way to provide external library:
> 
> --with-zlib -> system zlib used
> --with-zlib=pathname -> zlib from pathname is used
> 
> I have never needed different include and lib paths, but
> this is supported by gcc.
> 
> (Furthermore, I think that --with-zlib vs --with-libz-prefix is confusing).

I'm not a GCC build machinery maintainer, but I do second Tristan's
suggestion to stay compatible with the existing --with-[...] options that
GCC already supports:

> Cf:
> 
> --with-gmp=pathname
> --with-gmp-include=pathname
> --with-gmp-lib=pathname
> --with-mpfr=pathname
> --with-mpfr-include=pathname
> --with-mpfr-lib=pathname
> --with-mpc=pathname
> --with-mpc-include=pathname
> --with-mpc-lib=pathname
> If you want to build GCC but do not have the GMP library, the MPFR library and/or the MPC library installed in a standard location and do not have their sources present in the GCC source tree then you can explicitly specify the directory where they are installed (‘--with-gmp=gmpinstalldir’, ‘--with-mpfr=mpfrinstalldir’, ‘--with-mpc=mpcinstalldir’). The --with-gmp=gmpinstalldir option is shorthand for --with-gmp-lib=gmpinstalldir/lib and --with-gmp-include=gmpinstalldir/include. Likewise the --with-mpfr=mpfrinstalldir option is shorthand for --with-mpfr-lib=mpfrinstalldir/lib and --with-mpfr-include=mpfrinstalldir/include, also the --with-mpc=mpcinstalldir option is shorthand for --with-mpc-lib=mpcinstalldir/lib and --with-mpc-include=mpcinstalldir/include. If these shorthand assumptions are not correct, you can use the explicit include and lib options directly. You might also need to ensure the shared libraries can be found by the dynamic linker when building and using GCC, for example by setting the runtime shared library path variable (LD_LIBRARY_PATH on GNU/Linux and Solaris systems).
> These flags are applicable to the host platform only. When building a cross compiler, they will not be used to configure target libraries. 


Grüße,
 Thomas
  
Thomas Schwinge Feb. 19, 2015, 7:58 a.m. UTC | #25
Hi!

On Thu, 19 Feb 2015 08:54:46 +0100, I wrote:
> On Wed, 7 Jan 2015 17:00:59 +0100, Tristan Gingold <gingold@adacore.com> wrote:
> > 
> > > On 07 Jan 2015, at 15:45, Joel Brobecker <brobecker@adacore.com> wrote:
> > > This patch enhances config/zlib.m4 to introduce an extra option
> > > --with-libz-prefix which allows us to provide the location of
> > > the zlib library we want to use during the build.
> > 
> > I prefer the gcc way to provide external library:
> > 
> > --with-zlib -> system zlib used
> > --with-zlib=pathname -> zlib from pathname is used
> > 
> > I have never needed different include and lib paths, but
> > this is supported by gcc.
> > 
> > (Furthermore, I think that --with-zlib vs --with-libz-prefix is confusing).
> 
> I'm not a GCC build machinery maintainer, but I do second Tristan's
> suggestion to stay compatible with the existing --with-[...] options that
> GCC already supports:
> 
> > Cf:
> > 
> > --with-gmp=pathname
> > --with-gmp-include=pathname
> > --with-gmp-lib=pathname
> > --with-mpfr=pathname
> > --with-mpfr-include=pathname
> > --with-mpfr-lib=pathname
> > --with-mpc=pathname
> > --with-mpc-include=pathname
> > --with-mpc-lib=pathname
> > If you want to build GCC but do not have the GMP library, the MPFR library and/or the MPC library installed in a standard location and do not have their sources present in the GCC source tree then you can explicitly specify the directory where they are installed (‘--with-gmp=gmpinstalldir’, ‘--with-mpfr=mpfrinstalldir’, ‘--with-mpc=mpcinstalldir’). The --with-gmp=gmpinstalldir option is shorthand for --with-gmp-lib=gmpinstalldir/lib and --with-gmp-include=gmpinstalldir/include. Likewise the --with-mpfr=mpfrinstalldir option is shorthand for --with-mpfr-lib=mpfrinstalldir/lib and --with-mpfr-include=mpfrinstalldir/include, also the --with-mpc=mpcinstalldir option is shorthand for --with-mpc-lib=mpcinstalldir/lib and --with-mpc-include=mpcinstalldir/include. If these shorthand assumptions are not correct, you can use the explicit include and lib options directly. You might also need to ensure the shared libraries can be found by the dynamic linker when building and using GCC, for example by setting the runtime shared library path variable (LD_LIBRARY_PATH on GNU/Linux and Solaris systems).
> > These flags are applicable to the host platform only. When building a cross compiler, they will not be used to configure target libraries. 

Ah, now I've seen the other email: zlib is not actually used in GCC, and
GCC and binutils/GDB have already diverged in their handling of such
options -- unfortunately.


Grüße,
 Thomas
  
H.J. Lu Feb. 19, 2015, 1:52 p.m. UTC | #26
On Wed, Feb 18, 2015 at 11:17 PM, Mark Wielaard <mjw@redhat.com> wrote:
> On Wed, Feb 18, 2015 at 01:54:17PM -0800, H.J. Lu wrote:
>> On Wed, Feb 18, 2015 at 1:40 PM, Mark Wielaard <mjw@redhat.com> wrote:
>> > On Wed, 2015-02-18 at 12:53 -0800, H.J. Lu wrote:
>> >> On Wed, Feb 18, 2015 at 12:32 PM, Mark Wielaard <mjw@redhat.com> wrote:
>> >> > That doesn't seem like a smart default. And why is is Linux/x86 only?
>> >> > Shouldn't that be something that is done explicitly by a distro
>> >> > configuring binutils after making sure it actually is beneficial
>> >> > (debuginfo is often compressed in a different way, on the package/file
>> >> > level or with dwz). And after making sure all tools actually work with
>> >> > it? There are various tools that don't handle the .zdebug format like
>> >> > valgrind. And at least elfutils has trouble with it for ET_REL files,
>> >> > like kernel modules, because relocations don't actually apply anymore to
>> >> > the section data as is (but only after the decompression).
>> >>
>> >> Now it becomes a monthly topic:
>> >>
>> >> https://sourceware.org/ml/binutils/2015-01/msg00089.html
>> >
>> > Thanks, I hadn't seen that before. Alan Modra makes some good points in
>> > that thread why it is not a good change:
>> > https://sourceware.org/ml/binutils/2015-01/msg00135.html
>> > Do people agree with that? And/Or can the change be reverted for now
>> > till there is agreement it is a desirable default?
>> >
>>
>> It may not be a good idea for all targets.  If you find an issue
>> on Linux/x86, please file a bug binutils report.
>
> The issue is that this is not something that is target architecture
> specific. As others have pointed out this isn't something that is
> target architecture-dependent. So please first get agreement on whether
> or not to default for the OS (or for all ELF targets or the GNU targets).

As I said before, I don't think it will happen any time soon.

> Otherwise distros will have to revert on a target by target basis to get
> something consistent. Secondly the bug is not directly in binutils (but
> there might be an issue between versions compiled with/without zlib
> support). If .zdebug sections are left in on disk ET_REL files, like
> kernel modules, there is a problem for programs that don't deal with

Please stop spreading your FUD about kernel modules.  If you find a problem
with kernel modules,  please open a binutils bug report.

> .zdebug sections (and/or relocations against them) in ET_REL files
> like elfutils, systemtap, debugedit, dwz, etc.

I opened a bug against elfutils:

https://bugzilla.redhat.com/show_bug.cgi?id=807053

It shouldn't be be too hard to fix.  We fixed it in readelf.
  
Mark Wielaard Feb. 20, 2015, 8:01 a.m. UTC | #27
On Thu, Feb 19, 2015 at 05:52:26AM -0800, H.J. Lu wrote:
> On Wed, Feb 18, 2015 at 11:17 PM, Mark Wielaard <mjw@redhat.com> wrote:
> >> >> Now it becomes a monthly topic:
> >> >>
> >> >> https://sourceware.org/ml/binutils/2015-01/msg00089.html
> >> >
> >> > Thanks, I hadn't seen that before. Alan Modra makes some good points in
> >> > that thread why it is not a good change:
> >> > https://sourceware.org/ml/binutils/2015-01/msg00135.html
> >> > Do people agree with that? And/Or can the change be reverted for now
> >> > till there is agreement it is a desirable default?
> >> >
> >>
> >> It may not be a good idea for all targets.  If you find an issue
> >> on Linux/x86, please file a bug binutils report.
> >
> > The issue is that this is not something that is target architecture
> > specific. As others have pointed out this isn't something that is
> > target architecture-dependent. So please first get agreement on whether
> > or not to default for the OS (or for all ELF targets or the GNU targets).
> 
> As I said before, I don't think it will happen any time soon.

You will have to convince a global maintainer or the other architecture
maintainers this is a good default.

> > Otherwise distros will have to revert on a target by target basis to get
> > something consistent. Secondly the bug is not directly in binutils (but
> > there might be an issue between versions compiled with/without zlib
> > support). If .zdebug sections are left in on disk ET_REL files, like
> > kernel modules, there is a problem for programs that don't deal with
> 
> Please stop spreading your FUD about kernel modules.  If you find a problem
> with kernel modules,  please open a binutils bug report.

I think you misunderstand. Although a quick search indicates there are
issues in binutils dealing with .zdebug sections (e.g. #11819 and #15989)
I wasn't talking about binutils. Other utilities that might have problems
with ET_REL files containing .zdebug sections. I know that is the case
for kernel modules. But as you point out below there are other issues/bugs
in tools dealing with .zdebug ET_REL files too. The point was that Alan
mentions a couple of issues that I didn't see you address yet. You might
run into difficulty with other tools or older binutils that deal with
relocatable object files that are important to consider before making this
the default. You might just want to reply to his message if you feel I
am misrepresenting things:
https://sourceware.org/ml/binutils/2015-01/msg00135.html

> > .zdebug sections (and/or relocations against them) in ET_REL files
> > like elfutils, systemtap, debugedit, dwz, etc.
> 
> I opened a bug against elfutils:
> 
> https://bugzilla.redhat.com/show_bug.cgi?id=807053
> 
> It shouldn't be be too hard to fix.

Thanks. Patches welcome of course.
It is slightly tricky because in elfutils the code that deals with
.[z]debug DWARF data (libdw) is separate from the code that deals with
loading of ELF data and applying relocations (libdwfl). The relocations
are applied early by code that doesn't know about .zdebug compression
and so relies on the section headers to know data offsets and sizes.
The bug report has some hints how to maybe handle this.

Cheers,

Mark
  

Patch

From 9dfb8ddb97c6dc56a5e1482e7029120d07dc07c8 Mon Sep 17 00:00:00 2001
From: Joel Brobecker <brobecker@adacore.com>
Date: Wed, 7 Jan 2015 14:47:51 +0400
Subject: [PATCH] config/zlib.m4: Add support for --with-libz-prefix

This patch enhances config/zlib.m4 to introduce an extra option
--with-libz-prefix which allows us to provide the location of
the zlib library we want to use during the build.

config/ChangeLog:

        * zlib.m4 (AM_ZLIB): Add --with-libz-prefix option support.

bfd/ChangeLog:

        * Makefile.in, aclocal.m4, config.in, configure: Regenerate.

bfd/doc/ChangeLog:

        * doc/Makefile.in: Regenerate.

binutils/ChangeLog:

        * Makefile.in, config.in, configure: Regenerate.

binutils/doc/ChangeLog:

        * Makefile.in: Regenerate.

gas/ChangeLog:

        * Makefile.in, aclocal.m4, config.in, configure, doc/Makefile.in:
        Regenerate.

gdb/ChangeLog:

        * config.in, configure: Regenerate.

gold/ChangeLog:

        * Makefile.in, aclocal.m4, config.in, configure,
        testsuite/Makefile.in: Regenerate.

ld/ChangeLog:

        * Makefile.in, aclocal.m4, config.in, configure: Regenerate.

sim/common/ChangeLog:

        * acinclude.m4, config.in, configure: Regenerate.

sim/ppc/ChangeLog:

        * config.in, configure: Regenerate.

This was tested by regenerating all autoconf/automake files in
the binutils-gdb project, and rebuilding GDB, using the following
combinations:

  --with-zlib (system zlib used)
  --with-libz-prefix=/zlib/prefix (specific zlib linked in)
  --with-zlib --with-libz-prefix=/zlib/prefix (specific zlib linked in)

  --without-zlib (zlib support turned off)
  --without-zlib --with-zlib-prefix (zlib support turned off)

  --with-zlib (no system zlib available, configure fails with expected error)
      --with-zlib --with-libz-prefix=/invalid/zlib/prefix
                  (no system zlib, configure fails with same error)
---
 bfd/Makefile.in            |   6 +
 bfd/aclocal.m4             |   3 +
 bfd/config.in              |   3 +
 bfd/configure              | 669 +++++++++++++++++++++++++++---
 bfd/doc/Makefile.in        |   6 +
 binutils/Makefile.in       |   3 +
 binutils/config.in         |   3 +
 binutils/configure         | 652 ++++++++++++++++++++++++------
 binutils/doc/Makefile.in   |   3 +
 config/zlib.m4             |  11 +-
 gas/Makefile.in            |   6 +
 gas/aclocal.m4             |   3 +
 gas/config.in              |   3 +
 gas/configure              | 669 +++++++++++++++++++++++++++---
 gas/doc/Makefile.in        |   6 +
 gdb/config.in              |   3 +
 gdb/configure              | 986 ++++++++++++++++++++++++++++++++-------------
 gold/Makefile.in           |   6 +
 gold/aclocal.m4            |   3 +
 gold/config.in             |   3 +
 gold/configure             | 666 ++++++++++++++++++++++++++++--
 gold/testsuite/Makefile.in |   6 +
 ld/Makefile.in             |   6 +
 ld/aclocal.m4              |   3 +
 ld/config.in               |   3 +
 ld/configure               | 669 +++++++++++++++++++++++++++---
 sim/common/acinclude.m4    |   3 +
 sim/common/config.in       |   3 +
 sim/common/configure       | 671 +++++++++++++++++++++++++++---
 sim/ppc/config.in          |   3 +
 sim/ppc/configure          | 697 ++++++++++++++++++++++++++++++--
 31 files changed, 5107 insertions(+), 670 deletions(-)

diff --git a/bfd/Makefile.in b/bfd/Makefile.in
index 2c9435c..934d62a 100644
--- a/bfd/Makefile.in
+++ b/bfd/Makefile.in
@@ -70,6 +70,9 @@  am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
 	$(top_srcdir)/../config/gettext-sister.m4 \
 	$(top_srcdir)/../config/largefile.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
+	$(top_srcdir)/../config/lib-ld.m4 \
+	$(top_srcdir)/../config/lib-link.m4 \
+	$(top_srcdir)/../config/lib-prefix.m4 \
 	$(top_srcdir)/../config/nls.m4 \
 	$(top_srcdir)/../config/override.m4 \
 	$(top_srcdir)/../config/plugins.m4 \
@@ -204,6 +207,7 @@  FGREP = @FGREP@
 GENCAT = @GENCAT@
 GMSGFMT = @GMSGFMT@
 GREP = @GREP@
+HAVE_LIBZ = @HAVE_LIBZ@
 HDEFINES = @HDEFINES@
 INCINTL = @INCINTL@
 INSTALL = @INSTALL@
@@ -220,9 +224,11 @@  LIBM = @LIBM@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
+LIBZ = @LIBZ@
 LIPO = @LIPO@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
+LTLIBZ = @LTLIBZ@
 MAINT = @MAINT@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
diff --git a/bfd/aclocal.m4 b/bfd/aclocal.m4
index d9e743e..358fe09 100644
--- a/bfd/aclocal.m4
+++ b/bfd/aclocal.m4
@@ -973,6 +973,9 @@  m4_include([../config/depstand.m4])
 m4_include([../config/gettext-sister.m4])
 m4_include([../config/largefile.m4])
 m4_include([../config/lead-dot.m4])
+m4_include([../config/lib-ld.m4])
+m4_include([../config/lib-link.m4])
+m4_include([../config/lib-prefix.m4])
 m4_include([../config/nls.m4])
 m4_include([../config/override.m4])
 m4_include([../config/plugins.m4])
diff --git a/bfd/config.in b/bfd/config.in
index b911bf6..cf1a97a 100644
--- a/bfd/config.in
+++ b/bfd/config.in
@@ -125,6 +125,9 @@ 
 /* Define to 1 if you have the <inttypes.h> header file. */
 #undef HAVE_INTTYPES_H
 
+/* Define if you have the z library. */
+#undef HAVE_LIBZ
+
 /* Define if <sys/procfs.h> has lwpstatus_t. */
 #undef HAVE_LWPSTATUS_T
 
diff --git a/bfd/configure b/bfd/configure
index f7a9e81..8c92742 100755
--- a/bfd/configure
+++ b/bfd/configure
@@ -620,6 +620,9 @@  SHARED_LDFLAGS
 LIBM
 COREFLAG
 COREFILE
+LTLIBZ
+LIBZ
+HAVE_LIBZ
 EXEEXT_FOR_BUILD
 CC_FOR_BUILD
 BFD_HOSTPTR_T
@@ -798,6 +801,8 @@  enable_maintainer_mode
 enable_install_libbfd
 enable_nls
 with_zlib
+enable_rpath
+with_libz_prefix
 '
       ac_precious_vars='build_alias
 host_alias
@@ -1449,6 +1454,7 @@  Optional Features:
 			  (and sometimes confusing) to the casual installer
   --enable-install-libbfd controls installation of libbfd and related headers
   --disable-nls           do not use Native Language Support
+  --disable-rpath         do not hardcode runtime library paths
 
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
@@ -1464,6 +1470,9 @@  Optional Packages:
                           Binutils"
   --with-bugurl=URL       Direct users to URL to report a bug
   --with-zlib             include zlib support (auto/yes/no) default=auto
+  --with-gnu-ld           assume the C compiler uses GNU ld default=no
+  --with-libz-prefix[=DIR]  search for libz in DIR/include and DIR/lib
+  --without-libz-prefix     don't search for libz in includedir and libdir
 
 Some influential environment variables:
   CC          C compiler command
@@ -11421,7 +11430,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11424 "configure"
+#line 11433 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11527,7 +11536,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11530 "configure"
+#line 11539 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -13854,6 +13863,164 @@  _ACEOF
 # Link in zlib if we can.  This allows us to read compressed debug sections.
 # This is used only by compress.c.
 
+      if test "X$prefix" = "XNONE"; then
+    acl_final_prefix="$ac_default_prefix"
+  else
+    acl_final_prefix="$prefix"
+  fi
+  if test "X$exec_prefix" = "XNONE"; then
+    acl_final_exec_prefix='${prefix}'
+  else
+    acl_final_exec_prefix="$exec_prefix"
+  fi
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
+  prefix="$acl_save_prefix"
+
+
+# Check whether --with-gnu-ld was given.
+if test "${with_gnu_ld+set}" = set; then :
+  withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
+else
+  with_gnu_ld=no
+fi
+
+# Prepare PATH_SEPARATOR.
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+  echo "#! /bin/sh" >conf$$.sh
+  echo  "exit 0"   >>conf$$.sh
+  chmod +x conf$$.sh
+  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
+    PATH_SEPARATOR=';'
+  else
+    PATH_SEPARATOR=:
+  fi
+  rm -f conf$$.sh
+fi
+ac_prog=ld
+if test "$GCC" = yes; then
+  # Check if gcc -print-prog-name=ld gives a path.
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by GCC" >&5
+$as_echo_n "checking for ld used by GCC... " >&6; }
+  case $host in
+  *-*-mingw*)
+    # gcc leaves a trailing carriage return which upsets mingw
+    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
+  *)
+    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
+  esac
+  case $ac_prog in
+    # Accept absolute paths.
+    [\\/]* | [A-Za-z]:[\\/]*)
+      re_direlt='/[^/][^/]*/\.\./'
+      # Canonicalize the path of ld
+      ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
+      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
+	ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
+      done
+      test -z "$LD" && LD="$ac_prog"
+      ;;
+  "")
+    # If it fails, then pretend we aren't using GCC.
+    ac_prog=ld
+    ;;
+  *)
+    # If it is relative, then search for the first ld in PATH.
+    with_gnu_ld=unknown
+    ;;
+  esac
+elif test "$with_gnu_ld" = yes; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
+$as_echo_n "checking for GNU ld... " >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
+$as_echo_n "checking for non-GNU ld... " >&6; }
+fi
+if test "${acl_cv_path_LD+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -z "$LD"; then
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
+  for ac_dir in $PATH; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+      acl_cv_path_LD="$ac_dir/$ac_prog"
+      # Check to see if the program is GNU ld.  I'd rather use --version,
+      # but apparently some GNU ld's only accept -v.
+      # Break only if it was the GNU/non-GNU ld that we prefer.
+      if "$acl_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
+	test "$with_gnu_ld" != no && break
+      else
+	test "$with_gnu_ld" != yes && break
+      fi
+    fi
+  done
+  IFS="$ac_save_ifs"
+else
+  acl_cv_path_LD="$LD" # Let the user override the test with a path.
+fi
+fi
+
+LD="$acl_cv_path_LD"
+if test -n "$LD"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
+$as_echo "$LD" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+test -z "$LD" && as_fn_error "no acceptable ld found in \$PATH" "$LINENO" 5
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
+$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; }
+if test "${acl_cv_prog_gnu_ld+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  # I'd rather use --version here, but apparently some GNU ld's only accept -v.
+if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
+  acl_cv_prog_gnu_ld=yes
+else
+  acl_cv_prog_gnu_ld=no
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_prog_gnu_ld" >&5
+$as_echo "$acl_cv_prog_gnu_ld" >&6; }
+with_gnu_ld=$acl_cv_prog_gnu_ld
+
+
+
+                                                { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5
+$as_echo_n "checking for shared library run path origin... " >&6; }
+if test "${acl_cv_rpath+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+    CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
+    ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
+    . ./conftest.sh
+    rm -f ./conftest.sh
+    acl_cv_rpath=done
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_rpath" >&5
+$as_echo "$acl_cv_rpath" >&6; }
+  wl="$acl_cv_wl"
+  libext="$acl_cv_libext"
+  shlibext="$acl_cv_shlibext"
+  hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
+  hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
+  hardcode_direct="$acl_cv_hardcode_direct"
+  hardcode_minus_L="$acl_cv_hardcode_minus_L"
+    # Check whether --enable-rpath was given.
+if test "${enable_rpath+set}" = set; then :
+  enableval=$enable_rpath; :
+else
+  enable_rpath=yes
+fi
+
+
+
   # See if the user specified whether he wants zlib support or not.
 
 # Check whether --with-zlib was given.
@@ -13865,60 +14032,472 @@  fi
 
 
   if test "$with_zlib" != "no"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing zlibVersion" >&5
-$as_echo_n "checking for library containing zlibVersion... " >&6; }
-if test "${ac_cv_search_zlibVersion+set}" = set; then :
+
+
+
+
+
+
+
+
+    use_additional=yes
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+
+    eval additional_includedir=\"$includedir\"
+    eval additional_libdir=\"$libdir\"
+
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+
+# Check whether --with-libz-prefix was given.
+if test "${with_libz_prefix+set}" = set; then :
+  withval=$with_libz_prefix;
+    if test "X$withval" = "Xno"; then
+      use_additional=no
+    else
+      if test "X$withval" = "X"; then
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+
+          eval additional_includedir=\"$includedir\"
+          eval additional_libdir=\"$libdir\"
+
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+      else
+        additional_includedir="$withval/include"
+        additional_libdir="$withval/lib"
+      fi
+    fi
+
+fi
+
+      LIBZ=
+  LTLIBZ=
+  INCZ=
+  rpathdirs=
+  ltrpathdirs=
+  names_already_handled=
+  names_next_round='z '
+  while test -n "$names_next_round"; do
+    names_this_round="$names_next_round"
+    names_next_round=
+    for name in $names_this_round; do
+      already_handled=
+      for n in $names_already_handled; do
+        if test "$n" = "$name"; then
+          already_handled=yes
+          break
+        fi
+      done
+      if test -z "$already_handled"; then
+        names_already_handled="$names_already_handled $name"
+                        uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
+        eval value=\"\$HAVE_LIB$uppername\"
+        if test -n "$value"; then
+          if test "$value" = yes; then
+            eval value=\"\$LIB$uppername\"
+            test -z "$value" || LIBZ="${LIBZ}${LIBZ:+ }$value"
+            eval value=\"\$LTLIB$uppername\"
+            test -z "$value" || LTLIBZ="${LTLIBZ}${LTLIBZ:+ }$value"
+          else
+                                    :
+          fi
+        else
+                              found_dir=
+          found_la=
+          found_so=
+          found_a=
+          if test $use_additional = yes; then
+            if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then
+              found_dir="$additional_libdir"
+              found_so="$additional_libdir/lib$name.$shlibext"
+              if test -f "$additional_libdir/lib$name.la"; then
+                found_la="$additional_libdir/lib$name.la"
+              fi
+            else
+              if test -f "$additional_libdir/lib$name.$libext"; then
+                found_dir="$additional_libdir"
+                found_a="$additional_libdir/lib$name.$libext"
+                if test -f "$additional_libdir/lib$name.la"; then
+                  found_la="$additional_libdir/lib$name.la"
+                fi
+              fi
+            fi
+          fi
+          if test "X$found_dir" = "X"; then
+            for x in $LDFLAGS $LTLIBZ; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+              case "$x" in
+                -L*)
+                  dir=`echo "X$x" | sed -e 's/^X-L//'`
+                  if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then
+                    found_dir="$dir"
+                    found_so="$dir/lib$name.$shlibext"
+                    if test -f "$dir/lib$name.la"; then
+                      found_la="$dir/lib$name.la"
+                    fi
+                  else
+                    if test -f "$dir/lib$name.$libext"; then
+                      found_dir="$dir"
+                      found_a="$dir/lib$name.$libext"
+                      if test -f "$dir/lib$name.la"; then
+                        found_la="$dir/lib$name.la"
+                      fi
+                    fi
+                  fi
+                  ;;
+              esac
+              if test "X$found_dir" != "X"; then
+                break
+              fi
+            done
+          fi
+          if test "X$found_dir" != "X"; then
+                        LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-L$found_dir -l$name"
+            if test "X$found_so" != "X"; then
+                                                        if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then
+                                LIBZ="${LIBZ}${LIBZ:+ }$found_so"
+              else
+                                                                                haveit=
+                for x in $ltrpathdirs; do
+                  if test "X$x" = "X$found_dir"; then
+                    haveit=yes
+                    break
+                  fi
+                done
+                if test -z "$haveit"; then
+                  ltrpathdirs="$ltrpathdirs $found_dir"
+                fi
+                                if test "$hardcode_direct" = yes; then
+                                                      LIBZ="${LIBZ}${LIBZ:+ }$found_so"
+                else
+                  if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then
+                                                            LIBZ="${LIBZ}${LIBZ:+ }$found_so"
+                                                            haveit=
+                    for x in $rpathdirs; do
+                      if test "X$x" = "X$found_dir"; then
+                        haveit=yes
+                        break
+                      fi
+                    done
+                    if test -z "$haveit"; then
+                      rpathdirs="$rpathdirs $found_dir"
+                    fi
+                  else
+                                                                                haveit=
+                    for x in $LDFLAGS $LIBZ; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+                      if test "X$x" = "X-L$found_dir"; then
+                        haveit=yes
+                        break
+                      fi
+                    done
+                    if test -z "$haveit"; then
+                      LIBZ="${LIBZ}${LIBZ:+ }-L$found_dir"
+                    fi
+                    if test "$hardcode_minus_L" != no; then
+                                                                                        LIBZ="${LIBZ}${LIBZ:+ }$found_so"
+                    else
+                                                                                                                                                                                LIBZ="${LIBZ}${LIBZ:+ }-l$name"
+                    fi
+                  fi
+                fi
+              fi
+            else
+              if test "X$found_a" != "X"; then
+                                LIBZ="${LIBZ}${LIBZ:+ }$found_a"
+              else
+                                                LIBZ="${LIBZ}${LIBZ:+ }-L$found_dir -l$name"
+              fi
+            fi
+                        additional_includedir=
+            case "$found_dir" in
+              */lib | */lib/)
+                basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'`
+                additional_includedir="$basedir/include"
+                ;;
+            esac
+            if test "X$additional_includedir" != "X"; then
+                                                                                                                if test "X$additional_includedir" != "X/usr/include"; then
+                haveit=
+                if test "X$additional_includedir" = "X/usr/local/include"; then
+                  if test -n "$GCC"; then
+                    case $host_os in
+                      linux*) haveit=yes;;
+                    esac
+                  fi
+                fi
+                if test -z "$haveit"; then
+                  for x in $CPPFLAGS $INCZ; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+                    if test "X$x" = "X-I$additional_includedir"; then
+                      haveit=yes
+                      break
+                    fi
+                  done
+                  if test -z "$haveit"; then
+                    if test -d "$additional_includedir"; then
+                                            INCZ="${INCZ}${INCZ:+ }-I$additional_includedir"
+                    fi
+                  fi
+                fi
+              fi
+            fi
+                        if test -n "$found_la"; then
+                                                        save_libdir="$libdir"
+              case "$found_la" in
+                */* | *\\*) . "$found_la" ;;
+                *) . "./$found_la" ;;
+              esac
+              libdir="$save_libdir"
+                            for dep in $dependency_libs; do
+                case "$dep" in
+                  -L*)
+                    additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
+                                                                                                                                                                if test "X$additional_libdir" != "X/usr/lib"; then
+                      haveit=
+                      if test "X$additional_libdir" = "X/usr/local/lib"; then
+                        if test -n "$GCC"; then
+                          case $host_os in
+                            linux*) haveit=yes;;
+                          esac
+                        fi
+                      fi
+                      if test -z "$haveit"; then
+                        haveit=
+                        for x in $LDFLAGS $LIBZ; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+                          if test "X$x" = "X-L$additional_libdir"; then
+                            haveit=yes
+                            break
+                          fi
+                        done
+                        if test -z "$haveit"; then
+                          if test -d "$additional_libdir"; then
+                                                        LIBZ="${LIBZ}${LIBZ:+ }-L$additional_libdir"
+                          fi
+                        fi
+                        haveit=
+                        for x in $LDFLAGS $LTLIBZ; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+                          if test "X$x" = "X-L$additional_libdir"; then
+                            haveit=yes
+                            break
+                          fi
+                        done
+                        if test -z "$haveit"; then
+                          if test -d "$additional_libdir"; then
+                                                        LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-L$additional_libdir"
+                          fi
+                        fi
+                      fi
+                    fi
+                    ;;
+                  -R*)
+                    dir=`echo "X$dep" | sed -e 's/^X-R//'`
+                    if test "$enable_rpath" != no; then
+                                                                  haveit=
+                      for x in $rpathdirs; do
+                        if test "X$x" = "X$dir"; then
+                          haveit=yes
+                          break
+                        fi
+                      done
+                      if test -z "$haveit"; then
+                        rpathdirs="$rpathdirs $dir"
+                      fi
+                                                                  haveit=
+                      for x in $ltrpathdirs; do
+                        if test "X$x" = "X$dir"; then
+                          haveit=yes
+                          break
+                        fi
+                      done
+                      if test -z "$haveit"; then
+                        ltrpathdirs="$ltrpathdirs $dir"
+                      fi
+                    fi
+                    ;;
+                  -l*)
+                                        names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
+                    ;;
+                  *.la)
+                                                                                names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
+                    ;;
+                  *)
+                                        LIBZ="${LIBZ}${LIBZ:+ }$dep"
+                    LTLIBZ="${LTLIBZ}${LTLIBZ:+ }$dep"
+                    ;;
+                esac
+              done
+            fi
+          else
+                                                            LIBZ="${LIBZ}${LIBZ:+ }-l$name"
+            LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-l$name"
+          fi
+        fi
+      fi
+    done
+  done
+  if test "X$rpathdirs" != "X"; then
+    if test -n "$hardcode_libdir_separator"; then
+                        alldirs=
+      for found_dir in $rpathdirs; do
+        alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir"
+      done
+            acl_save_libdir="$libdir"
+      libdir="$alldirs"
+      eval flag=\"$hardcode_libdir_flag_spec\"
+      libdir="$acl_save_libdir"
+      LIBZ="${LIBZ}${LIBZ:+ }$flag"
+    else
+            for found_dir in $rpathdirs; do
+        acl_save_libdir="$libdir"
+        libdir="$found_dir"
+        eval flag=\"$hardcode_libdir_flag_spec\"
+        libdir="$acl_save_libdir"
+        LIBZ="${LIBZ}${LIBZ:+ }$flag"
+      done
+    fi
+  fi
+  if test "X$ltrpathdirs" != "X"; then
+            for found_dir in $ltrpathdirs; do
+      LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-R$found_dir"
+    done
+  fi
+
+
+        ac_save_CPPFLAGS="$CPPFLAGS"
+
+  for element in $INCZ; do
+    haveit=
+    for x in $CPPFLAGS; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+      if test "X$x" = "X$element"; then
+        haveit=yes
+        break
+      fi
+    done
+    if test -z "$haveit"; then
+      CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element"
+    fi
+  done
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libz" >&5
+$as_echo_n "checking for libz... " >&6; }
+if test "${ac_cv_libz+set}" = set; then :
   $as_echo_n "(cached) " >&6
 else
-  ac_func_search_save_LIBS=$LIBS
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
 
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char zlibVersion ();
+    ac_save_LIBS="$LIBS"
+    LIBS="$LIBS $LIBZ"
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include "zlib.h";
 int
 main ()
 {
-return zlibVersion ();
+int ret = deflateInit(NULL, 1);
   ;
   return 0;
 }
 _ACEOF
-for ac_lib in '' z; do
-  if test -z "$ac_lib"; then
-    ac_res="none required"
-  else
-    ac_res=-l$ac_lib
-    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
-  fi
-  if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_search_zlibVersion=$ac_res
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_libz=yes
+else
+  ac_cv_libz=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext
-  if test "${ac_cv_search_zlibVersion+set}" = set; then :
-  break
-fi
-done
-if test "${ac_cv_search_zlibVersion+set}" = set; then :
+    conftest$ac_exeext conftest.$ac_ext
+    LIBS="$ac_save_LIBS"
 
-else
-  ac_cv_search_zlibVersion=no
 fi
-rm conftest.$ac_ext
-LIBS=$ac_func_search_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_zlibVersion" >&5
-$as_echo "$ac_cv_search_zlibVersion" >&6; }
-ac_res=$ac_cv_search_zlibVersion
-if test "$ac_res" != no; then :
-  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
-  for ac_header in zlib.h
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_libz" >&5
+$as_echo "$ac_cv_libz" >&6; }
+  if test "$ac_cv_libz" = yes; then
+    HAVE_LIBZ=yes
+
+$as_echo "#define HAVE_LIBZ 1" >>confdefs.h
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libz" >&5
+$as_echo_n "checking how to link with libz... " >&6; }
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBZ" >&5
+$as_echo "$LIBZ" >&6; }
+  else
+    HAVE_LIBZ=no
+            CPPFLAGS="$ac_save_CPPFLAGS"
+    LIBZ=
+    LTLIBZ=
+  fi
+
+
+
+
+
+
+    if test "$HAVE_LIBZ" = "yes"; then
+      # Make sure HAVE_ZLIB_H gets defined.  Some code uses that over
+      # HAVE_LIBZ, since initially we were only defining HAVE_ZLIB_H.
+      for ac_header in zlib.h
 do :
   ac_fn_c_check_header_mongrel "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default"
 if test "x$ac_cv_header_zlib_h" = x""yes; then :
@@ -13930,9 +14509,9 @@  fi
 
 done
 
-fi
-
-    if test "$with_zlib" = "yes" -a "$ac_cv_header_zlib_h" != "yes"; then
+      LIBS="$LIBS $LIBZ"
+    fi
+    if test "$with_zlib" = "yes" -a "$HAVE_LIBZ" != "yes"; then
       as_fn_error "zlib (libz) library was explicitly requested but not found" "$LINENO" 5
     fi
   fi
diff --git a/bfd/doc/Makefile.in b/bfd/doc/Makefile.in
index 3be6a5e..7257ed9 100644
--- a/bfd/doc/Makefile.in
+++ b/bfd/doc/Makefile.in
@@ -66,6 +66,9 @@  am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
 	$(top_srcdir)/../config/gettext-sister.m4 \
 	$(top_srcdir)/../config/largefile.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
+	$(top_srcdir)/../config/lib-ld.m4 \
+	$(top_srcdir)/../config/lib-link.m4 \
+	$(top_srcdir)/../config/lib-prefix.m4 \
 	$(top_srcdir)/../config/nls.m4 \
 	$(top_srcdir)/../config/override.m4 \
 	$(top_srcdir)/../config/plugins.m4 \
@@ -164,6 +167,7 @@  FGREP = @FGREP@
 GENCAT = @GENCAT@
 GMSGFMT = @GMSGFMT@
 GREP = @GREP@
+HAVE_LIBZ = @HAVE_LIBZ@
 HDEFINES = @HDEFINES@
 INCINTL = @INCINTL@
 INSTALL = @INSTALL@
@@ -180,9 +184,11 @@  LIBM = @LIBM@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
+LIBZ = @LIBZ@
 LIPO = @LIPO@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
+LTLIBZ = @LTLIBZ@
 MAINT = @MAINT@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
diff --git a/binutils/Makefile.in b/binutils/Makefile.in
index aaf4d51..05fb968 100644
--- a/binutils/Makefile.in
+++ b/binutils/Makefile.in
@@ -316,6 +316,7 @@  FGREP = @FGREP@
 GENCAT = @GENCAT@
 GMSGFMT = @GMSGFMT@
 GREP = @GREP@
+HAVE_LIBZ = @HAVE_LIBZ@
 HDEFINES = @HDEFINES@
 INCINTL = @INCINTL@
 INSTALL = @INSTALL@
@@ -335,10 +336,12 @@  LIBINTL_DEP = @LIBINTL_DEP@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
+LIBZ = @LIBZ@
 LIPO = @LIPO@
 LN_S = @LN_S@
 LTLIBICONV = @LTLIBICONV@
 LTLIBOBJS = @LTLIBOBJS@
+LTLIBZ = @LTLIBZ@
 MAINT = @MAINT@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
diff --git a/binutils/config.in b/binutils/config.in
index a0ed034..dd7d832 100644
--- a/binutils/config.in
+++ b/binutils/config.in
@@ -102,6 +102,9 @@ 
 /* Define if your <locale.h> file defines LC_MESSAGES. */
 #undef HAVE_LC_MESSAGES
 
+/* Define if you have the z library. */
+#undef HAVE_LIBZ
+
 /* Define to 1 if you have the <limits.h> header file. */
 #undef HAVE_LIMITS_H
 
diff --git a/binutils/configure b/binutils/configure
index b960c19..8280dd8 100755
--- a/binutils/configure
+++ b/binutils/configure
@@ -618,6 +618,9 @@  BUILD_NLMCONV
 NLMCONV_DEFS
 LTLIBICONV
 LIBICONV
+LTLIBZ
+LIBZ
+HAVE_LIBZ
 ALLOCA
 DEMANGLER_NAME
 EXEEXT_FOR_BUILD
@@ -779,6 +782,7 @@  enable_nls
 enable_maintainer_mode
 with_zlib
 enable_rpath
+with_libz_prefix
 with_libiconv_prefix
 '
       ac_precious_vars='build_alias
@@ -1441,6 +1445,8 @@  Optional Packages:
   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
   --with-zlib             include zlib support (auto/yes/no) default=auto
   --with-gnu-ld           assume the C compiler uses GNU ld default=no
+  --with-libz-prefix[=DIR]  search for libz in DIR/include and DIR/lib
+  --without-libz-prefix     don't search for libz in includedir and libdir
   --with-libiconv-prefix[=DIR]  search for libiconv in DIR/include and DIR/lib
   --without-libiconv-prefix     don't search for libiconv in includedir and libdir
 
@@ -11219,7 +11225,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11222 "configure"
+#line 11228 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11325,7 +11331,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11328 "configure"
+#line 11334 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -13540,121 +13546,6 @@  _ACEOF
 # sections.  This is used only by readelf.c (objdump uses bfd for
 # reading compressed sections).
 
-  # See if the user specified whether he wants zlib support or not.
-
-# Check whether --with-zlib was given.
-if test "${with_zlib+set}" = set; then :
-  withval=$with_zlib;
-else
-  with_zlib=auto
-fi
-
-
-  if test "$with_zlib" != "no"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing zlibVersion" >&5
-$as_echo_n "checking for library containing zlibVersion... " >&6; }
-if test "${ac_cv_search_zlibVersion+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_func_search_save_LIBS=$LIBS
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char zlibVersion ();
-int
-main ()
-{
-return zlibVersion ();
-  ;
-  return 0;
-}
-_ACEOF
-for ac_lib in '' z; do
-  if test -z "$ac_lib"; then
-    ac_res="none required"
-  else
-    ac_res=-l$ac_lib
-    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
-  fi
-  if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_search_zlibVersion=$ac_res
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext
-  if test "${ac_cv_search_zlibVersion+set}" = set; then :
-  break
-fi
-done
-if test "${ac_cv_search_zlibVersion+set}" = set; then :
-
-else
-  ac_cv_search_zlibVersion=no
-fi
-rm conftest.$ac_ext
-LIBS=$ac_func_search_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_zlibVersion" >&5
-$as_echo "$ac_cv_search_zlibVersion" >&6; }
-ac_res=$ac_cv_search_zlibVersion
-if test "$ac_res" != no; then :
-  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
-  for ac_header in zlib.h
-do :
-  ac_fn_c_check_header_mongrel "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default"
-if test "x$ac_cv_header_zlib_h" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_ZLIB_H 1
-_ACEOF
-
-fi
-
-done
-
-fi
-
-    if test "$with_zlib" = "yes" -a "$ac_cv_header_zlib_h" != "yes"; then
-      as_fn_error "zlib (libz) library was explicitly requested but not found" "$LINENO" 5
-    fi
-  fi
-
-
-
-case "${host}" in
-*-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows*)
-
-$as_echo "#define USE_BINARY_FOPEN 1" >>confdefs.h
- ;;
-esac
-
-# target-specific stuff:
-
-# Canonicalize the secondary target names.
-if test -n "$enable_targets"; then
-    for targ in `echo $enable_targets | sed 's/,/ /g'`
-    do
-	result=`$ac_config_sub $targ 2>/dev/null`
-	if test -n "$result"; then
-	    canon_targets="$canon_targets $result"
-	else
-	    # Allow targets that config.sub doesn't recognize, like "all".
-	    canon_targets="$canon_targets $targ"
-	fi
-    done
-fi
-
-ac_fn_c_check_header_mongrel "$LINENO" "iconv.h" "ac_cv_header_iconv_h" "$ac_includes_default"
-if test "x$ac_cv_header_iconv_h" = x""yes; then :
-
-fi
-
-
-
       if test "X$prefix" = "XNONE"; then
     acl_final_prefix="$ac_default_prefix"
   else
@@ -13813,6 +13704,533 @@  fi
 
 
 
+  # See if the user specified whether he wants zlib support or not.
+
+# Check whether --with-zlib was given.
+if test "${with_zlib+set}" = set; then :
+  withval=$with_zlib;
+else
+  with_zlib=auto
+fi
+
+
+  if test "$with_zlib" != "no"; then
+
+
+
+
+
+
+
+
+    use_additional=yes
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+
+    eval additional_includedir=\"$includedir\"
+    eval additional_libdir=\"$libdir\"
+
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+
+# Check whether --with-libz-prefix was given.
+if test "${with_libz_prefix+set}" = set; then :
+  withval=$with_libz_prefix;
+    if test "X$withval" = "Xno"; then
+      use_additional=no
+    else
+      if test "X$withval" = "X"; then
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+
+          eval additional_includedir=\"$includedir\"
+          eval additional_libdir=\"$libdir\"
+
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+      else
+        additional_includedir="$withval/include"
+        additional_libdir="$withval/lib"
+      fi
+    fi
+
+fi
+
+      LIBZ=
+  LTLIBZ=
+  INCZ=
+  rpathdirs=
+  ltrpathdirs=
+  names_already_handled=
+  names_next_round='z '
+  while test -n "$names_next_round"; do
+    names_this_round="$names_next_round"
+    names_next_round=
+    for name in $names_this_round; do
+      already_handled=
+      for n in $names_already_handled; do
+        if test "$n" = "$name"; then
+          already_handled=yes
+          break
+        fi
+      done
+      if test -z "$already_handled"; then
+        names_already_handled="$names_already_handled $name"
+                        uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
+        eval value=\"\$HAVE_LIB$uppername\"
+        if test -n "$value"; then
+          if test "$value" = yes; then
+            eval value=\"\$LIB$uppername\"
+            test -z "$value" || LIBZ="${LIBZ}${LIBZ:+ }$value"
+            eval value=\"\$LTLIB$uppername\"
+            test -z "$value" || LTLIBZ="${LTLIBZ}${LTLIBZ:+ }$value"
+          else
+                                    :
+          fi
+        else
+                              found_dir=
+          found_la=
+          found_so=
+          found_a=
+          if test $use_additional = yes; then
+            if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then
+              found_dir="$additional_libdir"
+              found_so="$additional_libdir/lib$name.$shlibext"
+              if test -f "$additional_libdir/lib$name.la"; then
+                found_la="$additional_libdir/lib$name.la"
+              fi
+            else
+              if test -f "$additional_libdir/lib$name.$libext"; then
+                found_dir="$additional_libdir"
+                found_a="$additional_libdir/lib$name.$libext"
+                if test -f "$additional_libdir/lib$name.la"; then
+                  found_la="$additional_libdir/lib$name.la"
+                fi
+              fi
+            fi
+          fi
+          if test "X$found_dir" = "X"; then
+            for x in $LDFLAGS $LTLIBZ; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+              case "$x" in
+                -L*)
+                  dir=`echo "X$x" | sed -e 's/^X-L//'`
+                  if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then
+                    found_dir="$dir"
+                    found_so="$dir/lib$name.$shlibext"
+                    if test -f "$dir/lib$name.la"; then
+                      found_la="$dir/lib$name.la"
+                    fi
+                  else
+                    if test -f "$dir/lib$name.$libext"; then
+                      found_dir="$dir"
+                      found_a="$dir/lib$name.$libext"
+                      if test -f "$dir/lib$name.la"; then
+                        found_la="$dir/lib$name.la"
+                      fi
+                    fi
+                  fi
+                  ;;
+              esac
+              if test "X$found_dir" != "X"; then
+                break
+              fi
+            done
+          fi
+          if test "X$found_dir" != "X"; then
+                        LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-L$found_dir -l$name"
+            if test "X$found_so" != "X"; then
+                                                        if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then
+                                LIBZ="${LIBZ}${LIBZ:+ }$found_so"
+              else
+                                                                                haveit=
+                for x in $ltrpathdirs; do
+                  if test "X$x" = "X$found_dir"; then
+                    haveit=yes
+                    break
+                  fi
+                done
+                if test -z "$haveit"; then
+                  ltrpathdirs="$ltrpathdirs $found_dir"
+                fi
+                                if test "$hardcode_direct" = yes; then
+                                                      LIBZ="${LIBZ}${LIBZ:+ }$found_so"
+                else
+                  if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then
+                                                            LIBZ="${LIBZ}${LIBZ:+ }$found_so"
+                                                            haveit=
+                    for x in $rpathdirs; do
+                      if test "X$x" = "X$found_dir"; then
+                        haveit=yes
+                        break
+                      fi
+                    done
+                    if test -z "$haveit"; then
+                      rpathdirs="$rpathdirs $found_dir"
+                    fi
+                  else
+                                                                                haveit=
+                    for x in $LDFLAGS $LIBZ; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+                      if test "X$x" = "X-L$found_dir"; then
+                        haveit=yes
+                        break
+                      fi
+                    done
+                    if test -z "$haveit"; then
+                      LIBZ="${LIBZ}${LIBZ:+ }-L$found_dir"
+                    fi
+                    if test "$hardcode_minus_L" != no; then
+                                                                                        LIBZ="${LIBZ}${LIBZ:+ }$found_so"
+                    else
+                                                                                                                                                                                LIBZ="${LIBZ}${LIBZ:+ }-l$name"
+                    fi
+                  fi
+                fi
+              fi
+            else
+              if test "X$found_a" != "X"; then
+                                LIBZ="${LIBZ}${LIBZ:+ }$found_a"
+              else
+                                                LIBZ="${LIBZ}${LIBZ:+ }-L$found_dir -l$name"
+              fi
+            fi
+                        additional_includedir=
+            case "$found_dir" in
+              */lib | */lib/)
+                basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'`
+                additional_includedir="$basedir/include"
+                ;;
+            esac
+            if test "X$additional_includedir" != "X"; then
+                                                                                                                if test "X$additional_includedir" != "X/usr/include"; then
+                haveit=
+                if test "X$additional_includedir" = "X/usr/local/include"; then
+                  if test -n "$GCC"; then
+                    case $host_os in
+                      linux*) haveit=yes;;
+                    esac
+                  fi
+                fi
+                if test -z "$haveit"; then
+                  for x in $CPPFLAGS $INCZ; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+                    if test "X$x" = "X-I$additional_includedir"; then
+                      haveit=yes
+                      break
+                    fi
+                  done
+                  if test -z "$haveit"; then
+                    if test -d "$additional_includedir"; then
+                                            INCZ="${INCZ}${INCZ:+ }-I$additional_includedir"
+                    fi
+                  fi
+                fi
+              fi
+            fi
+                        if test -n "$found_la"; then
+                                                        save_libdir="$libdir"
+              case "$found_la" in
+                */* | *\\*) . "$found_la" ;;
+                *) . "./$found_la" ;;
+              esac
+              libdir="$save_libdir"
+                            for dep in $dependency_libs; do
+                case "$dep" in
+                  -L*)
+                    additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
+                                                                                                                                                                if test "X$additional_libdir" != "X/usr/lib"; then
+                      haveit=
+                      if test "X$additional_libdir" = "X/usr/local/lib"; then
+                        if test -n "$GCC"; then
+                          case $host_os in
+                            linux*) haveit=yes;;
+                          esac
+                        fi
+                      fi
+                      if test -z "$haveit"; then
+                        haveit=
+                        for x in $LDFLAGS $LIBZ; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+                          if test "X$x" = "X-L$additional_libdir"; then
+                            haveit=yes
+                            break
+                          fi
+                        done
+                        if test -z "$haveit"; then
+                          if test -d "$additional_libdir"; then
+                                                        LIBZ="${LIBZ}${LIBZ:+ }-L$additional_libdir"
+                          fi
+                        fi
+                        haveit=
+                        for x in $LDFLAGS $LTLIBZ; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+                          if test "X$x" = "X-L$additional_libdir"; then
+                            haveit=yes
+                            break
+                          fi
+                        done
+                        if test -z "$haveit"; then
+                          if test -d "$additional_libdir"; then
+                                                        LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-L$additional_libdir"
+                          fi
+                        fi
+                      fi
+                    fi
+                    ;;
+                  -R*)
+                    dir=`echo "X$dep" | sed -e 's/^X-R//'`
+                    if test "$enable_rpath" != no; then
+                                                                  haveit=
+                      for x in $rpathdirs; do
+                        if test "X$x" = "X$dir"; then
+                          haveit=yes
+                          break
+                        fi
+                      done
+                      if test -z "$haveit"; then
+                        rpathdirs="$rpathdirs $dir"
+                      fi
+                                                                  haveit=
+                      for x in $ltrpathdirs; do
+                        if test "X$x" = "X$dir"; then
+                          haveit=yes
+                          break
+                        fi
+                      done
+                      if test -z "$haveit"; then
+                        ltrpathdirs="$ltrpathdirs $dir"
+                      fi
+                    fi
+                    ;;
+                  -l*)
+                                        names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
+                    ;;
+                  *.la)
+                                                                                names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
+                    ;;
+                  *)
+                                        LIBZ="${LIBZ}${LIBZ:+ }$dep"
+                    LTLIBZ="${LTLIBZ}${LTLIBZ:+ }$dep"
+                    ;;
+                esac
+              done
+            fi
+          else
+                                                            LIBZ="${LIBZ}${LIBZ:+ }-l$name"
+            LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-l$name"
+          fi
+        fi
+      fi
+    done
+  done
+  if test "X$rpathdirs" != "X"; then
+    if test -n "$hardcode_libdir_separator"; then
+                        alldirs=
+      for found_dir in $rpathdirs; do
+        alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir"
+      done
+            acl_save_libdir="$libdir"
+      libdir="$alldirs"
+      eval flag=\"$hardcode_libdir_flag_spec\"
+      libdir="$acl_save_libdir"
+      LIBZ="${LIBZ}${LIBZ:+ }$flag"
+    else
+            for found_dir in $rpathdirs; do
+        acl_save_libdir="$libdir"
+        libdir="$found_dir"
+        eval flag=\"$hardcode_libdir_flag_spec\"
+        libdir="$acl_save_libdir"
+        LIBZ="${LIBZ}${LIBZ:+ }$flag"
+      done
+    fi
+  fi
+  if test "X$ltrpathdirs" != "X"; then
+            for found_dir in $ltrpathdirs; do
+      LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-R$found_dir"
+    done
+  fi
+
+
+        ac_save_CPPFLAGS="$CPPFLAGS"
+
+  for element in $INCZ; do
+    haveit=
+    for x in $CPPFLAGS; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+      if test "X$x" = "X$element"; then
+        haveit=yes
+        break
+      fi
+    done
+    if test -z "$haveit"; then
+      CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element"
+    fi
+  done
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libz" >&5
+$as_echo_n "checking for libz... " >&6; }
+if test "${ac_cv_libz+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+    ac_save_LIBS="$LIBS"
+    LIBS="$LIBS $LIBZ"
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include "zlib.h";
+int
+main ()
+{
+int ret = deflateInit(NULL, 1);
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_libz=yes
+else
+  ac_cv_libz=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+    LIBS="$ac_save_LIBS"
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_libz" >&5
+$as_echo "$ac_cv_libz" >&6; }
+  if test "$ac_cv_libz" = yes; then
+    HAVE_LIBZ=yes
+
+$as_echo "#define HAVE_LIBZ 1" >>confdefs.h
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libz" >&5
+$as_echo_n "checking how to link with libz... " >&6; }
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBZ" >&5
+$as_echo "$LIBZ" >&6; }
+  else
+    HAVE_LIBZ=no
+            CPPFLAGS="$ac_save_CPPFLAGS"
+    LIBZ=
+    LTLIBZ=
+  fi
+
+
+
+
+
+
+    if test "$HAVE_LIBZ" = "yes"; then
+      # Make sure HAVE_ZLIB_H gets defined.  Some code uses that over
+      # HAVE_LIBZ, since initially we were only defining HAVE_ZLIB_H.
+      for ac_header in zlib.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default"
+if test "x$ac_cv_header_zlib_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_ZLIB_H 1
+_ACEOF
+
+fi
+
+done
+
+      LIBS="$LIBS $LIBZ"
+    fi
+    if test "$with_zlib" = "yes" -a "$HAVE_LIBZ" != "yes"; then
+      as_fn_error "zlib (libz) library was explicitly requested but not found" "$LINENO" 5
+    fi
+  fi
+
+
+
+case "${host}" in
+*-*-msdos* | *-*-go32* | *-*-mingw32* | *-*-cygwin* | *-*-windows*)
+
+$as_echo "#define USE_BINARY_FOPEN 1" >>confdefs.h
+ ;;
+esac
+
+# target-specific stuff:
+
+# Canonicalize the secondary target names.
+if test -n "$enable_targets"; then
+    for targ in `echo $enable_targets | sed 's/,/ /g'`
+    do
+	result=`$ac_config_sub $targ 2>/dev/null`
+	if test -n "$result"; then
+	    canon_targets="$canon_targets $result"
+	else
+	    # Allow targets that config.sub doesn't recognize, like "all".
+	    canon_targets="$canon_targets $targ"
+	fi
+    done
+fi
+
+ac_fn_c_check_header_mongrel "$LINENO" "iconv.h" "ac_cv_header_iconv_h" "$ac_includes_default"
+if test "x$ac_cv_header_iconv_h" = x""yes; then :
+
+fi
+
+
+
 
 
 
diff --git a/binutils/doc/Makefile.in b/binutils/doc/Makefile.in
index c828aae..96657ed 100644
--- a/binutils/doc/Makefile.in
+++ b/binutils/doc/Makefile.in
@@ -166,6 +166,7 @@  FGREP = @FGREP@
 GENCAT = @GENCAT@
 GMSGFMT = @GMSGFMT@
 GREP = @GREP@
+HAVE_LIBZ = @HAVE_LIBZ@
 HDEFINES = @HDEFINES@
 INCINTL = @INCINTL@
 INSTALL = @INSTALL@
@@ -185,10 +186,12 @@  LIBINTL_DEP = @LIBINTL_DEP@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
+LIBZ = @LIBZ@
 LIPO = @LIPO@
 LN_S = @LN_S@
 LTLIBICONV = @LTLIBICONV@
 LTLIBOBJS = @LTLIBOBJS@
+LTLIBZ = @LTLIBZ@
 MAINT = @MAINT@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
diff --git a/config/zlib.m4 b/config/zlib.m4
index b017499..1581124 100644
--- a/config/zlib.m4
+++ b/config/zlib.m4
@@ -9,8 +9,15 @@  AC_DEFUN([AM_ZLIB],
     [], [with_zlib=auto])
 
   if test "$with_zlib" != "no"; then
-    AC_SEARCH_LIBS(zlibVersion, z, [AC_CHECK_HEADERS(zlib.h)])
-    if test "$with_zlib" = "yes" -a "$ac_cv_header_zlib_h" != "yes"; then
+    AC_LIB_HAVE_LINKFLAGS([z], [], [#include "zlib.h";],
+                          [int ret = deflateInit(NULL, 1);])
+    if test "$HAVE_LIBZ" = "yes"; then
+      # Make sure HAVE_ZLIB_H gets defined.  Some code uses that over
+      # HAVE_LIBZ, since initially we were only defining HAVE_ZLIB_H.
+      AC_CHECK_HEADERS(zlib.h)
+      LIBS="$LIBS $LIBZ"
+    fi
+    if test "$with_zlib" = "yes" -a "$HAVE_LIBZ" != "yes"; then
       AC_MSG_ERROR([zlib (libz) library was explicitly requested but not found])
     fi
   fi
diff --git a/gas/Makefile.in b/gas/Makefile.in
index f190714..dd21288 100644
--- a/gas/Makefile.in
+++ b/gas/Makefile.in
@@ -73,6 +73,9 @@  am__aclocal_m4_deps = $(top_srcdir)/../bfd/acinclude.m4 \
 	$(top_srcdir)/../config/largefile.m4 \
 	$(top_srcdir)/../config/lcmessage.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
+	$(top_srcdir)/../config/lib-ld.m4 \
+	$(top_srcdir)/../config/lib-link.m4 \
+	$(top_srcdir)/../config/lib-prefix.m4 \
 	$(top_srcdir)/../config/nls.m4 \
 	$(top_srcdir)/../config/override.m4 \
 	$(top_srcdir)/../config/plugins.m4 \
@@ -181,6 +184,7 @@  GDBINIT = @GDBINIT@
 GENCAT = @GENCAT@
 GMSGFMT = @GMSGFMT@
 GREP = @GREP@
+HAVE_LIBZ = @HAVE_LIBZ@
 INCINTL = @INCINTL@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -199,9 +203,11 @@  LIBM = @LIBM@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
+LIBZ = @LIBZ@
 LIPO = @LIPO@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
+LTLIBZ = @LTLIBZ@
 MAINT = @MAINT@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
diff --git a/gas/aclocal.m4 b/gas/aclocal.m4
index ea731ac..3d9deaf 100644
--- a/gas/aclocal.m4
+++ b/gas/aclocal.m4
@@ -997,6 +997,9 @@  m4_include([../config/gettext-sister.m4])
 m4_include([../config/largefile.m4])
 m4_include([../config/lcmessage.m4])
 m4_include([../config/lead-dot.m4])
+m4_include([../config/lib-ld.m4])
+m4_include([../config/lib-link.m4])
+m4_include([../config/lib-prefix.m4])
 m4_include([../config/nls.m4])
 m4_include([../config/override.m4])
 m4_include([../config/plugins.m4])
diff --git a/gas/config.in b/gas/config.in
index fef16ee..c326c74 100644
--- a/gas/config.in
+++ b/gas/config.in
@@ -100,6 +100,9 @@ 
 /* Define if your <locale.h> file defines LC_MESSAGES. */
 #undef HAVE_LC_MESSAGES
 
+/* Define if you have the z library. */
+#undef HAVE_LIBZ
+
 /* Define to 1 if you have the <limits.h> header file. */
 #undef HAVE_LIMITS_H
 
diff --git a/gas/configure b/gas/configure
index 75d8a52..7ebd36a 100755
--- a/gas/configure
+++ b/gas/configure
@@ -602,6 +602,9 @@  ac_subst_vars='am__EXEEXT_FALSE
 am__EXEEXT_TRUE
 LTLIBOBJS
 LIBOBJS
+LTLIBZ
+LIBZ
+HAVE_LIBZ
 LIBM
 ALLOCA
 GENINSRC_NEVER_FALSE
@@ -767,6 +770,8 @@  enable_build_warnings
 enable_nls
 enable_maintainer_mode
 with_zlib
+enable_rpath
+with_libz_prefix
 '
       ac_precious_vars='build_alias
 host_alias
@@ -1415,6 +1420,7 @@  Optional Features:
   --disable-nls           do not use Native Language Support
   --enable-maintainer-mode  enable make rules and dependencies not useful
 			  (and sometimes confusing) to the casual installer
+  --disable-rpath         do not hardcode runtime library paths
 
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
@@ -1423,6 +1429,9 @@  Optional Packages:
                           both]
   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
   --with-zlib             include zlib support (auto/yes/no) default=auto
+  --with-gnu-ld           assume the C compiler uses GNU ld default=no
+  --with-libz-prefix[=DIR]  search for libz in DIR/include and DIR/lib
+  --without-libz-prefix     don't search for libz in includedir and libdir
 
 Some influential environment variables:
   CC          C compiler command
@@ -10967,7 +10976,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10970 "configure"
+#line 10979 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11073,7 +11082,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11076 "configure"
+#line 11085 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -14321,6 +14330,164 @@  esac
 
 # Link in zlib if we can.  This allows us to write compressed debug sections.
 
+      if test "X$prefix" = "XNONE"; then
+    acl_final_prefix="$ac_default_prefix"
+  else
+    acl_final_prefix="$prefix"
+  fi
+  if test "X$exec_prefix" = "XNONE"; then
+    acl_final_exec_prefix='${prefix}'
+  else
+    acl_final_exec_prefix="$exec_prefix"
+  fi
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
+  prefix="$acl_save_prefix"
+
+
+# Check whether --with-gnu-ld was given.
+if test "${with_gnu_ld+set}" = set; then :
+  withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
+else
+  with_gnu_ld=no
+fi
+
+# Prepare PATH_SEPARATOR.
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+  echo "#! /bin/sh" >conf$$.sh
+  echo  "exit 0"   >>conf$$.sh
+  chmod +x conf$$.sh
+  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
+    PATH_SEPARATOR=';'
+  else
+    PATH_SEPARATOR=:
+  fi
+  rm -f conf$$.sh
+fi
+ac_prog=ld
+if test "$GCC" = yes; then
+  # Check if gcc -print-prog-name=ld gives a path.
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by GCC" >&5
+$as_echo_n "checking for ld used by GCC... " >&6; }
+  case $host in
+  *-*-mingw*)
+    # gcc leaves a trailing carriage return which upsets mingw
+    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
+  *)
+    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
+  esac
+  case $ac_prog in
+    # Accept absolute paths.
+    [\\/]* | [A-Za-z]:[\\/]*)
+      re_direlt='/[^/][^/]*/\.\./'
+      # Canonicalize the path of ld
+      ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
+      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
+	ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
+      done
+      test -z "$LD" && LD="$ac_prog"
+      ;;
+  "")
+    # If it fails, then pretend we aren't using GCC.
+    ac_prog=ld
+    ;;
+  *)
+    # If it is relative, then search for the first ld in PATH.
+    with_gnu_ld=unknown
+    ;;
+  esac
+elif test "$with_gnu_ld" = yes; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
+$as_echo_n "checking for GNU ld... " >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
+$as_echo_n "checking for non-GNU ld... " >&6; }
+fi
+if test "${acl_cv_path_LD+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -z "$LD"; then
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
+  for ac_dir in $PATH; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+      acl_cv_path_LD="$ac_dir/$ac_prog"
+      # Check to see if the program is GNU ld.  I'd rather use --version,
+      # but apparently some GNU ld's only accept -v.
+      # Break only if it was the GNU/non-GNU ld that we prefer.
+      if "$acl_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
+	test "$with_gnu_ld" != no && break
+      else
+	test "$with_gnu_ld" != yes && break
+      fi
+    fi
+  done
+  IFS="$ac_save_ifs"
+else
+  acl_cv_path_LD="$LD" # Let the user override the test with a path.
+fi
+fi
+
+LD="$acl_cv_path_LD"
+if test -n "$LD"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
+$as_echo "$LD" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+test -z "$LD" && as_fn_error "no acceptable ld found in \$PATH" "$LINENO" 5
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
+$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; }
+if test "${acl_cv_prog_gnu_ld+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  # I'd rather use --version here, but apparently some GNU ld's only accept -v.
+if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
+  acl_cv_prog_gnu_ld=yes
+else
+  acl_cv_prog_gnu_ld=no
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_prog_gnu_ld" >&5
+$as_echo "$acl_cv_prog_gnu_ld" >&6; }
+with_gnu_ld=$acl_cv_prog_gnu_ld
+
+
+
+                                                { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5
+$as_echo_n "checking for shared library run path origin... " >&6; }
+if test "${acl_cv_rpath+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+    CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
+    ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
+    . ./conftest.sh
+    rm -f ./conftest.sh
+    acl_cv_rpath=done
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_rpath" >&5
+$as_echo "$acl_cv_rpath" >&6; }
+  wl="$acl_cv_wl"
+  libext="$acl_cv_libext"
+  shlibext="$acl_cv_shlibext"
+  hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
+  hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
+  hardcode_direct="$acl_cv_hardcode_direct"
+  hardcode_minus_L="$acl_cv_hardcode_minus_L"
+    # Check whether --enable-rpath was given.
+if test "${enable_rpath+set}" = set; then :
+  enableval=$enable_rpath; :
+else
+  enable_rpath=yes
+fi
+
+
+
   # See if the user specified whether he wants zlib support or not.
 
 # Check whether --with-zlib was given.
@@ -14332,60 +14499,472 @@  fi
 
 
   if test "$with_zlib" != "no"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing zlibVersion" >&5
-$as_echo_n "checking for library containing zlibVersion... " >&6; }
-if test "${ac_cv_search_zlibVersion+set}" = set; then :
+
+
+
+
+
+
+
+
+    use_additional=yes
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+
+    eval additional_includedir=\"$includedir\"
+    eval additional_libdir=\"$libdir\"
+
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+
+# Check whether --with-libz-prefix was given.
+if test "${with_libz_prefix+set}" = set; then :
+  withval=$with_libz_prefix;
+    if test "X$withval" = "Xno"; then
+      use_additional=no
+    else
+      if test "X$withval" = "X"; then
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+
+          eval additional_includedir=\"$includedir\"
+          eval additional_libdir=\"$libdir\"
+
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+      else
+        additional_includedir="$withval/include"
+        additional_libdir="$withval/lib"
+      fi
+    fi
+
+fi
+
+      LIBZ=
+  LTLIBZ=
+  INCZ=
+  rpathdirs=
+  ltrpathdirs=
+  names_already_handled=
+  names_next_round='z '
+  while test -n "$names_next_round"; do
+    names_this_round="$names_next_round"
+    names_next_round=
+    for name in $names_this_round; do
+      already_handled=
+      for n in $names_already_handled; do
+        if test "$n" = "$name"; then
+          already_handled=yes
+          break
+        fi
+      done
+      if test -z "$already_handled"; then
+        names_already_handled="$names_already_handled $name"
+                        uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
+        eval value=\"\$HAVE_LIB$uppername\"
+        if test -n "$value"; then
+          if test "$value" = yes; then
+            eval value=\"\$LIB$uppername\"
+            test -z "$value" || LIBZ="${LIBZ}${LIBZ:+ }$value"
+            eval value=\"\$LTLIB$uppername\"
+            test -z "$value" || LTLIBZ="${LTLIBZ}${LTLIBZ:+ }$value"
+          else
+                                    :
+          fi
+        else
+                              found_dir=
+          found_la=
+          found_so=
+          found_a=
+          if test $use_additional = yes; then
+            if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then
+              found_dir="$additional_libdir"
+              found_so="$additional_libdir/lib$name.$shlibext"
+              if test -f "$additional_libdir/lib$name.la"; then
+                found_la="$additional_libdir/lib$name.la"
+              fi
+            else
+              if test -f "$additional_libdir/lib$name.$libext"; then
+                found_dir="$additional_libdir"
+                found_a="$additional_libdir/lib$name.$libext"
+                if test -f "$additional_libdir/lib$name.la"; then
+                  found_la="$additional_libdir/lib$name.la"
+                fi
+              fi
+            fi
+          fi
+          if test "X$found_dir" = "X"; then
+            for x in $LDFLAGS $LTLIBZ; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+              case "$x" in
+                -L*)
+                  dir=`echo "X$x" | sed -e 's/^X-L//'`
+                  if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then
+                    found_dir="$dir"
+                    found_so="$dir/lib$name.$shlibext"
+                    if test -f "$dir/lib$name.la"; then
+                      found_la="$dir/lib$name.la"
+                    fi
+                  else
+                    if test -f "$dir/lib$name.$libext"; then
+                      found_dir="$dir"
+                      found_a="$dir/lib$name.$libext"
+                      if test -f "$dir/lib$name.la"; then
+                        found_la="$dir/lib$name.la"
+                      fi
+                    fi
+                  fi
+                  ;;
+              esac
+              if test "X$found_dir" != "X"; then
+                break
+              fi
+            done
+          fi
+          if test "X$found_dir" != "X"; then
+                        LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-L$found_dir -l$name"
+            if test "X$found_so" != "X"; then
+                                                        if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then
+                                LIBZ="${LIBZ}${LIBZ:+ }$found_so"
+              else
+                                                                                haveit=
+                for x in $ltrpathdirs; do
+                  if test "X$x" = "X$found_dir"; then
+                    haveit=yes
+                    break
+                  fi
+                done
+                if test -z "$haveit"; then
+                  ltrpathdirs="$ltrpathdirs $found_dir"
+                fi
+                                if test "$hardcode_direct" = yes; then
+                                                      LIBZ="${LIBZ}${LIBZ:+ }$found_so"
+                else
+                  if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then
+                                                            LIBZ="${LIBZ}${LIBZ:+ }$found_so"
+                                                            haveit=
+                    for x in $rpathdirs; do
+                      if test "X$x" = "X$found_dir"; then
+                        haveit=yes
+                        break
+                      fi
+                    done
+                    if test -z "$haveit"; then
+                      rpathdirs="$rpathdirs $found_dir"
+                    fi
+                  else
+                                                                                haveit=
+                    for x in $LDFLAGS $LIBZ; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+                      if test "X$x" = "X-L$found_dir"; then
+                        haveit=yes
+                        break
+                      fi
+                    done
+                    if test -z "$haveit"; then
+                      LIBZ="${LIBZ}${LIBZ:+ }-L$found_dir"
+                    fi
+                    if test "$hardcode_minus_L" != no; then
+                                                                                        LIBZ="${LIBZ}${LIBZ:+ }$found_so"
+                    else
+                                                                                                                                                                                LIBZ="${LIBZ}${LIBZ:+ }-l$name"
+                    fi
+                  fi
+                fi
+              fi
+            else
+              if test "X$found_a" != "X"; then
+                                LIBZ="${LIBZ}${LIBZ:+ }$found_a"
+              else
+                                                LIBZ="${LIBZ}${LIBZ:+ }-L$found_dir -l$name"
+              fi
+            fi
+                        additional_includedir=
+            case "$found_dir" in
+              */lib | */lib/)
+                basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'`
+                additional_includedir="$basedir/include"
+                ;;
+            esac
+            if test "X$additional_includedir" != "X"; then
+                                                                                                                if test "X$additional_includedir" != "X/usr/include"; then
+                haveit=
+                if test "X$additional_includedir" = "X/usr/local/include"; then
+                  if test -n "$GCC"; then
+                    case $host_os in
+                      linux*) haveit=yes;;
+                    esac
+                  fi
+                fi
+                if test -z "$haveit"; then
+                  for x in $CPPFLAGS $INCZ; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+                    if test "X$x" = "X-I$additional_includedir"; then
+                      haveit=yes
+                      break
+                    fi
+                  done
+                  if test -z "$haveit"; then
+                    if test -d "$additional_includedir"; then
+                                            INCZ="${INCZ}${INCZ:+ }-I$additional_includedir"
+                    fi
+                  fi
+                fi
+              fi
+            fi
+                        if test -n "$found_la"; then
+                                                        save_libdir="$libdir"
+              case "$found_la" in
+                */* | *\\*) . "$found_la" ;;
+                *) . "./$found_la" ;;
+              esac
+              libdir="$save_libdir"
+                            for dep in $dependency_libs; do
+                case "$dep" in
+                  -L*)
+                    additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
+                                                                                                                                                                if test "X$additional_libdir" != "X/usr/lib"; then
+                      haveit=
+                      if test "X$additional_libdir" = "X/usr/local/lib"; then
+                        if test -n "$GCC"; then
+                          case $host_os in
+                            linux*) haveit=yes;;
+                          esac
+                        fi
+                      fi
+                      if test -z "$haveit"; then
+                        haveit=
+                        for x in $LDFLAGS $LIBZ; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+                          if test "X$x" = "X-L$additional_libdir"; then
+                            haveit=yes
+                            break
+                          fi
+                        done
+                        if test -z "$haveit"; then
+                          if test -d "$additional_libdir"; then
+                                                        LIBZ="${LIBZ}${LIBZ:+ }-L$additional_libdir"
+                          fi
+                        fi
+                        haveit=
+                        for x in $LDFLAGS $LTLIBZ; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+                          if test "X$x" = "X-L$additional_libdir"; then
+                            haveit=yes
+                            break
+                          fi
+                        done
+                        if test -z "$haveit"; then
+                          if test -d "$additional_libdir"; then
+                                                        LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-L$additional_libdir"
+                          fi
+                        fi
+                      fi
+                    fi
+                    ;;
+                  -R*)
+                    dir=`echo "X$dep" | sed -e 's/^X-R//'`
+                    if test "$enable_rpath" != no; then
+                                                                  haveit=
+                      for x in $rpathdirs; do
+                        if test "X$x" = "X$dir"; then
+                          haveit=yes
+                          break
+                        fi
+                      done
+                      if test -z "$haveit"; then
+                        rpathdirs="$rpathdirs $dir"
+                      fi
+                                                                  haveit=
+                      for x in $ltrpathdirs; do
+                        if test "X$x" = "X$dir"; then
+                          haveit=yes
+                          break
+                        fi
+                      done
+                      if test -z "$haveit"; then
+                        ltrpathdirs="$ltrpathdirs $dir"
+                      fi
+                    fi
+                    ;;
+                  -l*)
+                                        names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
+                    ;;
+                  *.la)
+                                                                                names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
+                    ;;
+                  *)
+                                        LIBZ="${LIBZ}${LIBZ:+ }$dep"
+                    LTLIBZ="${LTLIBZ}${LTLIBZ:+ }$dep"
+                    ;;
+                esac
+              done
+            fi
+          else
+                                                            LIBZ="${LIBZ}${LIBZ:+ }-l$name"
+            LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-l$name"
+          fi
+        fi
+      fi
+    done
+  done
+  if test "X$rpathdirs" != "X"; then
+    if test -n "$hardcode_libdir_separator"; then
+                        alldirs=
+      for found_dir in $rpathdirs; do
+        alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir"
+      done
+            acl_save_libdir="$libdir"
+      libdir="$alldirs"
+      eval flag=\"$hardcode_libdir_flag_spec\"
+      libdir="$acl_save_libdir"
+      LIBZ="${LIBZ}${LIBZ:+ }$flag"
+    else
+            for found_dir in $rpathdirs; do
+        acl_save_libdir="$libdir"
+        libdir="$found_dir"
+        eval flag=\"$hardcode_libdir_flag_spec\"
+        libdir="$acl_save_libdir"
+        LIBZ="${LIBZ}${LIBZ:+ }$flag"
+      done
+    fi
+  fi
+  if test "X$ltrpathdirs" != "X"; then
+            for found_dir in $ltrpathdirs; do
+      LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-R$found_dir"
+    done
+  fi
+
+
+        ac_save_CPPFLAGS="$CPPFLAGS"
+
+  for element in $INCZ; do
+    haveit=
+    for x in $CPPFLAGS; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+      if test "X$x" = "X$element"; then
+        haveit=yes
+        break
+      fi
+    done
+    if test -z "$haveit"; then
+      CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element"
+    fi
+  done
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libz" >&5
+$as_echo_n "checking for libz... " >&6; }
+if test "${ac_cv_libz+set}" = set; then :
   $as_echo_n "(cached) " >&6
 else
-  ac_func_search_save_LIBS=$LIBS
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
 
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char zlibVersion ();
+    ac_save_LIBS="$LIBS"
+    LIBS="$LIBS $LIBZ"
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include "zlib.h";
 int
 main ()
 {
-return zlibVersion ();
+int ret = deflateInit(NULL, 1);
   ;
   return 0;
 }
 _ACEOF
-for ac_lib in '' z; do
-  if test -z "$ac_lib"; then
-    ac_res="none required"
-  else
-    ac_res=-l$ac_lib
-    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
-  fi
-  if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_search_zlibVersion=$ac_res
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_libz=yes
+else
+  ac_cv_libz=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext
-  if test "${ac_cv_search_zlibVersion+set}" = set; then :
-  break
-fi
-done
-if test "${ac_cv_search_zlibVersion+set}" = set; then :
+    conftest$ac_exeext conftest.$ac_ext
+    LIBS="$ac_save_LIBS"
 
-else
-  ac_cv_search_zlibVersion=no
 fi
-rm conftest.$ac_ext
-LIBS=$ac_func_search_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_zlibVersion" >&5
-$as_echo "$ac_cv_search_zlibVersion" >&6; }
-ac_res=$ac_cv_search_zlibVersion
-if test "$ac_res" != no; then :
-  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
-  for ac_header in zlib.h
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_libz" >&5
+$as_echo "$ac_cv_libz" >&6; }
+  if test "$ac_cv_libz" = yes; then
+    HAVE_LIBZ=yes
+
+$as_echo "#define HAVE_LIBZ 1" >>confdefs.h
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libz" >&5
+$as_echo_n "checking how to link with libz... " >&6; }
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBZ" >&5
+$as_echo "$LIBZ" >&6; }
+  else
+    HAVE_LIBZ=no
+            CPPFLAGS="$ac_save_CPPFLAGS"
+    LIBZ=
+    LTLIBZ=
+  fi
+
+
+
+
+
+
+    if test "$HAVE_LIBZ" = "yes"; then
+      # Make sure HAVE_ZLIB_H gets defined.  Some code uses that over
+      # HAVE_LIBZ, since initially we were only defining HAVE_ZLIB_H.
+      for ac_header in zlib.h
 do :
   ac_fn_c_check_header_mongrel "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default"
 if test "x$ac_cv_header_zlib_h" = x""yes; then :
@@ -14397,9 +14976,9 @@  fi
 
 done
 
-fi
-
-    if test "$with_zlib" = "yes" -a "$ac_cv_header_zlib_h" != "yes"; then
+      LIBS="$LIBS $LIBZ"
+    fi
+    if test "$with_zlib" = "yes" -a "$HAVE_LIBZ" != "yes"; then
       as_fn_error "zlib (libz) library was explicitly requested but not found" "$LINENO" 5
     fi
   fi
diff --git a/gas/doc/Makefile.in b/gas/doc/Makefile.in
index 02841d9..86d5a5d 100644
--- a/gas/doc/Makefile.in
+++ b/gas/doc/Makefile.in
@@ -64,6 +64,9 @@  am__aclocal_m4_deps = $(top_srcdir)/../bfd/acinclude.m4 \
 	$(top_srcdir)/../config/largefile.m4 \
 	$(top_srcdir)/../config/lcmessage.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
+	$(top_srcdir)/../config/lib-ld.m4 \
+	$(top_srcdir)/../config/lib-link.m4 \
+	$(top_srcdir)/../config/lib-prefix.m4 \
 	$(top_srcdir)/../config/nls.m4 \
 	$(top_srcdir)/../config/override.m4 \
 	$(top_srcdir)/../config/plugins.m4 \
@@ -150,6 +153,7 @@  GDBINIT = @GDBINIT@
 GENCAT = @GENCAT@
 GMSGFMT = @GMSGFMT@
 GREP = @GREP@
+HAVE_LIBZ = @HAVE_LIBZ@
 INCINTL = @INCINTL@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -168,9 +172,11 @@  LIBM = @LIBM@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
+LIBZ = @LIBZ@
 LIPO = @LIPO@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
+LTLIBZ = @LTLIBZ@
 MAINT = @MAINT@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
diff --git a/gdb/config.in b/gdb/config.in
index 9d3f32d..9b04c29 100644
--- a/gdb/config.in
+++ b/gdb/config.in
@@ -213,6 +213,9 @@ 
 /* Define to 1 if you have the `w' library (-lw). */
 #undef HAVE_LIBW
 
+/* Define if you have the z library. */
+#undef HAVE_LIBZ
+
 /* Define to 1 if you have the <linux/perf_event.h> header file. */
 #undef HAVE_LINUX_PERF_EVENT_H
 
diff --git a/gdb/configure b/gdb/configure
index 7ff74ba..0ae5c79 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -680,6 +680,9 @@  READLINE_TEXI_INCFLAG
 READLINE_CFLAGS
 READLINE_DEPS
 READLINE
+LTLIBZ
+LIBZ
+HAVE_LIBZ
 MIG
 WINDRES
 DLLTOOL
@@ -813,13 +816,14 @@  enable_profiling
 with_pkgversion
 with_bugurl
 with_zlib
+with_gnu_ld
+enable_rpath
+with_libz_prefix
 with_libiconv_prefix
 with_iconv_bin
 with_system_readline
 with_jit_reader_dir
 with_expat
-with_gnu_ld
-enable_rpath
 with_libexpat_prefix
 with_python
 with_guile
@@ -1528,6 +1532,9 @@  Optional Packages:
   --with-pkgversion=PKG   Use PKG in the version string in place of "GDB"
   --with-bugurl=URL       Direct users to URL to report a bug
   --with-zlib             include zlib support (auto/yes/no) default=auto
+  --with-gnu-ld           assume the C compiler uses GNU ld default=no
+  --with-libz-prefix[=DIR]  search for libz in DIR/include and DIR/lib
+  --without-libz-prefix     don't search for libz in includedir and libdir
   --with-libiconv-prefix=DIR
                           search for libiconv in DIR/include and DIR/lib
   --with-iconv-bin=PATH   specify where to find the iconv program
@@ -1535,7 +1542,6 @@  Optional Packages:
   --with-jit-reader-dir=PATH
                           directory to load the JIT readers from
   --with-expat            include expat support (auto/yes/no)
-  --with-gnu-ld           assume the C compiler uses GNU ld default=no
   --with-libexpat-prefix[=DIR]  search for libexpat in DIR/include and DIR/lib
   --without-libexpat-prefix     don't search for libexpat in includedir and libdir
   --with-python[=PYTHON]  include python support
@@ -6682,163 +6688,733 @@  fi
 
 # Link in zlib if we can.  This allows us to read compressed debug sections.
 
-  # See if the user specified whether he wants zlib support or not.
-
-# Check whether --with-zlib was given.
-if test "${with_zlib+set}" = set; then :
-  withval=$with_zlib;
-else
-  with_zlib=auto
-fi
+      if test "X$prefix" = "XNONE"; then
+    acl_final_prefix="$ac_default_prefix"
+  else
+    acl_final_prefix="$prefix"
+  fi
+  if test "X$exec_prefix" = "XNONE"; then
+    acl_final_exec_prefix='${prefix}'
+  else
+    acl_final_exec_prefix="$exec_prefix"
+  fi
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
+  prefix="$acl_save_prefix"
 
 
-  if test "$with_zlib" != "no"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing zlibVersion" >&5
-$as_echo_n "checking for library containing zlibVersion... " >&6; }
-if test "${ac_cv_search_zlibVersion+set}" = set; then :
-  $as_echo_n "(cached) " >&6
+# Check whether --with-gnu-ld was given.
+if test "${with_gnu_ld+set}" = set; then :
+  withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
 else
-  ac_func_search_save_LIBS=$LIBS
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
+  with_gnu_ld=no
+fi
 
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char zlibVersion ();
-int
-main ()
-{
-return zlibVersion ();
-  ;
-  return 0;
-}
-_ACEOF
-for ac_lib in '' z; do
-  if test -z "$ac_lib"; then
-    ac_res="none required"
+# Prepare PATH_SEPARATOR.
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+  echo "#! /bin/sh" >conf$$.sh
+  echo  "exit 0"   >>conf$$.sh
+  chmod +x conf$$.sh
+  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
+    PATH_SEPARATOR=';'
   else
-    ac_res=-l$ac_lib
-    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
+    PATH_SEPARATOR=:
   fi
-  if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_search_zlibVersion=$ac_res
+  rm -f conf$$.sh
 fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext
-  if test "${ac_cv_search_zlibVersion+set}" = set; then :
-  break
+ac_prog=ld
+if test "$GCC" = yes; then
+  # Check if gcc -print-prog-name=ld gives a path.
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by GCC" >&5
+$as_echo_n "checking for ld used by GCC... " >&6; }
+  case $host in
+  *-*-mingw*)
+    # gcc leaves a trailing carriage return which upsets mingw
+    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
+  *)
+    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
+  esac
+  case $ac_prog in
+    # Accept absolute paths.
+    [\\/]* | [A-Za-z]:[\\/]*)
+      re_direlt='/[^/][^/]*/\.\./'
+      # Canonicalize the path of ld
+      ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
+      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
+	ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
+      done
+      test -z "$LD" && LD="$ac_prog"
+      ;;
+  "")
+    # If it fails, then pretend we aren't using GCC.
+    ac_prog=ld
+    ;;
+  *)
+    # If it is relative, then search for the first ld in PATH.
+    with_gnu_ld=unknown
+    ;;
+  esac
+elif test "$with_gnu_ld" = yes; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
+$as_echo_n "checking for GNU ld... " >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
+$as_echo_n "checking for non-GNU ld... " >&6; }
 fi
-done
-if test "${ac_cv_search_zlibVersion+set}" = set; then :
-
+if test "${acl_cv_path_LD+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -z "$LD"; then
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
+  for ac_dir in $PATH; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+      acl_cv_path_LD="$ac_dir/$ac_prog"
+      # Check to see if the program is GNU ld.  I'd rather use --version,
+      # but apparently some GNU ld's only accept -v.
+      # Break only if it was the GNU/non-GNU ld that we prefer.
+      if "$acl_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
+	test "$with_gnu_ld" != no && break
+      else
+	test "$with_gnu_ld" != yes && break
+      fi
+    fi
+  done
+  IFS="$ac_save_ifs"
 else
-  ac_cv_search_zlibVersion=no
+  acl_cv_path_LD="$LD" # Let the user override the test with a path.
 fi
-rm conftest.$ac_ext
-LIBS=$ac_func_search_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_zlibVersion" >&5
-$as_echo "$ac_cv_search_zlibVersion" >&6; }
-ac_res=$ac_cv_search_zlibVersion
-if test "$ac_res" != no; then :
-  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
-  for ac_header in zlib.h
-do :
-  ac_fn_c_check_header_mongrel "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default"
-if test "x$ac_cv_header_zlib_h" = x""yes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_ZLIB_H 1
-_ACEOF
 
+LD="$acl_cv_path_LD"
+if test -n "$LD"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
+$as_echo "$LD" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+test -z "$LD" && as_fn_error "no acceptable ld found in \$PATH" "$LINENO" 5
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
+$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; }
+if test "${acl_cv_prog_gnu_ld+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  # I'd rather use --version here, but apparently some GNU ld's only accept -v.
+if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
+  acl_cv_prog_gnu_ld=yes
+else
+  acl_cv_prog_gnu_ld=no
 fi
-
-done
-
 fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_prog_gnu_ld" >&5
+$as_echo "$acl_cv_prog_gnu_ld" >&6; }
+with_gnu_ld=$acl_cv_prog_gnu_ld
 
-    if test "$with_zlib" = "yes" -a "$ac_cv_header_zlib_h" != "yes"; then
-      as_fn_error "zlib (libz) library was explicitly requested but not found" "$LINENO" 5
-    fi
-  fi
 
 
-# On HP/UX we may need libxpdl for dlgetmodinfo (used by solib-pa64.c).
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing dlgetmodinfo" >&5
-$as_echo_n "checking for library containing dlgetmodinfo... " >&6; }
-if test "${ac_cv_search_dlgetmodinfo+set}" = set; then :
+                                                { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5
+$as_echo_n "checking for shared library run path origin... " >&6; }
+if test "${acl_cv_rpath+set}" = set; then :
   $as_echo_n "(cached) " >&6
 else
-  ac_func_search_save_LIBS=$LIBS
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
 
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char dlgetmodinfo ();
-int
-main ()
-{
-return dlgetmodinfo ();
-  ;
-  return 0;
-}
-_ACEOF
-for ac_lib in '' dl xpdl; do
-  if test -z "$ac_lib"; then
-    ac_res="none required"
-  else
-    ac_res=-l$ac_lib
-    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
-  fi
-  if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_search_dlgetmodinfo=$ac_res
+    CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
+    ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
+    . ./conftest.sh
+    rm -f ./conftest.sh
+    acl_cv_rpath=done
+
 fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext
-  if test "${ac_cv_search_dlgetmodinfo+set}" = set; then :
-  break
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_rpath" >&5
+$as_echo "$acl_cv_rpath" >&6; }
+  wl="$acl_cv_wl"
+  libext="$acl_cv_libext"
+  shlibext="$acl_cv_shlibext"
+  hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
+  hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
+  hardcode_direct="$acl_cv_hardcode_direct"
+  hardcode_minus_L="$acl_cv_hardcode_minus_L"
+    # Check whether --enable-rpath was given.
+if test "${enable_rpath+set}" = set; then :
+  enableval=$enable_rpath; :
+else
+  enable_rpath=yes
 fi
-done
-if test "${ac_cv_search_dlgetmodinfo+set}" = set; then :
 
+
+
+  # See if the user specified whether he wants zlib support or not.
+
+# Check whether --with-zlib was given.
+if test "${with_zlib+set}" = set; then :
+  withval=$with_zlib;
 else
-  ac_cv_search_dlgetmodinfo=no
-fi
-rm conftest.$ac_ext
-LIBS=$ac_func_search_save_LIBS
+  with_zlib=auto
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_dlgetmodinfo" >&5
-$as_echo "$ac_cv_search_dlgetmodinfo" >&6; }
-ac_res=$ac_cv_search_dlgetmodinfo
-if test "$ac_res" != no; then :
-  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
 
-fi
 
+  if test "$with_zlib" != "no"; then
 
 
 
 
-# Check whether --with-libiconv-prefix was given.
-if test "${with_libiconv_prefix+set}" = set; then :
-  withval=$with_libiconv_prefix;
-    for dir in `echo "$withval" | tr : ' '`; do
-      if test -d $dir/include; then LIBICONV_INCLUDE="-I$dir/include"; fi
-      if test -d $dir/lib; then LIBICONV_LIBDIR="-L$dir/lib"; fi
-    done
 
-fi
 
 
-  BUILD_LIBICONV_LIBDIRS="../libiconv/lib/.libs ../libiconv/lib/_libs"
+
+    use_additional=yes
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+
+    eval additional_includedir=\"$includedir\"
+    eval additional_libdir=\"$libdir\"
+
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+
+# Check whether --with-libz-prefix was given.
+if test "${with_libz_prefix+set}" = set; then :
+  withval=$with_libz_prefix;
+    if test "X$withval" = "Xno"; then
+      use_additional=no
+    else
+      if test "X$withval" = "X"; then
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+
+          eval additional_includedir=\"$includedir\"
+          eval additional_libdir=\"$libdir\"
+
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+      else
+        additional_includedir="$withval/include"
+        additional_libdir="$withval/lib"
+      fi
+    fi
+
+fi
+
+      LIBZ=
+  LTLIBZ=
+  INCZ=
+  rpathdirs=
+  ltrpathdirs=
+  names_already_handled=
+  names_next_round='z '
+  while test -n "$names_next_round"; do
+    names_this_round="$names_next_round"
+    names_next_round=
+    for name in $names_this_round; do
+      already_handled=
+      for n in $names_already_handled; do
+        if test "$n" = "$name"; then
+          already_handled=yes
+          break
+        fi
+      done
+      if test -z "$already_handled"; then
+        names_already_handled="$names_already_handled $name"
+                        uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
+        eval value=\"\$HAVE_LIB$uppername\"
+        if test -n "$value"; then
+          if test "$value" = yes; then
+            eval value=\"\$LIB$uppername\"
+            test -z "$value" || LIBZ="${LIBZ}${LIBZ:+ }$value"
+            eval value=\"\$LTLIB$uppername\"
+            test -z "$value" || LTLIBZ="${LTLIBZ}${LTLIBZ:+ }$value"
+          else
+                                    :
+          fi
+        else
+                              found_dir=
+          found_la=
+          found_so=
+          found_a=
+          if test $use_additional = yes; then
+            if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then
+              found_dir="$additional_libdir"
+              found_so="$additional_libdir/lib$name.$shlibext"
+              if test -f "$additional_libdir/lib$name.la"; then
+                found_la="$additional_libdir/lib$name.la"
+              fi
+            else
+              if test -f "$additional_libdir/lib$name.$libext"; then
+                found_dir="$additional_libdir"
+                found_a="$additional_libdir/lib$name.$libext"
+                if test -f "$additional_libdir/lib$name.la"; then
+                  found_la="$additional_libdir/lib$name.la"
+                fi
+              fi
+            fi
+          fi
+          if test "X$found_dir" = "X"; then
+            for x in $LDFLAGS $LTLIBZ; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+              case "$x" in
+                -L*)
+                  dir=`echo "X$x" | sed -e 's/^X-L//'`
+                  if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then
+                    found_dir="$dir"
+                    found_so="$dir/lib$name.$shlibext"
+                    if test -f "$dir/lib$name.la"; then
+                      found_la="$dir/lib$name.la"
+                    fi
+                  else
+                    if test -f "$dir/lib$name.$libext"; then
+                      found_dir="$dir"
+                      found_a="$dir/lib$name.$libext"
+                      if test -f "$dir/lib$name.la"; then
+                        found_la="$dir/lib$name.la"
+                      fi
+                    fi
+                  fi
+                  ;;
+              esac
+              if test "X$found_dir" != "X"; then
+                break
+              fi
+            done
+          fi
+          if test "X$found_dir" != "X"; then
+                        LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-L$found_dir -l$name"
+            if test "X$found_so" != "X"; then
+                                                        if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then
+                                LIBZ="${LIBZ}${LIBZ:+ }$found_so"
+              else
+                                                                                haveit=
+                for x in $ltrpathdirs; do
+                  if test "X$x" = "X$found_dir"; then
+                    haveit=yes
+                    break
+                  fi
+                done
+                if test -z "$haveit"; then
+                  ltrpathdirs="$ltrpathdirs $found_dir"
+                fi
+                                if test "$hardcode_direct" = yes; then
+                                                      LIBZ="${LIBZ}${LIBZ:+ }$found_so"
+                else
+                  if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then
+                                                            LIBZ="${LIBZ}${LIBZ:+ }$found_so"
+                                                            haveit=
+                    for x in $rpathdirs; do
+                      if test "X$x" = "X$found_dir"; then
+                        haveit=yes
+                        break
+                      fi
+                    done
+                    if test -z "$haveit"; then
+                      rpathdirs="$rpathdirs $found_dir"
+                    fi
+                  else
+                                                                                haveit=
+                    for x in $LDFLAGS $LIBZ; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+                      if test "X$x" = "X-L$found_dir"; then
+                        haveit=yes
+                        break
+                      fi
+                    done
+                    if test -z "$haveit"; then
+                      LIBZ="${LIBZ}${LIBZ:+ }-L$found_dir"
+                    fi
+                    if test "$hardcode_minus_L" != no; then
+                                                                                        LIBZ="${LIBZ}${LIBZ:+ }$found_so"
+                    else
+                                                                                                                                                                                LIBZ="${LIBZ}${LIBZ:+ }-l$name"
+                    fi
+                  fi
+                fi
+              fi
+            else
+              if test "X$found_a" != "X"; then
+                                LIBZ="${LIBZ}${LIBZ:+ }$found_a"
+              else
+                                                LIBZ="${LIBZ}${LIBZ:+ }-L$found_dir -l$name"
+              fi
+            fi
+                        additional_includedir=
+            case "$found_dir" in
+              */lib | */lib/)
+                basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'`
+                additional_includedir="$basedir/include"
+                ;;
+            esac
+            if test "X$additional_includedir" != "X"; then
+                                                                                                                if test "X$additional_includedir" != "X/usr/include"; then
+                haveit=
+                if test "X$additional_includedir" = "X/usr/local/include"; then
+                  if test -n "$GCC"; then
+                    case $host_os in
+                      linux*) haveit=yes;;
+                    esac
+                  fi
+                fi
+                if test -z "$haveit"; then
+                  for x in $CPPFLAGS $INCZ; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+                    if test "X$x" = "X-I$additional_includedir"; then
+                      haveit=yes
+                      break
+                    fi
+                  done
+                  if test -z "$haveit"; then
+                    if test -d "$additional_includedir"; then
+                                            INCZ="${INCZ}${INCZ:+ }-I$additional_includedir"
+                    fi
+                  fi
+                fi
+              fi
+            fi
+                        if test -n "$found_la"; then
+                                                        save_libdir="$libdir"
+              case "$found_la" in
+                */* | *\\*) . "$found_la" ;;
+                *) . "./$found_la" ;;
+              esac
+              libdir="$save_libdir"
+                            for dep in $dependency_libs; do
+                case "$dep" in
+                  -L*)
+                    additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
+                                                                                                                                                                if test "X$additional_libdir" != "X/usr/lib"; then
+                      haveit=
+                      if test "X$additional_libdir" = "X/usr/local/lib"; then
+                        if test -n "$GCC"; then
+                          case $host_os in
+                            linux*) haveit=yes;;
+                          esac
+                        fi
+                      fi
+                      if test -z "$haveit"; then
+                        haveit=
+                        for x in $LDFLAGS $LIBZ; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+                          if test "X$x" = "X-L$additional_libdir"; then
+                            haveit=yes
+                            break
+                          fi
+                        done
+                        if test -z "$haveit"; then
+                          if test -d "$additional_libdir"; then
+                                                        LIBZ="${LIBZ}${LIBZ:+ }-L$additional_libdir"
+                          fi
+                        fi
+                        haveit=
+                        for x in $LDFLAGS $LTLIBZ; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+                          if test "X$x" = "X-L$additional_libdir"; then
+                            haveit=yes
+                            break
+                          fi
+                        done
+                        if test -z "$haveit"; then
+                          if test -d "$additional_libdir"; then
+                                                        LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-L$additional_libdir"
+                          fi
+                        fi
+                      fi
+                    fi
+                    ;;
+                  -R*)
+                    dir=`echo "X$dep" | sed -e 's/^X-R//'`
+                    if test "$enable_rpath" != no; then
+                                                                  haveit=
+                      for x in $rpathdirs; do
+                        if test "X$x" = "X$dir"; then
+                          haveit=yes
+                          break
+                        fi
+                      done
+                      if test -z "$haveit"; then
+                        rpathdirs="$rpathdirs $dir"
+                      fi
+                                                                  haveit=
+                      for x in $ltrpathdirs; do
+                        if test "X$x" = "X$dir"; then
+                          haveit=yes
+                          break
+                        fi
+                      done
+                      if test -z "$haveit"; then
+                        ltrpathdirs="$ltrpathdirs $dir"
+                      fi
+                    fi
+                    ;;
+                  -l*)
+                                        names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
+                    ;;
+                  *.la)
+                                                                                names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
+                    ;;
+                  *)
+                                        LIBZ="${LIBZ}${LIBZ:+ }$dep"
+                    LTLIBZ="${LTLIBZ}${LTLIBZ:+ }$dep"
+                    ;;
+                esac
+              done
+            fi
+          else
+                                                            LIBZ="${LIBZ}${LIBZ:+ }-l$name"
+            LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-l$name"
+          fi
+        fi
+      fi
+    done
+  done
+  if test "X$rpathdirs" != "X"; then
+    if test -n "$hardcode_libdir_separator"; then
+                        alldirs=
+      for found_dir in $rpathdirs; do
+        alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir"
+      done
+            acl_save_libdir="$libdir"
+      libdir="$alldirs"
+      eval flag=\"$hardcode_libdir_flag_spec\"
+      libdir="$acl_save_libdir"
+      LIBZ="${LIBZ}${LIBZ:+ }$flag"
+    else
+            for found_dir in $rpathdirs; do
+        acl_save_libdir="$libdir"
+        libdir="$found_dir"
+        eval flag=\"$hardcode_libdir_flag_spec\"
+        libdir="$acl_save_libdir"
+        LIBZ="${LIBZ}${LIBZ:+ }$flag"
+      done
+    fi
+  fi
+  if test "X$ltrpathdirs" != "X"; then
+            for found_dir in $ltrpathdirs; do
+      LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-R$found_dir"
+    done
+  fi
+
+
+        ac_save_CPPFLAGS="$CPPFLAGS"
+
+  for element in $INCZ; do
+    haveit=
+    for x in $CPPFLAGS; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+      if test "X$x" = "X$element"; then
+        haveit=yes
+        break
+      fi
+    done
+    if test -z "$haveit"; then
+      CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element"
+    fi
+  done
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libz" >&5
+$as_echo_n "checking for libz... " >&6; }
+if test "${ac_cv_libz+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+    ac_save_LIBS="$LIBS"
+    LIBS="$LIBS $LIBZ"
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include "zlib.h";
+int
+main ()
+{
+int ret = deflateInit(NULL, 1);
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_libz=yes
+else
+  ac_cv_libz=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+    LIBS="$ac_save_LIBS"
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_libz" >&5
+$as_echo "$ac_cv_libz" >&6; }
+  if test "$ac_cv_libz" = yes; then
+    HAVE_LIBZ=yes
+
+$as_echo "#define HAVE_LIBZ 1" >>confdefs.h
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libz" >&5
+$as_echo_n "checking how to link with libz... " >&6; }
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBZ" >&5
+$as_echo "$LIBZ" >&6; }
+  else
+    HAVE_LIBZ=no
+            CPPFLAGS="$ac_save_CPPFLAGS"
+    LIBZ=
+    LTLIBZ=
+  fi
+
+
+
+
+
+
+    if test "$HAVE_LIBZ" = "yes"; then
+      # Make sure HAVE_ZLIB_H gets defined.  Some code uses that over
+      # HAVE_LIBZ, since initially we were only defining HAVE_ZLIB_H.
+      for ac_header in zlib.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default"
+if test "x$ac_cv_header_zlib_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_ZLIB_H 1
+_ACEOF
+
+fi
+
+done
+
+      LIBS="$LIBS $LIBZ"
+    fi
+    if test "$with_zlib" = "yes" -a "$HAVE_LIBZ" != "yes"; then
+      as_fn_error "zlib (libz) library was explicitly requested but not found" "$LINENO" 5
+    fi
+  fi
+
+
+# On HP/UX we may need libxpdl for dlgetmodinfo (used by solib-pa64.c).
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing dlgetmodinfo" >&5
+$as_echo_n "checking for library containing dlgetmodinfo... " >&6; }
+if test "${ac_cv_search_dlgetmodinfo+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dlgetmodinfo ();
+int
+main ()
+{
+return dlgetmodinfo ();
+  ;
+  return 0;
+}
+_ACEOF
+for ac_lib in '' dl xpdl; do
+  if test -z "$ac_lib"; then
+    ac_res="none required"
+  else
+    ac_res=-l$ac_lib
+    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
+  fi
+  if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_search_dlgetmodinfo=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext
+  if test "${ac_cv_search_dlgetmodinfo+set}" = set; then :
+  break
+fi
+done
+if test "${ac_cv_search_dlgetmodinfo+set}" = set; then :
+
+else
+  ac_cv_search_dlgetmodinfo=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_dlgetmodinfo" >&5
+$as_echo "$ac_cv_search_dlgetmodinfo" >&6; }
+ac_res=$ac_cv_search_dlgetmodinfo
+if test "$ac_res" != no; then :
+  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+fi
+
+
+
+
+
+# Check whether --with-libiconv-prefix was given.
+if test "${with_libiconv_prefix+set}" = set; then :
+  withval=$with_libiconv_prefix;
+    for dir in `echo "$withval" | tr : ' '`; do
+      if test -d $dir/include; then LIBICONV_INCLUDE="-I$dir/include"; fi
+      if test -d $dir/lib; then LIBICONV_LIBDIR="-L$dir/lib"; fi
+    done
+
+fi
+
+
+  BUILD_LIBICONV_LIBDIRS="../libiconv/lib/.libs ../libiconv/lib/_libs"
   BUILD_LIBICONV_INCLUDE="-I../libiconv/include"
 
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for iconv" >&5
@@ -7519,164 +8095,6 @@  $as_echo "$as_me: WARNING: expat support disabled; some features may be unavaila
   HAVE_LIBEXPAT=no
 else
 
-      if test "X$prefix" = "XNONE"; then
-    acl_final_prefix="$ac_default_prefix"
-  else
-    acl_final_prefix="$prefix"
-  fi
-  if test "X$exec_prefix" = "XNONE"; then
-    acl_final_exec_prefix='${prefix}'
-  else
-    acl_final_exec_prefix="$exec_prefix"
-  fi
-  acl_save_prefix="$prefix"
-  prefix="$acl_final_prefix"
-  eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
-  prefix="$acl_save_prefix"
-
-
-# Check whether --with-gnu-ld was given.
-if test "${with_gnu_ld+set}" = set; then :
-  withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
-else
-  with_gnu_ld=no
-fi
-
-# Prepare PATH_SEPARATOR.
-# The user is always right.
-if test "${PATH_SEPARATOR+set}" != set; then
-  echo "#! /bin/sh" >conf$$.sh
-  echo  "exit 0"   >>conf$$.sh
-  chmod +x conf$$.sh
-  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
-    PATH_SEPARATOR=';'
-  else
-    PATH_SEPARATOR=:
-  fi
-  rm -f conf$$.sh
-fi
-ac_prog=ld
-if test "$GCC" = yes; then
-  # Check if gcc -print-prog-name=ld gives a path.
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by GCC" >&5
-$as_echo_n "checking for ld used by GCC... " >&6; }
-  case $host in
-  *-*-mingw*)
-    # gcc leaves a trailing carriage return which upsets mingw
-    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
-  *)
-    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
-  esac
-  case $ac_prog in
-    # Accept absolute paths.
-    [\\/]* | [A-Za-z]:[\\/]*)
-      re_direlt='/[^/][^/]*/\.\./'
-      # Canonicalize the path of ld
-      ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
-      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
-	ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
-      done
-      test -z "$LD" && LD="$ac_prog"
-      ;;
-  "")
-    # If it fails, then pretend we aren't using GCC.
-    ac_prog=ld
-    ;;
-  *)
-    # If it is relative, then search for the first ld in PATH.
-    with_gnu_ld=unknown
-    ;;
-  esac
-elif test "$with_gnu_ld" = yes; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
-$as_echo_n "checking for GNU ld... " >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
-$as_echo_n "checking for non-GNU ld... " >&6; }
-fi
-if test "${acl_cv_path_LD+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -z "$LD"; then
-  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
-  for ac_dir in $PATH; do
-    test -z "$ac_dir" && ac_dir=.
-    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
-      acl_cv_path_LD="$ac_dir/$ac_prog"
-      # Check to see if the program is GNU ld.  I'd rather use --version,
-      # but apparently some GNU ld's only accept -v.
-      # Break only if it was the GNU/non-GNU ld that we prefer.
-      if "$acl_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
-	test "$with_gnu_ld" != no && break
-      else
-	test "$with_gnu_ld" != yes && break
-      fi
-    fi
-  done
-  IFS="$ac_save_ifs"
-else
-  acl_cv_path_LD="$LD" # Let the user override the test with a path.
-fi
-fi
-
-LD="$acl_cv_path_LD"
-if test -n "$LD"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
-$as_echo "$LD" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-test -z "$LD" && as_fn_error "no acceptable ld found in \$PATH" "$LINENO" 5
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
-$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; }
-if test "${acl_cv_prog_gnu_ld+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-  # I'd rather use --version here, but apparently some GNU ld's only accept -v.
-if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
-  acl_cv_prog_gnu_ld=yes
-else
-  acl_cv_prog_gnu_ld=no
-fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_prog_gnu_ld" >&5
-$as_echo "$acl_cv_prog_gnu_ld" >&6; }
-with_gnu_ld=$acl_cv_prog_gnu_ld
-
-
-
-                                                { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5
-$as_echo_n "checking for shared library run path origin... " >&6; }
-if test "${acl_cv_rpath+set}" = set; then :
-  $as_echo_n "(cached) " >&6
-else
-
-    CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
-    ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
-    . ./conftest.sh
-    rm -f ./conftest.sh
-    acl_cv_rpath=done
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_rpath" >&5
-$as_echo "$acl_cv_rpath" >&6; }
-  wl="$acl_cv_wl"
-  libext="$acl_cv_libext"
-  shlibext="$acl_cv_shlibext"
-  hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
-  hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
-  hardcode_direct="$acl_cv_hardcode_direct"
-  hardcode_minus_L="$acl_cv_hardcode_minus_L"
-    # Check whether --enable-rpath was given.
-if test "${enable_rpath+set}" = set; then :
-  enableval=$enable_rpath; :
-else
-  enable_rpath=yes
-fi
-
-
-
 
 
 
diff --git a/gold/Makefile.in b/gold/Makefile.in
index cd4d165..01a7fee 100644
--- a/gold/Makefile.in
+++ b/gold/Makefile.in
@@ -78,6 +78,9 @@  am__aclocal_m4_deps = $(top_srcdir)/../config/depstand.m4 \
 	$(top_srcdir)/../config/gettext-sister.m4 \
 	$(top_srcdir)/../config/lcmessage.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
+	$(top_srcdir)/../config/lib-ld.m4 \
+	$(top_srcdir)/../config/lib-link.m4 \
+	$(top_srcdir)/../config/lib-prefix.m4 \
 	$(top_srcdir)/../config/nls.m4 \
 	$(top_srcdir)/../config/override.m4 \
 	$(top_srcdir)/../config/po.m4 \
@@ -301,6 +304,7 @@  GMSGFMT = @GMSGFMT@
 GOLD_LDADD = @GOLD_LDADD@
 GOLD_LDFLAGS = @GOLD_LDFLAGS@
 GREP = @GREP@
+HAVE_LIBZ = @HAVE_LIBZ@
 INCINTL = @INCINTL@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -314,8 +318,10 @@  LIBINTL = @LIBINTL@
 LIBINTL_DEP = @LIBINTL_DEP@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LIBZ = @LIBZ@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
+LTLIBZ = @LTLIBZ@
 MAINT = @MAINT@
 MAKEINFO = @MAKEINFO@
 MERGE_CONSTANTS_FLAG = @MERGE_CONSTANTS_FLAG@
diff --git a/gold/aclocal.m4 b/gold/aclocal.m4
index 8321894..8444d1d 100644
--- a/gold/aclocal.m4
+++ b/gold/aclocal.m4
@@ -984,6 +984,9 @@  m4_include([../config/depstand.m4])
 m4_include([../config/gettext-sister.m4])
 m4_include([../config/lcmessage.m4])
 m4_include([../config/lead-dot.m4])
+m4_include([../config/lib-ld.m4])
+m4_include([../config/lib-link.m4])
+m4_include([../config/lib-prefix.m4])
 m4_include([../config/nls.m4])
 m4_include([../config/override.m4])
 m4_include([../config/po.m4])
diff --git a/gold/config.in b/gold/config.in
index be77810..1871eb5 100644
--- a/gold/config.in
+++ b/gold/config.in
@@ -97,6 +97,9 @@ 
 /* Define if your <locale.h> file defines LC_MESSAGES. */
 #undef HAVE_LC_MESSAGES
 
+/* Define if you have the z library. */
+#undef HAVE_LIBZ
+
 /* Define to 1 if you have the <locale.h> header file. */
 #undef HAVE_LOCALE_H
 
diff --git a/gold/configure b/gold/configure
index 23e4735..66554cd 100755
--- a/gold/configure
+++ b/gold/configure
@@ -602,6 +602,9 @@  HAVE_PUBNAMES_FALSE
 HAVE_PUBNAMES_TRUE
 HAVE_ZLIB_FALSE
 HAVE_ZLIB_TRUE
+LTLIBZ
+LIBZ
+HAVE_LIBZ
 LIBOBJS
 LFS_CFLAGS
 GOLD_LDADD
@@ -797,6 +800,9 @@  enable_build_warnings
 with_gold_ldflags
 with_gold_ldadd
 with_zlib
+with_gnu_ld
+enable_rpath
+with_libz_prefix
 enable_maintainer_mode
 '
       ac_precious_vars='build_alias
@@ -1443,6 +1449,7 @@  Optional Features:
   --disable-nls           do not use Native Language Support
   --enable-werror         treat compile warnings as errors
   --enable-build-warnings enable build-time compiler warnings
+  --disable-rpath         do not hardcode runtime library paths
   --enable-maintainer-mode  enable make rules and dependencies not useful
 			  (and sometimes confusing) to the casual installer
 
@@ -1454,6 +1461,9 @@  Optional Packages:
   --with-gold-ldflags=FLAGS  additional link flags for gold
   --with-gold-ldadd=LIBS     additional libraries for gold
   --with-zlib             include zlib support (auto/yes/no) default=auto
+  --with-gnu-ld           assume the C compiler uses GNU ld default=no
+  --with-libz-prefix[=DIR]  search for libz in DIR/include and DIR/lib
+  --without-libz-prefix     don't search for libz in includedir and libdir
 
 Some influential environment variables:
   CC          C compiler command
@@ -6874,6 +6884,164 @@  fi
 
 # Link in zlib if we can.  This allows us to write compressed sections.
 
+      if test "X$prefix" = "XNONE"; then
+    acl_final_prefix="$ac_default_prefix"
+  else
+    acl_final_prefix="$prefix"
+  fi
+  if test "X$exec_prefix" = "XNONE"; then
+    acl_final_exec_prefix='${prefix}'
+  else
+    acl_final_exec_prefix="$exec_prefix"
+  fi
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
+  prefix="$acl_save_prefix"
+
+
+# Check whether --with-gnu-ld was given.
+if test "${with_gnu_ld+set}" = set; then :
+  withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
+else
+  with_gnu_ld=no
+fi
+
+# Prepare PATH_SEPARATOR.
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+  echo "#! /bin/sh" >conf$$.sh
+  echo  "exit 0"   >>conf$$.sh
+  chmod +x conf$$.sh
+  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
+    PATH_SEPARATOR=';'
+  else
+    PATH_SEPARATOR=:
+  fi
+  rm -f conf$$.sh
+fi
+ac_prog=ld
+if test "$GCC" = yes; then
+  # Check if gcc -print-prog-name=ld gives a path.
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by GCC" >&5
+$as_echo_n "checking for ld used by GCC... " >&6; }
+  case $host in
+  *-*-mingw*)
+    # gcc leaves a trailing carriage return which upsets mingw
+    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
+  *)
+    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
+  esac
+  case $ac_prog in
+    # Accept absolute paths.
+    [\\/]* | [A-Za-z]:[\\/]*)
+      re_direlt='/[^/][^/]*/\.\./'
+      # Canonicalize the path of ld
+      ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
+      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
+	ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
+      done
+      test -z "$LD" && LD="$ac_prog"
+      ;;
+  "")
+    # If it fails, then pretend we aren't using GCC.
+    ac_prog=ld
+    ;;
+  *)
+    # If it is relative, then search for the first ld in PATH.
+    with_gnu_ld=unknown
+    ;;
+  esac
+elif test "$with_gnu_ld" = yes; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
+$as_echo_n "checking for GNU ld... " >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
+$as_echo_n "checking for non-GNU ld... " >&6; }
+fi
+if test "${acl_cv_path_LD+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -z "$LD"; then
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
+  for ac_dir in $PATH; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+      acl_cv_path_LD="$ac_dir/$ac_prog"
+      # Check to see if the program is GNU ld.  I'd rather use --version,
+      # but apparently some GNU ld's only accept -v.
+      # Break only if it was the GNU/non-GNU ld that we prefer.
+      if "$acl_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
+	test "$with_gnu_ld" != no && break
+      else
+	test "$with_gnu_ld" != yes && break
+      fi
+    fi
+  done
+  IFS="$ac_save_ifs"
+else
+  acl_cv_path_LD="$LD" # Let the user override the test with a path.
+fi
+fi
+
+LD="$acl_cv_path_LD"
+if test -n "$LD"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
+$as_echo "$LD" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+test -z "$LD" && as_fn_error "no acceptable ld found in \$PATH" "$LINENO" 5
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
+$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; }
+if test "${acl_cv_prog_gnu_ld+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  # I'd rather use --version here, but apparently some GNU ld's only accept -v.
+if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
+  acl_cv_prog_gnu_ld=yes
+else
+  acl_cv_prog_gnu_ld=no
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_prog_gnu_ld" >&5
+$as_echo "$acl_cv_prog_gnu_ld" >&6; }
+with_gnu_ld=$acl_cv_prog_gnu_ld
+
+
+
+                                                { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5
+$as_echo_n "checking for shared library run path origin... " >&6; }
+if test "${acl_cv_rpath+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+    CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
+    ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
+    . ./conftest.sh
+    rm -f ./conftest.sh
+    acl_cv_rpath=done
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_rpath" >&5
+$as_echo "$acl_cv_rpath" >&6; }
+  wl="$acl_cv_wl"
+  libext="$acl_cv_libext"
+  shlibext="$acl_cv_shlibext"
+  hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
+  hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
+  hardcode_direct="$acl_cv_hardcode_direct"
+  hardcode_minus_L="$acl_cv_hardcode_minus_L"
+    # Check whether --enable-rpath was given.
+if test "${enable_rpath+set}" = set; then :
+  enableval=$enable_rpath; :
+else
+  enable_rpath=yes
+fi
+
+
+
   # See if the user specified whether he wants zlib support or not.
 
 # Check whether --with-zlib was given.
@@ -6885,60 +7053,472 @@  fi
 
 
   if test "$with_zlib" != "no"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing zlibVersion" >&5
-$as_echo_n "checking for library containing zlibVersion... " >&6; }
-if test "${ac_cv_search_zlibVersion+set}" = set; then :
+
+
+
+
+
+
+
+
+    use_additional=yes
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+
+    eval additional_includedir=\"$includedir\"
+    eval additional_libdir=\"$libdir\"
+
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+
+# Check whether --with-libz-prefix was given.
+if test "${with_libz_prefix+set}" = set; then :
+  withval=$with_libz_prefix;
+    if test "X$withval" = "Xno"; then
+      use_additional=no
+    else
+      if test "X$withval" = "X"; then
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+
+          eval additional_includedir=\"$includedir\"
+          eval additional_libdir=\"$libdir\"
+
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+      else
+        additional_includedir="$withval/include"
+        additional_libdir="$withval/lib"
+      fi
+    fi
+
+fi
+
+      LIBZ=
+  LTLIBZ=
+  INCZ=
+  rpathdirs=
+  ltrpathdirs=
+  names_already_handled=
+  names_next_round='z '
+  while test -n "$names_next_round"; do
+    names_this_round="$names_next_round"
+    names_next_round=
+    for name in $names_this_round; do
+      already_handled=
+      for n in $names_already_handled; do
+        if test "$n" = "$name"; then
+          already_handled=yes
+          break
+        fi
+      done
+      if test -z "$already_handled"; then
+        names_already_handled="$names_already_handled $name"
+                        uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
+        eval value=\"\$HAVE_LIB$uppername\"
+        if test -n "$value"; then
+          if test "$value" = yes; then
+            eval value=\"\$LIB$uppername\"
+            test -z "$value" || LIBZ="${LIBZ}${LIBZ:+ }$value"
+            eval value=\"\$LTLIB$uppername\"
+            test -z "$value" || LTLIBZ="${LTLIBZ}${LTLIBZ:+ }$value"
+          else
+                                    :
+          fi
+        else
+                              found_dir=
+          found_la=
+          found_so=
+          found_a=
+          if test $use_additional = yes; then
+            if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then
+              found_dir="$additional_libdir"
+              found_so="$additional_libdir/lib$name.$shlibext"
+              if test -f "$additional_libdir/lib$name.la"; then
+                found_la="$additional_libdir/lib$name.la"
+              fi
+            else
+              if test -f "$additional_libdir/lib$name.$libext"; then
+                found_dir="$additional_libdir"
+                found_a="$additional_libdir/lib$name.$libext"
+                if test -f "$additional_libdir/lib$name.la"; then
+                  found_la="$additional_libdir/lib$name.la"
+                fi
+              fi
+            fi
+          fi
+          if test "X$found_dir" = "X"; then
+            for x in $LDFLAGS $LTLIBZ; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+              case "$x" in
+                -L*)
+                  dir=`echo "X$x" | sed -e 's/^X-L//'`
+                  if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then
+                    found_dir="$dir"
+                    found_so="$dir/lib$name.$shlibext"
+                    if test -f "$dir/lib$name.la"; then
+                      found_la="$dir/lib$name.la"
+                    fi
+                  else
+                    if test -f "$dir/lib$name.$libext"; then
+                      found_dir="$dir"
+                      found_a="$dir/lib$name.$libext"
+                      if test -f "$dir/lib$name.la"; then
+                        found_la="$dir/lib$name.la"
+                      fi
+                    fi
+                  fi
+                  ;;
+              esac
+              if test "X$found_dir" != "X"; then
+                break
+              fi
+            done
+          fi
+          if test "X$found_dir" != "X"; then
+                        LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-L$found_dir -l$name"
+            if test "X$found_so" != "X"; then
+                                                        if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then
+                                LIBZ="${LIBZ}${LIBZ:+ }$found_so"
+              else
+                                                                                haveit=
+                for x in $ltrpathdirs; do
+                  if test "X$x" = "X$found_dir"; then
+                    haveit=yes
+                    break
+                  fi
+                done
+                if test -z "$haveit"; then
+                  ltrpathdirs="$ltrpathdirs $found_dir"
+                fi
+                                if test "$hardcode_direct" = yes; then
+                                                      LIBZ="${LIBZ}${LIBZ:+ }$found_so"
+                else
+                  if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then
+                                                            LIBZ="${LIBZ}${LIBZ:+ }$found_so"
+                                                            haveit=
+                    for x in $rpathdirs; do
+                      if test "X$x" = "X$found_dir"; then
+                        haveit=yes
+                        break
+                      fi
+                    done
+                    if test -z "$haveit"; then
+                      rpathdirs="$rpathdirs $found_dir"
+                    fi
+                  else
+                                                                                haveit=
+                    for x in $LDFLAGS $LIBZ; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+                      if test "X$x" = "X-L$found_dir"; then
+                        haveit=yes
+                        break
+                      fi
+                    done
+                    if test -z "$haveit"; then
+                      LIBZ="${LIBZ}${LIBZ:+ }-L$found_dir"
+                    fi
+                    if test "$hardcode_minus_L" != no; then
+                                                                                        LIBZ="${LIBZ}${LIBZ:+ }$found_so"
+                    else
+                                                                                                                                                                                LIBZ="${LIBZ}${LIBZ:+ }-l$name"
+                    fi
+                  fi
+                fi
+              fi
+            else
+              if test "X$found_a" != "X"; then
+                                LIBZ="${LIBZ}${LIBZ:+ }$found_a"
+              else
+                                                LIBZ="${LIBZ}${LIBZ:+ }-L$found_dir -l$name"
+              fi
+            fi
+                        additional_includedir=
+            case "$found_dir" in
+              */lib | */lib/)
+                basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'`
+                additional_includedir="$basedir/include"
+                ;;
+            esac
+            if test "X$additional_includedir" != "X"; then
+                                                                                                                if test "X$additional_includedir" != "X/usr/include"; then
+                haveit=
+                if test "X$additional_includedir" = "X/usr/local/include"; then
+                  if test -n "$GCC"; then
+                    case $host_os in
+                      linux*) haveit=yes;;
+                    esac
+                  fi
+                fi
+                if test -z "$haveit"; then
+                  for x in $CPPFLAGS $INCZ; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+                    if test "X$x" = "X-I$additional_includedir"; then
+                      haveit=yes
+                      break
+                    fi
+                  done
+                  if test -z "$haveit"; then
+                    if test -d "$additional_includedir"; then
+                                            INCZ="${INCZ}${INCZ:+ }-I$additional_includedir"
+                    fi
+                  fi
+                fi
+              fi
+            fi
+                        if test -n "$found_la"; then
+                                                        save_libdir="$libdir"
+              case "$found_la" in
+                */* | *\\*) . "$found_la" ;;
+                *) . "./$found_la" ;;
+              esac
+              libdir="$save_libdir"
+                            for dep in $dependency_libs; do
+                case "$dep" in
+                  -L*)
+                    additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
+                                                                                                                                                                if test "X$additional_libdir" != "X/usr/lib"; then
+                      haveit=
+                      if test "X$additional_libdir" = "X/usr/local/lib"; then
+                        if test -n "$GCC"; then
+                          case $host_os in
+                            linux*) haveit=yes;;
+                          esac
+                        fi
+                      fi
+                      if test -z "$haveit"; then
+                        haveit=
+                        for x in $LDFLAGS $LIBZ; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+                          if test "X$x" = "X-L$additional_libdir"; then
+                            haveit=yes
+                            break
+                          fi
+                        done
+                        if test -z "$haveit"; then
+                          if test -d "$additional_libdir"; then
+                                                        LIBZ="${LIBZ}${LIBZ:+ }-L$additional_libdir"
+                          fi
+                        fi
+                        haveit=
+                        for x in $LDFLAGS $LTLIBZ; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+                          if test "X$x" = "X-L$additional_libdir"; then
+                            haveit=yes
+                            break
+                          fi
+                        done
+                        if test -z "$haveit"; then
+                          if test -d "$additional_libdir"; then
+                                                        LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-L$additional_libdir"
+                          fi
+                        fi
+                      fi
+                    fi
+                    ;;
+                  -R*)
+                    dir=`echo "X$dep" | sed -e 's/^X-R//'`
+                    if test "$enable_rpath" != no; then
+                                                                  haveit=
+                      for x in $rpathdirs; do
+                        if test "X$x" = "X$dir"; then
+                          haveit=yes
+                          break
+                        fi
+                      done
+                      if test -z "$haveit"; then
+                        rpathdirs="$rpathdirs $dir"
+                      fi
+                                                                  haveit=
+                      for x in $ltrpathdirs; do
+                        if test "X$x" = "X$dir"; then
+                          haveit=yes
+                          break
+                        fi
+                      done
+                      if test -z "$haveit"; then
+                        ltrpathdirs="$ltrpathdirs $dir"
+                      fi
+                    fi
+                    ;;
+                  -l*)
+                                        names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
+                    ;;
+                  *.la)
+                                                                                names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
+                    ;;
+                  *)
+                                        LIBZ="${LIBZ}${LIBZ:+ }$dep"
+                    LTLIBZ="${LTLIBZ}${LTLIBZ:+ }$dep"
+                    ;;
+                esac
+              done
+            fi
+          else
+                                                            LIBZ="${LIBZ}${LIBZ:+ }-l$name"
+            LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-l$name"
+          fi
+        fi
+      fi
+    done
+  done
+  if test "X$rpathdirs" != "X"; then
+    if test -n "$hardcode_libdir_separator"; then
+                        alldirs=
+      for found_dir in $rpathdirs; do
+        alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir"
+      done
+            acl_save_libdir="$libdir"
+      libdir="$alldirs"
+      eval flag=\"$hardcode_libdir_flag_spec\"
+      libdir="$acl_save_libdir"
+      LIBZ="${LIBZ}${LIBZ:+ }$flag"
+    else
+            for found_dir in $rpathdirs; do
+        acl_save_libdir="$libdir"
+        libdir="$found_dir"
+        eval flag=\"$hardcode_libdir_flag_spec\"
+        libdir="$acl_save_libdir"
+        LIBZ="${LIBZ}${LIBZ:+ }$flag"
+      done
+    fi
+  fi
+  if test "X$ltrpathdirs" != "X"; then
+            for found_dir in $ltrpathdirs; do
+      LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-R$found_dir"
+    done
+  fi
+
+
+        ac_save_CPPFLAGS="$CPPFLAGS"
+
+  for element in $INCZ; do
+    haveit=
+    for x in $CPPFLAGS; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+      if test "X$x" = "X$element"; then
+        haveit=yes
+        break
+      fi
+    done
+    if test -z "$haveit"; then
+      CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element"
+    fi
+  done
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libz" >&5
+$as_echo_n "checking for libz... " >&6; }
+if test "${ac_cv_libz+set}" = set; then :
   $as_echo_n "(cached) " >&6
 else
-  ac_func_search_save_LIBS=$LIBS
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
 
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char zlibVersion ();
+    ac_save_LIBS="$LIBS"
+    LIBS="$LIBS $LIBZ"
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include "zlib.h";
 int
 main ()
 {
-return zlibVersion ();
+int ret = deflateInit(NULL, 1);
   ;
   return 0;
 }
 _ACEOF
-for ac_lib in '' z; do
-  if test -z "$ac_lib"; then
-    ac_res="none required"
-  else
-    ac_res=-l$ac_lib
-    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
-  fi
-  if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_search_zlibVersion=$ac_res
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_libz=yes
+else
+  ac_cv_libz=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext
-  if test "${ac_cv_search_zlibVersion+set}" = set; then :
-  break
-fi
-done
-if test "${ac_cv_search_zlibVersion+set}" = set; then :
+    conftest$ac_exeext conftest.$ac_ext
+    LIBS="$ac_save_LIBS"
 
-else
-  ac_cv_search_zlibVersion=no
 fi
-rm conftest.$ac_ext
-LIBS=$ac_func_search_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_zlibVersion" >&5
-$as_echo "$ac_cv_search_zlibVersion" >&6; }
-ac_res=$ac_cv_search_zlibVersion
-if test "$ac_res" != no; then :
-  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
-  for ac_header in zlib.h
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_libz" >&5
+$as_echo "$ac_cv_libz" >&6; }
+  if test "$ac_cv_libz" = yes; then
+    HAVE_LIBZ=yes
+
+$as_echo "#define HAVE_LIBZ 1" >>confdefs.h
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libz" >&5
+$as_echo_n "checking how to link with libz... " >&6; }
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBZ" >&5
+$as_echo "$LIBZ" >&6; }
+  else
+    HAVE_LIBZ=no
+            CPPFLAGS="$ac_save_CPPFLAGS"
+    LIBZ=
+    LTLIBZ=
+  fi
+
+
+
+
+
+
+    if test "$HAVE_LIBZ" = "yes"; then
+      # Make sure HAVE_ZLIB_H gets defined.  Some code uses that over
+      # HAVE_LIBZ, since initially we were only defining HAVE_ZLIB_H.
+      for ac_header in zlib.h
 do :
   ac_fn_c_check_header_mongrel "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default"
 if test "x$ac_cv_header_zlib_h" = x""yes; then :
@@ -6950,9 +7530,9 @@  fi
 
 done
 
-fi
-
-    if test "$with_zlib" = "yes" -a "$ac_cv_header_zlib_h" != "yes"; then
+      LIBS="$LIBS $LIBZ"
+    fi
+    if test "$with_zlib" = "yes" -a "$HAVE_LIBZ" != "yes"; then
       as_fn_error "zlib (libz) library was explicitly requested but not found" "$LINENO" 5
     fi
   fi
diff --git a/gold/testsuite/Makefile.in b/gold/testsuite/Makefile.in
index d818570..14aa076 100644
--- a/gold/testsuite/Makefile.in
+++ b/gold/testsuite/Makefile.in
@@ -756,6 +756,9 @@  am__aclocal_m4_deps = $(top_srcdir)/../config/depstand.m4 \
 	$(top_srcdir)/../config/gettext-sister.m4 \
 	$(top_srcdir)/../config/lcmessage.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
+	$(top_srcdir)/../config/lib-ld.m4 \
+	$(top_srcdir)/../config/lib-link.m4 \
+	$(top_srcdir)/../config/lib-prefix.m4 \
 	$(top_srcdir)/../config/nls.m4 \
 	$(top_srcdir)/../config/override.m4 \
 	$(top_srcdir)/../config/po.m4 \
@@ -2055,6 +2058,7 @@  GMSGFMT = @GMSGFMT@
 GOLD_LDADD = @GOLD_LDADD@
 GOLD_LDFLAGS = @GOLD_LDFLAGS@
 GREP = @GREP@
+HAVE_LIBZ = @HAVE_LIBZ@
 INCINTL = @INCINTL@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -2068,8 +2072,10 @@  LIBINTL = @LIBINTL@
 LIBINTL_DEP = @LIBINTL_DEP@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
+LIBZ = @LIBZ@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
+LTLIBZ = @LTLIBZ@
 MAINT = @MAINT@
 MAKEINFO = @MAKEINFO@
 MERGE_CONSTANTS_FLAG = @MERGE_CONSTANTS_FLAG@
diff --git a/ld/Makefile.in b/ld/Makefile.in
index 311452d..a54bc97 100644
--- a/ld/Makefile.in
+++ b/ld/Makefile.in
@@ -75,6 +75,9 @@  am__aclocal_m4_deps = $(top_srcdir)/../bfd/acinclude.m4 \
 	$(top_srcdir)/../config/largefile.m4 \
 	$(top_srcdir)/../config/lcmessage.m4 \
 	$(top_srcdir)/../config/lead-dot.m4 \
+	$(top_srcdir)/../config/lib-ld.m4 \
+	$(top_srcdir)/../config/lib-link.m4 \
+	$(top_srcdir)/../config/lib-prefix.m4 \
 	$(top_srcdir)/../config/nls.m4 \
 	$(top_srcdir)/../config/override.m4 \
 	$(top_srcdir)/../config/plugins.m4 \
@@ -226,6 +229,7 @@  FGREP = @FGREP@
 GENCAT = @GENCAT@
 GMSGFMT = @GMSGFMT@
 GREP = @GREP@
+HAVE_LIBZ = @HAVE_LIBZ@
 HDEFINES = @HDEFINES@
 
 #stuff for self hosting (can be overridden in config file).
@@ -250,6 +254,7 @@  LIBINTL_DEP = @LIBINTL_DEP@
 LIBOBJS = @LIBOBJS@
 LIBS = @LIBS@
 LIBTOOL = @LIBTOOL@
+LIBZ = @LIBZ@
 
 # Search path to override the default search path for -lfoo libraries.
 # If LIB_PATH is empty, the ones in the script (if any) are left alone.
@@ -262,6 +267,7 @@  LIB_PATH = @LIB_PATH@
 LIPO = @LIPO@
 LN_S = @LN_S@
 LTLIBOBJS = @LTLIBOBJS@
+LTLIBZ = @LTLIBZ@
 MAINT = @MAINT@
 MAKEINFO = @MAKEINFO@
 MKDIR_P = @MKDIR_P@
diff --git a/ld/aclocal.m4 b/ld/aclocal.m4
index 6585160..fed7950 100644
--- a/ld/aclocal.m4
+++ b/ld/aclocal.m4
@@ -997,6 +997,9 @@  m4_include([../config/gettext-sister.m4])
 m4_include([../config/largefile.m4])
 m4_include([../config/lcmessage.m4])
 m4_include([../config/lead-dot.m4])
+m4_include([../config/lib-ld.m4])
+m4_include([../config/lib-link.m4])
+m4_include([../config/lib-prefix.m4])
 m4_include([../config/nls.m4])
 m4_include([../config/override.m4])
 m4_include([../config/plugins.m4])
diff --git a/ld/config.in b/ld/config.in
index 2ab4844..226009e 100644
--- a/ld/config.in
+++ b/ld/config.in
@@ -68,6 +68,9 @@ 
 /* Define if your <locale.h> file defines LC_MESSAGES. */
 #undef HAVE_LC_MESSAGES
 
+/* Define if you have the z library. */
+#undef HAVE_LIBZ
+
 /* Define to 1 if you have the <limits.h> header file. */
 #undef HAVE_LIMITS_H
 
diff --git a/ld/configure b/ld/configure
index 8a7bd20..a0078da 100755
--- a/ld/configure
+++ b/ld/configure
@@ -609,6 +609,9 @@  EMUL_EXTRA_OFILES
 EMULATION_OFILES
 EMUL
 STRINGIFY
+LTLIBZ
+LIBZ
+HAVE_LIBZ
 enable_initfini_array
 ENABLE_PLUGINS_FALSE
 ENABLE_PLUGINS_TRUE
@@ -790,6 +793,8 @@  enable_build_warnings
 enable_nls
 enable_initfini_array
 with_zlib
+enable_rpath
+with_libz_prefix
 '
       ac_precious_vars='build_alias
 host_alias
@@ -1446,6 +1451,7 @@  Optional Features:
   --enable-build-warnings enable build-time compiler warnings
   --disable-nls           do not use Native Language Support
   --enable-initfini-array	use .init_array/.fini_array sections
+  --disable-rpath         do not hardcode runtime library paths
 
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
@@ -1456,6 +1462,9 @@  Optional Packages:
   --with-lib-path=dir1:dir2...  set default LIB_PATH
   --with-sysroot=DIR Search for usr/lib et al within DIR.
   --with-zlib             include zlib support (auto/yes/no) default=auto
+  --with-gnu-ld           assume the C compiler uses GNU ld default=no
+  --with-libz-prefix[=DIR]  search for libz in DIR/include and DIR/lib
+  --without-libz-prefix     don't search for libz in includedir and libdir
 
 Some influential environment variables:
   CC          C compiler command
@@ -11712,7 +11721,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11715 "configure"
+#line 11724 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11818,7 +11827,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11821 "configure"
+#line 11830 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -16757,6 +16766,164 @@  _ACEOF
 # Link in zlib if we can.  This is needed only for the bootstrap tests
 # right now, since those tests use libbfd, which depends on zlib.
 
+      if test "X$prefix" = "XNONE"; then
+    acl_final_prefix="$ac_default_prefix"
+  else
+    acl_final_prefix="$prefix"
+  fi
+  if test "X$exec_prefix" = "XNONE"; then
+    acl_final_exec_prefix='${prefix}'
+  else
+    acl_final_exec_prefix="$exec_prefix"
+  fi
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
+  prefix="$acl_save_prefix"
+
+
+# Check whether --with-gnu-ld was given.
+if test "${with_gnu_ld+set}" = set; then :
+  withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
+else
+  with_gnu_ld=no
+fi
+
+# Prepare PATH_SEPARATOR.
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+  echo "#! /bin/sh" >conf$$.sh
+  echo  "exit 0"   >>conf$$.sh
+  chmod +x conf$$.sh
+  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
+    PATH_SEPARATOR=';'
+  else
+    PATH_SEPARATOR=:
+  fi
+  rm -f conf$$.sh
+fi
+ac_prog=ld
+if test "$GCC" = yes; then
+  # Check if gcc -print-prog-name=ld gives a path.
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by GCC" >&5
+$as_echo_n "checking for ld used by GCC... " >&6; }
+  case $host in
+  *-*-mingw*)
+    # gcc leaves a trailing carriage return which upsets mingw
+    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
+  *)
+    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
+  esac
+  case $ac_prog in
+    # Accept absolute paths.
+    [\\/]* | [A-Za-z]:[\\/]*)
+      re_direlt='/[^/][^/]*/\.\./'
+      # Canonicalize the path of ld
+      ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
+      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
+	ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
+      done
+      test -z "$LD" && LD="$ac_prog"
+      ;;
+  "")
+    # If it fails, then pretend we aren't using GCC.
+    ac_prog=ld
+    ;;
+  *)
+    # If it is relative, then search for the first ld in PATH.
+    with_gnu_ld=unknown
+    ;;
+  esac
+elif test "$with_gnu_ld" = yes; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
+$as_echo_n "checking for GNU ld... " >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
+$as_echo_n "checking for non-GNU ld... " >&6; }
+fi
+if test "${acl_cv_path_LD+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -z "$LD"; then
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
+  for ac_dir in $PATH; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+      acl_cv_path_LD="$ac_dir/$ac_prog"
+      # Check to see if the program is GNU ld.  I'd rather use --version,
+      # but apparently some GNU ld's only accept -v.
+      # Break only if it was the GNU/non-GNU ld that we prefer.
+      if "$acl_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
+	test "$with_gnu_ld" != no && break
+      else
+	test "$with_gnu_ld" != yes && break
+      fi
+    fi
+  done
+  IFS="$ac_save_ifs"
+else
+  acl_cv_path_LD="$LD" # Let the user override the test with a path.
+fi
+fi
+
+LD="$acl_cv_path_LD"
+if test -n "$LD"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
+$as_echo "$LD" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+test -z "$LD" && as_fn_error "no acceptable ld found in \$PATH" "$LINENO" 5
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
+$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; }
+if test "${acl_cv_prog_gnu_ld+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  # I'd rather use --version here, but apparently some GNU ld's only accept -v.
+if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
+  acl_cv_prog_gnu_ld=yes
+else
+  acl_cv_prog_gnu_ld=no
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_prog_gnu_ld" >&5
+$as_echo "$acl_cv_prog_gnu_ld" >&6; }
+with_gnu_ld=$acl_cv_prog_gnu_ld
+
+
+
+                                                { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5
+$as_echo_n "checking for shared library run path origin... " >&6; }
+if test "${acl_cv_rpath+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+    CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
+    ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
+    . ./conftest.sh
+    rm -f ./conftest.sh
+    acl_cv_rpath=done
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_rpath" >&5
+$as_echo "$acl_cv_rpath" >&6; }
+  wl="$acl_cv_wl"
+  libext="$acl_cv_libext"
+  shlibext="$acl_cv_shlibext"
+  hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
+  hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
+  hardcode_direct="$acl_cv_hardcode_direct"
+  hardcode_minus_L="$acl_cv_hardcode_minus_L"
+    # Check whether --enable-rpath was given.
+if test "${enable_rpath+set}" = set; then :
+  enableval=$enable_rpath; :
+else
+  enable_rpath=yes
+fi
+
+
+
   # See if the user specified whether he wants zlib support or not.
 
 # Check whether --with-zlib was given.
@@ -16768,60 +16935,472 @@  fi
 
 
   if test "$with_zlib" != "no"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing zlibVersion" >&5
-$as_echo_n "checking for library containing zlibVersion... " >&6; }
-if test "${ac_cv_search_zlibVersion+set}" = set; then :
+
+
+
+
+
+
+
+
+    use_additional=yes
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+
+    eval additional_includedir=\"$includedir\"
+    eval additional_libdir=\"$libdir\"
+
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+
+# Check whether --with-libz-prefix was given.
+if test "${with_libz_prefix+set}" = set; then :
+  withval=$with_libz_prefix;
+    if test "X$withval" = "Xno"; then
+      use_additional=no
+    else
+      if test "X$withval" = "X"; then
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+
+          eval additional_includedir=\"$includedir\"
+          eval additional_libdir=\"$libdir\"
+
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+      else
+        additional_includedir="$withval/include"
+        additional_libdir="$withval/lib"
+      fi
+    fi
+
+fi
+
+      LIBZ=
+  LTLIBZ=
+  INCZ=
+  rpathdirs=
+  ltrpathdirs=
+  names_already_handled=
+  names_next_round='z '
+  while test -n "$names_next_round"; do
+    names_this_round="$names_next_round"
+    names_next_round=
+    for name in $names_this_round; do
+      already_handled=
+      for n in $names_already_handled; do
+        if test "$n" = "$name"; then
+          already_handled=yes
+          break
+        fi
+      done
+      if test -z "$already_handled"; then
+        names_already_handled="$names_already_handled $name"
+                        uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
+        eval value=\"\$HAVE_LIB$uppername\"
+        if test -n "$value"; then
+          if test "$value" = yes; then
+            eval value=\"\$LIB$uppername\"
+            test -z "$value" || LIBZ="${LIBZ}${LIBZ:+ }$value"
+            eval value=\"\$LTLIB$uppername\"
+            test -z "$value" || LTLIBZ="${LTLIBZ}${LTLIBZ:+ }$value"
+          else
+                                    :
+          fi
+        else
+                              found_dir=
+          found_la=
+          found_so=
+          found_a=
+          if test $use_additional = yes; then
+            if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then
+              found_dir="$additional_libdir"
+              found_so="$additional_libdir/lib$name.$shlibext"
+              if test -f "$additional_libdir/lib$name.la"; then
+                found_la="$additional_libdir/lib$name.la"
+              fi
+            else
+              if test -f "$additional_libdir/lib$name.$libext"; then
+                found_dir="$additional_libdir"
+                found_a="$additional_libdir/lib$name.$libext"
+                if test -f "$additional_libdir/lib$name.la"; then
+                  found_la="$additional_libdir/lib$name.la"
+                fi
+              fi
+            fi
+          fi
+          if test "X$found_dir" = "X"; then
+            for x in $LDFLAGS $LTLIBZ; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+              case "$x" in
+                -L*)
+                  dir=`echo "X$x" | sed -e 's/^X-L//'`
+                  if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then
+                    found_dir="$dir"
+                    found_so="$dir/lib$name.$shlibext"
+                    if test -f "$dir/lib$name.la"; then
+                      found_la="$dir/lib$name.la"
+                    fi
+                  else
+                    if test -f "$dir/lib$name.$libext"; then
+                      found_dir="$dir"
+                      found_a="$dir/lib$name.$libext"
+                      if test -f "$dir/lib$name.la"; then
+                        found_la="$dir/lib$name.la"
+                      fi
+                    fi
+                  fi
+                  ;;
+              esac
+              if test "X$found_dir" != "X"; then
+                break
+              fi
+            done
+          fi
+          if test "X$found_dir" != "X"; then
+                        LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-L$found_dir -l$name"
+            if test "X$found_so" != "X"; then
+                                                        if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then
+                                LIBZ="${LIBZ}${LIBZ:+ }$found_so"
+              else
+                                                                                haveit=
+                for x in $ltrpathdirs; do
+                  if test "X$x" = "X$found_dir"; then
+                    haveit=yes
+                    break
+                  fi
+                done
+                if test -z "$haveit"; then
+                  ltrpathdirs="$ltrpathdirs $found_dir"
+                fi
+                                if test "$hardcode_direct" = yes; then
+                                                      LIBZ="${LIBZ}${LIBZ:+ }$found_so"
+                else
+                  if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then
+                                                            LIBZ="${LIBZ}${LIBZ:+ }$found_so"
+                                                            haveit=
+                    for x in $rpathdirs; do
+                      if test "X$x" = "X$found_dir"; then
+                        haveit=yes
+                        break
+                      fi
+                    done
+                    if test -z "$haveit"; then
+                      rpathdirs="$rpathdirs $found_dir"
+                    fi
+                  else
+                                                                                haveit=
+                    for x in $LDFLAGS $LIBZ; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+                      if test "X$x" = "X-L$found_dir"; then
+                        haveit=yes
+                        break
+                      fi
+                    done
+                    if test -z "$haveit"; then
+                      LIBZ="${LIBZ}${LIBZ:+ }-L$found_dir"
+                    fi
+                    if test "$hardcode_minus_L" != no; then
+                                                                                        LIBZ="${LIBZ}${LIBZ:+ }$found_so"
+                    else
+                                                                                                                                                                                LIBZ="${LIBZ}${LIBZ:+ }-l$name"
+                    fi
+                  fi
+                fi
+              fi
+            else
+              if test "X$found_a" != "X"; then
+                                LIBZ="${LIBZ}${LIBZ:+ }$found_a"
+              else
+                                                LIBZ="${LIBZ}${LIBZ:+ }-L$found_dir -l$name"
+              fi
+            fi
+                        additional_includedir=
+            case "$found_dir" in
+              */lib | */lib/)
+                basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'`
+                additional_includedir="$basedir/include"
+                ;;
+            esac
+            if test "X$additional_includedir" != "X"; then
+                                                                                                                if test "X$additional_includedir" != "X/usr/include"; then
+                haveit=
+                if test "X$additional_includedir" = "X/usr/local/include"; then
+                  if test -n "$GCC"; then
+                    case $host_os in
+                      linux*) haveit=yes;;
+                    esac
+                  fi
+                fi
+                if test -z "$haveit"; then
+                  for x in $CPPFLAGS $INCZ; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+                    if test "X$x" = "X-I$additional_includedir"; then
+                      haveit=yes
+                      break
+                    fi
+                  done
+                  if test -z "$haveit"; then
+                    if test -d "$additional_includedir"; then
+                                            INCZ="${INCZ}${INCZ:+ }-I$additional_includedir"
+                    fi
+                  fi
+                fi
+              fi
+            fi
+                        if test -n "$found_la"; then
+                                                        save_libdir="$libdir"
+              case "$found_la" in
+                */* | *\\*) . "$found_la" ;;
+                *) . "./$found_la" ;;
+              esac
+              libdir="$save_libdir"
+                            for dep in $dependency_libs; do
+                case "$dep" in
+                  -L*)
+                    additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
+                                                                                                                                                                if test "X$additional_libdir" != "X/usr/lib"; then
+                      haveit=
+                      if test "X$additional_libdir" = "X/usr/local/lib"; then
+                        if test -n "$GCC"; then
+                          case $host_os in
+                            linux*) haveit=yes;;
+                          esac
+                        fi
+                      fi
+                      if test -z "$haveit"; then
+                        haveit=
+                        for x in $LDFLAGS $LIBZ; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+                          if test "X$x" = "X-L$additional_libdir"; then
+                            haveit=yes
+                            break
+                          fi
+                        done
+                        if test -z "$haveit"; then
+                          if test -d "$additional_libdir"; then
+                                                        LIBZ="${LIBZ}${LIBZ:+ }-L$additional_libdir"
+                          fi
+                        fi
+                        haveit=
+                        for x in $LDFLAGS $LTLIBZ; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+                          if test "X$x" = "X-L$additional_libdir"; then
+                            haveit=yes
+                            break
+                          fi
+                        done
+                        if test -z "$haveit"; then
+                          if test -d "$additional_libdir"; then
+                                                        LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-L$additional_libdir"
+                          fi
+                        fi
+                      fi
+                    fi
+                    ;;
+                  -R*)
+                    dir=`echo "X$dep" | sed -e 's/^X-R//'`
+                    if test "$enable_rpath" != no; then
+                                                                  haveit=
+                      for x in $rpathdirs; do
+                        if test "X$x" = "X$dir"; then
+                          haveit=yes
+                          break
+                        fi
+                      done
+                      if test -z "$haveit"; then
+                        rpathdirs="$rpathdirs $dir"
+                      fi
+                                                                  haveit=
+                      for x in $ltrpathdirs; do
+                        if test "X$x" = "X$dir"; then
+                          haveit=yes
+                          break
+                        fi
+                      done
+                      if test -z "$haveit"; then
+                        ltrpathdirs="$ltrpathdirs $dir"
+                      fi
+                    fi
+                    ;;
+                  -l*)
+                                        names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
+                    ;;
+                  *.la)
+                                                                                names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
+                    ;;
+                  *)
+                                        LIBZ="${LIBZ}${LIBZ:+ }$dep"
+                    LTLIBZ="${LTLIBZ}${LTLIBZ:+ }$dep"
+                    ;;
+                esac
+              done
+            fi
+          else
+                                                            LIBZ="${LIBZ}${LIBZ:+ }-l$name"
+            LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-l$name"
+          fi
+        fi
+      fi
+    done
+  done
+  if test "X$rpathdirs" != "X"; then
+    if test -n "$hardcode_libdir_separator"; then
+                        alldirs=
+      for found_dir in $rpathdirs; do
+        alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir"
+      done
+            acl_save_libdir="$libdir"
+      libdir="$alldirs"
+      eval flag=\"$hardcode_libdir_flag_spec\"
+      libdir="$acl_save_libdir"
+      LIBZ="${LIBZ}${LIBZ:+ }$flag"
+    else
+            for found_dir in $rpathdirs; do
+        acl_save_libdir="$libdir"
+        libdir="$found_dir"
+        eval flag=\"$hardcode_libdir_flag_spec\"
+        libdir="$acl_save_libdir"
+        LIBZ="${LIBZ}${LIBZ:+ }$flag"
+      done
+    fi
+  fi
+  if test "X$ltrpathdirs" != "X"; then
+            for found_dir in $ltrpathdirs; do
+      LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-R$found_dir"
+    done
+  fi
+
+
+        ac_save_CPPFLAGS="$CPPFLAGS"
+
+  for element in $INCZ; do
+    haveit=
+    for x in $CPPFLAGS; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+      if test "X$x" = "X$element"; then
+        haveit=yes
+        break
+      fi
+    done
+    if test -z "$haveit"; then
+      CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element"
+    fi
+  done
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libz" >&5
+$as_echo_n "checking for libz... " >&6; }
+if test "${ac_cv_libz+set}" = set; then :
   $as_echo_n "(cached) " >&6
 else
-  ac_func_search_save_LIBS=$LIBS
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
 
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char zlibVersion ();
+    ac_save_LIBS="$LIBS"
+    LIBS="$LIBS $LIBZ"
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include "zlib.h";
 int
 main ()
 {
-return zlibVersion ();
+int ret = deflateInit(NULL, 1);
   ;
   return 0;
 }
 _ACEOF
-for ac_lib in '' z; do
-  if test -z "$ac_lib"; then
-    ac_res="none required"
-  else
-    ac_res=-l$ac_lib
-    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
-  fi
-  if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_search_zlibVersion=$ac_res
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_libz=yes
+else
+  ac_cv_libz=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext
-  if test "${ac_cv_search_zlibVersion+set}" = set; then :
-  break
-fi
-done
-if test "${ac_cv_search_zlibVersion+set}" = set; then :
+    conftest$ac_exeext conftest.$ac_ext
+    LIBS="$ac_save_LIBS"
 
-else
-  ac_cv_search_zlibVersion=no
 fi
-rm conftest.$ac_ext
-LIBS=$ac_func_search_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_zlibVersion" >&5
-$as_echo "$ac_cv_search_zlibVersion" >&6; }
-ac_res=$ac_cv_search_zlibVersion
-if test "$ac_res" != no; then :
-  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
-  for ac_header in zlib.h
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_libz" >&5
+$as_echo "$ac_cv_libz" >&6; }
+  if test "$ac_cv_libz" = yes; then
+    HAVE_LIBZ=yes
+
+$as_echo "#define HAVE_LIBZ 1" >>confdefs.h
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libz" >&5
+$as_echo_n "checking how to link with libz... " >&6; }
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBZ" >&5
+$as_echo "$LIBZ" >&6; }
+  else
+    HAVE_LIBZ=no
+            CPPFLAGS="$ac_save_CPPFLAGS"
+    LIBZ=
+    LTLIBZ=
+  fi
+
+
+
+
+
+
+    if test "$HAVE_LIBZ" = "yes"; then
+      # Make sure HAVE_ZLIB_H gets defined.  Some code uses that over
+      # HAVE_LIBZ, since initially we were only defining HAVE_ZLIB_H.
+      for ac_header in zlib.h
 do :
   ac_fn_c_check_header_mongrel "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default"
 if test "x$ac_cv_header_zlib_h" = x""yes; then :
@@ -16833,9 +17412,9 @@  fi
 
 done
 
-fi
-
-    if test "$with_zlib" = "yes" -a "$ac_cv_header_zlib_h" != "yes"; then
+      LIBS="$LIBS $LIBZ"
+    fi
+    if test "$with_zlib" = "yes" -a "$HAVE_LIBZ" != "yes"; then
       as_fn_error "zlib (libz) library was explicitly requested but not found" "$LINENO" 5
     fi
   fi
diff --git a/sim/common/acinclude.m4 b/sim/common/acinclude.m4
index f96ec35..430ae0e 100644
--- a/sim/common/acinclude.m4
+++ b/sim/common/acinclude.m4
@@ -20,6 +20,9 @@ 
 
 # Include global overrides and fixes for Autoconf.
 m4_include(../../config/override.m4)
+m4_include([../../config/lib-ld.m4])
+m4_include([../../config/lib-link.m4])
+m4_include([../../config/lib-prefix.m4])
 sinclude([../../config/zlib.m4])
 m4_include([../../config/plugins.m4])
 m4_include([../../libtool.m4])
diff --git a/sim/common/config.in b/sim/common/config.in
index 5b8ebd8..d6d595e 100644
--- a/sim/common/config.in
+++ b/sim/common/config.in
@@ -31,6 +31,9 @@ 
 /* Define to 1 if you have the `socket' library (-lsocket). */
 #undef HAVE_LIBSOCKET
 
+/* Define if you have the z library. */
+#undef HAVE_LIBZ
+
 /* Define to 1 if you have the `lstat' function. */
 #undef HAVE_LSTAT
 
diff --git a/sim/common/configure b/sim/common/configure
index add4c0f..16f6f28 100755
--- a/sim/common/configure
+++ b/sim/common/configure
@@ -633,6 +633,9 @@  SED
 LIBTOOL
 PLUGINS_FALSE
 PLUGINS_TRUE
+LTLIBZ
+LIBZ
+HAVE_LIBZ
 CATOBJEXT
 GENCAT
 INSTOBJEXT
@@ -744,12 +747,14 @@  ac_subst_files=''
 ac_user_opts='
 enable_option_checking
 with_zlib
+with_gnu_ld
+enable_rpath
+with_libz_prefix
 enable_plugins
 enable_shared
 enable_static
 with_pic
 enable_fast_install
-with_gnu_ld
 enable_libtool_lock
 enable_maintainer_mode
 enable_sim_bswap
@@ -1388,6 +1393,7 @@  Optional Features:
   --disable-option-checking  ignore unrecognized --enable/--with options
   --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
   --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
+  --disable-rpath         do not hardcode runtime library paths
   --enable-plugins        Enable support for plugins
   --enable-shared[=PKGS]  build shared libraries [default=yes]
   --enable-static[=PKGS]  build static libraries [default=yes]
@@ -1407,6 +1413,9 @@  Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
   --with-zlib             include zlib support (auto/yes/no) default=auto
+  --with-gnu-ld           assume the C compiler uses GNU ld default=no
+  --with-libz-prefix[=DIR]  search for libz in DIR/include and DIR/lib
+  --without-libz-prefix     don't search for libz in includedir and libdir
   --with-pic              try to use only PIC/non-PIC objects [default=use
                           both]
   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
@@ -3788,6 +3797,164 @@  rmdir .tst 2>/dev/null
 
 DEPDIR="${am__leading_dot}deps"
 
+
+      if test "X$prefix" = "XNONE"; then
+    acl_final_prefix="$ac_default_prefix"
+  else
+    acl_final_prefix="$prefix"
+  fi
+  if test "X$exec_prefix" = "XNONE"; then
+    acl_final_exec_prefix='${prefix}'
+  else
+    acl_final_exec_prefix="$exec_prefix"
+  fi
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
+  prefix="$acl_save_prefix"
+
+
+# Check whether --with-gnu-ld was given.
+if test "${with_gnu_ld+set}" = set; then :
+  withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
+else
+  with_gnu_ld=no
+fi
+
+# Prepare PATH_SEPARATOR.
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+  echo "#! /bin/sh" >conf$$.sh
+  echo  "exit 0"   >>conf$$.sh
+  chmod +x conf$$.sh
+  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
+    PATH_SEPARATOR=';'
+  else
+    PATH_SEPARATOR=:
+  fi
+  rm -f conf$$.sh
+fi
+ac_prog=ld
+if test "$GCC" = yes; then
+  # Check if gcc -print-prog-name=ld gives a path.
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by GCC" >&5
+$as_echo_n "checking for ld used by GCC... " >&6; }
+  case $host in
+  *-*-mingw*)
+    # gcc leaves a trailing carriage return which upsets mingw
+    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
+  *)
+    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
+  esac
+  case $ac_prog in
+    # Accept absolute paths.
+    [\\/]* | [A-Za-z]:[\\/]*)
+      re_direlt='/[^/][^/]*/\.\./'
+      # Canonicalize the path of ld
+      ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
+      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
+	ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
+      done
+      test -z "$LD" && LD="$ac_prog"
+      ;;
+  "")
+    # If it fails, then pretend we aren't using GCC.
+    ac_prog=ld
+    ;;
+  *)
+    # If it is relative, then search for the first ld in PATH.
+    with_gnu_ld=unknown
+    ;;
+  esac
+elif test "$with_gnu_ld" = yes; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
+$as_echo_n "checking for GNU ld... " >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
+$as_echo_n "checking for non-GNU ld... " >&6; }
+fi
+if test "${acl_cv_path_LD+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -z "$LD"; then
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
+  for ac_dir in $PATH; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+      acl_cv_path_LD="$ac_dir/$ac_prog"
+      # Check to see if the program is GNU ld.  I'd rather use --version,
+      # but apparently some GNU ld's only accept -v.
+      # Break only if it was the GNU/non-GNU ld that we prefer.
+      if "$acl_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
+	test "$with_gnu_ld" != no && break
+      else
+	test "$with_gnu_ld" != yes && break
+      fi
+    fi
+  done
+  IFS="$ac_save_ifs"
+else
+  acl_cv_path_LD="$LD" # Let the user override the test with a path.
+fi
+fi
+
+LD="$acl_cv_path_LD"
+if test -n "$LD"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
+$as_echo "$LD" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+test -z "$LD" && as_fn_error "no acceptable ld found in \$PATH" "$LINENO" 5
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
+$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; }
+if test "${acl_cv_prog_gnu_ld+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  # I'd rather use --version here, but apparently some GNU ld's only accept -v.
+if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
+  acl_cv_prog_gnu_ld=yes
+else
+  acl_cv_prog_gnu_ld=no
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_prog_gnu_ld" >&5
+$as_echo "$acl_cv_prog_gnu_ld" >&6; }
+with_gnu_ld=$acl_cv_prog_gnu_ld
+
+
+
+                                                { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5
+$as_echo_n "checking for shared library run path origin... " >&6; }
+if test "${acl_cv_rpath+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+    CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
+    ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
+    . ./conftest.sh
+    rm -f ./conftest.sh
+    acl_cv_rpath=done
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_rpath" >&5
+$as_echo "$acl_cv_rpath" >&6; }
+  wl="$acl_cv_wl"
+  libext="$acl_cv_libext"
+  shlibext="$acl_cv_shlibext"
+  hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
+  hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
+  hardcode_direct="$acl_cv_hardcode_direct"
+  hardcode_minus_L="$acl_cv_hardcode_minus_L"
+    # Check whether --enable-rpath was given.
+if test "${enable_rpath+set}" = set; then :
+  enableval=$enable_rpath; :
+else
+  enable_rpath=yes
+fi
+
+
 case `pwd` in
   *\ * | *\	*)
     { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5
@@ -6962,60 +7129,472 @@  fi
 
 
   if test "$with_zlib" != "no"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing zlibVersion" >&5
-$as_echo_n "checking for library containing zlibVersion... " >&6; }
-if test "${ac_cv_search_zlibVersion+set}" = set; then :
+
+
+
+
+
+
+
+
+    use_additional=yes
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+
+    eval additional_includedir=\"$includedir\"
+    eval additional_libdir=\"$libdir\"
+
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+
+# Check whether --with-libz-prefix was given.
+if test "${with_libz_prefix+set}" = set; then :
+  withval=$with_libz_prefix;
+    if test "X$withval" = "Xno"; then
+      use_additional=no
+    else
+      if test "X$withval" = "X"; then
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+
+          eval additional_includedir=\"$includedir\"
+          eval additional_libdir=\"$libdir\"
+
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+      else
+        additional_includedir="$withval/include"
+        additional_libdir="$withval/lib"
+      fi
+    fi
+
+fi
+
+      LIBZ=
+  LTLIBZ=
+  INCZ=
+  rpathdirs=
+  ltrpathdirs=
+  names_already_handled=
+  names_next_round='z '
+  while test -n "$names_next_round"; do
+    names_this_round="$names_next_round"
+    names_next_round=
+    for name in $names_this_round; do
+      already_handled=
+      for n in $names_already_handled; do
+        if test "$n" = "$name"; then
+          already_handled=yes
+          break
+        fi
+      done
+      if test -z "$already_handled"; then
+        names_already_handled="$names_already_handled $name"
+                        uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
+        eval value=\"\$HAVE_LIB$uppername\"
+        if test -n "$value"; then
+          if test "$value" = yes; then
+            eval value=\"\$LIB$uppername\"
+            test -z "$value" || LIBZ="${LIBZ}${LIBZ:+ }$value"
+            eval value=\"\$LTLIB$uppername\"
+            test -z "$value" || LTLIBZ="${LTLIBZ}${LTLIBZ:+ }$value"
+          else
+                                    :
+          fi
+        else
+                              found_dir=
+          found_la=
+          found_so=
+          found_a=
+          if test $use_additional = yes; then
+            if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then
+              found_dir="$additional_libdir"
+              found_so="$additional_libdir/lib$name.$shlibext"
+              if test -f "$additional_libdir/lib$name.la"; then
+                found_la="$additional_libdir/lib$name.la"
+              fi
+            else
+              if test -f "$additional_libdir/lib$name.$libext"; then
+                found_dir="$additional_libdir"
+                found_a="$additional_libdir/lib$name.$libext"
+                if test -f "$additional_libdir/lib$name.la"; then
+                  found_la="$additional_libdir/lib$name.la"
+                fi
+              fi
+            fi
+          fi
+          if test "X$found_dir" = "X"; then
+            for x in $LDFLAGS $LTLIBZ; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+              case "$x" in
+                -L*)
+                  dir=`echo "X$x" | sed -e 's/^X-L//'`
+                  if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then
+                    found_dir="$dir"
+                    found_so="$dir/lib$name.$shlibext"
+                    if test -f "$dir/lib$name.la"; then
+                      found_la="$dir/lib$name.la"
+                    fi
+                  else
+                    if test -f "$dir/lib$name.$libext"; then
+                      found_dir="$dir"
+                      found_a="$dir/lib$name.$libext"
+                      if test -f "$dir/lib$name.la"; then
+                        found_la="$dir/lib$name.la"
+                      fi
+                    fi
+                  fi
+                  ;;
+              esac
+              if test "X$found_dir" != "X"; then
+                break
+              fi
+            done
+          fi
+          if test "X$found_dir" != "X"; then
+                        LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-L$found_dir -l$name"
+            if test "X$found_so" != "X"; then
+                                                        if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then
+                                LIBZ="${LIBZ}${LIBZ:+ }$found_so"
+              else
+                                                                                haveit=
+                for x in $ltrpathdirs; do
+                  if test "X$x" = "X$found_dir"; then
+                    haveit=yes
+                    break
+                  fi
+                done
+                if test -z "$haveit"; then
+                  ltrpathdirs="$ltrpathdirs $found_dir"
+                fi
+                                if test "$hardcode_direct" = yes; then
+                                                      LIBZ="${LIBZ}${LIBZ:+ }$found_so"
+                else
+                  if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then
+                                                            LIBZ="${LIBZ}${LIBZ:+ }$found_so"
+                                                            haveit=
+                    for x in $rpathdirs; do
+                      if test "X$x" = "X$found_dir"; then
+                        haveit=yes
+                        break
+                      fi
+                    done
+                    if test -z "$haveit"; then
+                      rpathdirs="$rpathdirs $found_dir"
+                    fi
+                  else
+                                                                                haveit=
+                    for x in $LDFLAGS $LIBZ; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+                      if test "X$x" = "X-L$found_dir"; then
+                        haveit=yes
+                        break
+                      fi
+                    done
+                    if test -z "$haveit"; then
+                      LIBZ="${LIBZ}${LIBZ:+ }-L$found_dir"
+                    fi
+                    if test "$hardcode_minus_L" != no; then
+                                                                                        LIBZ="${LIBZ}${LIBZ:+ }$found_so"
+                    else
+                                                                                                                                                                                LIBZ="${LIBZ}${LIBZ:+ }-l$name"
+                    fi
+                  fi
+                fi
+              fi
+            else
+              if test "X$found_a" != "X"; then
+                                LIBZ="${LIBZ}${LIBZ:+ }$found_a"
+              else
+                                                LIBZ="${LIBZ}${LIBZ:+ }-L$found_dir -l$name"
+              fi
+            fi
+                        additional_includedir=
+            case "$found_dir" in
+              */lib | */lib/)
+                basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'`
+                additional_includedir="$basedir/include"
+                ;;
+            esac
+            if test "X$additional_includedir" != "X"; then
+                                                                                                                if test "X$additional_includedir" != "X/usr/include"; then
+                haveit=
+                if test "X$additional_includedir" = "X/usr/local/include"; then
+                  if test -n "$GCC"; then
+                    case $host_os in
+                      linux*) haveit=yes;;
+                    esac
+                  fi
+                fi
+                if test -z "$haveit"; then
+                  for x in $CPPFLAGS $INCZ; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+                    if test "X$x" = "X-I$additional_includedir"; then
+                      haveit=yes
+                      break
+                    fi
+                  done
+                  if test -z "$haveit"; then
+                    if test -d "$additional_includedir"; then
+                                            INCZ="${INCZ}${INCZ:+ }-I$additional_includedir"
+                    fi
+                  fi
+                fi
+              fi
+            fi
+                        if test -n "$found_la"; then
+                                                        save_libdir="$libdir"
+              case "$found_la" in
+                */* | *\\*) . "$found_la" ;;
+                *) . "./$found_la" ;;
+              esac
+              libdir="$save_libdir"
+                            for dep in $dependency_libs; do
+                case "$dep" in
+                  -L*)
+                    additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
+                                                                                                                                                                if test "X$additional_libdir" != "X/usr/lib"; then
+                      haveit=
+                      if test "X$additional_libdir" = "X/usr/local/lib"; then
+                        if test -n "$GCC"; then
+                          case $host_os in
+                            linux*) haveit=yes;;
+                          esac
+                        fi
+                      fi
+                      if test -z "$haveit"; then
+                        haveit=
+                        for x in $LDFLAGS $LIBZ; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+                          if test "X$x" = "X-L$additional_libdir"; then
+                            haveit=yes
+                            break
+                          fi
+                        done
+                        if test -z "$haveit"; then
+                          if test -d "$additional_libdir"; then
+                                                        LIBZ="${LIBZ}${LIBZ:+ }-L$additional_libdir"
+                          fi
+                        fi
+                        haveit=
+                        for x in $LDFLAGS $LTLIBZ; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+                          if test "X$x" = "X-L$additional_libdir"; then
+                            haveit=yes
+                            break
+                          fi
+                        done
+                        if test -z "$haveit"; then
+                          if test -d "$additional_libdir"; then
+                                                        LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-L$additional_libdir"
+                          fi
+                        fi
+                      fi
+                    fi
+                    ;;
+                  -R*)
+                    dir=`echo "X$dep" | sed -e 's/^X-R//'`
+                    if test "$enable_rpath" != no; then
+                                                                  haveit=
+                      for x in $rpathdirs; do
+                        if test "X$x" = "X$dir"; then
+                          haveit=yes
+                          break
+                        fi
+                      done
+                      if test -z "$haveit"; then
+                        rpathdirs="$rpathdirs $dir"
+                      fi
+                                                                  haveit=
+                      for x in $ltrpathdirs; do
+                        if test "X$x" = "X$dir"; then
+                          haveit=yes
+                          break
+                        fi
+                      done
+                      if test -z "$haveit"; then
+                        ltrpathdirs="$ltrpathdirs $dir"
+                      fi
+                    fi
+                    ;;
+                  -l*)
+                                        names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
+                    ;;
+                  *.la)
+                                                                                names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
+                    ;;
+                  *)
+                                        LIBZ="${LIBZ}${LIBZ:+ }$dep"
+                    LTLIBZ="${LTLIBZ}${LTLIBZ:+ }$dep"
+                    ;;
+                esac
+              done
+            fi
+          else
+                                                            LIBZ="${LIBZ}${LIBZ:+ }-l$name"
+            LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-l$name"
+          fi
+        fi
+      fi
+    done
+  done
+  if test "X$rpathdirs" != "X"; then
+    if test -n "$hardcode_libdir_separator"; then
+                        alldirs=
+      for found_dir in $rpathdirs; do
+        alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir"
+      done
+            acl_save_libdir="$libdir"
+      libdir="$alldirs"
+      eval flag=\"$hardcode_libdir_flag_spec\"
+      libdir="$acl_save_libdir"
+      LIBZ="${LIBZ}${LIBZ:+ }$flag"
+    else
+            for found_dir in $rpathdirs; do
+        acl_save_libdir="$libdir"
+        libdir="$found_dir"
+        eval flag=\"$hardcode_libdir_flag_spec\"
+        libdir="$acl_save_libdir"
+        LIBZ="${LIBZ}${LIBZ:+ }$flag"
+      done
+    fi
+  fi
+  if test "X$ltrpathdirs" != "X"; then
+            for found_dir in $ltrpathdirs; do
+      LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-R$found_dir"
+    done
+  fi
+
+
+        ac_save_CPPFLAGS="$CPPFLAGS"
+
+  for element in $INCZ; do
+    haveit=
+    for x in $CPPFLAGS; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+      if test "X$x" = "X$element"; then
+        haveit=yes
+        break
+      fi
+    done
+    if test -z "$haveit"; then
+      CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element"
+    fi
+  done
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libz" >&5
+$as_echo_n "checking for libz... " >&6; }
+if test "${ac_cv_libz+set}" = set; then :
   $as_echo_n "(cached) " >&6
 else
-  ac_func_search_save_LIBS=$LIBS
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
 
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char zlibVersion ();
+    ac_save_LIBS="$LIBS"
+    LIBS="$LIBS $LIBZ"
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include "zlib.h";
 int
 main ()
 {
-return zlibVersion ();
+int ret = deflateInit(NULL, 1);
   ;
   return 0;
 }
 _ACEOF
-for ac_lib in '' z; do
-  if test -z "$ac_lib"; then
-    ac_res="none required"
-  else
-    ac_res=-l$ac_lib
-    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
-  fi
-  if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_search_zlibVersion=$ac_res
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_libz=yes
+else
+  ac_cv_libz=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext
-  if test "${ac_cv_search_zlibVersion+set}" = set; then :
-  break
-fi
-done
-if test "${ac_cv_search_zlibVersion+set}" = set; then :
+    conftest$ac_exeext conftest.$ac_ext
+    LIBS="$ac_save_LIBS"
 
-else
-  ac_cv_search_zlibVersion=no
-fi
-rm conftest.$ac_ext
-LIBS=$ac_func_search_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_zlibVersion" >&5
-$as_echo "$ac_cv_search_zlibVersion" >&6; }
-ac_res=$ac_cv_search_zlibVersion
-if test "$ac_res" != no; then :
-  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
-  for ac_header in zlib.h
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_libz" >&5
+$as_echo "$ac_cv_libz" >&6; }
+  if test "$ac_cv_libz" = yes; then
+    HAVE_LIBZ=yes
+
+$as_echo "#define HAVE_LIBZ 1" >>confdefs.h
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libz" >&5
+$as_echo_n "checking how to link with libz... " >&6; }
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBZ" >&5
+$as_echo "$LIBZ" >&6; }
+  else
+    HAVE_LIBZ=no
+            CPPFLAGS="$ac_save_CPPFLAGS"
+    LIBZ=
+    LTLIBZ=
+  fi
+
+
+
+
+
+
+    if test "$HAVE_LIBZ" = "yes"; then
+      # Make sure HAVE_ZLIB_H gets defined.  Some code uses that over
+      # HAVE_LIBZ, since initially we were only defining HAVE_ZLIB_H.
+      for ac_header in zlib.h
 do :
   ac_fn_c_check_header_mongrel "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default"
 if test "x$ac_cv_header_zlib_h" = x""yes; then :
@@ -7027,9 +7606,9 @@  fi
 
 done
 
-fi
-
-    if test "$with_zlib" = "yes" -a "$ac_cv_header_zlib_h" != "yes"; then
+      LIBS="$LIBS $LIBZ"
+    fi
+    if test "$with_zlib" = "yes" -a "$HAVE_LIBZ" != "yes"; then
       as_fn_error "zlib (libz) library was explicitly requested but not found" "$LINENO" 5
     fi
   fi
@@ -10623,7 +11202,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10626 "configure"
+#line 11205 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -10729,7 +11308,7 @@  else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 10732 "configure"
+#line 11311 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git a/sim/ppc/config.in b/sim/ppc/config.in
index b0c9e6f..32605bc 100644
--- a/sim/ppc/config.in
+++ b/sim/ppc/config.in
@@ -106,6 +106,9 @@ 
 /* Define to 1 if you have the `kill' function. */
 #undef HAVE_KILL
 
+/* Define if you have the z library. */
+#undef HAVE_LIBZ
+
 /* Define to 1 if you have the `link' function. */
 #undef HAVE_LINK
 
diff --git a/sim/ppc/configure b/sim/ppc/configure
index 5044383..6ec0fd0 100755
--- a/sim/ppc/configure
+++ b/sim/ppc/configure
@@ -627,6 +627,9 @@  HDEFINES
 CFLAGS_FOR_BUILD
 CC_FOR_BUILD
 LIBOBJS
+LTLIBZ
+LIBZ
+HAVE_LIBZ
 target_os
 target_vendor
 target_cpu
@@ -767,6 +770,9 @@  enable_sim_xor_endian
 with_pkgversion
 with_bugurl
 with_zlib
+with_gnu_ld
+enable_rpath
+with_libz_prefix
 enable_plugins
 '
       ac_precious_vars='build_alias
@@ -1431,6 +1437,7 @@  Optional Features:
   --enable-sim-trace			Specify whether tracing is supported.
   --enable-sim-warnings=opts		Extra CFLAGS for turning on compiler warnings except for idecode.o, semantics.o and psim.o
   --enable-sim-xor-endian=n		Specify number bytes involved in PowerPC XOR bi-endian mode (default 8).
+  --disable-rpath         do not hardcode runtime library paths
   --enable-plugins        Enable support for plugins
 
 Optional Packages:
@@ -1439,6 +1446,9 @@  Optional Packages:
   --with-pkgversion=PKG   Use PKG in the version string in place of "GDB"
   --with-bugurl=URL       Direct users to URL to report a bug
   --with-zlib             include zlib support (auto/yes/no) default=auto
+  --with-gnu-ld           assume the C compiler uses GNU ld default=no
+  --with-libz-prefix[=DIR]  search for libz in DIR/include and DIR/lib
+  --without-libz-prefix     don't search for libz in includedir and libdir
 
 Some influential environment variables:
   CC          C compiler command
@@ -2448,6 +2458,37 @@  ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
 
+# lib-ld.m4 serial 2 (gettext-0.12)
+
+
+
+
+
+
+# lib-link.m4 serial 4 (gettext-0.12)
+
+
+
+
+
+
+
+
+
+
+
+
+# lib-prefix.m4 serial 2 (gettext-0.12)
+
+
+
+
+
+
+
+
+
+
 
 
 
@@ -6817,6 +6858,164 @@  program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"`
 # BFD conditionally uses zlib, so we must link it in if libbfd does, by
 # using the same condition.
 
+      if test "X$prefix" = "XNONE"; then
+    acl_final_prefix="$ac_default_prefix"
+  else
+    acl_final_prefix="$prefix"
+  fi
+  if test "X$exec_prefix" = "XNONE"; then
+    acl_final_exec_prefix='${prefix}'
+  else
+    acl_final_exec_prefix="$exec_prefix"
+  fi
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
+  prefix="$acl_save_prefix"
+
+
+# Check whether --with-gnu-ld was given.
+if test "${with_gnu_ld+set}" = set; then :
+  withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
+else
+  with_gnu_ld=no
+fi
+
+# Prepare PATH_SEPARATOR.
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+  echo "#! /bin/sh" >conf$$.sh
+  echo  "exit 0"   >>conf$$.sh
+  chmod +x conf$$.sh
+  if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
+    PATH_SEPARATOR=';'
+  else
+    PATH_SEPARATOR=:
+  fi
+  rm -f conf$$.sh
+fi
+ac_prog=ld
+if test "$GCC" = yes; then
+  # Check if gcc -print-prog-name=ld gives a path.
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by GCC" >&5
+$as_echo_n "checking for ld used by GCC... " >&6; }
+  case $host in
+  *-*-mingw*)
+    # gcc leaves a trailing carriage return which upsets mingw
+    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
+  *)
+    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
+  esac
+  case $ac_prog in
+    # Accept absolute paths.
+    [\\/]* | [A-Za-z]:[\\/]*)
+      re_direlt='/[^/][^/]*/\.\./'
+      # Canonicalize the path of ld
+      ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
+      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
+	ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
+      done
+      test -z "$LD" && LD="$ac_prog"
+      ;;
+  "")
+    # If it fails, then pretend we aren't using GCC.
+    ac_prog=ld
+    ;;
+  *)
+    # If it is relative, then search for the first ld in PATH.
+    with_gnu_ld=unknown
+    ;;
+  esac
+elif test "$with_gnu_ld" = yes; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
+$as_echo_n "checking for GNU ld... " >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
+$as_echo_n "checking for non-GNU ld... " >&6; }
+fi
+if test "${acl_cv_path_LD+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -z "$LD"; then
+  IFS="${IFS= 	}"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
+  for ac_dir in $PATH; do
+    test -z "$ac_dir" && ac_dir=.
+    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+      acl_cv_path_LD="$ac_dir/$ac_prog"
+      # Check to see if the program is GNU ld.  I'd rather use --version,
+      # but apparently some GNU ld's only accept -v.
+      # Break only if it was the GNU/non-GNU ld that we prefer.
+      if "$acl_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
+	test "$with_gnu_ld" != no && break
+      else
+	test "$with_gnu_ld" != yes && break
+      fi
+    fi
+  done
+  IFS="$ac_save_ifs"
+else
+  acl_cv_path_LD="$LD" # Let the user override the test with a path.
+fi
+fi
+
+LD="$acl_cv_path_LD"
+if test -n "$LD"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
+$as_echo "$LD" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+test -z "$LD" && as_fn_error "no acceptable ld found in \$PATH" "$LINENO" 5
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
+$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; }
+if test "${acl_cv_prog_gnu_ld+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  # I'd rather use --version here, but apparently some GNU ld's only accept -v.
+if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
+  acl_cv_prog_gnu_ld=yes
+else
+  acl_cv_prog_gnu_ld=no
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_prog_gnu_ld" >&5
+$as_echo "$acl_cv_prog_gnu_ld" >&6; }
+with_gnu_ld=$acl_cv_prog_gnu_ld
+
+
+
+                                                { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5
+$as_echo_n "checking for shared library run path origin... " >&6; }
+if test "${acl_cv_rpath+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+    CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
+    ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
+    . ./conftest.sh
+    rm -f ./conftest.sh
+    acl_cv_rpath=done
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acl_cv_rpath" >&5
+$as_echo "$acl_cv_rpath" >&6; }
+  wl="$acl_cv_wl"
+  libext="$acl_cv_libext"
+  shlibext="$acl_cv_shlibext"
+  hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
+  hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
+  hardcode_direct="$acl_cv_hardcode_direct"
+  hardcode_minus_L="$acl_cv_hardcode_minus_L"
+    # Check whether --enable-rpath was given.
+if test "${enable_rpath+set}" = set; then :
+  enableval=$enable_rpath; :
+else
+  enable_rpath=yes
+fi
+
+
+
   # See if the user specified whether he wants zlib support or not.
 
 # Check whether --with-zlib was given.
@@ -6828,60 +7027,472 @@  fi
 
 
   if test "$with_zlib" != "no"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing zlibVersion" >&5
-$as_echo_n "checking for library containing zlibVersion... " >&6; }
-if test "${ac_cv_search_zlibVersion+set}" = set; then :
+
+
+
+
+
+
+
+
+    use_additional=yes
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+
+    eval additional_includedir=\"$includedir\"
+    eval additional_libdir=\"$libdir\"
+
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+
+# Check whether --with-libz-prefix was given.
+if test "${with_libz_prefix+set}" = set; then :
+  withval=$with_libz_prefix;
+    if test "X$withval" = "Xno"; then
+      use_additional=no
+    else
+      if test "X$withval" = "X"; then
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+
+          eval additional_includedir=\"$includedir\"
+          eval additional_libdir=\"$libdir\"
+
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+      else
+        additional_includedir="$withval/include"
+        additional_libdir="$withval/lib"
+      fi
+    fi
+
+fi
+
+      LIBZ=
+  LTLIBZ=
+  INCZ=
+  rpathdirs=
+  ltrpathdirs=
+  names_already_handled=
+  names_next_round='z '
+  while test -n "$names_next_round"; do
+    names_this_round="$names_next_round"
+    names_next_round=
+    for name in $names_this_round; do
+      already_handled=
+      for n in $names_already_handled; do
+        if test "$n" = "$name"; then
+          already_handled=yes
+          break
+        fi
+      done
+      if test -z "$already_handled"; then
+        names_already_handled="$names_already_handled $name"
+                        uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
+        eval value=\"\$HAVE_LIB$uppername\"
+        if test -n "$value"; then
+          if test "$value" = yes; then
+            eval value=\"\$LIB$uppername\"
+            test -z "$value" || LIBZ="${LIBZ}${LIBZ:+ }$value"
+            eval value=\"\$LTLIB$uppername\"
+            test -z "$value" || LTLIBZ="${LTLIBZ}${LTLIBZ:+ }$value"
+          else
+                                    :
+          fi
+        else
+                              found_dir=
+          found_la=
+          found_so=
+          found_a=
+          if test $use_additional = yes; then
+            if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then
+              found_dir="$additional_libdir"
+              found_so="$additional_libdir/lib$name.$shlibext"
+              if test -f "$additional_libdir/lib$name.la"; then
+                found_la="$additional_libdir/lib$name.la"
+              fi
+            else
+              if test -f "$additional_libdir/lib$name.$libext"; then
+                found_dir="$additional_libdir"
+                found_a="$additional_libdir/lib$name.$libext"
+                if test -f "$additional_libdir/lib$name.la"; then
+                  found_la="$additional_libdir/lib$name.la"
+                fi
+              fi
+            fi
+          fi
+          if test "X$found_dir" = "X"; then
+            for x in $LDFLAGS $LTLIBZ; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+              case "$x" in
+                -L*)
+                  dir=`echo "X$x" | sed -e 's/^X-L//'`
+                  if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then
+                    found_dir="$dir"
+                    found_so="$dir/lib$name.$shlibext"
+                    if test -f "$dir/lib$name.la"; then
+                      found_la="$dir/lib$name.la"
+                    fi
+                  else
+                    if test -f "$dir/lib$name.$libext"; then
+                      found_dir="$dir"
+                      found_a="$dir/lib$name.$libext"
+                      if test -f "$dir/lib$name.la"; then
+                        found_la="$dir/lib$name.la"
+                      fi
+                    fi
+                  fi
+                  ;;
+              esac
+              if test "X$found_dir" != "X"; then
+                break
+              fi
+            done
+          fi
+          if test "X$found_dir" != "X"; then
+                        LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-L$found_dir -l$name"
+            if test "X$found_so" != "X"; then
+                                                        if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then
+                                LIBZ="${LIBZ}${LIBZ:+ }$found_so"
+              else
+                                                                                haveit=
+                for x in $ltrpathdirs; do
+                  if test "X$x" = "X$found_dir"; then
+                    haveit=yes
+                    break
+                  fi
+                done
+                if test -z "$haveit"; then
+                  ltrpathdirs="$ltrpathdirs $found_dir"
+                fi
+                                if test "$hardcode_direct" = yes; then
+                                                      LIBZ="${LIBZ}${LIBZ:+ }$found_so"
+                else
+                  if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then
+                                                            LIBZ="${LIBZ}${LIBZ:+ }$found_so"
+                                                            haveit=
+                    for x in $rpathdirs; do
+                      if test "X$x" = "X$found_dir"; then
+                        haveit=yes
+                        break
+                      fi
+                    done
+                    if test -z "$haveit"; then
+                      rpathdirs="$rpathdirs $found_dir"
+                    fi
+                  else
+                                                                                haveit=
+                    for x in $LDFLAGS $LIBZ; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+                      if test "X$x" = "X-L$found_dir"; then
+                        haveit=yes
+                        break
+                      fi
+                    done
+                    if test -z "$haveit"; then
+                      LIBZ="${LIBZ}${LIBZ:+ }-L$found_dir"
+                    fi
+                    if test "$hardcode_minus_L" != no; then
+                                                                                        LIBZ="${LIBZ}${LIBZ:+ }$found_so"
+                    else
+                                                                                                                                                                                LIBZ="${LIBZ}${LIBZ:+ }-l$name"
+                    fi
+                  fi
+                fi
+              fi
+            else
+              if test "X$found_a" != "X"; then
+                                LIBZ="${LIBZ}${LIBZ:+ }$found_a"
+              else
+                                                LIBZ="${LIBZ}${LIBZ:+ }-L$found_dir -l$name"
+              fi
+            fi
+                        additional_includedir=
+            case "$found_dir" in
+              */lib | */lib/)
+                basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'`
+                additional_includedir="$basedir/include"
+                ;;
+            esac
+            if test "X$additional_includedir" != "X"; then
+                                                                                                                if test "X$additional_includedir" != "X/usr/include"; then
+                haveit=
+                if test "X$additional_includedir" = "X/usr/local/include"; then
+                  if test -n "$GCC"; then
+                    case $host_os in
+                      linux*) haveit=yes;;
+                    esac
+                  fi
+                fi
+                if test -z "$haveit"; then
+                  for x in $CPPFLAGS $INCZ; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+                    if test "X$x" = "X-I$additional_includedir"; then
+                      haveit=yes
+                      break
+                    fi
+                  done
+                  if test -z "$haveit"; then
+                    if test -d "$additional_includedir"; then
+                                            INCZ="${INCZ}${INCZ:+ }-I$additional_includedir"
+                    fi
+                  fi
+                fi
+              fi
+            fi
+                        if test -n "$found_la"; then
+                                                        save_libdir="$libdir"
+              case "$found_la" in
+                */* | *\\*) . "$found_la" ;;
+                *) . "./$found_la" ;;
+              esac
+              libdir="$save_libdir"
+                            for dep in $dependency_libs; do
+                case "$dep" in
+                  -L*)
+                    additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
+                                                                                                                                                                if test "X$additional_libdir" != "X/usr/lib"; then
+                      haveit=
+                      if test "X$additional_libdir" = "X/usr/local/lib"; then
+                        if test -n "$GCC"; then
+                          case $host_os in
+                            linux*) haveit=yes;;
+                          esac
+                        fi
+                      fi
+                      if test -z "$haveit"; then
+                        haveit=
+                        for x in $LDFLAGS $LIBZ; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+                          if test "X$x" = "X-L$additional_libdir"; then
+                            haveit=yes
+                            break
+                          fi
+                        done
+                        if test -z "$haveit"; then
+                          if test -d "$additional_libdir"; then
+                                                        LIBZ="${LIBZ}${LIBZ:+ }-L$additional_libdir"
+                          fi
+                        fi
+                        haveit=
+                        for x in $LDFLAGS $LTLIBZ; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+                          if test "X$x" = "X-L$additional_libdir"; then
+                            haveit=yes
+                            break
+                          fi
+                        done
+                        if test -z "$haveit"; then
+                          if test -d "$additional_libdir"; then
+                                                        LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-L$additional_libdir"
+                          fi
+                        fi
+                      fi
+                    fi
+                    ;;
+                  -R*)
+                    dir=`echo "X$dep" | sed -e 's/^X-R//'`
+                    if test "$enable_rpath" != no; then
+                                                                  haveit=
+                      for x in $rpathdirs; do
+                        if test "X$x" = "X$dir"; then
+                          haveit=yes
+                          break
+                        fi
+                      done
+                      if test -z "$haveit"; then
+                        rpathdirs="$rpathdirs $dir"
+                      fi
+                                                                  haveit=
+                      for x in $ltrpathdirs; do
+                        if test "X$x" = "X$dir"; then
+                          haveit=yes
+                          break
+                        fi
+                      done
+                      if test -z "$haveit"; then
+                        ltrpathdirs="$ltrpathdirs $dir"
+                      fi
+                    fi
+                    ;;
+                  -l*)
+                                        names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
+                    ;;
+                  *.la)
+                                                                                names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
+                    ;;
+                  *)
+                                        LIBZ="${LIBZ}${LIBZ:+ }$dep"
+                    LTLIBZ="${LTLIBZ}${LTLIBZ:+ }$dep"
+                    ;;
+                esac
+              done
+            fi
+          else
+                                                            LIBZ="${LIBZ}${LIBZ:+ }-l$name"
+            LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-l$name"
+          fi
+        fi
+      fi
+    done
+  done
+  if test "X$rpathdirs" != "X"; then
+    if test -n "$hardcode_libdir_separator"; then
+                        alldirs=
+      for found_dir in $rpathdirs; do
+        alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir"
+      done
+            acl_save_libdir="$libdir"
+      libdir="$alldirs"
+      eval flag=\"$hardcode_libdir_flag_spec\"
+      libdir="$acl_save_libdir"
+      LIBZ="${LIBZ}${LIBZ:+ }$flag"
+    else
+            for found_dir in $rpathdirs; do
+        acl_save_libdir="$libdir"
+        libdir="$found_dir"
+        eval flag=\"$hardcode_libdir_flag_spec\"
+        libdir="$acl_save_libdir"
+        LIBZ="${LIBZ}${LIBZ:+ }$flag"
+      done
+    fi
+  fi
+  if test "X$ltrpathdirs" != "X"; then
+            for found_dir in $ltrpathdirs; do
+      LTLIBZ="${LTLIBZ}${LTLIBZ:+ }-R$found_dir"
+    done
+  fi
+
+
+        ac_save_CPPFLAGS="$CPPFLAGS"
+
+  for element in $INCZ; do
+    haveit=
+    for x in $CPPFLAGS; do
+
+  acl_save_prefix="$prefix"
+  prefix="$acl_final_prefix"
+  acl_save_exec_prefix="$exec_prefix"
+  exec_prefix="$acl_final_exec_prefix"
+  eval x=\"$x\"
+  exec_prefix="$acl_save_exec_prefix"
+  prefix="$acl_save_prefix"
+
+      if test "X$x" = "X$element"; then
+        haveit=yes
+        break
+      fi
+    done
+    if test -z "$haveit"; then
+      CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element"
+    fi
+  done
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libz" >&5
+$as_echo_n "checking for libz... " >&6; }
+if test "${ac_cv_libz+set}" = set; then :
   $as_echo_n "(cached) " >&6
 else
-  ac_func_search_save_LIBS=$LIBS
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
 
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char zlibVersion ();
+    ac_save_LIBS="$LIBS"
+    LIBS="$LIBS $LIBZ"
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include "zlib.h";
 int
 main ()
 {
-return zlibVersion ();
+int ret = deflateInit(NULL, 1);
   ;
   return 0;
 }
 _ACEOF
-for ac_lib in '' z; do
-  if test -z "$ac_lib"; then
-    ac_res="none required"
-  else
-    ac_res=-l$ac_lib
-    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
-  fi
-  if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_search_zlibVersion=$ac_res
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_libz=yes
+else
+  ac_cv_libz=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext
-  if test "${ac_cv_search_zlibVersion+set}" = set; then :
-  break
-fi
-done
-if test "${ac_cv_search_zlibVersion+set}" = set; then :
+    conftest$ac_exeext conftest.$ac_ext
+    LIBS="$ac_save_LIBS"
 
-else
-  ac_cv_search_zlibVersion=no
-fi
-rm conftest.$ac_ext
-LIBS=$ac_func_search_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_zlibVersion" >&5
-$as_echo "$ac_cv_search_zlibVersion" >&6; }
-ac_res=$ac_cv_search_zlibVersion
-if test "$ac_res" != no; then :
-  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
-  for ac_header in zlib.h
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_libz" >&5
+$as_echo "$ac_cv_libz" >&6; }
+  if test "$ac_cv_libz" = yes; then
+    HAVE_LIBZ=yes
+
+$as_echo "#define HAVE_LIBZ 1" >>confdefs.h
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to link with libz" >&5
+$as_echo_n "checking how to link with libz... " >&6; }
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBZ" >&5
+$as_echo "$LIBZ" >&6; }
+  else
+    HAVE_LIBZ=no
+            CPPFLAGS="$ac_save_CPPFLAGS"
+    LIBZ=
+    LTLIBZ=
+  fi
+
+
+
+
+
+
+    if test "$HAVE_LIBZ" = "yes"; then
+      # Make sure HAVE_ZLIB_H gets defined.  Some code uses that over
+      # HAVE_LIBZ, since initially we were only defining HAVE_ZLIB_H.
+      for ac_header in zlib.h
 do :
   ac_fn_c_check_header_mongrel "$LINENO" "zlib.h" "ac_cv_header_zlib_h" "$ac_includes_default"
 if test "x$ac_cv_header_zlib_h" = x""yes; then :
@@ -6893,9 +7504,9 @@  fi
 
 done
 
-fi
-
-    if test "$with_zlib" = "yes" -a "$ac_cv_header_zlib_h" != "yes"; then
+      LIBS="$LIBS $LIBZ"
+    fi
+    if test "$with_zlib" = "yes" -a "$HAVE_LIBZ" != "yes"; then
       as_fn_error "zlib (libz) library was explicitly requested but not found" "$LINENO" 5
     fi
   fi
-- 
1.9.1