This patch adds --with-system-zlib and remove --with-zlib in bfd.
* Makefile.am (ZLIB): New.
(ZLIBINC): Likewise.
(AM_CFLAGS): Add $(ZLIBINC).
(libbfd_la_LIBADD): Add $(ZLIB).
* compress.c: Don't check HAVE_ZLIB_H to include <zlib.h>.
(decompress_contents): Don't check HAVE_ZLIB_H.
(decompress_contents): Likewise.
(bfd_compress_section_contents): Likewise.
(bfd_get_full_section_contents): Likewise.
(bfd_init_section_decompress_status): Likewise.
(bfd_init_section_compress_status): Likewise.
* configure.ac (AM_ZLIB): Removed
(zlibdir): New. AC_SUBST.
(zlibinc): Likewise.
Add --with-system-zlib.
* Makefile.in: Regenerated.
* acinclude.m4: Likewise.
* config.in: Likewise.
* configure: Likewise.
* doc/Makefile.in: Likewise.
+2015-03-29 H.J. Lu <hongjiu.lu@intel.com>
+
+ * Makefile.am (ZLIB): New.
+ (ZLIBINC): Likewise.
+ (AM_CFLAGS): Add $(ZLIBINC).
+ (libbfd_la_LIBADD): Add $(ZLIB).
+ * compress.c: Don't check HAVE_ZLIB_H to include <zlib.h>.
+ (decompress_contents): Don't check HAVE_ZLIB_H.
+ (decompress_contents): Likewise.
+ (bfd_compress_section_contents): Likewise.
+ (bfd_get_full_section_contents): Likewise.
+ (bfd_init_section_decompress_status): Likewise.
+ (bfd_init_section_compress_status): Likewise.
+ * configure.ac (AM_ZLIB): Removed
+ (zlibdir): New. AC_SUBST.
+ (zlibinc): Likewise.
+ Add --with-system-zlib.
+ * Makefile.in: Regenerated.
+ * acinclude.m4: Likewise.
+ * config.in: Likewise.
+ * configure: Likewise.
+ * doc/Makefile.in: Likewise.
+
2015-03-27 Alan Modra <amodra@gmail.com>
PR ld/15228
libbfd_la_LDFLAGS += -rpath $(rpath_bfdlibdir)
endif
+# This is where we get zlib from. zlibdir is -L../zlib and zlibinc is
+# -I../zlib, unless we were configured with --with-system-zlib, in which
+# case both are empty.
+ZLIB = @zlibdir@ -lz
+ZLIBINC = @zlibinc@
+
WARN_CFLAGS = @WARN_CFLAGS@
NO_WERROR = @NO_WERROR@
-AM_CFLAGS = $(WARN_CFLAGS)
+AM_CFLAGS = $(WARN_CFLAGS) $(ZLIBINC)
AM_CPPFLAGS = -DBINDIR='"$(bindir)"'
if PLUGINS
bfdinclude_HEADERS += $(INCDIR)/plugin-api.h
libbfd_la_SOURCES = $(BFD32_LIBS_CFILES)
EXTRA_libbfd_la_SOURCES = $(CFILES)
libbfd_la_DEPENDENCIES = $(OFILES) ofiles
-libbfd_la_LIBADD = `cat ofiles` @SHARED_LIBADD@ $(LIBDL)
+libbfd_la_LIBADD = `cat ofiles` @SHARED_LIBADD@ $(LIBDL) $(ZLIB)
libbfd_la_LDFLAGS += -release `cat libtool-soversion` @SHARED_LDFLAGS@
# libtool will build .libs/libbfd.a. We create libbfd.a in the build
$(top_srcdir)/../ltoptions.m4 $(top_srcdir)/../ltsugar.m4 \
$(top_srcdir)/../ltversion.m4 $(top_srcdir)/../lt~obsolete.m4 \
$(top_srcdir)/bfd.m4 $(top_srcdir)/warning.m4 \
- $(top_srcdir)/acinclude.m4 $(top_srcdir)/../config/zlib.m4 \
- $(top_srcdir)/version.m4 $(top_srcdir)/configure.ac
+ $(top_srcdir)/acinclude.m4 $(top_srcdir)/version.m4 \
+ $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
wordsize = @wordsize@
+zlibdir = @zlibdir@
+zlibinc = @zlibinc@
AUTOMAKE_OPTIONS = 1.11 no-dist foreign
ACLOCAL_AMFLAGS = -I . -I .. -I ../config
INCDIR = $(srcdir)/../include
@INSTALL_LIBBFD_TRUE@ $(INCDIR)/bfdlink.h $(am__append_2)
@INSTALL_LIBBFD_FALSE@rpath_bfdlibdir = @bfdlibdir@
@INSTALL_LIBBFD_FALSE@noinst_LTLIBRARIES = libbfd.la
-AM_CFLAGS = $(WARN_CFLAGS)
+
+# This is where we get zlib from. zlibdir is -L../zlib and zlibinc is
+# -I../zlib, unless we were configured with --with-system-zlib, in which
+# case both are empty.
+ZLIB = @zlibdir@ -lz
+ZLIBINC = @zlibinc@
+AM_CFLAGS = $(WARN_CFLAGS) $(ZLIBINC)
AM_CPPFLAGS = -DBINDIR='"$(bindir)"'
@PLUGINS_TRUE@LIBDL = @lt_cv_dlopen_libs@
libbfd_la_SOURCES = $(BFD32_LIBS_CFILES)
EXTRA_libbfd_la_SOURCES = $(CFILES)
libbfd_la_DEPENDENCIES = $(OFILES) ofiles
-libbfd_la_LIBADD = `cat ofiles` @SHARED_LIBADD@ $(LIBDL)
+libbfd_la_LIBADD = `cat ofiles` @SHARED_LIBADD@ $(LIBDL) $(ZLIB)
# libtool will build .libs/libbfd.a. We create libbfd.a in the build
# directory so that we don't have to convert all the programs that use
dnl <http://www.gnu.org/licenses/>.
dnl
-sinclude([../config/zlib.m4])
-
dnl See whether we need to use fopen-bin.h rather than fopen-same.h.
AC_DEFUN([BFD_BINARY_FOPEN],
[AC_REQUIRE([AC_CANONICAL_TARGET])
MA 02110-1301, USA. */
#include "sysdep.h"
+#include <zlib.h>
#include "bfd.h"
#include "libbfd.h"
-#ifdef HAVE_ZLIB_H
-#include <zlib.h>
-#endif
#include "safe-ctype.h"
-#ifdef HAVE_ZLIB_H
static bfd_boolean
decompress_contents (bfd_byte *compressed_buffer,
bfd_size_type compressed_size,
successfully. */
static bfd_boolean
-bfd_compress_section_contents (bfd *abfd ATTRIBUTE_UNUSED,
- sec_ptr sec ATTRIBUTE_UNUSED,
- bfd_byte *uncompressed_buffer ATTRIBUTE_UNUSED,
- bfd_size_type uncompressed_size ATTRIBUTE_UNUSED)
+bfd_compress_section_contents (bfd *abfd ATTRIBUTE_UNUSED, sec_ptr sec,
+ bfd_byte *uncompressed_buffer,
+ bfd_size_type uncompressed_size)
{
uLong compressed_size;
bfd_byte *compressed_buffer;
return TRUE;
}
-#endif /* HAVE_ZLIB_H */
/*
FUNCTION
{
bfd_size_type sz;
bfd_byte *p = *ptr;
-#ifdef HAVE_ZLIB_H
bfd_boolean ret;
bfd_size_type save_size;
bfd_size_type save_rawsize;
bfd_byte *compressed_buffer;
-#endif
if (abfd->direction != write_direction && sec->rawsize != 0)
sz = sec->rawsize;
return TRUE;
case DECOMPRESS_SECTION_SIZED:
-#ifndef HAVE_ZLIB_H
- bfd_set_error (bfd_error_invalid_operation);
- return FALSE;
-#else
/* Read in the full compressed section contents. */
compressed_buffer = (bfd_byte *) bfd_malloc (sec->compressed_size);
if (compressed_buffer == NULL)
free (compressed_buffer);
*ptr = p;
return TRUE;
-#endif
case COMPRESS_SECTION_DONE:
if (sec->contents == NULL)
*/
bfd_boolean
-bfd_init_section_decompress_status (bfd *abfd ATTRIBUTE_UNUSED,
- sec_ptr sec ATTRIBUTE_UNUSED)
+bfd_init_section_decompress_status (bfd *abfd, sec_ptr sec)
{
-#ifndef HAVE_ZLIB_H
- bfd_set_error (bfd_error_invalid_operation);
- return FALSE;
-#else
bfd_byte compressed_buffer [12];
bfd_size_type uncompressed_size;
sec->compress_status = DECOMPRESS_SECTION_SIZED;
return TRUE;
-#endif
}
/*
*/
bfd_boolean
-bfd_init_section_compress_status (bfd *abfd ATTRIBUTE_UNUSED,
- sec_ptr sec ATTRIBUTE_UNUSED)
+bfd_init_section_compress_status (bfd *abfd, sec_ptr sec)
{
-#ifndef HAVE_ZLIB_H
- bfd_set_error (bfd_error_invalid_operation);
- return FALSE;
-#else
bfd_size_type uncompressed_size;
bfd_byte *uncompressed_buffer;
bfd_boolean ret;
uncompressed_size);
return ret;
-#endif
}
/* Define to 1 if you have the <windows.h> header file. */
#undef HAVE_WINDOWS_H
-/* Define to 1 if you have the <zlib.h> header file. */
-#undef HAVE_ZLIB_H
-
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#undef LT_OBJDIR
LIBM
COREFLAG
COREFILE
+zlibinc
+zlibdir
EXEEXT_FOR_BUILD
CC_FOR_BUILD
BFD_HOSTPTR_T
enable_maintainer_mode
enable_install_libbfd
enable_nls
-with_zlib
+with_system_zlib
'
ac_precious_vars='build_alias
host_alias
--with-pkgversion=PKG Use PKG in the version string in place of "GNU
Binutils"
--with-bugurl=URL Direct users to URL to report a bug
- --with-zlib include zlib support (auto/yes/no) default=auto
+ --with-system-zlib use installed libz
Some influential environment variables:
CC C compiler command
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 11426 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
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 11532 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
_ACEOF
-# Link in zlib if we can. This allows us to read compressed debug sections.
-# This is used only by compress.c.
+# Use the system's zlib library.
+zlibdir=-L../zlib
+zlibinc="-I\$(srcdir)/../zlib"
- # See if the user specified whether he wants zlib support or not.
+# Check whether --with-system-zlib was given.
+if test "${with_system_zlib+set}" = set; then :
+ withval=$with_system_zlib; zlibdir=
+zlibinc=
-# 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
# If we are configured native, pick a core file support file.
AC_CHECK_DECLS(vsnprintf)
AC_CHECK_DECLS(strnlen)
-# Link in zlib if we can. This allows us to read compressed debug sections.
-# This is used only by compress.c.
-AM_ZLIB
+# Use the system's zlib library.
+zlibdir=-L../zlib
+zlibinc="-I\$(srcdir)/../zlib"
+AC_ARG_WITH(system-zlib,
+[AS_HELP_STRING([--with-system-zlib], [use installed libz])],
+zlibdir=
+zlibinc=
+)
+AC_SUBST(zlibdir)
+AC_SUBST(zlibinc)
# If we are configured native, pick a core file support file.
COREFILE=
$(top_srcdir)/../ltoptions.m4 $(top_srcdir)/../ltsugar.m4 \
$(top_srcdir)/../ltversion.m4 $(top_srcdir)/../lt~obsolete.m4 \
$(top_srcdir)/bfd.m4 $(top_srcdir)/warning.m4 \
- $(top_srcdir)/acinclude.m4 $(top_srcdir)/../config/zlib.m4 \
- $(top_srcdir)/version.m4 $(top_srcdir)/configure.ac
+ $(top_srcdir)/acinclude.m4 $(top_srcdir)/version.m4 \
+ $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
wordsize = @wordsize@
+zlibdir = @zlibdir@
+zlibinc = @zlibinc@
AUTOMAKE_OPTIONS = 1.9 cygnus
DOCFILES = aoutx.texi archive.texi archures.texi \
bfdt.texi cache.texi coffcode.texi \