dnl Copyright (C) 2009 Nick Bowler dnl Copying and distribution of this file, with or without modification, dnl are permitted in any medium without royalty provided the copyright dnl notice and this notice are preserved. This file is offered as-is, dnl without any warranty. dnl _GLIB_TRY_VERSION(min-version) AC_DEFUN([_GLIB_TRY_VERSION], [dnl shead='s/@<:@0-9@:>@@<:@0-9@:>@*/<<<&>>>/' sbody='s/.*<<<\(.*\)>>>.*/\1/;t' stail='s/.*/0/' glib_min_major=`printf '%s' '$1' | sed -e "$shead"1 -e "$sbody" -e "$stail"` glib_min_minor=`printf '%s' '$1' | sed -e "$shead"2 -e "$sbody" -e "$stail"` glib_min_release=`printf '%s' '$1' | sed -e "$shead"3 -e "$sbody" -e "$stail"` AC_CACHE_CHECK([for glib version at least $1], [glib_cv_sufficient_ver], [AC_LINK_IFELSE([AC_LANG_PROGRAM([dnl _GLIB_INCLUDES #if !GLIB_CHECK_VERSION($glib_min_major,$glib_min_minor,$glib_min_release) # error Insufficient glib version #endif ], [dnl _GLIB_MAIN ])], [glib_cv_sufficient_ver=yes], [glib_cv_sufficient_ver=no])]) ]) dnl _GLIB_MODULE([module-name], [module-list]) AC_DEFUN([_GLIB_MODULE], [ifelse(m4_bregexp([$2], [\(^\| \)$1\( \|$\)]), [-1], [], [dnl AC_ARG_VAR([LIB]m4_toupper([$1])[_CFLAGS], [C compiler flags for lib$1]) AC_ARG_VAR([LIB]m4_toupper([$1])[_LIBS], [linker flags for lib$1]) ifelse([$1], [gobject], [dnl m4_append([_GLIB_INCLUDES], [dnl #include ], [ ]) m4_append([_GLIB_MAIN], [dnl g_type_init(); { GObject *obj = g_object_new(G_TYPE_OBJECT, NULL); }], [ ]) ]) ifelse([$1], [gthread], [dnl m4_append([_GLIB_MAIN], [dnl g_thread_init(NULL); ]) ]) if test x"$PKG_CONFIG" != x; then AC_MSG_CHECKING([pkg-config database for $1-2.0]) _PKG_CONFIG([lib$1_cflags], [cflags], [$1-2.0]) _PKG_CONFIG([lib$1_libs], [libs], [$1-2.0]) if test x$pkg_failed = xyes; then errors=`$PKG_CONFIG --errors-to-stdout --print-errors lib$1` echo "$errors" >&AS_MESSAGE_LOG_FD AC_MSG_RESULT([no]) else if test x"$LIB[]m4_toupper([$1])_CFLAGS" = x; then LIB[]m4_toupper([$1])_CFLAGS=$pkg_cv_lib$1_cflags fi if test x"$LIB[]m4_toupper([$1])_LIBS" = x; then LIB[]m4_toupper([$1])_LIBS=$pkg_cv_lib$1_libs fi AC_MSG_RESULT([yes]) fi fi GLIB_CFLAGS="$GLIB_CFLAGS $LIB[]m4_toupper([$1])_CFLAGS" GLIB_LIBS="$GLIB_LIBS $LIB[]m4_toupper([$1])_LIBS" ])]) dnl CHECK_GLIB_2([min-version], [modules], [action-if-ok], [action-if-fail]) AC_DEFUN([CHECK_GLIB_2], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl m4_define([_GLIB_INCLUDES], [#include ]) m4_define([_GLIB_MAIN], [const char *ver = glib_check_version(2,0,0);]) GLIB_CFLAGS= GLIB_LIBS= _GLIB_MODULE([glib], [glib]) _GLIB_MODULE([gobject], [$2]) _GLIB_MODULE([gthread], [$2]) AC_LANG_PUSH([C]) old_cflags=$CFLAGS old_libs=$LIBS CFLAGS="$GLIB_CFLAGS $CFLAGS" LIBS="$GLIB_LIBS $LIBS" _GLIB_TRY_VERSION(ifelse([$1], [], [2.0], [$1])) CFLAGS=$old_cflags LIBS=$old_libs AC_LANG_POP([C]) if test x"$glib_cv_sufficient_ver" = x"yes"; then AC_SUBST([GLIB_CFLAGS]) AC_SUBST([GLIB_LIBS]) ifelse([$3], [], [:], [$3]) else ifelse([$4], [], [AC_MSG_FAILURE([dnl glib version >= ifelse([$1], [], [2.0], [$1]) is required. The latest version can be obtained from ftp://ftp.gtk.org/pub/glib. If libglib is installed but was not found by this configure script, consider adjusting LIBGLIB_CFLAGS and/or LIBGLIB_LIBS as necessary. If pkg-config is installed, it may help to adjust PKG_CONFIG_PATH if libglib is installed in a non-standard prefix. ])], [$4]) fi ])