
AC_MSG_CHECKING(for Qt with OpenGL support)
AC_CACHE_VAL(ac_cv_kde_qt_has_opengl,
[
  AC_LANG_SAVE
  AC_LANG_CPLUSPLUS

  save_CXXFLAGS="$CXXFLAGS"
  save_LIBS="$LIBS"
  save_LDFLAGS="$LDFLAGS"

  CXXFLAGS="$CXXFLAGS -I$qt_incdir $all_includes"
  LDFLAGS="$LDFLAGS -L$qt_libdir $all_libraries $USER_LDFLAGS $KDE_MT_LDFLAGS"
  LIBS="$LIBS $LIBQT $KDE_MT_LIBS"

  AC_TRY_LINK([
  #include <qgl.h>
  ],
  [
   (void)new QGLWidget((QWidget*)0, "qgl");
  ],
  ac_cv_kde_qt_has_opengl=yes,
  ac_cv_kde_qt_has_opengl=no)

  CXXFLAGS="$save_CXXFLAGS"
  LIBS="$save_LIBS"
  LDFLAGS="$save_LDFLAGS"
  AC_LANG_RESTORE
])
AC_MSG_RESULT($ac_cv_kde_qt_has_opengl)

AC_HAVE_GL( have_gl=yes, have_gl=no )

AM_CONDITIONAL(COMPILE_GL_XSAVERS, test x$have_gl = xyes)
AM_CONDITIONAL(COMPILE_GL_KSAVERS, test x$have_gl = xyes && test x$ac_cv_kde_qt_has_opengl = xyes) 
AM_CONDITIONAL(COMPILE_X11_KSAVERS, test "x$ac_x_includes" != x && test "x$ac_x_libraries" != x)
AM_CONDITIONAL(COMPILE_ARTS_KSAVERS, test x$build_arts = xyes)
AM_CONDITIONAL(COMPILE_ARTS_GL_KSAVERS, test x$have_gl = xyes && test x$ac_cv_kde_qt_has_opengl = xyes && test x$build_arts = xyes)

AC_ARG_WITH(libart,
  [AC_HELP_STRING(--with-libart,
    [enable support for libart @<:@default=check@:>@])],
  [], with_libart=check)

LIBART=
if test "x$with_libart" != xno; then
  KDE_FIND_PATH(libart2-config, LIBART_CONFIG, [${prefix}/bin ${exec_prefix}/bin /usr/local/bin /opt/local/bin], [
    AC_MSG_WARN([Could not find libart anywhere, check http://www.levien.com/libart/])
  ])

  if test -n "$LIBART_CONFIG"; then
    vers=`$LIBART_CONFIG --version 2>/dev/null | awk 'BEGIN { FS = "."; } { printf "%d", ($1 * 1000 + $2) * 1000 + $3;}'`
    if test -n "$vers" && test "$vers" -ge 2003008; then
      LIBART_LIBS="`$LIBART_CONFIG --libs`"
      LIBART_RPATH=
      for args in $LIBART_LIBS; do
	  case $args in
	    -L*)
	       LIBART_RPATH="$LIBART_RPATH $args"
	       ;;
          esac
      done
      LIBART_RPATH=`echo $LIBART_RPATH | sed -e "s/-L/-R/g"`
      LIBART_CFLAGS="`$LIBART_CONFIG --cflags`"
      LIBART=yes

      AC_DEFINE_UNQUOTED(HAVE_LIBART, 1, [Defines if your system has the libart library])
    else
      AC_MSG_WARN([You need at least libart 2.3.8])
    fi
  fi

  if test "x$with_libart" != xcheck && test -z "$LIBART"; then
      AC_MSG_ERROR([--with-libart was given, but test for libart failed])
  fi
fi

AC_SUBST(LIBART_LIBS)
AC_SUBST(LIBART_CFLAGS)
AC_SUBST(LIBART_RPATH)
AM_CONDITIONAL(COMPILE_LIBART_KSAVERS, test -n "$LIBART")


AC_CHECK_FUNCS(gettimeofday)

AC_HAVE_DPMS()
