fi
AM_CONDITIONAL([BUILD_LBXIMG], [test x"$have_libpng" = x"yes"])
-# A horrible combination of bugs makes this necessary for GTK+ detection.
-unset POSIXLY_CORRECT
-
-AM_PATH_GTK_2_0([2.16.0], [have_gtk=yes], [have_gtk=no])
+AC_ARG_ENABLE([lbxgui],
+ [AS_HELP_STRING([--enable-lbxgui],
+ [build the lbxgui tool (requires GTK+) [default=auto]])],
+ [enable_lbxgui=$enableval],
+ [enable_lbxgui=auto])
+
+have_gtk=no
+if test x"$enable_lbxgui" = x"auto"; then
+DX_CHECK_GTK2([2.16], [have_gtk=yes], [have_gtk=no])
+fi
+if test x"$enable_lbxgui" = x"yes"; then
+DX_CHECK_GTK2([2.16], [have_gtk=yes])
+fi
AM_CONDITIONAL([BUILD_LBXGUI], [test x"$have_gtk" = x"yes"])
AC_CONFIG_FILES([
--- /dev/null
+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
+])