]> git.draconx.ca Git - liblbx.git/blobdiff - m4/gtk2.m4
build: Implement a better GTK+ detection macro.
[liblbx.git] / m4 / gtk2.m4
diff --git a/m4/gtk2.m4 b/m4/gtk2.m4
new file mode 100644 (file)
index 0000000..d10b0c3
--- /dev/null
@@ -0,0 +1,49 @@
+dnl Copyright (C) 2010 Nick Bowler
+dnl Copying and distribution of this file, with or without modification,
+dnl are permitted in any medium without royalty provided the copyright
+dnl notice and this notice are preserved.  This file is offered as-is,
+dnl without any warranty.
+
+dnl _DX_GTK2_TEST_PROGRAM(major, minor, micro)
+AC_DEFUN([_DX_GTK2_TEST_PROGRAM], [AC_LANG_PROGRAM([dnl
+#include <gtk/gtk.h>
+#if !GTK_CHECK_VERSION( \
+       ifelse([$1], [], [2], [$1]), \
+       ifelse([$2], [], [0], [$2]), \
+       ifelse([$3], [], [0], [$3]))
+#  error Insufficient GTK version
+#endif
+], [dnl
+int argc = 0;
+char *argv[] = {NULL};
+gtk_init(&argc, &argv);
+gtk_main();
+])])
+
+dnl DX_CHECK_GTK2([min-version], [action-if-ok], [action-if-fail])
+AC_DEFUN([DX_CHECK_GTK2],
+[DX_PKG_CONFIG([gtk], [gtk+-2.0], [GTK+])
+
+DX_CHECK_LIB([gtk],
+       [for GTK+ version at least ifelse([$1], [], [2.0], [$1])],
+       [m4_apply([_DX_GTK2_TEST_PROGRAM], m4_split([$1], [\.]))], [dnl
+               [[$GTK_CFLAGS], [$GTK_LIBS]],
+               [[$pkg_cv_gtk_cflags], [$pkg_cv_gtk_libs],
+                       [test ! x"$pkg_failed" = x"yes"]],
+               ])
+
+if test x"$dx_cv_gtk_found" = x"yes"; then
+       ifelse([$2], [], [:], [$2])
+else
+       ifelse([$3], [], [AC_MSG_FAILURE([dnl
+GTK+ version at least ifelse([$1], [], [2.0], [$1]) is required.  The latest
+version can be obtained from ftp://ftk.gtk.org/.
+
+If GTK+ is installed but was not found by this configure script,
+consider adjusting GTK_CFLAGS and/or GTK_LIBS as necessary.
+
+If pkg-config is installed, it may help to adjust PKG_CONFIG_PATH
+if GTK+ is installed in a non-standard prefix.
+])], [$3])
+fi
+])