From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21351 invoked by alias); 13 Dec 2012 19:51:29 -0000 Received: (qmail 21343 invoked by uid 22791); 13 Dec 2012 19:51:28 -0000 X-SWARE-Spam-Status: No, hits=-6.4 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,SPF_HELO_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 13 Dec 2012 19:51:20 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qBDJpJfq003907 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 13 Dec 2012 14:51:19 -0500 Received: from barimba (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id qBDJpIY0001168 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Thu, 13 Dec 2012 14:51:18 -0500 From: Tom Tromey To: gdb-patches@sourceware.org Subject: [1/2] RFC: refactor BFD check into autoconf macro Date: Thu, 13 Dec 2012 19:51:00 -0000 Message-ID: <87k3sl4top.fsf@fleche.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.2.90 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-12/txt/msg00464.txt.bz2 This patch is just preparation for the next one. It moves a BFD check into an autoconf macro in acinclude.m4. This way we can reuse it for another similar check. Tested by rebuilding. Tom * acinclude.m4 (GDB_AC_CHECK_BFD): New macro. * configure.ac: Use GDB_AC_CHECK_BFD. * configure: Rebuild. --- gdb/acinclude.m4 | 34 ++++++++++++++++++++++++++++++++++ gdb/configure | 45 +++++++++++++++++++++++---------------------- gdb/configure.ac | 29 +++-------------------------- 3 files changed, 60 insertions(+), 48 deletions(-) diff --git a/gdb/acinclude.m4 b/gdb/acinclude.m4 index 0873f66..c2f3a2d 100644 --- a/gdb/acinclude.m4 +++ b/gdb/acinclude.m4 @@ -424,3 +424,37 @@ AC_DEFUN([GDB_AC_WITH_DIR], [ AC_SUBST([$1]) GDB_AC_DEFINE_RELOCATABLE([$1], [$2], ${ac_define_dir}) ]) + +dnl GDB_AC_CHECK_BFD([MESSAGE], [CV], [CODE], [HEADER]) +dnl Check whether BFD provides a feature. +dnl MESSAGE is the "checking" message to display. +dnl CV is the name of the cache variable where the result is stored. +dnl The result will be "yes" or "no". +dnl CODE is some code to compile that checks for the feature. +dnl A link test is run. +dnl HEADER is the name of an extra BFD header to include. +AC_DEFUN([GDB_AC_CHECK_BFD], [ + OLD_CFLAGS=$CFLAGS + OLD_LDFLAGS=$LDFLAGS + OLD_LIBS=$LIBS + # Put the old CFLAGS/LDFLAGS last, in case the user's (C|LD)FLAGS + # 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" + intl=`echo $LIBINTL | sed 's,${top_builddir}/,,g'` + # -ldl is provided by bfd/Makfile.am (LIBDL) . + if test "$plugins" = "yes"; then + LIBS="-ldl $LIBS" + fi + LIBS="-lbfd -liberty $intl $LIBS" + AC_CACHE_CHECK([$1], [$2], + [AC_TRY_LINK( + [#include + #include "bfd.h" + #include "$4" + ], + [return $3;], [[$2]=yes], [[$2]=no])]) + CFLAGS=$OLD_CFLAGS + LDFLAGS=$OLD_LDFLAGS + LIBS=$OLD_LIBS]) diff --git a/gdb/configure.ac b/gdb/configure.ac index 5797561..26c88f4 100644 --- a/gdb/configure.ac +++ b/gdb/configure.ac @@ -2015,40 +2015,17 @@ esac AC_SUBST(WIN32LIBS) # Add ELF support to GDB, but only if BFD includes ELF support. -OLD_CFLAGS=$CFLAGS -OLD_LDFLAGS=$LDFLAGS -OLD_LIBS=$LIBS -# Put the old CFLAGS/LDFLAGS last, in case the user's (C|LD)FLAGS -# 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" -intl=`echo $LIBINTL | sed 's,${top_builddir}/,,g'` -# -ldl is provided by bfd/Makfile.am (LIBDL) . -if test "$plugins" = "yes"; then - LIBS="-ldl $LIBS" -fi -LIBS="-lbfd -liberty $intl $LIBS" -AC_CACHE_CHECK([for ELF support in BFD], gdb_cv_var_elf, -[AC_TRY_LINK( -[#include -#include "bfd.h" -#include "elf-bfd.h" -], -[bfd *abfd = NULL; bfd_get_elf_phdr_upper_bound (abfd); ], -gdb_cv_var_elf=yes, gdb_cv_var_elf=no)]) +GDB_AC_CHECK_BFD([for ELF support in BFD], gdb_cv_var_elf, + [bfd_get_elf_phdr_upper_bound (NULL)], elf-bfd.h) if test $gdb_cv_var_elf = yes; then CONFIG_OBS="$CONFIG_OBS elfread.o stap-probe.o" AC_DEFINE(HAVE_ELF, 1, [Define if ELF support should be included.]) # -ldl is provided by bfd/Makfile.am (LIBDL) . if test "$plugins" = "yes"; then - OLD_LIBS="-ldl $OLD_LIBS" + LIBS="-ldl $LIBS" fi fi -CFLAGS=$OLD_CFLAGS -LDFLAGS=$OLD_LDFLAGS -LIBS=$OLD_LIBS # Add any host-specific objects to GDB. CONFIG_OBS="${CONFIG_OBS} ${gdb_host_obs}" -- 1.7.7.6