Make abidiff --harmless show harmless changes in unions
[platform/upstream/libabigail.git] / abigail.m4
1 # Copyright (C) 2013 Free Software Foundation, Inc.
2
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
8 # later version.
9
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.
14
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.
18
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/>.
23
24 # ABIGAIL_INIT
25 #
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.
31 #
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.
35 #
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],
39 [
40  AC_ARG_WITH([abigail],
41              [AS_HELP_STRING([--with-abigail],
42                              [Prefix directory for abigail library])],
43              [],
44              [])
45
46  AC_ARG_WITH([abigail-include],
47              [AS_HELP_STRING([--with-abigail-include],
48                              [Directory for installed abigail include files])],
49              [],
50              [])
51
52  AC_ARG_WITH([abigail-lib],
53              [AS_HELP_STRING([--with-abigail-lib],
54                              [Directory for installed abigail library])],
55              [],
56              [])
57
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])
63
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"
67    found_abigail_lib=yes
68    found_abigail_inc=yes
69  fi
70
71  if test x$with_abigail_include != x -a x$with_abigail != xno; then
72    abigailinc="-I$with_abigail_include"
73    found_abigail_inc=yes
74  fi
75
76  if test x$with_abigail_lib != x -a x$with_abigail != xno; then
77    abigaillibs="-L$with_abigail_lib"
78    found_abigail_lib=yes
79  fi
80
81  if test x$abigaillibs = x; then
82     AC_CHECK_LIB(abigail, abigail_get_library_version,
83                  [found_abigail_lib=yes], [], [])
84  fi
85
86  if test x$abigailinc = x; then
87     AC_LANG_PUSH(C++)
88     AC_CHECK_HEADER([libabigail/abg-version.h],
89                     [found_abigail_inc=yes], [], [])
90     AC_LANG_POP(C++)
91  fi
92
93  if test x$found_abigail_lib = xyes -a x$found_abigail_inc = xyes; then
94     HAVE_LIBABIGAIL=yes
95  else
96     HAVE_LIBABIGAIL=no
97  fi
98
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
107       HAVE_LIBABIGAIL=yes
108       AC_MSG_WARN([using in-tree libabigail, disabling version check]);
109       ENABLE_ABIGAIL_VERSION_CHECK=no
110    fi
111  fi
112
113  if test x$found_abigail_lib = xyes; then
114     abigaillibs="$abigaillibs -Wl,-Bstatic -labigail -Wl,-Bdynamic"
115  fi
116
117 ]
118 )
119
120 # IF_ABIGAIL_PRESENT(ACTION-IF-PRESENT)
121 AC_DEFUN([IF_ABIGAIL_PRESENT],
122 [
123  AC_REQUIRE([ABIGAIL_INIT])
124
125  if test x$HAVE_LIBABIGAIL = xyes; then
126    $1
127  fi
128 ]
129 )
130
131 # IF_ABIGAIL_NOT_PRESENT(ACTION-IF-NOT-PRESENT)
132 AC_DEFUN([IF_ABIGAIL_NOT_PRESENT],
133 [
134   AC_REQUIRE([ABIGAIL_INIT])
135   if test x$HAVE_LIBABIGAIL != xyes; then
136      $1
137   fi
138 ]
139 )
140
141 # ABIGAIL_CHECK_VERSION(MAJOR, MINOR)
142
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],
148 [
149  AC_REQUIRE([ABIGAIL_INIT])
150
151  if test x$ENABLE_ABIGAIL_VERSION_CHECK = xyes; then
152    _abigail_saved_CXXFLAGS=$CXXFLAGLS
153    _abigail_saved_LDFLAGS=$LDFLAGS
154
155    CXXFLAGS="$abigailinc"
156    LDFLAGS="$abigaillibs"
157
158    AC_MSG_CHECKING([for version $1.$2 of libabigail])
159    AC_LANG_PUSH(C++)
160    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include "abg-version.h"],
161                                       [#if ABIGAIL_VERSION_MAJOR != $1 || ABIGAIL_VERSION_MINOR < $2
162                                           choke here
163                                        #endif
164                                       ])
165                                       ],
166                      has_right_abigail_version=yes,
167                      has_right_abigail_version=no)
168    AC_LANG_POP(C++)
169    AC_MSG_RESULT([$has_right_abigail_version])
170
171    CXXFLAGS=$_abigail_saved_CXXFLAGS
172    LDFLAGS=$_abigail_saved_LDFLAGS
173  else
174    # Version checking was disabled, so assume we have the right
175    # version of libabigail.
176    has_right_abigail_version=yes
177  fi
178 ]
179 )