1# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 2# 3# Copyright (C) 2013-2020 Red Hat, Inc 4# 5# Author: Dodji Seketeli <dodji@redhat.com> 6 7# 8# ABIGAIL_INIT 9# 10# Handle the detection of the libabigail header and library files on 11# the system. If these are present, set the 'abigailinc' variable to 12# the compiler option necessary to locate the headers of the library; 13# also set the 'abigaillibs' variable to the compiler/linker option 14# necessary to locate the library. 15# 16# Note that this macro defines the handling of --with-abigail, 17# --with-abigail-include, --with-abigail-lib and 18# --enable-abigail-version-check switches to the configure script. 19# 20# If libabigail has been found, this macro sets the variable 21# HAVE_LIBABIGAIL to 'yes', otherwise, it sets it to 'no'. 22AC_DEFUN([ABIGAIL_INIT], 23[ 24 AC_ARG_WITH([abigail], 25 [AS_HELP_STRING([--with-abigail], 26 [Prefix directory for abigail library])], 27 [], 28 []) 29 30 AC_ARG_WITH([abigail-include], 31 [AS_HELP_STRING([--with-abigail-include], 32 [Directory for installed abigail include files])], 33 [], 34 []) 35 36 AC_ARG_WITH([abigail-lib], 37 [AS_HELP_STRING([--with-abigail-lib], 38 [Directory for installed abigail library])], 39 [], 40 []) 41 42 AC_ARG_ENABLE(abigail-version-check, 43 [AS_HELP_STRING([--enable-abigail-version-check], 44 [Enable check for libabigail version])], 45 [ENABLE_ABIGAIL_VERSION_CHECK=$enableval], 46 [ENABLE_ABIGAIL_VERSION_CHECK=yes]) 47 48 if test x$with_abigail != x -a x$with_abigail != xno; then 49 abigailinc="-I$with_abigail/include/libabigail" 50 abigaillibs="-L$with_abigail/lib" 51 found_abigail_lib=yes 52 found_abigail_inc=yes 53 fi 54 55 if test x$with_abigail_include != x -a x$with_abigail != xno; then 56 abigailinc="-I$with_abigail_include" 57 found_abigail_inc=yes 58 fi 59 60 if test x$with_abigail_lib != x -a x$with_abigail != xno; then 61 abigaillibs="-L$with_abigail_lib" 62 found_abigail_lib=yes 63 fi 64 65 if test x$abigaillibs = x; then 66 AC_CHECK_LIB(abigail, abigail_get_library_version, 67 [found_abigail_lib=yes], [], []) 68 fi 69 70 if test x$abigailinc = x; then 71 AC_LANG_PUSH(C++) 72 AC_CHECK_HEADER([libabigail/abg-version.h], 73 [found_abigail_inc=yes], [], []) 74 AC_LANG_POP(C++) 75 fi 76 77 if test x$found_abigail_lib = xyes -a x$found_abigail_inc = xyes; then 78 HAVE_LIBABIGAIL=yes 79 else 80 HAVE_LIBABIGAIL=no 81 fi 82 83 #Test whether libabigail is in the gcc source tree. 84 if test x$HAVE_LIBABIGAIL != xyes; then 85 if test -d $srcdir/libabigail -a -f $srcdir/gcc/gcc.c; then 86 libpath='$$r/$(HOST_SUBDIR)/libabigail/src/'"${lt_cv_objdir}" 87 abigaillibs="-L$libpath ${abigaillibs}" 88 abigailinc='-I${srcdir}/libabigail/include '"${abigailinc}" 89 found_abigail_lib=yes 90 found_abigail_inc=yes 91 HAVE_LIBABIGAIL=yes 92 AC_MSG_WARN([using in-tree libabigail, disabling version check]); 93 ENABLE_ABIGAIL_VERSION_CHECK=no 94 fi 95 fi 96 97 if test x$found_abigail_lib = xyes; then 98 abigaillibs="$abigaillibs -Wl,-Bstatic -labigail -Wl,-Bdynamic" 99 fi 100 101] 102) 103 104# IF_ABIGAIL_PRESENT(ACTION-IF-PRESENT) 105AC_DEFUN([IF_ABIGAIL_PRESENT], 106[ 107 AC_REQUIRE([ABIGAIL_INIT]) 108 109 if test x$HAVE_LIBABIGAIL = xyes; then 110 $1 111 fi 112] 113) 114 115# IF_ABIGAIL_NOT_PRESENT(ACTION-IF-NOT-PRESENT) 116AC_DEFUN([IF_ABIGAIL_NOT_PRESENT], 117[ 118 AC_REQUIRE([ABIGAIL_INIT]) 119 if test x$HAVE_LIBABIGAIL != xyes; then 120 $1 121 fi 122] 123) 124 125# ABIGAIL_CHECK_VERSION(MAJOR, MINOR) 126# 127# Test the whether the found major and minor version numbers of the 128# found abigail library is compatible with the MAJOR.MINOR version 129# number given in argument. The result of the test ('yes' or 'no') is 130# put in the variable has_right_abigail_version. 131AC_DEFUN([ABIGAIL_CHECK_VERSION], 132[ 133 AC_REQUIRE([ABIGAIL_INIT]) 134 135 if test x$ENABLE_ABIGAIL_VERSION_CHECK = xyes; then 136 _abigail_saved_CXXFLAGS=$CXXFLAGLS 137 _abigail_saved_LDFLAGS=$LDFLAGS 138 139 CXXFLAGS="$abigailinc" 140 LDFLAGS="$abigaillibs" 141 142 AC_MSG_CHECKING([for version $1.$2 of libabigail]) 143 AC_LANG_PUSH(C++) 144 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include "abg-version.h"], 145 [#if ABIGAIL_VERSION_MAJOR != $1 || ABIGAIL_VERSION_MINOR < $2 146 choke here 147 #endif 148 ]) 149 ], 150 has_right_abigail_version=yes, 151 has_right_abigail_version=no) 152 AC_LANG_POP(C++) 153 AC_MSG_RESULT([$has_right_abigail_version]) 154 155 CXXFLAGS=$_abigail_saved_CXXFLAGS 156 LDFLAGS=$_abigail_saved_LDFLAGS 157 else 158 # Version checking was disabled, so assume we have the right 159 # version of libabigail. 160 has_right_abigail_version=yes 161 fi 162] 163) 164