From 243340ad57e30de3c15cffe6e4af0381995f15d9 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Sun, 29 Mar 2015 07:12:38 -0700 Subject: Add --with-system-zlib in bfd 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 . (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. --- bfd/ChangeLog | 23 +++++++++++++ bfd/Makefile.am | 10 ++++-- bfd/Makefile.in | 16 ++++++--- bfd/acinclude.m4 | 2 -- bfd/compress.c | 36 ++++---------------- bfd/config.in | 3 -- bfd/configure | 97 +++++++---------------------------------------------- bfd/configure.ac | 13 +++++-- bfd/doc/Makefile.in | 6 ++-- 9 files changed, 76 insertions(+), 130 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index cc8f96f..2beeade 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,26 @@ +2015-03-29 H.J. Lu + + * 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 . + (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 PR ld/15228 diff --git a/bfd/Makefile.am b/bfd/Makefile.am index 5d7f899..03b6442 100644 --- a/bfd/Makefile.am +++ b/bfd/Makefile.am @@ -43,9 +43,15 @@ noinst_LTLIBRARIES = libbfd.la 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 @@ -840,7 +846,7 @@ ofiles: stamp-ofiles ; @true 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 diff --git a/bfd/Makefile.in b/bfd/Makefile.in index 60d994f..92eb33d 100644 --- a/bfd/Makefile.in +++ b/bfd/Makefile.in @@ -79,8 +79,8 @@ am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \ $(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 \ @@ -334,6 +334,8 @@ top_build_prefix = @top_build_prefix@ 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 @@ -349,7 +351,13 @@ libbfd_la_LDFLAGS = $(am__append_1) -release `cat libtool-soversion` \ @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@ @@ -1113,7 +1121,7 @@ OFILES = $(BFD_BACKENDS) $(BFD_MACHINES) @COREFILE@ @bfd64_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 diff --git a/bfd/acinclude.m4 b/bfd/acinclude.m4 index acb6419..ce6a72e 100644 --- a/bfd/acinclude.m4 +++ b/bfd/acinclude.m4 @@ -16,8 +16,6 @@ dnl along with this program; see the file COPYING3. If not see dnl . 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]) diff --git a/bfd/compress.c b/bfd/compress.c index 993a1d3..7e498fa 100644 --- a/bfd/compress.c +++ b/bfd/compress.c @@ -19,14 +19,11 @@ MA 02110-1301, USA. */ #include "sysdep.h" +#include #include "bfd.h" #include "libbfd.h" -#ifdef HAVE_ZLIB_H -#include -#endif #include "safe-ctype.h" -#ifdef HAVE_ZLIB_H static bfd_boolean decompress_contents (bfd_byte *compressed_buffer, bfd_size_type compressed_size, @@ -72,10 +69,9 @@ decompress_contents (bfd_byte *compressed_buffer, 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; @@ -127,7 +123,6 @@ bfd_compress_section_contents (bfd *abfd ATTRIBUTE_UNUSED, return TRUE; } -#endif /* HAVE_ZLIB_H */ /* FUNCTION @@ -152,12 +147,10 @@ bfd_get_full_section_contents (bfd *abfd, sec_ptr sec, bfd_byte **ptr) { 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; @@ -189,10 +182,6 @@ bfd_get_full_section_contents (bfd *abfd, sec_ptr sec, bfd_byte **ptr) 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) @@ -232,7 +221,6 @@ bfd_get_full_section_contents (bfd *abfd, sec_ptr sec, bfd_byte **ptr) free (compressed_buffer); *ptr = p; return TRUE; -#endif case COMPRESS_SECTION_DONE: if (sec->contents == NULL) @@ -337,13 +325,8 @@ DESCRIPTION */ 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; @@ -378,7 +361,6 @@ bfd_init_section_decompress_status (bfd *abfd ATTRIBUTE_UNUSED, sec->compress_status = DECOMPRESS_SECTION_SIZED; return TRUE; -#endif } /* @@ -399,13 +381,8 @@ DESCRIPTION */ 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; @@ -433,5 +410,4 @@ bfd_init_section_compress_status (bfd *abfd ATTRIBUTE_UNUSED, uncompressed_size); return ret; -#endif } diff --git a/bfd/config.in b/bfd/config.in index 96a3e74..1ee1081 100644 --- a/bfd/config.in +++ b/bfd/config.in @@ -271,9 +271,6 @@ /* Define to 1 if you have the header file. */ #undef HAVE_WINDOWS_H -/* Define to 1 if you have the header file. */ -#undef HAVE_ZLIB_H - /* Define to the sub-directory in which libtool stores uninstalled libraries. */ #undef LT_OBJDIR diff --git a/bfd/configure b/bfd/configure index a328813..b8f1b2b 100755 --- a/bfd/configure +++ b/bfd/configure @@ -620,6 +620,8 @@ SHARED_LDFLAGS LIBM COREFLAG COREFILE +zlibinc +zlibdir EXEEXT_FOR_BUILD CC_FOR_BUILD BFD_HOSTPTR_T @@ -797,7 +799,7 @@ enable_build_warnings enable_maintainer_mode enable_install_libbfd enable_nls -with_zlib +with_system_zlib ' ac_precious_vars='build_alias host_alias @@ -1463,7 +1465,7 @@ Optional Packages: --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 @@ -11421,7 +11423,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 11426 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11527,7 +11529,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 11532 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -13851,91 +13853,18 @@ cat >>confdefs.h <<_ACEOF _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. diff --git a/bfd/configure.ac b/bfd/configure.ac index a1b2035..5426781 100644 --- a/bfd/configure.ac +++ b/bfd/configure.ac @@ -236,9 +236,16 @@ AC_CHECK_DECLS(snprintf) 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= diff --git a/bfd/doc/Makefile.in b/bfd/doc/Makefile.in index 72099f1..6038113 100644 --- a/bfd/doc/Makefile.in +++ b/bfd/doc/Makefile.in @@ -75,8 +75,8 @@ am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \ $(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 @@ -289,6 +289,8 @@ top_build_prefix = @top_build_prefix@ 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 \ -- cgit v1.1