From: Nick Bowler Date: Tue, 17 Mar 2009 22:25:02 +0000 (-0400) Subject: Add an autoconf macro for dealing with pkg-config variables. X-Git-Url: https://git.draconx.ca/gitweb/aspectbin.git/commitdiff_plain/e69d0468cbf98b0b9567881156a5be79fd728d3d Add an autoconf macro for dealing with pkg-config variables. --- diff --git a/.gitignore b/.gitignore index 4f11579..cec2c78 100644 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,6 @@ Makefile.in config.* aclocal.m4 autom4te.cache -m4 configure libtool ltmain.sh diff --git a/autogen.sh b/autogen.sh index b52b9c1..6ab185f 100755 --- a/autogen.sh +++ b/autogen.sh @@ -6,7 +6,7 @@ die() exit 1 } -aclocal --force || die "Failed to run aclocal." +aclocal --force -I m4 || die "Failed to run aclocal." autoheader --force || die "Failed to run autoheader." libtoolize --force --copy || die "Failed to run libtoolize." automake --force --add-missing || die "Failed to run automake." diff --git a/m4/.gitignore b/m4/.gitignore new file mode 100644 index 0000000..94f2b51 --- /dev/null +++ b/m4/.gitignore @@ -0,0 +1,2 @@ +libtool.m4 +lt*.m4 diff --git a/m4/pkgvar.m4 b/m4/pkgvar.m4 new file mode 100644 index 0000000..4b7fa9b --- /dev/null +++ b/m4/pkgvar.m4 @@ -0,0 +1,67 @@ +dnl PKG_CHECK_VAR(prefix, var, desc, pkg, [action-if-ok], [action-if-fail]) +AC_DEFUN([PKG_CHECK_VAR], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +AC_ARG_VAR(m4_toupper([$1][_$2]), [$3, overriding pkg-config])dnl + +m4_define([_PKG_VAR_TEXT], [dnl +Alternately, you may set the environment variable m4_toupper([$1][_$2]) to +avoid the need to call pkg-config. +See the pkg-config man page for more details.]) + +pkg_fail=no +AC_MSG_CHECKING([for $3]) +_PKG_CONFIG([$1][_$2], [variable=$2], [$4]) +if test -z "[$pkg_cv_$1][_$2]"; then + if test $pkg_failed = yes; then + _PKG_SHORT_ERRORS_SUPPORTED + if test $_pkg_short_errors_supported = yes; then + $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "$4" 2>&1` + else + $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors "$4" 2>&1` + fi + echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD + + ifelse([$6], , + [AC_MSG_ERROR([dnl +Package requirements ($4) were not met: + +$$1_PKG_ERRORS + +Consider adjusting the PKG_CONFIG_PATH environment variable if you installed +software in a non-standard prefix. + +_PKG_VAR_TEXT +])], + [AC_MSG_RESULT([unknown]) + $6]) + elif test $pkg_failed = untried; then + ifelse([$6], , + [AC_MSG_FAILURE([dnl +The pkg-config script could not be found or is too old. Make sure it is in +your PATH or set the PKG_CONFIG environment variable to the full path to +pkg-config. + +_PKG_VAR_TEXT + +To get pkg-config, see .])], + [$6]) + else + ifelse([$6], , + [AC_MSG_ERROR([dnl +The variable ``$2'' was not defined in the package description database for dnl +m4_apply([m4_car], m4_split([$4])). + +Consider adjusting the PKG_CONFIG_PATH environment variable if you installed +software in a non-standard prefix. + +_PKG_VAR_TEXT +])], + [AC_MSG_RESULT([unknown]) + $6]) + fi +else + $1[]_$2=$pkg_cv_$1[]_$2 + AC_MSG_RESULT([$$1][_$2]) + ifelse([$5], , :, [$5]) +fi +])