From 13559896fe19346966a664d6f1a9862d3629a925 Mon Sep 17 00:00:00 2001 From: Colomban Wendling Date: Sat, 4 Apr 2015 14:13:18 +0200 Subject: [PATCH] autotools: Detect GTK version to use automatically --- configure.ac | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/configure.ac b/configure.ac index 5a5cbaa9..985ab586 100644 --- a/configure.ac +++ b/configure.ac @@ -59,19 +59,28 @@ AC_CHECK_FUNCS([ftruncate fgetpos fnmatch mkstemp strerror strstr]) GEANY_CHECK_REVISION([dnl force debug mode for a VCS working copy CFLAGS="-g -DGEANY_DEBUG $CFLAGS"]) - +# GTK version check AC_ARG_ENABLE([gtk3], [AS_HELP_STRING([--enable-gtk3], - [compile with GTK3 support (experimental) [default=no]])], + [compile against GTK3 [default=auto]])], [enable_gtk3=$enableval], - [enable_gtk3=no]) + [enable_gtk3=auto]) -AS_IF([test "x$enable_gtk3" = xyes], - [gtk_package=gtk+-3.0 - gtk_min_version=3.0], - [gtk_package=gtk+-2.0 - gtk_min_version=2.24]) -AM_CONDITIONAL([GTK3], [test "x$gtk_package" = "xgtk+-3.0"]) +gtk2_package=gtk+-2.0 +gtk2_min_version=2.24 +gtk3_package=gtk+-3.0 +gtk3_min_version=3.0 + +PKG_CHECK_EXISTS([$gtk2_package >= $gtk2_min_version], [have_gtk2=yes], [have_gtk2=no]) +PKG_CHECK_EXISTS([$gtk3_package >= $gtk3_min_version], [have_gtk3=yes], [have_gtk3=no]) +AS_IF([test "x$enable_gtk3" = xyes || (test "x$enable_gtk3" != xno && + test "x$have_gtk3" = xyes && + test "x$have_gtk2" = xno)], + [gtk_package=$gtk3_package + gtk_min_version=$gtk3_min_version], + [gtk_package=$gtk2_package + gtk_min_version=$gtk2_min_version]) +AM_CONDITIONAL([GTK3], [test "x$gtk_package" = "x$gtk3_package"]) # GTK/GLib/GIO checks gtk_modules="$gtk_package >= $gtk_min_version glib-2.0 >= 2.32"