From 64934a762311630e2a9146ee1c8ddab3c040d24d Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Thu, 17 Feb 2011 09:33:07 +0000 Subject: [PATCH] m4: Fix GTK_CHECK_BACKEND() to also check for a minimum version This should make the macro slightly more useful. Update the documentation mentioning the macro as well. --- docs/reference/gtk/compiling.sgml | 7 ++++--- docs/reference/gtk/migrating-2to3.xml | 2 +- m4macros/gtk-3.0.m4 | 29 +++++++++------------------ 3 files changed, 15 insertions(+), 23 deletions(-) diff --git a/docs/reference/gtk/compiling.sgml b/docs/reference/gtk/compiling.sgml index 6f593a0d60..b8a080d3bf 100644 --- a/docs/reference/gtk/compiling.sgml +++ b/docs/reference/gtk/compiling.sgml @@ -88,10 +88,11 @@ line option -DGTK_MULTIDEVICE_SAFE=1. list of modules to be checked along with GTK+. - GTK_CHECK_BACKEND([backend-name], [if-found], [if-not-found]) + GTK_CHECK_BACKEND([backend-name], [minimum-version], [if-found], [if-not-found]) This macro should be used to check if a specific backend - is supported by GTK+. The if-found and the - if-not-found arguments are optional. + is supported by GTK+. The minimum-version, + if-found and if-not-found + arguments are optional. diff --git a/docs/reference/gtk/migrating-2to3.xml b/docs/reference/gtk/migrating-2to3.xml index 8be399639d..0c3a2e43a9 100644 --- a/docs/reference/gtk/migrating-2to3.xml +++ b/docs/reference/gtk/migrating-2to3.xml @@ -900,7 +900,7 @@ AM_CONDITIONAL(BUILD_X11, test `$PKG_CONFIG --variable=target gtk+-2.0` = "x11") then you should now use the M4 macro provided by GTK+ itself: -GTK_CHECK_BACKEND([x11], [have_x11=yes], [have_x11=no]) +GTK_CHECK_BACKEND([x11], [3.0.2], [have_x11=yes], [have_x11=no]) AM_CONDITIONAL(BUILD_x11, [test "x$have_x11" = "xyes"]) diff --git a/m4macros/gtk-3.0.m4 b/m4macros/gtk-3.0.m4 index 3147a76920..5238b43498 100644 --- a/m4macros/gtk-3.0.m4 +++ b/m4macros/gtk-3.0.m4 @@ -195,34 +195,25 @@ main () rm -f conf.gtktest ]) -dnl GTK_CHECK_BACKEND(BACKEND-NAME [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) +dnl GTK_CHECK_BACKEND(BACKEND-NAME [, MINIMUM-VERSION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) dnl Tests for BACKEND-NAME in the GTK targets list dnl AC_DEFUN([GTK_CHECK_BACKEND], [ - backend=$1 - if test "x$backend" = "x"; then - AC_MSG_ERROR([A backend must be specified]) - fi + pkg_config_args=ifelse([$1],,gtk+-3.0, gtk+-$1-3.0) + min_gtk_version=ifelse([$2],,3.0.0,$2) - PKG_PROG_PKG_CONFIG([0.16]) - GDK_TARGETS=`$PKG_CONFIG --variable=targets gdk-3.0` - if test "x$GDK_TARGETS" = "x"; then - ifelse([$3],,[AC_MSG_ERROR([GDK targets not found.])],[$3]) + AC_PATH_PROG(PKG_CONFIG, [pkg-config], [AC_MSG_ERROR([No pkg-config found])]) + + if $PKG_CONFIG --atleast-version $min_gtk_version $pkg_config_args ; then + target_found=yes else - ifelse([$2],,[:],[$2]) + target_found=no fi - target_found=no - for target in $GDK_TARGETS; do - if test "x$target" = "x$backend"; then - target_found=yes - fi - done - if test "x$target_found" = "xno"; then - ifelse([$3],,[AC_MSG_ERROR([Backend $backend not found.])],[$3]) + ifelse([$4],,[AC_MSG_ERROR([Backend $backend not found.])],[$4]) else - ifelse([$2],,[:],[$2]) + ifelse([$3],,[:],[$3]) fi ])