dnl Process this file with autoconf to produce a configure script.
AC_INIT(main.c)
AC_CONFIG_HEADER(config.h)

AC_ARG_WITH(platform,
[  --with-platform	  platform name, as detected by AppRun],
[AC_SUBST(with_platform)],
[
AC_MSG_ERROR([

Please do not run 'configure' manually - instead, run the AppRun script with
the --compile option, like this:
	$ ROX-Session/AppRun --compile

Thank you.
])
])

AC_MSG_CHECKING(that pkg-config runs)
if pkg-config --version > /dev/null 2>&1 ; then
  AC_MSG_RESULT(yes)
else
  AC_MSG_RESULT(no)
  AC_MSG_ERROR([*** pkg-config missing ***

'pkg-config --version' failed to run - make sure it is inside one of the
directories in your PATH environment variable!

pkg-config comes with the developement packages for GTK+-2.0, available at:

    http://www.gtk.org])
fi

AC_DEFUN(ROX_REQUIRE, [
AC_MSG_CHECKING(that $1 (version >= $2) is installed)
if pkg-config --atleast-version=$2 $1 ; then
  AC_MSG_RESULT(yes)
else
  AC_MSG_RESULT(no)
  if pkg-config --exists $1 ; then
    AC_MSG_ERROR(Current version is only `pkg-config $1 --modversion`)
  else
    AC_MSG_ERROR(Package is not installed)
  fi
fi
])

ROX_REQUIRE(gtk+-2.0, 2.0.1)
ROX_REQUIRE(libxml-2.0, 2.0.0)

dnl Checks for programs.
AC_PROG_CC
AC_PROG_MAKE_SET

dnl Use -Wall, etc if possible
[
if test "x$GCC" = "xyes"; then
  case " $CFLAGS " in
  *[\ \	]-Wall[\ \	]*) ;;
  *) CFLAGS="$CFLAGS -Wall -Wmissing-prototypes" ;;
  esac
fi
]

dnl Find the X libraries
AC_PATH_XTRA
if test x$no_x = xyes ; then
  AC_MSG_ERROR([X development libraries not found])
fi
LIBS="$LIBS $X_LIBS -lX11 $X_EXTRA_LIBS"
CFLAGS="$CFLAGS $X_CFLAGS"

dnl Extract version info from AppInfo.xml
AC_MSG_CHECKING(extracting version information)
[
VERSION=`sed -n 's/^.*<Version>\([.0-9]*\).*<\/Version>.*$/\1/p' ../AppInfo.xml`
]
AC_DEFINE_UNQUOTED(VERSION, "$VERSION")
AC_MSG_RESULT(version $VERSION)

dnl Checks for header files.
AC_PATH_X
AC_HEADER_STDC
AC_CHECK_HEADERS(locale.h)

dnl Checks for typedefs, structures, and compiler characteristics.

dnl Checks for library functions.
AC_CHECK_FUNCS(unsetenv getopt_long)

AC_OUTPUT(Makefile)
