]> git.draconx.ca Git - aspectbin.git/commitdiff
Add an autoconf macro for dealing with pkg-config variables.
authorNick Bowler <nbowler@draconx.ca>
Tue, 17 Mar 2009 22:25:02 +0000 (18:25 -0400)
committerNick Bowler <nbowler@draconx.ca>
Tue, 17 Mar 2009 22:48:10 +0000 (18:48 -0400)
.gitignore
autogen.sh
m4/.gitignore [new file with mode: 0644]
m4/pkgvar.m4 [new file with mode: 0644]

index 4f11579f703811c846ef18dbdeb613542683094d..cec2c78220ca229cfe288c68332a3291c7adad59 100644 (file)
@@ -8,7 +8,6 @@ Makefile.in
 config.*
 aclocal.m4
 autom4te.cache
-m4
 configure
 libtool
 ltmain.sh
index b52b9c1599055dd49e1ee771878de1ff93c31d38..6ab185f70d778956d256ea04db6da0e7ff0e9a96 100755 (executable)
@@ -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 (file)
index 0000000..94f2b51
--- /dev/null
@@ -0,0 +1,2 @@
+libtool.m4
+lt*.m4
diff --git a/m4/pkgvar.m4 b/m4/pkgvar.m4
new file mode 100644 (file)
index 0000000..4b7fa9b
--- /dev/null
@@ -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 <http://pkg-config.freedesktop.org/>.])],
+                       [$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
+])