1*a3cefe7fSPierre Pronchery# pkg.m4 - Macros to locate and use pkg-config. -*- Autoconf -*- 2*a3cefe7fSPierre Pronchery# serial 13 (pkgconf) 3*a3cefe7fSPierre Pronchery 4*a3cefe7fSPierre Proncherydnl Copyright © 2004 Scott James Remnant <scott@netsplit.com>. 5*a3cefe7fSPierre Proncherydnl Copyright © 2012-2015 Dan Nicholson <dbn.lists@gmail.com> 6*a3cefe7fSPierre Proncherydnl 7*a3cefe7fSPierre Proncherydnl This program is free software; you can redistribute it and/or modify 8*a3cefe7fSPierre Proncherydnl it under the terms of the GNU General Public License as published by 9*a3cefe7fSPierre Proncherydnl the Free Software Foundation; either version 2 of the License, or 10*a3cefe7fSPierre Proncherydnl (at your option) any later version. 11*a3cefe7fSPierre Proncherydnl 12*a3cefe7fSPierre Proncherydnl This program is distributed in the hope that it will be useful, but 13*a3cefe7fSPierre Proncherydnl WITHOUT ANY WARRANTY; without even the implied warranty of 14*a3cefe7fSPierre Proncherydnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15*a3cefe7fSPierre Proncherydnl General Public License for more details. 16*a3cefe7fSPierre Proncherydnl 17*a3cefe7fSPierre Proncherydnl You should have received a copy of the GNU General Public License 18*a3cefe7fSPierre Proncherydnl along with this program; if not, see <https://www.gnu.org/licenses/>. 19*a3cefe7fSPierre Proncherydnl 20*a3cefe7fSPierre Proncherydnl As a special exception to the GNU General Public License, if you 21*a3cefe7fSPierre Proncherydnl distribute this file as part of a program that contains a 22*a3cefe7fSPierre Proncherydnl configuration script generated by Autoconf, you may include it under 23*a3cefe7fSPierre Proncherydnl the same distribution terms that you use for the rest of that 24*a3cefe7fSPierre Proncherydnl program. 25*a3cefe7fSPierre Pronchery 26*a3cefe7fSPierre Proncherydnl PKG_PREREQ(MIN-VERSION) 27*a3cefe7fSPierre Proncherydnl ----------------------- 28*a3cefe7fSPierre Proncherydnl Since: 0.29 29*a3cefe7fSPierre Proncherydnl 30*a3cefe7fSPierre Proncherydnl Verify that the version of the pkg-config macros are at least 31*a3cefe7fSPierre Proncherydnl MIN-VERSION. Unlike PKG_PROG_PKG_CONFIG, which checks the user's 32*a3cefe7fSPierre Proncherydnl installed version of pkg-config, this checks the developer's version 33*a3cefe7fSPierre Proncherydnl of pkg.m4 when generating configure. 34*a3cefe7fSPierre Proncherydnl 35*a3cefe7fSPierre Proncherydnl To ensure that this macro is defined, also add: 36*a3cefe7fSPierre Proncherydnl m4_ifndef([PKG_PREREQ], 37*a3cefe7fSPierre Proncherydnl [m4_fatal([must install pkg-config 0.29 or later before running autoconf/autogen])]) 38*a3cefe7fSPierre Proncherydnl 39*a3cefe7fSPierre Proncherydnl See the "Since" comment for each macro you use to see what version 40*a3cefe7fSPierre Proncherydnl of the macros you require. 41*a3cefe7fSPierre Proncherym4_defun([PKG_PREREQ], 42*a3cefe7fSPierre Pronchery[m4_define([PKG_MACROS_VERSION], [0.29.2]) 43*a3cefe7fSPierre Proncherym4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1, 44*a3cefe7fSPierre Pronchery [m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])]) 45*a3cefe7fSPierre Pronchery])dnl PKG_PREREQ 46*a3cefe7fSPierre Pronchery 47*a3cefe7fSPierre Proncherydnl PKG_PROG_PKG_CONFIG([MIN-VERSION], [ACTION-IF-NOT-FOUND]) 48*a3cefe7fSPierre Proncherydnl --------------------------------------------------------- 49*a3cefe7fSPierre Proncherydnl Since: 0.16 50*a3cefe7fSPierre Proncherydnl 51*a3cefe7fSPierre Proncherydnl Search for the pkg-config tool and set the PKG_CONFIG variable to 52*a3cefe7fSPierre Proncherydnl first found in the path. Checks that the version of pkg-config found 53*a3cefe7fSPierre Proncherydnl is at least MIN-VERSION. If MIN-VERSION is not specified, 0.9.0 is 54*a3cefe7fSPierre Proncherydnl used since that's the first version where most current features of 55*a3cefe7fSPierre Proncherydnl pkg-config existed. 56*a3cefe7fSPierre Proncherydnl 57*a3cefe7fSPierre Proncherydnl If pkg-config is not found or older than specified, it will result 58*a3cefe7fSPierre Proncherydnl in an empty PKG_CONFIG variable. To avoid widespread issues with 59*a3cefe7fSPierre Proncherydnl scripts not checking it, ACTION-IF-NOT-FOUND defaults to aborting. 60*a3cefe7fSPierre Proncherydnl You can specify [PKG_CONFIG=false] as an action instead, which would 61*a3cefe7fSPierre Proncherydnl result in pkg-config tests failing, but no bogus error messages. 62*a3cefe7fSPierre ProncheryAC_DEFUN([PKG_PROG_PKG_CONFIG], 63*a3cefe7fSPierre Pronchery[m4_pattern_forbid([^_?PKG_[A-Z_]+$]) 64*a3cefe7fSPierre Proncherym4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$]) 65*a3cefe7fSPierre Proncherym4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$]) 66*a3cefe7fSPierre ProncheryAC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility]) 67*a3cefe7fSPierre ProncheryAC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path]) 68*a3cefe7fSPierre ProncheryAC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path]) 69*a3cefe7fSPierre Pronchery 70*a3cefe7fSPierre Proncheryif test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then 71*a3cefe7fSPierre Pronchery AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) 72*a3cefe7fSPierre Proncheryfi 73*a3cefe7fSPierre Proncheryif test -n "$PKG_CONFIG"; then 74*a3cefe7fSPierre Pronchery _pkg_min_version=m4_default([$1], [0.9.0]) 75*a3cefe7fSPierre Pronchery AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) 76*a3cefe7fSPierre Pronchery if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then 77*a3cefe7fSPierre Pronchery AC_MSG_RESULT([yes]) 78*a3cefe7fSPierre Pronchery else 79*a3cefe7fSPierre Pronchery AC_MSG_RESULT([no]) 80*a3cefe7fSPierre Pronchery PKG_CONFIG="" 81*a3cefe7fSPierre Pronchery fi 82*a3cefe7fSPierre Proncheryfi 83*a3cefe7fSPierre Proncheryif test -z "$PKG_CONFIG"; then 84*a3cefe7fSPierre Pronchery m4_default([$2], [AC_MSG_ERROR([pkg-config not found])]) 85*a3cefe7fSPierre Proncheryfi[]dnl 86*a3cefe7fSPierre Pronchery])dnl PKG_PROG_PKG_CONFIG 87*a3cefe7fSPierre Pronchery 88*a3cefe7fSPierre Proncherydnl PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) 89*a3cefe7fSPierre Proncherydnl ------------------------------------------------------------------- 90*a3cefe7fSPierre Proncherydnl Since: 0.18 91*a3cefe7fSPierre Proncherydnl 92*a3cefe7fSPierre Proncherydnl Check to see whether a particular set of modules exists. Similar to 93*a3cefe7fSPierre Proncherydnl PKG_CHECK_MODULES(), but does not set variables or print errors. 94*a3cefe7fSPierre Proncherydnl 95*a3cefe7fSPierre Proncherydnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) 96*a3cefe7fSPierre Proncherydnl only at the first occurrence in configure.ac, so if the first place 97*a3cefe7fSPierre Proncherydnl it's called might be skipped (such as if it is within an "if", you 98*a3cefe7fSPierre Proncherydnl have to call PKG_CHECK_EXISTS manually 99*a3cefe7fSPierre ProncheryAC_DEFUN([PKG_CHECK_EXISTS], 100*a3cefe7fSPierre Pronchery[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl 101*a3cefe7fSPierre Proncheryif test -n "$PKG_CONFIG" && \ 102*a3cefe7fSPierre Pronchery AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then 103*a3cefe7fSPierre Pronchery m4_default([$2], [:]) 104*a3cefe7fSPierre Proncherym4_ifvaln([$3], [else 105*a3cefe7fSPierre Pronchery $3])dnl 106*a3cefe7fSPierre Proncheryfi]) 107*a3cefe7fSPierre Pronchery 108*a3cefe7fSPierre Proncherydnl _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) 109*a3cefe7fSPierre Proncherydnl --------------------------------------------- 110*a3cefe7fSPierre Proncherydnl Internal wrapper calling pkg-config via PKG_CONFIG and setting 111*a3cefe7fSPierre Proncherydnl pkg_failed based on the result. 112*a3cefe7fSPierre Proncherym4_define([_PKG_CONFIG], 113*a3cefe7fSPierre Pronchery[if test -n "$$1"; then 114*a3cefe7fSPierre Pronchery pkg_cv_[]$1="$$1" 115*a3cefe7fSPierre Pronchery elif test -n "$PKG_CONFIG"; then 116*a3cefe7fSPierre Pronchery PKG_CHECK_EXISTS([$3], 117*a3cefe7fSPierre Pronchery [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null` 118*a3cefe7fSPierre Pronchery test "x$?" != "x0" && pkg_failed=yes ], 119*a3cefe7fSPierre Pronchery [pkg_failed=yes]) 120*a3cefe7fSPierre Pronchery else 121*a3cefe7fSPierre Pronchery pkg_failed=untried 122*a3cefe7fSPierre Proncheryfi[]dnl 123*a3cefe7fSPierre Pronchery])dnl _PKG_CONFIG 124*a3cefe7fSPierre Pronchery 125*a3cefe7fSPierre Proncherydnl _PKG_SHORT_ERRORS_SUPPORTED 126*a3cefe7fSPierre Proncherydnl --------------------------- 127*a3cefe7fSPierre Proncherydnl Internal check to see if pkg-config supports short errors. 128*a3cefe7fSPierre ProncheryAC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], 129*a3cefe7fSPierre Pronchery[AC_REQUIRE([PKG_PROG_PKG_CONFIG]) 130*a3cefe7fSPierre Proncheryif $PKG_CONFIG --atleast-pkgconfig-version 0.20; then 131*a3cefe7fSPierre Pronchery _pkg_short_errors_supported=yes 132*a3cefe7fSPierre Proncheryelse 133*a3cefe7fSPierre Pronchery _pkg_short_errors_supported=no 134*a3cefe7fSPierre Proncheryfi[]dnl 135*a3cefe7fSPierre Pronchery])dnl _PKG_SHORT_ERRORS_SUPPORTED 136*a3cefe7fSPierre Pronchery 137*a3cefe7fSPierre Pronchery 138*a3cefe7fSPierre Proncherydnl PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], 139*a3cefe7fSPierre Proncherydnl [ACTION-IF-NOT-FOUND]) 140*a3cefe7fSPierre Proncherydnl -------------------------------------------------------------- 141*a3cefe7fSPierre Proncherydnl Since: 0.4.0 142*a3cefe7fSPierre Proncherydnl 143*a3cefe7fSPierre Proncherydnl Note that if there is a possibility the first call to 144*a3cefe7fSPierre Proncherydnl PKG_CHECK_MODULES might not happen, you should be sure to include an 145*a3cefe7fSPierre Proncherydnl explicit call to PKG_PROG_PKG_CONFIG in your configure.ac 146*a3cefe7fSPierre ProncheryAC_DEFUN([PKG_CHECK_MODULES], 147*a3cefe7fSPierre Pronchery[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl 148*a3cefe7fSPierre ProncheryAC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl 149*a3cefe7fSPierre ProncheryAC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl 150*a3cefe7fSPierre Pronchery 151*a3cefe7fSPierre Proncherypkg_failed=no 152*a3cefe7fSPierre ProncheryAC_MSG_CHECKING([for $2]) 153*a3cefe7fSPierre Pronchery 154*a3cefe7fSPierre Pronchery_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) 155*a3cefe7fSPierre Pronchery_PKG_CONFIG([$1][_LIBS], [libs], [$2]) 156*a3cefe7fSPierre Pronchery 157*a3cefe7fSPierre Proncherym4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS 158*a3cefe7fSPierre Proncheryand $1[]_LIBS to avoid the need to call pkg-config. 159*a3cefe7fSPierre ProncherySee the pkg-config man page for more details.]) 160*a3cefe7fSPierre Pronchery 161*a3cefe7fSPierre Proncheryif test $pkg_failed = yes; then 162*a3cefe7fSPierre Pronchery AC_MSG_RESULT([no]) 163*a3cefe7fSPierre Pronchery _PKG_SHORT_ERRORS_SUPPORTED 164*a3cefe7fSPierre Pronchery if test $_pkg_short_errors_supported = yes; then 165*a3cefe7fSPierre Pronchery $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1` 166*a3cefe7fSPierre Pronchery else 167*a3cefe7fSPierre Pronchery $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1` 168*a3cefe7fSPierre Pronchery fi 169*a3cefe7fSPierre Pronchery # Put the nasty error message in config.log where it belongs 170*a3cefe7fSPierre Pronchery echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD 171*a3cefe7fSPierre Pronchery 172*a3cefe7fSPierre Pronchery m4_default([$4], [AC_MSG_ERROR( 173*a3cefe7fSPierre Pronchery[Package requirements ($2) were not met: 174*a3cefe7fSPierre Pronchery 175*a3cefe7fSPierre Pronchery$$1_PKG_ERRORS 176*a3cefe7fSPierre Pronchery 177*a3cefe7fSPierre ProncheryConsider adjusting the PKG_CONFIG_PATH environment variable if you 178*a3cefe7fSPierre Proncheryinstalled software in a non-standard prefix. 179*a3cefe7fSPierre Pronchery 180*a3cefe7fSPierre Pronchery_PKG_TEXT])[]dnl 181*a3cefe7fSPierre Pronchery ]) 182*a3cefe7fSPierre Proncheryelif test $pkg_failed = untried; then 183*a3cefe7fSPierre Pronchery AC_MSG_RESULT([no]) 184*a3cefe7fSPierre Pronchery m4_default([$4], [AC_MSG_FAILURE( 185*a3cefe7fSPierre Pronchery[The pkg-config script could not be found or is too old. Make sure it 186*a3cefe7fSPierre Proncheryis in your PATH or set the PKG_CONFIG environment variable to the full 187*a3cefe7fSPierre Proncherypath to pkg-config. 188*a3cefe7fSPierre Pronchery 189*a3cefe7fSPierre Pronchery_PKG_TEXT 190*a3cefe7fSPierre Pronchery 191*a3cefe7fSPierre ProncheryTo get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl 192*a3cefe7fSPierre Pronchery ]) 193*a3cefe7fSPierre Proncheryelse 194*a3cefe7fSPierre Pronchery $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS 195*a3cefe7fSPierre Pronchery $1[]_LIBS=$pkg_cv_[]$1[]_LIBS 196*a3cefe7fSPierre Pronchery AC_MSG_RESULT([yes]) 197*a3cefe7fSPierre Pronchery $3 198*a3cefe7fSPierre Proncheryfi[]dnl 199*a3cefe7fSPierre Pronchery])dnl PKG_CHECK_MODULES 200*a3cefe7fSPierre Pronchery 201*a3cefe7fSPierre Pronchery 202*a3cefe7fSPierre Proncherydnl PKG_CHECK_MODULES_STATIC(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], 203*a3cefe7fSPierre Proncherydnl [ACTION-IF-NOT-FOUND]) 204*a3cefe7fSPierre Proncherydnl --------------------------------------------------------------------- 205*a3cefe7fSPierre Proncherydnl Since: 0.29 206*a3cefe7fSPierre Proncherydnl 207*a3cefe7fSPierre Proncherydnl Checks for existence of MODULES and gathers its build flags with 208*a3cefe7fSPierre Proncherydnl static libraries enabled. Sets VARIABLE-PREFIX_CFLAGS from --cflags 209*a3cefe7fSPierre Proncherydnl and VARIABLE-PREFIX_LIBS from --libs. 210*a3cefe7fSPierre Proncherydnl 211*a3cefe7fSPierre Proncherydnl Note that if there is a possibility the first call to 212*a3cefe7fSPierre Proncherydnl PKG_CHECK_MODULES_STATIC might not happen, you should be sure to 213*a3cefe7fSPierre Proncherydnl include an explicit call to PKG_PROG_PKG_CONFIG in your 214*a3cefe7fSPierre Proncherydnl configure.ac. 215*a3cefe7fSPierre ProncheryAC_DEFUN([PKG_CHECK_MODULES_STATIC], 216*a3cefe7fSPierre Pronchery[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl 217*a3cefe7fSPierre Pronchery_save_PKG_CONFIG=$PKG_CONFIG 218*a3cefe7fSPierre ProncheryPKG_CONFIG="$PKG_CONFIG --static" 219*a3cefe7fSPierre ProncheryPKG_CHECK_MODULES($@) 220*a3cefe7fSPierre ProncheryPKG_CONFIG=$_save_PKG_CONFIG[]dnl 221*a3cefe7fSPierre Pronchery])dnl PKG_CHECK_MODULES_STATIC 222*a3cefe7fSPierre Pronchery 223*a3cefe7fSPierre Pronchery 224*a3cefe7fSPierre Proncherydnl PKG_INSTALLDIR([DIRECTORY]) 225*a3cefe7fSPierre Proncherydnl ------------------------- 226*a3cefe7fSPierre Proncherydnl Since: 0.27 227*a3cefe7fSPierre Proncherydnl 228*a3cefe7fSPierre Proncherydnl Substitutes the variable pkgconfigdir as the location where a module 229*a3cefe7fSPierre Proncherydnl should install pkg-config .pc files. By default the directory is 230*a3cefe7fSPierre Proncherydnl $libdir/pkgconfig, but the default can be changed by passing 231*a3cefe7fSPierre Proncherydnl DIRECTORY. The user can override through the --with-pkgconfigdir 232*a3cefe7fSPierre Proncherydnl parameter. 233*a3cefe7fSPierre ProncheryAC_DEFUN([PKG_INSTALLDIR], 234*a3cefe7fSPierre Pronchery[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])]) 235*a3cefe7fSPierre Proncherym4_pushdef([pkg_description], 236*a3cefe7fSPierre Pronchery [pkg-config installation directory @<:@]pkg_default[@:>@]) 237*a3cefe7fSPierre ProncheryAC_ARG_WITH([pkgconfigdir], 238*a3cefe7fSPierre Pronchery [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],, 239*a3cefe7fSPierre Pronchery [with_pkgconfigdir=]pkg_default) 240*a3cefe7fSPierre ProncheryAC_SUBST([pkgconfigdir], [$with_pkgconfigdir]) 241*a3cefe7fSPierre Proncherym4_popdef([pkg_default]) 242*a3cefe7fSPierre Proncherym4_popdef([pkg_description]) 243*a3cefe7fSPierre Pronchery])dnl PKG_INSTALLDIR 244*a3cefe7fSPierre Pronchery 245*a3cefe7fSPierre Pronchery 246*a3cefe7fSPierre Proncherydnl PKG_NOARCH_INSTALLDIR([DIRECTORY]) 247*a3cefe7fSPierre Proncherydnl -------------------------------- 248*a3cefe7fSPierre Proncherydnl Since: 0.27 249*a3cefe7fSPierre Proncherydnl 250*a3cefe7fSPierre Proncherydnl Substitutes the variable noarch_pkgconfigdir as the location where a 251*a3cefe7fSPierre Proncherydnl module should install arch-independent pkg-config .pc files. By 252*a3cefe7fSPierre Proncherydnl default the directory is $datadir/pkgconfig, but the default can be 253*a3cefe7fSPierre Proncherydnl changed by passing DIRECTORY. The user can override through the 254*a3cefe7fSPierre Proncherydnl --with-noarch-pkgconfigdir parameter. 255*a3cefe7fSPierre ProncheryAC_DEFUN([PKG_NOARCH_INSTALLDIR], 256*a3cefe7fSPierre Pronchery[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])]) 257*a3cefe7fSPierre Proncherym4_pushdef([pkg_description], 258*a3cefe7fSPierre Pronchery [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@]) 259*a3cefe7fSPierre ProncheryAC_ARG_WITH([noarch-pkgconfigdir], 260*a3cefe7fSPierre Pronchery [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],, 261*a3cefe7fSPierre Pronchery [with_noarch_pkgconfigdir=]pkg_default) 262*a3cefe7fSPierre ProncheryAC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir]) 263*a3cefe7fSPierre Proncherym4_popdef([pkg_default]) 264*a3cefe7fSPierre Proncherym4_popdef([pkg_description]) 265*a3cefe7fSPierre Pronchery])dnl PKG_NOARCH_INSTALLDIR 266*a3cefe7fSPierre Pronchery 267*a3cefe7fSPierre Pronchery 268*a3cefe7fSPierre Proncherydnl PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE, 269*a3cefe7fSPierre Proncherydnl [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) 270*a3cefe7fSPierre Proncherydnl ------------------------------------------- 271*a3cefe7fSPierre Proncherydnl Since: 0.28 272*a3cefe7fSPierre Proncherydnl 273*a3cefe7fSPierre Proncherydnl Retrieves the value of the pkg-config variable for the given module. 274*a3cefe7fSPierre ProncheryAC_DEFUN([PKG_CHECK_VAR], 275*a3cefe7fSPierre Pronchery[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl 276*a3cefe7fSPierre ProncheryAC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl 277*a3cefe7fSPierre Pronchery 278*a3cefe7fSPierre Pronchery_PKG_CONFIG([$1], [variable="][$3]["], [$2]) 279*a3cefe7fSPierre ProncheryAS_VAR_COPY([$1], [pkg_cv_][$1]) 280*a3cefe7fSPierre Pronchery 281*a3cefe7fSPierre ProncheryAS_VAR_IF([$1], [""], [$5], [$4])dnl 282*a3cefe7fSPierre Pronchery])dnl PKG_CHECK_VAR 283*a3cefe7fSPierre Pronchery 284*a3cefe7fSPierre Proncherydnl PKG_WITH_MODULES(VARIABLE-PREFIX, MODULES, 285*a3cefe7fSPierre Proncherydnl [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND], 286*a3cefe7fSPierre Proncherydnl [DESCRIPTION], [DEFAULT]) 287*a3cefe7fSPierre Proncherydnl ------------------------------------------ 288*a3cefe7fSPierre Proncherydnl 289*a3cefe7fSPierre Proncherydnl Prepare a "--with-" configure option using the lowercase 290*a3cefe7fSPierre Proncherydnl [VARIABLE-PREFIX] name, merging the behaviour of AC_ARG_WITH and 291*a3cefe7fSPierre Proncherydnl PKG_CHECK_MODULES in a single macro. 292*a3cefe7fSPierre ProncheryAC_DEFUN([PKG_WITH_MODULES], 293*a3cefe7fSPierre Pronchery[ 294*a3cefe7fSPierre Proncherym4_pushdef([with_arg], m4_tolower([$1])) 295*a3cefe7fSPierre Pronchery 296*a3cefe7fSPierre Proncherym4_pushdef([description], 297*a3cefe7fSPierre Pronchery [m4_default([$5], [build with ]with_arg[ support])]) 298*a3cefe7fSPierre Pronchery 299*a3cefe7fSPierre Proncherym4_pushdef([def_arg], [m4_default([$6], [auto])]) 300*a3cefe7fSPierre Proncherym4_pushdef([def_action_if_found], [AS_TR_SH([with_]with_arg)=yes]) 301*a3cefe7fSPierre Proncherym4_pushdef([def_action_if_not_found], [AS_TR_SH([with_]with_arg)=no]) 302*a3cefe7fSPierre Pronchery 303*a3cefe7fSPierre Proncherym4_case(def_arg, 304*a3cefe7fSPierre Pronchery [yes],[m4_pushdef([with_without], [--without-]with_arg)], 305*a3cefe7fSPierre Pronchery [m4_pushdef([with_without],[--with-]with_arg)]) 306*a3cefe7fSPierre Pronchery 307*a3cefe7fSPierre ProncheryAC_ARG_WITH(with_arg, 308*a3cefe7fSPierre Pronchery AS_HELP_STRING(with_without, description[ @<:@default=]def_arg[@:>@]),, 309*a3cefe7fSPierre Pronchery [AS_TR_SH([with_]with_arg)=def_arg]) 310*a3cefe7fSPierre Pronchery 311*a3cefe7fSPierre ProncheryAS_CASE([$AS_TR_SH([with_]with_arg)], 312*a3cefe7fSPierre Pronchery [yes],[PKG_CHECK_MODULES([$1],[$2],$3,$4)], 313*a3cefe7fSPierre Pronchery [auto],[PKG_CHECK_MODULES([$1],[$2], 314*a3cefe7fSPierre Pronchery [m4_n([def_action_if_found]) $3], 315*a3cefe7fSPierre Pronchery [m4_n([def_action_if_not_found]) $4])]) 316*a3cefe7fSPierre Pronchery 317*a3cefe7fSPierre Proncherym4_popdef([with_arg]) 318*a3cefe7fSPierre Proncherym4_popdef([description]) 319*a3cefe7fSPierre Proncherym4_popdef([def_arg]) 320*a3cefe7fSPierre Pronchery 321*a3cefe7fSPierre Pronchery])dnl PKG_WITH_MODULES 322*a3cefe7fSPierre Pronchery 323*a3cefe7fSPierre Proncherydnl PKG_HAVE_WITH_MODULES(VARIABLE-PREFIX, MODULES, 324*a3cefe7fSPierre Proncherydnl [DESCRIPTION], [DEFAULT]) 325*a3cefe7fSPierre Proncherydnl ----------------------------------------------- 326*a3cefe7fSPierre Proncherydnl 327*a3cefe7fSPierre Proncherydnl Convenience macro to trigger AM_CONDITIONAL after PKG_WITH_MODULES 328*a3cefe7fSPierre Proncherydnl check._[VARIABLE-PREFIX] is exported as make variable. 329*a3cefe7fSPierre ProncheryAC_DEFUN([PKG_HAVE_WITH_MODULES], 330*a3cefe7fSPierre Pronchery[ 331*a3cefe7fSPierre ProncheryPKG_WITH_MODULES([$1],[$2],,,[$3],[$4]) 332*a3cefe7fSPierre Pronchery 333*a3cefe7fSPierre ProncheryAM_CONDITIONAL([HAVE_][$1], 334*a3cefe7fSPierre Pronchery [test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"]) 335*a3cefe7fSPierre Pronchery])dnl PKG_HAVE_WITH_MODULES 336*a3cefe7fSPierre Pronchery 337*a3cefe7fSPierre Proncherydnl PKG_HAVE_DEFINE_WITH_MODULES(VARIABLE-PREFIX, MODULES, 338*a3cefe7fSPierre Proncherydnl [DESCRIPTION], [DEFAULT]) 339*a3cefe7fSPierre Proncherydnl ------------------------------------------------------ 340*a3cefe7fSPierre Proncherydnl 341*a3cefe7fSPierre Proncherydnl Convenience macro to run AM_CONDITIONAL and AC_DEFINE after 342*a3cefe7fSPierre Proncherydnl PKG_WITH_MODULES check. HAVE_[VARIABLE-PREFIX] is exported as make 343*a3cefe7fSPierre Proncherydnl and preprocessor variable. 344*a3cefe7fSPierre ProncheryAC_DEFUN([PKG_HAVE_DEFINE_WITH_MODULES], 345*a3cefe7fSPierre Pronchery[ 346*a3cefe7fSPierre ProncheryPKG_HAVE_WITH_MODULES([$1],[$2],[$3],[$4]) 347*a3cefe7fSPierre Pronchery 348*a3cefe7fSPierre ProncheryAS_IF([test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"], 349*a3cefe7fSPierre Pronchery [AC_DEFINE([HAVE_][$1], 1, [Enable ]m4_tolower([$1])[ support])]) 350*a3cefe7fSPierre Pronchery])dnl PKG_HAVE_DEFINE_WITH_MODULES 351