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.
This commit is contained in:
Pino Toscano
2016-07-28 10:56:58 +02:00
parent 108509ec19
commit 2ed76e6f17

View File

@@ -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