]> git.draconx.ca Git - dxcommon.git/blobdiff - m4/pkg.m4
Add libpng detection macro.
[dxcommon.git] / m4 / pkg.m4
diff --git a/m4/pkg.m4 b/m4/pkg.m4
new file mode 100644 (file)
index 0000000..9fd99a9
--- /dev/null
+++ b/m4/pkg.m4
@@ -0,0 +1,22 @@
+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([$?])])])])])