1dnl Copyright (C) 2004-2020 by Carnegie Mellon University. 2dnl 3dnl @OPENSOURCE_LICENSE_START@ 4dnl See license information in ../LICENSE.txt 5dnl @OPENSOURCE_LICENSE_END@ 6 7dnl RCSIDENT("$SiLK: ax_pkg_check_libipa.m4 ef14e54179be 2020-04-14 21:57:45Z mthomas $") 8 9 10# --------------------------------------------------------------------------- 11# AX_PKG_CHECK_LIBIPA 12# 13# Determine how to use the IPA library. Function accepts two 14# arguments (requires 1): minimum allowed version and too-new 15# version. 16# 17# Output variables: LIBIPA_CFLAGS, LIBIPA_LDFLAGS 18# Output definition: ENABLE_IPA 19# 20AC_DEFUN([AX_PKG_CHECK_LIBIPA],[ 21 AC_SUBST([LIBIPA_CFLAGS]) 22 AC_SUBST([LIBIPA_LDFLAGS]) 23 24 # Either one or two arguments; first is minimum version required; 25 # if a second is present, it represents a version that is "too 26 # new" 27 libipa_required_version="$1" 28 if test "x$2" = "x" 29 then 30 version_check="libipa >= $1" 31 else 32 version_check="libipa >= $1 libipa < $2" 33 fi 34 35 ENABLE_IPA=0 36 37 # whether to exit with an error when building without libipa. 38 # this is set to true when --with-libipa is given and its argument 39 # is not "no" 40 sk_withval_used=false 41 42 # The configure switch 43 sk_pkg_config="" 44 AC_ARG_WITH([libipa],[AS_HELP_STRING([--with-libipa=DIR], 45 [specify location of the IPA IP-address annotation package; find "libipa.pc" in the directory DIR/ (i.e., prepend DIR to PKG_CONFIG_PATH). The last component of DIR is likely "pkgconfig" [auto]])[]dnl 46 ],[ 47 case "x${withval}" in 48 xno) sk_pkg_config="${withval}" ;; 49 xyes) sk_withval_used=true ;; 50 *) sk_pkg_config="${withval}" sk_withval_used=true ;; 51 esac 52 ]) 53 54 if test "x${sk_pkg_config}" = "xno" 55 then 56 AC_MSG_NOTICE([Building without IPA support at user request]) 57 else 58 if test "x${sk_pkg_config}" != "x" 59 then 60 # prepend the argument to PKG_CONFIG_PATH, and warn when 61 # that argument does not end with "/pkgconfig" 62 sk_save_PKG_CONFIG_PATH="${PKG_CONFIG_PATH}" 63 PKG_CONFIG_PATH="${sk_pkg_config}:${PKG_CONFIG_PATH}" 64 export PKG_CONFIG_PATH 65 66 if expr "x${sk_pkg_config}" : '.*/pkgconfig$' > /dev/null 67 then 68 : 69 else 70 AC_MSG_WARN([Argument to --with-libipa should probably end with '/pkgconfig']) 71 fi 72 fi 73 74 # use pkg-config to check for libipa existence 75 echo "${as_me}:${LINENO}: Using PKG_CONFIG_PATH='${PKG_CONFIG_PATH}'" >&AS_MESSAGE_LOG_FD 76 PKG_CHECK_MODULES([LIBIPA], 77 [${version_check}], 78 [ENABLE_IPA=1], [ENABLE_IPA=0]) 79 if test "x${ENABLE_IPA}" = "x0" 80 then 81 AC_MSG_NOTICE([Building without IPA support: pkg-config failed to find libipa]) 82 if ${sk_withval_used} 83 then 84 AC_MSG_ERROR([unable to use IPA; fix or remove --with-libipa switch]) 85 fi 86 else 87 # verify that libipa has any packages it depends on 88 sk_pkg_modversion=`${PKG_CONFIG} --modversion libipa 2>/dev/null` 89 if test "x${sk_pkg_modversion}" = "x" 90 then 91 # PKG_CHECK_MODULES() says package is available, but 92 # pkg-config does not find it; assume the user set the 93 # LIBIPA_LIBS/LIBIPA_CFLAGS variables 94 sk_pkg_modversion=unknown 95 else 96 AC_MSG_CHECKING([presence of libipa-${sk_pkg_modversion} dependencies]) 97 echo "${as_me}:${LINENO}: \$PKG_CONFIG --libs libipa >/dev/null 2>&AS_MESSAGE_LOG_FD" >&AS_MESSAGE_LOG_FD 98 (${PKG_CONFIG} --libs libipa) >/dev/null 2>&AS_MESSAGE_LOG_FD 99 sk_pkg_status=$? 100 echo "${as_me}:${LINENO}: \$? = ${sk_pkg_status}" >&AS_MESSAGE_LOG_FD 101 102 if test 0 -eq ${sk_pkg_status} 103 then 104 AC_MSG_RESULT([yes]) 105 else 106 AC_MSG_RESULT([no]) 107 AC_MSG_NOTICE([Building without IPA support: pkg-config failed to find dependencies of libipa. Details in config.log]) 108 if ${sk_withval_used} 109 then 110 AC_MSG_ERROR([unable to use IPA; fix or remove --with-libipa switch]) 111 fi 112 ENABLE_IPA=0 113 fi 114 fi 115 fi 116 117 # Restore the PKG_CONFIG_PATH to the saved value 118 if test "x${sk_pkg_config}" != "x" 119 then 120 PKG_CONFIG_PATH="${sk_save_PKG_CONFIG_PATH}" 121 export PKG_CONFIG_PATH 122 fi 123 fi 124 125 # compile program that uses libipa 126 if test "x${ENABLE_IPA}" = "x1" 127 then 128 # Cache current values 129 sk_save_LDFLAGS="${LDFLAGS}" 130 sk_save_LIBS="${LIBS}" 131 sk_save_CFLAGS="${CFLAGS}" 132 sk_save_CPPFLAGS="${CPPFLAGS}" 133 134 LIBIPA_LDFLAGS="${LIBIPA_LIBS}" 135 LIBS="${LIBIPA_LDFLAGS} ${LIBS}" 136 137 CPPFLAGS="${LIBIPA_CFLAGS} ${CPPFLAGS}" 138 139 AC_MSG_CHECKING([usability of libipa-${sk_pkg_modversion} library and headers]) 140 AC_LINK_IFELSE( 141 [AC_LANG_PROGRAM([ 142#include <ipa/ipa.h> 143 ],[ 144IPAContext *ctx; 145 ])],[ENABLE_IPA=1],[ENABLE_IPA=0]) 146 147 if test "x${ENABLE_IPA}" = "x1" 148 then 149 AC_MSG_RESULT([yes]) 150 else 151 AC_MSG_RESULT([no]) 152 AC_MSG_NOTICE([Building without IPA support: pkg-config found libipa-${sk_pkg_modversion} but failed to compile a program that uses it. Details in config.log]) 153 if ${sk_withval_used} 154 then 155 AC_MSG_ERROR([unable to use IPA; fix or remove --with-libipa switch]) 156 fi 157 fi 158 159 # Restore cached values 160 LDFLAGS="${sk_save_LDFLAGS}" 161 LIBS="${sk_save_LIBS}" 162 CFLAGS="${sk_save_CFLAGS}" 163 CPPFLAGS="${sk_save_CPPFLAGS}" 164 fi 165 166 if test "x${ENABLE_IPA}" = "x0" 167 then 168 LIBIPA_LDFLAGS= 169 LIBIPA_CFLAGS= 170 fi 171 172 AM_CONDITIONAL(HAVE_IPA, [test "x${ENABLE_IPA}" = "x1"]) 173 174 AC_DEFINE_UNQUOTED([ENABLE_IPA], [${ENABLE_IPA}], 175 [Define to 1 to build with support for IPA. Define to 0 otherwise. 176 Requires the libipa library and the <ipa/ipa.h> header file.]) 177 178])# AX_PKG_CHECK_LIBIPA 179 180dnl Local Variables: 181dnl mode:autoconf 182dnl indent-tabs-mode:nil 183dnl End: 184