From 2ed76e6f17d67b3218f10551cb394d46cbd0fb9a Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Thu, 28 Jul 2016 10:56:58 +0200 Subject: [PATCH] build: improve Gtk check Check the presence of Gtk properly depending on the value of --with-gtk: if a specific version is chosen, then let PKG_CHECK_MODULES fail if that version if not found, otherwise fallback from gtk3 to gtk2 to no gtk. Also move few common AC_SUBST in a single place. --- m4/guestfs_misc_libraries.m4 | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/m4/guestfs_misc_libraries.m4 b/m4/guestfs_misc_libraries.m4 index 4ae057693..fee265b68 100644 --- a/m4/guestfs_misc_libraries.m4 +++ b/m4/guestfs_misc_libraries.m4 @@ -85,29 +85,31 @@ AC_ARG_WITH([gtk], AC_MSG_RESULT([not set, will check for installed Gtk])] ) -if test "x$GTK_LIBS" = "x" && \ - ( test "x$with_gtk" = "x3" || test "x$with_gtk" = "xcheck" ) ; then +if test "x$with_gtk" = "x3"; then PKG_CHECK_MODULES([GTK], [gtk+-3.0], [ - AC_SUBST([GTK_CFLAGS]) - AC_SUBST([GTK_LIBS]) GTK_VERSION=3 - AC_SUBST([GTK_VERSION]) - ], []) -fi -if test "x$GTK_LIBS" = "x" && \ - ( test "x$with_gtk" = "x2" || test "x$with_gtk" = "xcheck" ) ; then + ]) +elif test "x$with_gtk" = "x2"; then PKG_CHECK_MODULES([GTK], [gtk+-2.0], [ - AC_SUBST([GTK_CFLAGS]) - AC_SUBST([GTK_LIBS]) GTK_VERSION=2 - AC_SUBST([GTK_VERSION]) ], []) +elif test "x$with_gtk" = "xcheck"; then + PKG_CHECK_MODULES([GTK], [gtk+-3.0], [ + GTK_VERSION=3 + ], [ + PKG_CHECK_MODULES([GTK], [gtk+-2.0], [ + GTK_VERSION=2 + ], [:]) + ]) fi dnl Can we build virt-p2v? AC_MSG_CHECKING([if we can build virt-p2v]) if test "x$GTK_LIBS" != "x"; then AC_MSG_RESULT([yes, with Gtk $GTK_VERSION]) + AC_SUBST([GTK_CFLAGS]) + AC_SUBST([GTK_LIBS]) + AC_SUBST([GTK_VERSION]) else AC_MSG_RESULT([no]) fi