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 <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.
This commit is contained in:
H.J. Lu 2015-03-29 07:12:38 -07:00
parent ea6b7543b4
commit 243340ad57
9 changed files with 76 additions and 130 deletions

View File

@ -1,3 +1,26 @@
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> 2015-03-27 Alan Modra <amodra@gmail.com>
PR ld/15228 PR ld/15228

View File

@ -43,9 +43,15 @@ noinst_LTLIBRARIES = libbfd.la
libbfd_la_LDFLAGS += -rpath $(rpath_bfdlibdir) libbfd_la_LDFLAGS += -rpath $(rpath_bfdlibdir)
endif 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@ WARN_CFLAGS = @WARN_CFLAGS@
NO_WERROR = @NO_WERROR@ NO_WERROR = @NO_WERROR@
AM_CFLAGS = $(WARN_CFLAGS) AM_CFLAGS = $(WARN_CFLAGS) $(ZLIBINC)
AM_CPPFLAGS = -DBINDIR='"$(bindir)"' AM_CPPFLAGS = -DBINDIR='"$(bindir)"'
if PLUGINS if PLUGINS
bfdinclude_HEADERS += $(INCDIR)/plugin-api.h bfdinclude_HEADERS += $(INCDIR)/plugin-api.h
@ -840,7 +846,7 @@ ofiles: stamp-ofiles ; @true
libbfd_la_SOURCES = $(BFD32_LIBS_CFILES) libbfd_la_SOURCES = $(BFD32_LIBS_CFILES)
EXTRA_libbfd_la_SOURCES = $(CFILES) EXTRA_libbfd_la_SOURCES = $(CFILES)
libbfd_la_DEPENDENCIES = $(OFILES) ofiles 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@ libbfd_la_LDFLAGS += -release `cat libtool-soversion` @SHARED_LDFLAGS@
# libtool will build .libs/libbfd.a. We create libbfd.a in the build # libtool will build .libs/libbfd.a. We create libbfd.a in the build

View File

@ -79,8 +79,8 @@ am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
$(top_srcdir)/../ltoptions.m4 $(top_srcdir)/../ltsugar.m4 \ $(top_srcdir)/../ltoptions.m4 $(top_srcdir)/../ltsugar.m4 \
$(top_srcdir)/../ltversion.m4 $(top_srcdir)/../lt~obsolete.m4 \ $(top_srcdir)/../ltversion.m4 $(top_srcdir)/../lt~obsolete.m4 \
$(top_srcdir)/bfd.m4 $(top_srcdir)/warning.m4 \ $(top_srcdir)/bfd.m4 $(top_srcdir)/warning.m4 \
$(top_srcdir)/acinclude.m4 $(top_srcdir)/../config/zlib.m4 \ $(top_srcdir)/acinclude.m4 $(top_srcdir)/version.m4 \
$(top_srcdir)/version.m4 $(top_srcdir)/configure.ac $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4) $(ACLOCAL_M4)
am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ 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_builddir = @top_builddir@
top_srcdir = @top_srcdir@ top_srcdir = @top_srcdir@
wordsize = @wordsize@ wordsize = @wordsize@
zlibdir = @zlibdir@
zlibinc = @zlibinc@
AUTOMAKE_OPTIONS = 1.11 no-dist foreign AUTOMAKE_OPTIONS = 1.11 no-dist foreign
ACLOCAL_AMFLAGS = -I . -I .. -I ../config ACLOCAL_AMFLAGS = -I . -I .. -I ../config
INCDIR = $(srcdir)/../include 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_TRUE@ $(INCDIR)/bfdlink.h $(am__append_2)
@INSTALL_LIBBFD_FALSE@rpath_bfdlibdir = @bfdlibdir@ @INSTALL_LIBBFD_FALSE@rpath_bfdlibdir = @bfdlibdir@
@INSTALL_LIBBFD_FALSE@noinst_LTLIBRARIES = libbfd.la @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)"' AM_CPPFLAGS = -DBINDIR='"$(bindir)"'
@PLUGINS_TRUE@LIBDL = @lt_cv_dlopen_libs@ @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) libbfd_la_SOURCES = $(BFD32_LIBS_CFILES)
EXTRA_libbfd_la_SOURCES = $(CFILES) EXTRA_libbfd_la_SOURCES = $(CFILES)
libbfd_la_DEPENDENCIES = $(OFILES) ofiles 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 # 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 # directory so that we don't have to convert all the programs that use

View File

@ -16,8 +16,6 @@ dnl along with this program; see the file COPYING3. If not see
dnl <http://www.gnu.org/licenses/>. dnl <http://www.gnu.org/licenses/>.
dnl dnl
sinclude([../config/zlib.m4])
dnl See whether we need to use fopen-bin.h rather than fopen-same.h. dnl See whether we need to use fopen-bin.h rather than fopen-same.h.
AC_DEFUN([BFD_BINARY_FOPEN], AC_DEFUN([BFD_BINARY_FOPEN],
[AC_REQUIRE([AC_CANONICAL_TARGET]) [AC_REQUIRE([AC_CANONICAL_TARGET])

View File

@ -19,14 +19,11 @@
MA 02110-1301, USA. */ MA 02110-1301, USA. */
#include "sysdep.h" #include "sysdep.h"
#include <zlib.h>
#include "bfd.h" #include "bfd.h"
#include "libbfd.h" #include "libbfd.h"
#ifdef HAVE_ZLIB_H
#include <zlib.h>
#endif
#include "safe-ctype.h" #include "safe-ctype.h"
#ifdef HAVE_ZLIB_H
static bfd_boolean static bfd_boolean
decompress_contents (bfd_byte *compressed_buffer, decompress_contents (bfd_byte *compressed_buffer,
bfd_size_type compressed_size, bfd_size_type compressed_size,
@ -72,10 +69,9 @@ decompress_contents (bfd_byte *compressed_buffer,
successfully. */ successfully. */
static bfd_boolean static bfd_boolean
bfd_compress_section_contents (bfd *abfd ATTRIBUTE_UNUSED, bfd_compress_section_contents (bfd *abfd ATTRIBUTE_UNUSED, sec_ptr sec,
sec_ptr sec ATTRIBUTE_UNUSED, bfd_byte *uncompressed_buffer,
bfd_byte *uncompressed_buffer ATTRIBUTE_UNUSED, bfd_size_type uncompressed_size)
bfd_size_type uncompressed_size ATTRIBUTE_UNUSED)
{ {
uLong compressed_size; uLong compressed_size;
bfd_byte *compressed_buffer; bfd_byte *compressed_buffer;
@ -127,7 +123,6 @@ bfd_compress_section_contents (bfd *abfd ATTRIBUTE_UNUSED,
return TRUE; return TRUE;
} }
#endif /* HAVE_ZLIB_H */
/* /*
FUNCTION FUNCTION
@ -152,12 +147,10 @@ bfd_get_full_section_contents (bfd *abfd, sec_ptr sec, bfd_byte **ptr)
{ {
bfd_size_type sz; bfd_size_type sz;
bfd_byte *p = *ptr; bfd_byte *p = *ptr;
#ifdef HAVE_ZLIB_H
bfd_boolean ret; bfd_boolean ret;
bfd_size_type save_size; bfd_size_type save_size;
bfd_size_type save_rawsize; bfd_size_type save_rawsize;
bfd_byte *compressed_buffer; bfd_byte *compressed_buffer;
#endif
if (abfd->direction != write_direction && sec->rawsize != 0) if (abfd->direction != write_direction && sec->rawsize != 0)
sz = sec->rawsize; sz = sec->rawsize;
@ -189,10 +182,6 @@ bfd_get_full_section_contents (bfd *abfd, sec_ptr sec, bfd_byte **ptr)
return TRUE; return TRUE;
case DECOMPRESS_SECTION_SIZED: 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. */ /* Read in the full compressed section contents. */
compressed_buffer = (bfd_byte *) bfd_malloc (sec->compressed_size); compressed_buffer = (bfd_byte *) bfd_malloc (sec->compressed_size);
if (compressed_buffer == NULL) if (compressed_buffer == NULL)
@ -232,7 +221,6 @@ bfd_get_full_section_contents (bfd *abfd, sec_ptr sec, bfd_byte **ptr)
free (compressed_buffer); free (compressed_buffer);
*ptr = p; *ptr = p;
return TRUE; return TRUE;
#endif
case COMPRESS_SECTION_DONE: case COMPRESS_SECTION_DONE:
if (sec->contents == NULL) if (sec->contents == NULL)
@ -337,13 +325,8 @@ DESCRIPTION
*/ */
bfd_boolean bfd_boolean
bfd_init_section_decompress_status (bfd *abfd ATTRIBUTE_UNUSED, bfd_init_section_decompress_status (bfd *abfd, sec_ptr sec)
sec_ptr sec ATTRIBUTE_UNUSED)
{ {
#ifndef HAVE_ZLIB_H
bfd_set_error (bfd_error_invalid_operation);
return FALSE;
#else
bfd_byte compressed_buffer [12]; bfd_byte compressed_buffer [12];
bfd_size_type uncompressed_size; bfd_size_type uncompressed_size;
@ -378,7 +361,6 @@ bfd_init_section_decompress_status (bfd *abfd ATTRIBUTE_UNUSED,
sec->compress_status = DECOMPRESS_SECTION_SIZED; sec->compress_status = DECOMPRESS_SECTION_SIZED;
return TRUE; return TRUE;
#endif
} }
/* /*
@ -399,13 +381,8 @@ DESCRIPTION
*/ */
bfd_boolean bfd_boolean
bfd_init_section_compress_status (bfd *abfd ATTRIBUTE_UNUSED, bfd_init_section_compress_status (bfd *abfd, sec_ptr sec)
sec_ptr sec ATTRIBUTE_UNUSED)
{ {
#ifndef HAVE_ZLIB_H
bfd_set_error (bfd_error_invalid_operation);
return FALSE;
#else
bfd_size_type uncompressed_size; bfd_size_type uncompressed_size;
bfd_byte *uncompressed_buffer; bfd_byte *uncompressed_buffer;
bfd_boolean ret; bfd_boolean ret;
@ -433,5 +410,4 @@ bfd_init_section_compress_status (bfd *abfd ATTRIBUTE_UNUSED,
uncompressed_size); uncompressed_size);
return ret; return ret;
#endif
} }

View File

@ -271,9 +271,6 @@
/* Define to 1 if you have the <windows.h> header file. */ /* Define to 1 if you have the <windows.h> header file. */
#undef HAVE_WINDOWS_H #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. /* Define to the sub-directory in which libtool stores uninstalled libraries.
*/ */
#undef LT_OBJDIR #undef LT_OBJDIR

97
bfd/configure vendored
View File

@ -620,6 +620,8 @@ SHARED_LDFLAGS
LIBM LIBM
COREFLAG COREFLAG
COREFILE COREFILE
zlibinc
zlibdir
EXEEXT_FOR_BUILD EXEEXT_FOR_BUILD
CC_FOR_BUILD CC_FOR_BUILD
BFD_HOSTPTR_T BFD_HOSTPTR_T
@ -797,7 +799,7 @@ enable_build_warnings
enable_maintainer_mode enable_maintainer_mode
enable_install_libbfd enable_install_libbfd
enable_nls enable_nls
with_zlib with_system_zlib
' '
ac_precious_vars='build_alias ac_precious_vars='build_alias
host_alias host_alias
@ -1463,7 +1465,7 @@ Optional Packages:
--with-pkgversion=PKG Use PKG in the version string in place of "GNU --with-pkgversion=PKG Use PKG in the version string in place of "GNU
Binutils" Binutils"
--with-bugurl=URL Direct users to URL to report a bug --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: Some influential environment variables:
CC C compiler command CC C compiler command
@ -11421,7 +11423,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF cat > conftest.$ac_ext <<_LT_EOF
#line 11424 "configure" #line 11426 "configure"
#include "confdefs.h" #include "confdefs.h"
#if HAVE_DLFCN_H #if HAVE_DLFCN_H
@ -11527,7 +11529,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF cat > conftest.$ac_ext <<_LT_EOF
#line 11530 "configure" #line 11532 "configure"
#include "confdefs.h" #include "confdefs.h"
#if HAVE_DLFCN_H #if HAVE_DLFCN_H
@ -13851,91 +13853,18 @@ cat >>confdefs.h <<_ACEOF
_ACEOF _ACEOF
# Link in zlib if we can. This allows us to read compressed debug sections. # Use the system's zlib library.
# This is used only by compress.c. 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 :
# Check whether --with-zlib was given. withval=$with_system_zlib; zlibdir=
if test "${with_zlib+set}" = set; then : zlibinc=
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 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. # If we are configured native, pick a core file support file.

View File

@ -236,9 +236,16 @@ AC_CHECK_DECLS(snprintf)
AC_CHECK_DECLS(vsnprintf) AC_CHECK_DECLS(vsnprintf)
AC_CHECK_DECLS(strnlen) AC_CHECK_DECLS(strnlen)
# Link in zlib if we can. This allows us to read compressed debug sections. # Use the system's zlib library.
# This is used only by compress.c. zlibdir=-L../zlib
AM_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. # If we are configured native, pick a core file support file.
COREFILE= COREFILE=

View File

@ -75,8 +75,8 @@ am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \
$(top_srcdir)/../ltoptions.m4 $(top_srcdir)/../ltsugar.m4 \ $(top_srcdir)/../ltoptions.m4 $(top_srcdir)/../ltsugar.m4 \
$(top_srcdir)/../ltversion.m4 $(top_srcdir)/../lt~obsolete.m4 \ $(top_srcdir)/../ltversion.m4 $(top_srcdir)/../lt~obsolete.m4 \
$(top_srcdir)/bfd.m4 $(top_srcdir)/warning.m4 \ $(top_srcdir)/bfd.m4 $(top_srcdir)/warning.m4 \
$(top_srcdir)/acinclude.m4 $(top_srcdir)/../config/zlib.m4 \ $(top_srcdir)/acinclude.m4 $(top_srcdir)/version.m4 \
$(top_srcdir)/version.m4 $(top_srcdir)/configure.ac $(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4) $(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs mkinstalldirs = $(SHELL) $(top_srcdir)/../mkinstalldirs
@ -289,6 +289,8 @@ top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@ top_srcdir = @top_srcdir@
wordsize = @wordsize@ wordsize = @wordsize@
zlibdir = @zlibdir@
zlibinc = @zlibinc@
AUTOMAKE_OPTIONS = 1.9 cygnus AUTOMAKE_OPTIONS = 1.9 cygnus
DOCFILES = aoutx.texi archive.texi archures.texi \ DOCFILES = aoutx.texi archive.texi archures.texi \
bfdt.texi cache.texi coffcode.texi \ bfdt.texi cache.texi coffcode.texi \