--- /dev/null
+dnl Copyright © 2014 Nick Bowler
+dnl
+dnl License WTFPL2: Do What The Fuck You Want To Public License, version 2.
+dnl This is free software: you are free to do what the fuck you want to.
+dnl There is NO WARRANTY, to the extent permitted by law.
+
+m4_pattern_forbid([^PKG_PROG_PKG_CONFIG$])
+
+dnl DX_PKG_CONFIG(shell-variable, arguments,
+dnl [action-if-ok], [action-if-failed],
+dnl [action-if-not-available])
+dnl
+dnl Execute pkg-config with the given arguments, and store the output in
+dnl the specified shell variable. If successful, execute action-if-ok. If
+dnl unsuccessful, execute action-if-failed. If pkg-config is not available,
+dnl execute action-if-not-available.
+AC_DEFUN([DX_PKG_CONFIG], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+AS_UNSET([$1])
+AS_IF([test x"$PKG_CONFIG" = x""],
+ [m4_default([$5], [AS_SET_STATUS([2])])],
+ [DX_COMMAND_OUTPUT([$1], [$PKG_CONFIG --print-errors $2],
+ [$3], [m4_default([$4], [AS_SET_STATUS([$?])])])])])