1 # Copyright (C) 2013 Free Software Foundation, Inc.
3 # This file is part of the GNU Application Binary Interface Generic
4 # Analysis and Instrumentation Library (libabigail). This library is
5 # free software; you can redistribute it and/or modify it under the
6 # terms of the GNU General Public License as published by the Free
7 # Software Foundation; either version 3, or (at your option) any
10 # This library is distributed in the hope that it will be useful, but
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # General Public License for more details.
15 # Under Section 7 of GPL version 3, you are granted additional
16 # permissions described in the GCC Runtime Library Exception, version
17 # 3.1, as published by the Free Software Foundation.
19 # You should have received a copy of the GNU General Public License
20 # and a copy of the GCC Runtime Library Exception along with this
21 # program; see the files COPYING3 and COPYING.RUNTIME respectively.
22 # If not, see <http://www.gnu.org/licenses/>.
26 # Handle the detection of the libabigail header and library files on
27 # the system. If these are present, set the 'abigailinc' variable to
28 # the compiler option necessary to locate the headers of the library;
29 # also set the 'abigaillibs' variable to the compiler/linker option
30 # necessary to locate the library.
32 # Note that this macro defines the handling of --with-abigail,
33 # --with-abigail-include, --with-abigail-lib and
34 # --enable-abigail-version-check switches to the configure script.
36 # If libabigail has been found, this macro sets the variable
37 # HAVE_LIBABIGAIL to 'yes', otherwise, it sets it to 'no'.
38 AC_DEFUN([ABIGAIL_INIT],
40 AC_ARG_WITH([abigail],
41 [AS_HELP_STRING([--with-abigail],
42 [Prefix directory for abigail library])],
46 AC_ARG_WITH([abigail-include],
47 [AS_HELP_STRING([--with-abigail-include],
48 [Directory for installed abigail include files])],
52 AC_ARG_WITH([abigail-lib],
53 [AS_HELP_STRING([--with-abigail-lib],
54 [Directory for installed abigail library])],
58 AC_ARG_ENABLE(abigail-version-check,
59 [AS_HELP_STRING([--enable-abigail-version-check],
60 [Enable check for libabigail version])],
61 [ENABLE_ABIGAIL_VERSION_CHECK=$enableval],
62 [ENABLE_ABIGAIL_VERSION_CHECK=yes])
64 if test x$with_abigail != x -a x$with_abigail != xno; then
65 abigailinc="-I$with_abigail/include/libabigail"
66 abigaillibs="-L$with_abigail/lib"
71 if test x$with_abigail_include != x -a x$with_abigail != xno; then
72 abigailinc="-I$with_abigail_include"
76 if test x$with_abigail_lib != x -a x$with_abigail != xno; then
77 abigaillibs="-L$with_abigail_lib"
81 if test x$abigaillibs = x; then
82 AC_CHECK_LIB(abigail, abigail_get_library_version,
83 [found_abigail_lib=yes], [], [])
86 if test x$abigailinc = x; then
88 AC_CHECK_HEADER([libabigail/abg-version.h],
89 [found_abigail_inc=yes], [], [])
93 if test x$found_abigail_lib = xyes -a x$found_abigail_inc = xyes; then
99 #Test whether libabigail is in the gcc source tree.
100 if test x$HAVE_LIBABIGAIL != xyes; then
101 if test -d $srcdir/libabigail -a -f $srcdir/gcc/gcc.c; then
102 libpath='$$r/$(HOST_SUBDIR)/libabigail/src/'"${lt_cv_objdir}"
103 abigaillibs="-L$libpath ${abigaillibs}"
104 abigailinc='-I${srcdir}/libabigail/include '"${abigailinc}"
105 found_abigail_lib=yes
106 found_abigail_inc=yes
108 AC_MSG_WARN([using in-tree libabigail, disabling version check]);
109 ENABLE_ABIGAIL_VERSION_CHECK=no
113 if test x$found_abigail_lib = xyes; then
114 abigaillibs="$abigaillibs -Wl,-Bstatic -labigail -Wl,-Bdynamic"
120 # IF_ABIGAIL_PRESENT(ACTION-IF-PRESENT)
121 AC_DEFUN([IF_ABIGAIL_PRESENT],
123 AC_REQUIRE([ABIGAIL_INIT])
125 if test x$HAVE_LIBABIGAIL = xyes; then
131 # IF_ABIGAIL_NOT_PRESENT(ACTION-IF-NOT-PRESENT)
132 AC_DEFUN([IF_ABIGAIL_NOT_PRESENT],
134 AC_REQUIRE([ABIGAIL_INIT])
135 if test x$HAVE_LIBABIGAIL != xyes; then
141 # ABIGAIL_CHECK_VERSION(MAJOR, MINOR)
143 # Test the whether the found major and minor version numbers of the
144 # found abigail library is compatible with the MAJOR.MINOR version
145 # number given in argument. The result of the test ('yes' or 'no') is
146 # put in the variable has_right_abigail_version.
147 AC_DEFUN([ABIGAIL_CHECK_VERSION],
149 AC_REQUIRE([ABIGAIL_INIT])
151 if test x$ENABLE_ABIGAIL_VERSION_CHECK = xyes; then
152 _abigail_saved_CXXFLAGS=$CXXFLAGLS
153 _abigail_saved_LDFLAGS=$LDFLAGS
155 CXXFLAGS="$abigailinc"
156 LDFLAGS="$abigaillibs"
158 AC_MSG_CHECKING([for version $1.$2 of libabigail])
160 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include "abg-version.h"],
161 [#if ABIGAIL_VERSION_MAJOR != $1 || ABIGAIL_VERSION_MINOR < $2
166 has_right_abigail_version=yes,
167 has_right_abigail_version=no)
169 AC_MSG_RESULT([$has_right_abigail_version])
171 CXXFLAGS=$_abigail_saved_CXXFLAGS
172 LDFLAGS=$_abigail_saved_LDFLAGS
174 # Version checking was disabled, so assume we have the right
175 # version of libabigail.
176 has_right_abigail_version=yes