public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Add --with-system-zlib in gdb
@ 2015-03-31 11:27 H.J. Lu
  2015-03-31 11:51 ` H.J. Lu
  0 siblings, 1 reply; 6+ messages in thread
From: H.J. Lu @ 2015-03-31 11:27 UTC (permalink / raw)
  To: GDB

This patch adds --with-system-zlib and removes --with-zlib in gdb.
OK for master?

H.J.
--
	* Makefile.in (ZLIB): New.
	(CLIBS): Add $(ZLIB).
	(aclocal_m4_deps): Remove ../config/zlib.m4.
	* acinclude.m4: Don't include ../config/zlib.m4.
	(GDB_AC_CHECK_BFD): Add -lz to LIBS.
	* configure.ac (AM_ZLIB): Removed.
	(zlibdir): New.  AC_SUBST.
	Add --with-system-zlib.
	* gdb_bfd.c: Don't check HAVE_ZLIB_H to include <zlib.h>.
	* top.c (print_gdb_configuration): Remove --with-zlib and
	--without-zlib.
	* config.in: Regenerated.
	* configure: Likewise.
---
 gdb/Makefile.in  |  10 ++++--
 gdb/acinclude.m4 |   8 +++--
 gdb/config.in    |   3 --
 gdb/configure    | 102 ++++++++++---------------------------------------------
 gdb/configure.ac |   9 +++--
 gdb/gdb_bfd.c    |   3 --
 gdb/top.c        |   9 -----
 7 files changed, 37 insertions(+), 107 deletions(-)

diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 907997b..6561857 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -144,6 +144,11 @@ BFD = $(BFD_DIR)/libbfd.a
 BFD_SRC = $(srcdir)/$(BFD_DIR)
 BFD_CFLAGS = -I$(BFD_DIR) -I$(BFD_SRC)
 
+# 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
+
 # Where is the decnumber library?  Typically in ../libdecnumber.
 LIBDECNUMBER_DIR = ../libdecnumber
 LIBDECNUMBER = $(LIBDECNUMBER_DIR)/libdecnumber.a
@@ -578,7 +583,7 @@ INTERNAL_LDFLAGS = $(CFLAGS) $(GLOBAL_CFLAGS) $(MH_LDFLAGS) $(LDFLAGS) $(CONFIG_
 # Libraries and corresponding dependencies for compiling gdb.
 # XM_CLIBS, defined in *config files, have host-dependent libs.
 # LIBIBERTY appears twice on purpose.
-CLIBS = $(SIM) $(READLINE) $(OPCODES) $(BFD) $(INTL) $(LIBIBERTY) $(LIBDECNUMBER) \
+CLIBS = $(SIM) $(READLINE) $(OPCODES) $(BFD) $(ZLIB) $(INTL) $(LIBIBERTY) $(LIBDECNUMBER) \
 	$(XM_CLIBS) $(NAT_CLIBS) $(GDBTKLIBS) \
 	@LIBS@ @GUILE_LIBS@ @PYTHON_LIBS@ \
 	$(LIBEXPAT) $(LIBLZMA) $(LIBBABELTRACE) \
@@ -1551,8 +1556,7 @@ aclocal_m4_deps = \
 	../config/tcl.m4 \
 	../config/depstand.m4 \
 	../config/lcmessage.m4 \
-	../config/codeset.m4 \
-	../config/zlib.m4
+	../config/codeset.m4
 
 $(srcdir)/aclocal.m4: @MAINTAINER_MODE_TRUE@ $(aclocal_m4_deps)
 	cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
diff --git a/gdb/acinclude.m4 b/gdb/acinclude.m4
index da22fc2..d88b73c 100644
--- a/gdb/acinclude.m4
+++ b/gdb/acinclude.m4
@@ -53,8 +53,6 @@ sinclude([../config/lcmessage.m4])
 dnl For AM_LANGINFO_CODESET.
 sinclude([../config/codeset.m4])
 
-sinclude([../config/zlib.m4])
-
 m4_include([common/common.m4])
 
 dnl For libiberty_INIT.
@@ -467,7 +465,11 @@ AC_DEFUN([GDB_AC_CHECK_BFD], [
   CFLAGS="-I${srcdir}/../include -I../bfd -I${srcdir}/../bfd $CFLAGS"
   LDFLAGS="-L../bfd -L../libiberty $LDFLAGS"
   intl=`echo $LIBINTL | sed 's,${top_builddir}/,,g'`
-  LIBS="-lbfd -liberty $intl $LIBS"
+  if test -f ../zlib/Makefile; then
+    LIBS="-lbfd -L../zlib -lz -liberty $intl $LIBS"
+  else
+    LIBS="-lbfd -lz -liberty $intl $LIBS"
+  fi
   AC_CACHE_CHECK([$1], [$2],
   [AC_TRY_LINK(
   [#include <stdlib.h>
diff --git a/gdb/config.in b/gdb/config.in
index 8a27df0..d41e6cf 100644
--- a/gdb/config.in
+++ b/gdb/config.in
@@ -582,9 +582,6 @@
 /* Define to 1 if you have the `XML_StopParser' function. */
 #undef HAVE_XML_STOPPARSER
 
-/* Define to 1 if you have the <zlib.h> header file. */
-#undef HAVE_ZLIB_H
-
 /* Define to 1 if your system has the _etext variable. */
 #undef HAVE__ETEXT
 
diff --git a/gdb/configure b/gdb/configure
index db239b3..cdd56cf 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -680,6 +680,7 @@ READLINE_TEXI_INCFLAG
 READLINE_CFLAGS
 READLINE_DEPS
 READLINE
+zlibdir
 MIG
 WINDRES
 DLLTOOL
@@ -817,7 +818,7 @@ with_curses
 enable_profiling
 with_pkgversion
 with_bugurl
-with_zlib
+with_system_zlib
 with_libiconv_prefix
 with_iconv_bin
 with_system_readline
@@ -1536,7 +1537,7 @@ Optional Packages:
                           library
   --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-system-zlib      use installed libz
   --with-libiconv-prefix=DIR
                           search for libiconv in DIR/include and DIR/lib
   --with-iconv-bin=PATH   specify where to find the iconv program
@@ -7015,90 +7016,15 @@ if test "$ac_res" != no; then :
 fi
 
 
-# Link in zlib if we can.  This allows us to read compressed debug sections.
+# Use the system's zlib library.
+zlibdir=-L../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=
 
-# 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
 
 
 # On FreeBSD we may need libutil for kinfo_getvmmap (used by fbsd-nat.c).
@@ -13598,7 +13524,11 @@ esac
   CFLAGS="-I${srcdir}/../include -I../bfd -I${srcdir}/../bfd $CFLAGS"
   LDFLAGS="-L../bfd -L../libiberty $LDFLAGS"
   intl=`echo $LIBINTL | sed 's,${top_builddir}/,,g'`
-  LIBS="-lbfd -liberty $intl $LIBS"
+  if test -f ../zlib/Makefile; then
+    LIBS="-lbfd -L../zlib -lz -liberty $intl $LIBS"
+  else
+    LIBS="-lbfd -lz -liberty $intl $LIBS"
+  fi
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ELF support in BFD" >&5
 $as_echo_n "checking for ELF support in BFD... " >&6; }
 if test "${gdb_cv_var_elf+set}" = set; then :
@@ -13708,7 +13638,11 @@ fi
   CFLAGS="-I${srcdir}/../include -I../bfd -I${srcdir}/../bfd $CFLAGS"
   LDFLAGS="-L../bfd -L../libiberty $LDFLAGS"
   intl=`echo $LIBINTL | sed 's,${top_builddir}/,,g'`
-  LIBS="-lbfd -liberty $intl $LIBS"
+  if test -f ../zlib/Makefile; then
+    LIBS="-lbfd -L../zlib -lz -liberty $intl $LIBS"
+  else
+    LIBS="-lbfd -lz -liberty $intl $LIBS"
+  fi
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Mach-O support in BFD" >&5
 $as_echo_n "checking for Mach-O support in BFD... " >&6; }
 if test "${gdb_cv_var_macho+set}" = set; then :
diff --git a/gdb/configure.ac b/gdb/configure.ac
index ace033e..686f996 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -531,8 +531,13 @@ AC_SEARCH_LIBS(gethostbyname, nsl)
 # Some systems (e.g. Solaris) have `socketpair' in libsocket.
 AC_SEARCH_LIBS(socketpair, socket)
 
-# Link in zlib if we can.  This allows us to read compressed debug sections.
-AM_ZLIB
+# Use the system's zlib library.
+zlibdir=-L../zlib
+AC_ARG_WITH(system-zlib,
+[AS_HELP_STRING([--with-system-zlib], [use installed libz])],
+zlibdir=
+)
+AC_SUBST(zlibdir)
 
 # On FreeBSD we may need libutil for kinfo_getvmmap (used by fbsd-nat.c).
 AC_SEARCH_LIBS(kinfo_getvmmap, util,
diff --git a/gdb/gdb_bfd.c b/gdb/gdb_bfd.c
index 3f89d3a..40874a8 100644
--- a/gdb/gdb_bfd.c
+++ b/gdb/gdb_bfd.c
@@ -24,9 +24,6 @@
 #include "hashtab.h"
 #include "filestuff.h"
 #include "vec.h"
-#ifdef HAVE_ZLIB_H
-#include <zlib.h>
-#endif
 #ifdef HAVE_MMAP
 #include <sys/mman.h>
 #ifndef MAP_FAILED
diff --git a/gdb/top.c b/gdb/top.c
index b15c06b..647d9fb 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -1316,15 +1316,6 @@ This GDB was configured as follows:\n\
     fprintf_filtered (stream, _("\
              --with-system-gdbinit=%s%s\n\
 "), SYSTEM_GDBINIT, SYSTEM_GDBINIT_RELOCATABLE ? " (relocatable)" : "");
-#if HAVE_ZLIB_H
-  fprintf_filtered (stream, _("\
-             --with-zlib\n\
-"));
-#else
-  fprintf_filtered (stream, _("\
-             --without-zlib\n\
-"));
-#endif
 #if HAVE_LIBBABELTRACE
     fprintf_filtered (stream, _("\
              --with-babeltrace\n\
-- 
2.1.0

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Add --with-system-zlib in gdb
  2015-03-31 11:27 [PATCH] Add --with-system-zlib in gdb H.J. Lu
@ 2015-03-31 11:51 ` H.J. Lu
  2015-03-31 13:46   ` H.J. Lu
  0 siblings, 1 reply; 6+ messages in thread
From: H.J. Lu @ 2015-03-31 11:51 UTC (permalink / raw)
  To: GDB

On Tue, Mar 31, 2015 at 04:27:12AM -0700, H.J. Lu wrote:
> This patch adds --with-system-zlib and removes --with-zlib in gdb.
> OK for master?
> 
> H.J.
> --
> 	* Makefile.in (ZLIB): New.
> 	(CLIBS): Add $(ZLIB).
> 	(aclocal_m4_deps): Remove ../config/zlib.m4.
> 	* acinclude.m4: Don't include ../config/zlib.m4.
> 	(GDB_AC_CHECK_BFD): Add -lz to LIBS.
> 	* configure.ac (AM_ZLIB): Removed.
> 	(zlibdir): New.  AC_SUBST.
> 	Add --with-system-zlib.
> 	* gdb_bfd.c: Don't check HAVE_ZLIB_H to include <zlib.h>.
> 	* top.c (print_gdb_configuration): Remove --with-zlib and
> 	--without-zlib.
> 	* config.in: Regenerated.
> 	* configure: Likewise.

zlib header file may not be available.  This patch adds ZLIBINC.

H.J.
----
This patch adds --with-system-zlib and removes --with-zlib in gdb.

	* Makefile.in (ZLIB): New.
	(ZLIBINC): Likewise.
	(INTERNAL_CFLAGS_BASE): Add $(ZLIBINC).
	(CLIBS): Add $(ZLIB).
	(aclocal_m4_deps): Remove ../config/zlib.m4.
	* acinclude.m4: Don't include ../config/zlib.m4.
	(GDB_AC_CHECK_BFD): Add -lz to LIBS.
	* configure.ac (AM_ZLIB): Removed.
	(zlibdir): New.  AC_SUBST.
	(zlibinc): Likewise.
	Add --with-system-zlib.
	* gdb_bfd.c: Don't check HAVE_ZLIB_H to include <zlib.h>.
	* top.c (print_gdb_configuration): Remove --with-zlib and
	--without-zlib.
	* config.in: Regenerated.
	* configure: Likewise.
---
 gdb/Makefile.in  |  13 ++++---
 gdb/acinclude.m4 |   8 +++--
 gdb/config.in    |   3 --
 gdb/configure    | 104 +++++++++++--------------------------------------------
 gdb/configure.ac |  12 +++++--
 gdb/gdb_bfd.c    |   3 --
 gdb/top.c        |   9 -----
 7 files changed, 45 insertions(+), 107 deletions(-)

diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 907997b..63b0800 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -144,6 +144,12 @@ BFD = $(BFD_DIR)/libbfd.a
 BFD_SRC = $(srcdir)/$(BFD_DIR)
 BFD_CFLAGS = -I$(BFD_DIR) -I$(BFD_SRC)
 
+# 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@
+
 # Where is the decnumber library?  Typically in ../libdecnumber.
 LIBDECNUMBER_DIR = ../libdecnumber
 LIBDECNUMBER = $(LIBDECNUMBER_DIR)/libdecnumber.a
@@ -556,7 +562,7 @@ CXXFLAGS = -g -O
 # INTERNAL_CFLAGS is the aggregate of all other *CFLAGS macros.
 INTERNAL_CFLAGS_BASE = \
 	$(CFLAGS) $(GLOBAL_CFLAGS) $(PROFILE_CFLAGS) \
-	$(GDB_CFLAGS) $(OPCODES_CFLAGS) $(READLINE_CFLAGS) \
+	$(GDB_CFLAGS) $(OPCODES_CFLAGS) $(READLINE_CFLAGS) $(ZLIBINC) \
 	$(BFD_CFLAGS) $(INCLUDE_CFLAGS) $(LIBDECNUMBER_CFLAGS) \
 	$(INTL_CFLAGS) $(INCGNU) $(ENABLE_CFLAGS) $(INTERNAL_CPPFLAGS)
 INTERNAL_WARN_CFLAGS = $(INTERNAL_CFLAGS_BASE) $(GDB_WARN_CFLAGS)
@@ -578,7 +584,7 @@ INTERNAL_LDFLAGS = $(CFLAGS) $(GLOBAL_CFLAGS) $(MH_LDFLAGS) $(LDFLAGS) $(CONFIG_
 # Libraries and corresponding dependencies for compiling gdb.
 # XM_CLIBS, defined in *config files, have host-dependent libs.
 # LIBIBERTY appears twice on purpose.
-CLIBS = $(SIM) $(READLINE) $(OPCODES) $(BFD) $(INTL) $(LIBIBERTY) $(LIBDECNUMBER) \
+CLIBS = $(SIM) $(READLINE) $(OPCODES) $(BFD) $(ZLIB) $(INTL) $(LIBIBERTY) $(LIBDECNUMBER) \
 	$(XM_CLIBS) $(NAT_CLIBS) $(GDBTKLIBS) \
 	@LIBS@ @GUILE_LIBS@ @PYTHON_LIBS@ \
 	$(LIBEXPAT) $(LIBLZMA) $(LIBBABELTRACE) \
@@ -1551,8 +1557,7 @@ aclocal_m4_deps = \
 	../config/tcl.m4 \
 	../config/depstand.m4 \
 	../config/lcmessage.m4 \
-	../config/codeset.m4 \
-	../config/zlib.m4
+	../config/codeset.m4
 
 $(srcdir)/aclocal.m4: @MAINTAINER_MODE_TRUE@ $(aclocal_m4_deps)
 	cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
diff --git a/gdb/acinclude.m4 b/gdb/acinclude.m4
index da22fc2..d88b73c 100644
--- a/gdb/acinclude.m4
+++ b/gdb/acinclude.m4
@@ -53,8 +53,6 @@ sinclude([../config/lcmessage.m4])
 dnl For AM_LANGINFO_CODESET.
 sinclude([../config/codeset.m4])
 
-sinclude([../config/zlib.m4])
-
 m4_include([common/common.m4])
 
 dnl For libiberty_INIT.
@@ -467,7 +465,11 @@ AC_DEFUN([GDB_AC_CHECK_BFD], [
   CFLAGS="-I${srcdir}/../include -I../bfd -I${srcdir}/../bfd $CFLAGS"
   LDFLAGS="-L../bfd -L../libiberty $LDFLAGS"
   intl=`echo $LIBINTL | sed 's,${top_builddir}/,,g'`
-  LIBS="-lbfd -liberty $intl $LIBS"
+  if test -f ../zlib/Makefile; then
+    LIBS="-lbfd -L../zlib -lz -liberty $intl $LIBS"
+  else
+    LIBS="-lbfd -lz -liberty $intl $LIBS"
+  fi
   AC_CACHE_CHECK([$1], [$2],
   [AC_TRY_LINK(
   [#include <stdlib.h>
diff --git a/gdb/config.in b/gdb/config.in
index 8a27df0..d41e6cf 100644
--- a/gdb/config.in
+++ b/gdb/config.in
@@ -582,9 +582,6 @@
 /* Define to 1 if you have the `XML_StopParser' function. */
 #undef HAVE_XML_STOPPARSER
 
-/* Define to 1 if you have the <zlib.h> header file. */
-#undef HAVE_ZLIB_H
-
 /* Define to 1 if your system has the _etext variable. */
 #undef HAVE__ETEXT
 
diff --git a/gdb/configure b/gdb/configure
index db239b3..f042d9d 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -680,6 +680,8 @@ READLINE_TEXI_INCFLAG
 READLINE_CFLAGS
 READLINE_DEPS
 READLINE
+zlibinc
+zlibdir
 MIG
 WINDRES
 DLLTOOL
@@ -817,7 +819,7 @@ with_curses
 enable_profiling
 with_pkgversion
 with_bugurl
-with_zlib
+with_system_zlib
 with_libiconv_prefix
 with_iconv_bin
 with_system_readline
@@ -1536,7 +1538,7 @@ Optional Packages:
                           library
   --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-system-zlib      use installed libz
   --with-libiconv-prefix=DIR
                           search for libiconv in DIR/include and DIR/lib
   --with-iconv-bin=PATH   specify where to find the iconv program
@@ -7015,90 +7017,18 @@ if test "$ac_res" != no; then :
 fi
 
 
-# Link in zlib if we can.  This allows us to read compressed debug sections.
+# 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
 
 
 # On FreeBSD we may need libutil for kinfo_getvmmap (used by fbsd-nat.c).
@@ -13598,7 +13528,11 @@ esac
   CFLAGS="-I${srcdir}/../include -I../bfd -I${srcdir}/../bfd $CFLAGS"
   LDFLAGS="-L../bfd -L../libiberty $LDFLAGS"
   intl=`echo $LIBINTL | sed 's,${top_builddir}/,,g'`
-  LIBS="-lbfd -liberty $intl $LIBS"
+  if test -f ../zlib/Makefile; then
+    LIBS="-lbfd -L../zlib -lz -liberty $intl $LIBS"
+  else
+    LIBS="-lbfd -lz -liberty $intl $LIBS"
+  fi
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ELF support in BFD" >&5
 $as_echo_n "checking for ELF support in BFD... " >&6; }
 if test "${gdb_cv_var_elf+set}" = set; then :
@@ -13708,7 +13642,11 @@ fi
   CFLAGS="-I${srcdir}/../include -I../bfd -I${srcdir}/../bfd $CFLAGS"
   LDFLAGS="-L../bfd -L../libiberty $LDFLAGS"
   intl=`echo $LIBINTL | sed 's,${top_builddir}/,,g'`
-  LIBS="-lbfd -liberty $intl $LIBS"
+  if test -f ../zlib/Makefile; then
+    LIBS="-lbfd -L../zlib -lz -liberty $intl $LIBS"
+  else
+    LIBS="-lbfd -lz -liberty $intl $LIBS"
+  fi
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Mach-O support in BFD" >&5
 $as_echo_n "checking for Mach-O support in BFD... " >&6; }
 if test "${gdb_cv_var_macho+set}" = set; then :
diff --git a/gdb/configure.ac b/gdb/configure.ac
index ace033e..f37a670 100644
--- a/gdb/configure.ac
+++ b/gdb/configure.ac
@@ -531,8 +531,16 @@ AC_SEARCH_LIBS(gethostbyname, nsl)
 # Some systems (e.g. Solaris) have `socketpair' in libsocket.
 AC_SEARCH_LIBS(socketpair, socket)
 
-# Link in zlib if we can.  This allows us to read compressed debug sections.
-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)
 
 # On FreeBSD we may need libutil for kinfo_getvmmap (used by fbsd-nat.c).
 AC_SEARCH_LIBS(kinfo_getvmmap, util,
diff --git a/gdb/gdb_bfd.c b/gdb/gdb_bfd.c
index 3f89d3a..40874a8 100644
--- a/gdb/gdb_bfd.c
+++ b/gdb/gdb_bfd.c
@@ -24,9 +24,6 @@
 #include "hashtab.h"
 #include "filestuff.h"
 #include "vec.h"
-#ifdef HAVE_ZLIB_H
-#include <zlib.h>
-#endif
 #ifdef HAVE_MMAP
 #include <sys/mman.h>
 #ifndef MAP_FAILED
diff --git a/gdb/top.c b/gdb/top.c
index b15c06b..647d9fb 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -1316,15 +1316,6 @@ This GDB was configured as follows:\n\
     fprintf_filtered (stream, _("\
              --with-system-gdbinit=%s%s\n\
 "), SYSTEM_GDBINIT, SYSTEM_GDBINIT_RELOCATABLE ? " (relocatable)" : "");
-#if HAVE_ZLIB_H
-  fprintf_filtered (stream, _("\
-             --with-zlib\n\
-"));
-#else
-  fprintf_filtered (stream, _("\
-             --without-zlib\n\
-"));
-#endif
 #if HAVE_LIBBABELTRACE
     fprintf_filtered (stream, _("\
              --with-babeltrace\n\
-- 
2.1.0

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Add --with-system-zlib in gdb
  2015-03-31 11:51 ` H.J. Lu
@ 2015-03-31 13:46   ` H.J. Lu
  2015-03-31 14:01     ` Pedro Alves
  0 siblings, 1 reply; 6+ messages in thread
From: H.J. Lu @ 2015-03-31 13:46 UTC (permalink / raw)
  To: GDB

[-- Attachment #1: Type: text/plain, Size: 703 bytes --]

On Tue, Mar 31, 2015 at 4:51 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Tue, Mar 31, 2015 at 04:27:12AM -0700, H.J. Lu wrote:
>> This patch adds --with-system-zlib and removes --with-zlib in gdb.
>> OK for master?
>>

Here is the patch for updated zlib.m4.  OK for master?


-- 
H.J.
---
This patch adds --with-system-zlib and removes --with-zlib in gdb.

* Makefile.in (ZLIB): New.
(ZLIBINC): Likewise.
(INTERNAL_CFLAGS_BASE): Add $(ZLIBINC).
(CLIBS): Add $(ZLIB).
* acinclude.m4: (GDB_AC_CHECK_BFD): Add -lz to LIBS.
* gdb_bfd.c: Don't check HAVE_ZLIB_H to include <zlib.h>.
* top.c (print_gdb_configuration): Remove --with-zlib and
--without-zlib.
* config.in: Regenerated.
* configure: Likewise.

[-- Attachment #2: 0006-Add-with-system-zlib-in-gdb.patch --]
[-- Type: text/x-patch, Size: 9116 bytes --]

From 0707e5cbd2b8e47305def798c1f1cc14a74188c6 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Sat, 14 Mar 2015 11:16:15 -0700
Subject: [PATCH 6/7] Add --with-system-zlib in gdb

This patch adds --with-system-zlib and removes --with-zlib in gdb.

	* Makefile.in (ZLIB): New.
	(ZLIBINC): Likewise.
	(INTERNAL_CFLAGS_BASE): Add $(ZLIBINC).
	(CLIBS): Add $(ZLIB).
	* acinclude.m4: (GDB_AC_CHECK_BFD): Add -lz to LIBS.
	* gdb_bfd.c: Don't check HAVE_ZLIB_H to include <zlib.h>.
	* top.c (print_gdb_configuration): Remove --with-zlib and
	--without-zlib.
	* config.in: Regenerated.
	* configure: Likewise.
---
 gdb/Makefile.in  |  10 ++++--
 gdb/acinclude.m4 |   6 +++-
 gdb/config.in    |   3 --
 gdb/configure    | 101 ++++++++++++-------------------------------------------
 gdb/gdb_bfd.c    |   3 --
 gdb/top.c        |   9 -----
 6 files changed, 34 insertions(+), 98 deletions(-)

diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 907997b..d4d4a3e 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -144,6 +144,12 @@ BFD = $(BFD_DIR)/libbfd.a
 BFD_SRC = $(srcdir)/$(BFD_DIR)
 BFD_CFLAGS = -I$(BFD_DIR) -I$(BFD_SRC)
 
+# 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@
+
 # Where is the decnumber library?  Typically in ../libdecnumber.
 LIBDECNUMBER_DIR = ../libdecnumber
 LIBDECNUMBER = $(LIBDECNUMBER_DIR)/libdecnumber.a
@@ -556,7 +562,7 @@ CXXFLAGS = -g -O
 # INTERNAL_CFLAGS is the aggregate of all other *CFLAGS macros.
 INTERNAL_CFLAGS_BASE = \
 	$(CFLAGS) $(GLOBAL_CFLAGS) $(PROFILE_CFLAGS) \
-	$(GDB_CFLAGS) $(OPCODES_CFLAGS) $(READLINE_CFLAGS) \
+	$(GDB_CFLAGS) $(OPCODES_CFLAGS) $(READLINE_CFLAGS) $(ZLIBINC) \
 	$(BFD_CFLAGS) $(INCLUDE_CFLAGS) $(LIBDECNUMBER_CFLAGS) \
 	$(INTL_CFLAGS) $(INCGNU) $(ENABLE_CFLAGS) $(INTERNAL_CPPFLAGS)
 INTERNAL_WARN_CFLAGS = $(INTERNAL_CFLAGS_BASE) $(GDB_WARN_CFLAGS)
@@ -578,7 +584,7 @@ INTERNAL_LDFLAGS = $(CFLAGS) $(GLOBAL_CFLAGS) $(MH_LDFLAGS) $(LDFLAGS) $(CONFIG_
 # Libraries and corresponding dependencies for compiling gdb.
 # XM_CLIBS, defined in *config files, have host-dependent libs.
 # LIBIBERTY appears twice on purpose.
-CLIBS = $(SIM) $(READLINE) $(OPCODES) $(BFD) $(INTL) $(LIBIBERTY) $(LIBDECNUMBER) \
+CLIBS = $(SIM) $(READLINE) $(OPCODES) $(BFD) $(ZLIB) $(INTL) $(LIBIBERTY) $(LIBDECNUMBER) \
 	$(XM_CLIBS) $(NAT_CLIBS) $(GDBTKLIBS) \
 	@LIBS@ @GUILE_LIBS@ @PYTHON_LIBS@ \
 	$(LIBEXPAT) $(LIBLZMA) $(LIBBABELTRACE) \
diff --git a/gdb/acinclude.m4 b/gdb/acinclude.m4
index da22fc2..aa58b02 100644
--- a/gdb/acinclude.m4
+++ b/gdb/acinclude.m4
@@ -467,7 +467,11 @@ AC_DEFUN([GDB_AC_CHECK_BFD], [
   CFLAGS="-I${srcdir}/../include -I../bfd -I${srcdir}/../bfd $CFLAGS"
   LDFLAGS="-L../bfd -L../libiberty $LDFLAGS"
   intl=`echo $LIBINTL | sed 's,${top_builddir}/,,g'`
-  LIBS="-lbfd -liberty $intl $LIBS"
+  if test -f ../zlib/Makefile; then
+    LIBS="-lbfd -L../zlib -lz -liberty $intl $LIBS"
+  else
+    LIBS="-lbfd -lz -liberty $intl $LIBS"
+  fi
   AC_CACHE_CHECK([$1], [$2],
   [AC_TRY_LINK(
   [#include <stdlib.h>
diff --git a/gdb/config.in b/gdb/config.in
index 8a27df0..d41e6cf 100644
--- a/gdb/config.in
+++ b/gdb/config.in
@@ -582,9 +582,6 @@
 /* Define to 1 if you have the `XML_StopParser' function. */
 #undef HAVE_XML_STOPPARSER
 
-/* Define to 1 if you have the <zlib.h> header file. */
-#undef HAVE_ZLIB_H
-
 /* Define to 1 if your system has the _etext variable. */
 #undef HAVE__ETEXT
 
diff --git a/gdb/configure b/gdb/configure
index db239b3..e65c699 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -680,6 +680,8 @@ READLINE_TEXI_INCFLAG
 READLINE_CFLAGS
 READLINE_DEPS
 READLINE
+zlibinc
+zlibdir
 MIG
 WINDRES
 DLLTOOL
@@ -817,7 +819,7 @@ with_curses
 enable_profiling
 with_pkgversion
 with_bugurl
-with_zlib
+with_system_zlib
 with_libiconv_prefix
 with_iconv_bin
 with_system_readline
@@ -1536,7 +1538,7 @@ Optional Packages:
                           library
   --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-system-zlib      use installed libz
   --with-libiconv-prefix=DIR
                           search for libiconv in DIR/include and DIR/lib
   --with-iconv-bin=PATH   specify where to find the iconv program
@@ -7017,88 +7019,19 @@ 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.
+  # Use the system's zlib library.
+  zlibdir=-L../zlib
+  zlibinc="-I\$(srcdir)/../zlib"
 
-# 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.  */
+# Check whether --with-system-zlib was given.
+if test "${with_system_zlib+set}" = set; then :
+  withval=$with_system_zlib; zlibdir=
+  zlibinc=
 
-/* 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
 
 
 # On FreeBSD we may need libutil for kinfo_getvmmap (used by fbsd-nat.c).
@@ -13598,7 +13531,11 @@ esac
   CFLAGS="-I${srcdir}/../include -I../bfd -I${srcdir}/../bfd $CFLAGS"
   LDFLAGS="-L../bfd -L../libiberty $LDFLAGS"
   intl=`echo $LIBINTL | sed 's,${top_builddir}/,,g'`
-  LIBS="-lbfd -liberty $intl $LIBS"
+  if test -f ../zlib/Makefile; then
+    LIBS="-lbfd -L../zlib -lz -liberty $intl $LIBS"
+  else
+    LIBS="-lbfd -lz -liberty $intl $LIBS"
+  fi
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ELF support in BFD" >&5
 $as_echo_n "checking for ELF support in BFD... " >&6; }
 if test "${gdb_cv_var_elf+set}" = set; then :
@@ -13708,7 +13645,11 @@ fi
   CFLAGS="-I${srcdir}/../include -I../bfd -I${srcdir}/../bfd $CFLAGS"
   LDFLAGS="-L../bfd -L../libiberty $LDFLAGS"
   intl=`echo $LIBINTL | sed 's,${top_builddir}/,,g'`
-  LIBS="-lbfd -liberty $intl $LIBS"
+  if test -f ../zlib/Makefile; then
+    LIBS="-lbfd -L../zlib -lz -liberty $intl $LIBS"
+  else
+    LIBS="-lbfd -lz -liberty $intl $LIBS"
+  fi
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Mach-O support in BFD" >&5
 $as_echo_n "checking for Mach-O support in BFD... " >&6; }
 if test "${gdb_cv_var_macho+set}" = set; then :
diff --git a/gdb/gdb_bfd.c b/gdb/gdb_bfd.c
index 3f89d3a..40874a8 100644
--- a/gdb/gdb_bfd.c
+++ b/gdb/gdb_bfd.c
@@ -24,9 +24,6 @@
 #include "hashtab.h"
 #include "filestuff.h"
 #include "vec.h"
-#ifdef HAVE_ZLIB_H
-#include <zlib.h>
-#endif
 #ifdef HAVE_MMAP
 #include <sys/mman.h>
 #ifndef MAP_FAILED
diff --git a/gdb/top.c b/gdb/top.c
index b15c06b..647d9fb 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -1316,15 +1316,6 @@ This GDB was configured as follows:\n\
     fprintf_filtered (stream, _("\
              --with-system-gdbinit=%s%s\n\
 "), SYSTEM_GDBINIT, SYSTEM_GDBINIT_RELOCATABLE ? " (relocatable)" : "");
-#if HAVE_ZLIB_H
-  fprintf_filtered (stream, _("\
-             --with-zlib\n\
-"));
-#else
-  fprintf_filtered (stream, _("\
-             --without-zlib\n\
-"));
-#endif
 #if HAVE_LIBBABELTRACE
     fprintf_filtered (stream, _("\
              --with-babeltrace\n\
-- 
2.1.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Add --with-system-zlib in gdb
  2015-03-31 13:46   ` H.J. Lu
@ 2015-03-31 14:01     ` Pedro Alves
  2015-03-31 14:56       ` H.J. Lu
  0 siblings, 1 reply; 6+ messages in thread
From: Pedro Alves @ 2015-03-31 14:01 UTC (permalink / raw)
  To: H.J. Lu, GDB

On 03/31/2015 02:46 PM, H.J. Lu wrote:
> --- a/gdb/acinclude.m4
> +++ b/gdb/acinclude.m4
> @@ -467,7 +467,11 @@ AC_DEFUN([GDB_AC_CHECK_BFD], [
>    CFLAGS="-I${srcdir}/../include -I../bfd -I${srcdir}/../bfd $CFLAGS"
>    LDFLAGS="-L../bfd -L../libiberty $LDFLAGS"
>    intl=`echo $LIBINTL | sed 's,${top_builddir}/,,g'`
> -  LIBS="-lbfd -liberty $intl $LIBS"
> +  if test -f ../zlib/Makefile; then
> +    LIBS="-lbfd -L../zlib -lz -liberty $intl $LIBS"
> +  else
> +    LIBS="-lbfd -lz -liberty $intl $LIBS"
> +  fi

Seems quite fragile to have to configure and generate the zlib
Makefile first.  Why isn't this simply:

   LDFLAGS="-L../bfd -L../libiberty $zlibdir $LDFLAGS"

?

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Add --with-system-zlib in gdb
  2015-03-31 14:01     ` Pedro Alves
@ 2015-03-31 14:56       ` H.J. Lu
  2015-03-31 15:11         ` Pedro Alves
  0 siblings, 1 reply; 6+ messages in thread
From: H.J. Lu @ 2015-03-31 14:56 UTC (permalink / raw)
  To: Pedro Alves; +Cc: GDB

[-- Attachment #1: Type: text/plain, Size: 859 bytes --]

On Tue, Mar 31, 2015 at 7:01 AM, Pedro Alves <palves@redhat.com> wrote:
> On 03/31/2015 02:46 PM, H.J. Lu wrote:
>> --- a/gdb/acinclude.m4
>> +++ b/gdb/acinclude.m4
>> @@ -467,7 +467,11 @@ AC_DEFUN([GDB_AC_CHECK_BFD], [
>>    CFLAGS="-I${srcdir}/../include -I../bfd -I${srcdir}/../bfd $CFLAGS"
>>    LDFLAGS="-L../bfd -L../libiberty $LDFLAGS"
>>    intl=`echo $LIBINTL | sed 's,${top_builddir}/,,g'`
>> -  LIBS="-lbfd -liberty $intl $LIBS"
>> +  if test -f ../zlib/Makefile; then
>> +    LIBS="-lbfd -L../zlib -lz -liberty $intl $LIBS"
>> +  else
>> +    LIBS="-lbfd -lz -liberty $intl $LIBS"
>> +  fi
>
> Seems quite fragile to have to configure and generate the zlib
> Makefile first.  Why isn't this simply:
>
>    LDFLAGS="-L../bfd -L../libiberty $zlibdir $LDFLAGS"
>
> ?

It works.  Here is the updated patch for gdb.  OK for master?

Thanks.


-- 
H.J.

[-- Attachment #2: 0002-Add-with-system-zlib-in-gdb.patch --]
[-- Type: text/x-patch, Size: 9264 bytes --]

From 627de181fd225a66713159b75cc9e830e274c8d3 Mon Sep 17 00:00:00 2001
From: "H.J. Lu" <hjl.tools@gmail.com>
Date: Sat, 14 Mar 2015 11:16:15 -0700
Subject: [PATCH 2/3] Add --with-system-zlib in gdb

This patch adds --with-system-zlib and removes --with-zlib in gdb.

	* Makefile.in (ZLIB): New.
	(ZLIBINC): Likewise.
	(INTERNAL_CFLAGS_BASE): Add $(ZLIBINC).
	(CLIBS): Add $(ZLIB).
	* acinclude.m4: (GDB_AC_CHECK_BFD): Add $zlibdir to LDFLAGS.
	Add -lz to LIBS.
	* gdb_bfd.c: Don't check HAVE_ZLIB_H to include <zlib.h>.
	* top.c (print_gdb_configuration): Remove --with-zlib and
	--without-zlib.
	* config.in: Regenerated.
	* configure: Likewise.
---
 gdb/Makefile.in  | 10 ++++--
 gdb/acinclude.m4 |  4 +--
 gdb/config.in    |  3 --
 gdb/configure    | 97 +++++++++-----------------------------------------------
 gdb/gdb_bfd.c    |  3 --
 gdb/top.c        |  9 ------
 6 files changed, 25 insertions(+), 101 deletions(-)

diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 907997b..d4d4a3e 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -144,6 +144,12 @@ BFD = $(BFD_DIR)/libbfd.a
 BFD_SRC = $(srcdir)/$(BFD_DIR)
 BFD_CFLAGS = -I$(BFD_DIR) -I$(BFD_SRC)
 
+# 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@
+
 # Where is the decnumber library?  Typically in ../libdecnumber.
 LIBDECNUMBER_DIR = ../libdecnumber
 LIBDECNUMBER = $(LIBDECNUMBER_DIR)/libdecnumber.a
@@ -556,7 +562,7 @@ CXXFLAGS = -g -O
 # INTERNAL_CFLAGS is the aggregate of all other *CFLAGS macros.
 INTERNAL_CFLAGS_BASE = \
 	$(CFLAGS) $(GLOBAL_CFLAGS) $(PROFILE_CFLAGS) \
-	$(GDB_CFLAGS) $(OPCODES_CFLAGS) $(READLINE_CFLAGS) \
+	$(GDB_CFLAGS) $(OPCODES_CFLAGS) $(READLINE_CFLAGS) $(ZLIBINC) \
 	$(BFD_CFLAGS) $(INCLUDE_CFLAGS) $(LIBDECNUMBER_CFLAGS) \
 	$(INTL_CFLAGS) $(INCGNU) $(ENABLE_CFLAGS) $(INTERNAL_CPPFLAGS)
 INTERNAL_WARN_CFLAGS = $(INTERNAL_CFLAGS_BASE) $(GDB_WARN_CFLAGS)
@@ -578,7 +584,7 @@ INTERNAL_LDFLAGS = $(CFLAGS) $(GLOBAL_CFLAGS) $(MH_LDFLAGS) $(LDFLAGS) $(CONFIG_
 # Libraries and corresponding dependencies for compiling gdb.
 # XM_CLIBS, defined in *config files, have host-dependent libs.
 # LIBIBERTY appears twice on purpose.
-CLIBS = $(SIM) $(READLINE) $(OPCODES) $(BFD) $(INTL) $(LIBIBERTY) $(LIBDECNUMBER) \
+CLIBS = $(SIM) $(READLINE) $(OPCODES) $(BFD) $(ZLIB) $(INTL) $(LIBIBERTY) $(LIBDECNUMBER) \
 	$(XM_CLIBS) $(NAT_CLIBS) $(GDBTKLIBS) \
 	@LIBS@ @GUILE_LIBS@ @PYTHON_LIBS@ \
 	$(LIBEXPAT) $(LIBLZMA) $(LIBBABELTRACE) \
diff --git a/gdb/acinclude.m4 b/gdb/acinclude.m4
index da22fc2..98ae85f 100644
--- a/gdb/acinclude.m4
+++ b/gdb/acinclude.m4
@@ -465,9 +465,9 @@ AC_DEFUN([GDB_AC_CHECK_BFD], [
   # points somewhere with bfd, with -I/foo/lib and -L/foo/lib.  We
   # always want our bfd.
   CFLAGS="-I${srcdir}/../include -I../bfd -I${srcdir}/../bfd $CFLAGS"
-  LDFLAGS="-L../bfd -L../libiberty $LDFLAGS"
+  LDFLAGS="-L../bfd -L../libiberty $zlibdir $LDFLAGS"
   intl=`echo $LIBINTL | sed 's,${top_builddir}/,,g'`
-  LIBS="-lbfd -liberty $intl $LIBS"
+  LIBS="-lbfd -liberty -lz $intl $LIBS"
   AC_CACHE_CHECK([$1], [$2],
   [AC_TRY_LINK(
   [#include <stdlib.h>
diff --git a/gdb/config.in b/gdb/config.in
index 8a27df0..d41e6cf 100644
--- a/gdb/config.in
+++ b/gdb/config.in
@@ -582,9 +582,6 @@
 /* Define to 1 if you have the `XML_StopParser' function. */
 #undef HAVE_XML_STOPPARSER
 
-/* Define to 1 if you have the <zlib.h> header file. */
-#undef HAVE_ZLIB_H
-
 /* Define to 1 if your system has the _etext variable. */
 #undef HAVE__ETEXT
 
diff --git a/gdb/configure b/gdb/configure
index db239b3..d3d093d 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -680,6 +680,8 @@ READLINE_TEXI_INCFLAG
 READLINE_CFLAGS
 READLINE_DEPS
 READLINE
+zlibinc
+zlibdir
 MIG
 WINDRES
 DLLTOOL
@@ -817,7 +819,7 @@ with_curses
 enable_profiling
 with_pkgversion
 with_bugurl
-with_zlib
+with_system_zlib
 with_libiconv_prefix
 with_iconv_bin
 with_system_readline
@@ -1536,7 +1538,7 @@ Optional Packages:
                           library
   --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-system-zlib      use installed libz
   --with-libiconv-prefix=DIR
                           search for libiconv in DIR/include and DIR/lib
   --with-iconv-bin=PATH   specify where to find the iconv program
@@ -7017,88 +7019,19 @@ 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.
+  # Use the system's zlib library.
+  zlibdir=-L../zlib
+  zlibinc="-I\$(srcdir)/../zlib"
 
-# Check whether --with-zlib was given.
-if test "${with_zlib+set}" = set; then :
-  withval=$with_zlib;
-else
-  with_zlib=auto
-fi
+# Check whether --with-system-zlib was given.
+if test "${with_system_zlib+set}" = set; then :
+  withval=$with_system_zlib; zlibdir=
+  zlibinc=
 
-
-  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
 
 
 # On FreeBSD we may need libutil for kinfo_getvmmap (used by fbsd-nat.c).
@@ -13596,9 +13529,9 @@ esac
   # points somewhere with bfd, with -I/foo/lib and -L/foo/lib.  We
   # always want our bfd.
   CFLAGS="-I${srcdir}/../include -I../bfd -I${srcdir}/../bfd $CFLAGS"
-  LDFLAGS="-L../bfd -L../libiberty $LDFLAGS"
+  LDFLAGS="-L../bfd -L../libiberty $zlibdir $LDFLAGS"
   intl=`echo $LIBINTL | sed 's,${top_builddir}/,,g'`
-  LIBS="-lbfd -liberty $intl $LIBS"
+  LIBS="-lbfd -liberty -lz $intl $LIBS"
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ELF support in BFD" >&5
 $as_echo_n "checking for ELF support in BFD... " >&6; }
 if test "${gdb_cv_var_elf+set}" = set; then :
@@ -13706,9 +13639,9 @@ fi
   # points somewhere with bfd, with -I/foo/lib and -L/foo/lib.  We
   # always want our bfd.
   CFLAGS="-I${srcdir}/../include -I../bfd -I${srcdir}/../bfd $CFLAGS"
-  LDFLAGS="-L../bfd -L../libiberty $LDFLAGS"
+  LDFLAGS="-L../bfd -L../libiberty $zlibdir $LDFLAGS"
   intl=`echo $LIBINTL | sed 's,${top_builddir}/,,g'`
-  LIBS="-lbfd -liberty $intl $LIBS"
+  LIBS="-lbfd -liberty -lz $intl $LIBS"
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Mach-O support in BFD" >&5
 $as_echo_n "checking for Mach-O support in BFD... " >&6; }
 if test "${gdb_cv_var_macho+set}" = set; then :
diff --git a/gdb/gdb_bfd.c b/gdb/gdb_bfd.c
index 3f89d3a..40874a8 100644
--- a/gdb/gdb_bfd.c
+++ b/gdb/gdb_bfd.c
@@ -24,9 +24,6 @@
 #include "hashtab.h"
 #include "filestuff.h"
 #include "vec.h"
-#ifdef HAVE_ZLIB_H
-#include <zlib.h>
-#endif
 #ifdef HAVE_MMAP
 #include <sys/mman.h>
 #ifndef MAP_FAILED
diff --git a/gdb/top.c b/gdb/top.c
index b15c06b..647d9fb 100644
--- a/gdb/top.c
+++ b/gdb/top.c
@@ -1316,15 +1316,6 @@ This GDB was configured as follows:\n\
     fprintf_filtered (stream, _("\
              --with-system-gdbinit=%s%s\n\
 "), SYSTEM_GDBINIT, SYSTEM_GDBINIT_RELOCATABLE ? " (relocatable)" : "");
-#if HAVE_ZLIB_H
-  fprintf_filtered (stream, _("\
-             --with-zlib\n\
-"));
-#else
-  fprintf_filtered (stream, _("\
-             --without-zlib\n\
-"));
-#endif
 #if HAVE_LIBBABELTRACE
     fprintf_filtered (stream, _("\
              --with-babeltrace\n\
-- 
1.9.3


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] Add --with-system-zlib in gdb
  2015-03-31 14:56       ` H.J. Lu
@ 2015-03-31 15:11         ` Pedro Alves
  0 siblings, 0 replies; 6+ messages in thread
From: Pedro Alves @ 2015-03-31 15:11 UTC (permalink / raw)
  To: H.J. Lu; +Cc: GDB

On 03/31/2015 03:56 PM, H.J. Lu wrote:
> On Tue, Mar 31, 2015 at 7:01 AM, Pedro Alves <palves@redhat.com> wrote:
>> On 03/31/2015 02:46 PM, H.J. Lu wrote:
>>> --- a/gdb/acinclude.m4
>>> +++ b/gdb/acinclude.m4
>>> @@ -467,7 +467,11 @@ AC_DEFUN([GDB_AC_CHECK_BFD], [
>>>    CFLAGS="-I${srcdir}/../include -I../bfd -I${srcdir}/../bfd $CFLAGS"
>>>    LDFLAGS="-L../bfd -L../libiberty $LDFLAGS"
>>>    intl=`echo $LIBINTL | sed 's,${top_builddir}/,,g'`
>>> -  LIBS="-lbfd -liberty $intl $LIBS"
>>> +  if test -f ../zlib/Makefile; then
>>> +    LIBS="-lbfd -L../zlib -lz -liberty $intl $LIBS"
>>> +  else
>>> +    LIBS="-lbfd -lz -liberty $intl $LIBS"
>>> +  fi
>>
>> Seems quite fragile to have to configure and generate the zlib
>> Makefile first.  Why isn't this simply:
>>
>>    LDFLAGS="-L../bfd -L../libiberty $zlibdir $LDFLAGS"
>>
>> ?
> 
> It works.  Here is the updated patch for gdb.  OK for master?

OK.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-03-31 15:11 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-31 11:27 [PATCH] Add --with-system-zlib in gdb H.J. Lu
2015-03-31 11:51 ` H.J. Lu
2015-03-31 13:46   ` H.J. Lu
2015-03-31 14:01     ` Pedro Alves
2015-03-31 14:56       ` H.J. Lu
2015-03-31 15:11         ` Pedro Alves

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).