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