diff --git a/m4/check-qt.m4 b/m4/check-qt.m4
index d0842812c4606a0b7d6b5f2d84d45f0502731c53..6b50c07923a219b5f579aea1d2e1ea67a21d996e 100644
--- a/m4/check-qt.m4
+++ b/m4/check-qt.m4
@@ -1,3 +1,7 @@
+dnl
+dnl $1 == required: bail out on error
+dnl $1 == optional: just issue a warning.
+dnl
AC_DEFUN([ALBERT_CHECK_QT],
[AC_ARG_WITH([qtdir],
[ --with-qtdir=QTDIR Attempt to use the QT toolkit located in QTDIR.
@@ -6,7 +10,7 @@ AC_DEFUN([ALBERT_CHECK_QT],
yes)
;;
no)
- AC_MSG_ERROR([Nope, we _need_ QT])
+ test "$1" = required && AC_MSG_ERROR([Nope, we _need_ QT])
;;
*)
QTDIR=${withval}
@@ -21,7 +25,7 @@ done
])
AC_LANG_PUSH([C++])
ALBERT_CHECK_PACKAGE(Qt, qt-mt, ${QTDIR}/lib, ${X_LIBS} -lX11,
- qgl.h, ${QTDIR}/include, required)
+ qgl.h, ${QTDIR}/include, $1)
AC_LANG_POP
dnl
dnl check for QGLWidget
@@ -37,7 +41,11 @@ AC_CACHE_CHECK([whether class QGLWidget compiles and links],
#endif]],
[[QGLWidget qgl;]])],
[ac_cv_qglwidget_links=yes],
- [AC_MSG_FAILURE([Unable to compile and link a "QGLWidget"])
+ [if test "$1" = required; then
+ AC_MSG_FAILURE([Unable to compile and link a "QGLWidget"])
+ else
+ AC_MSG_RESULT([Unable to compile and link a "QGLWidget"])
+ fi
])
AC_LANG_POP
LDFLAGS="${ac_save_LDFLAGS}"
@@ -51,13 +59,19 @@ AC_ARG_WITH([moc],
yes)
;;
no)
- AC_MSG_ERROR([Nope, we need moc])
+ test "$1" = required && AC_MSG_ERROR([Nope, we need moc])
;;
*)
MOCPATH=${withval}
;;
esac],
[MOCPATH=${QTDIR}/bin])
-AC_PATH_PROG([MOC], moc, , [$MOCPATH:$QTDIR/bin:$PATH])
+AC_PATH_PROG([MOC], moc,
+ [test "$1" == required && AC_MSG_ERROR(["moc" not found])],
+ [$MOCPATH:$QTDIR/bin:$PATH])
+if test -n "$Qt_LIB" -a -n "$MOC" -a "$ac_cv_qglwidget_links" = yes; then
+ AC_DEFINE([HAVE_QGL_WIDGET], 1,
+ [Define to "1" if Qt's QGLWidget is present and compiles])
+fi
])