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. AC_DEFUN([_LIBMODPLUG_TEST], [dnl AC_CACHE_CHECK([whether libmodplug works], [libmodplug_cv_works], [AC_LINK_IFELSE([AC_LANG_PROGRAM([dnl #include ], [dnl unsigned char buf@<:@128@:>@ = {0}; ModPlugFile *f = ModPlug_Load(buf, sizeof buf); ModPlug_Unload(f); ])], [libmodplug_cv_works=yes], [libmodplug_cv_works=no])]) ]) dnl CHECK_LIBMODPLUG([action-if-ok], [action-if-fail]) AC_DEFUN([CHECK_LIBMODPLUG], [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl AC_ARG_VAR([LIBMODPLUG_CFLAGS], [C compiler flags for libmodplug])dnl AC_ARG_VAR([LIBMODPLUG_LIBS], [linker flags for libmodplug])dnl if test x"$PKG_CONFIG" != x; then AC_MSG_CHECKING([pkg-config database for libmodplug]) _PKG_CONFIG([libmodplug_cflags], [cflags], [libmodplug]) _PKG_CONFIG([libmodplug_libs], [libs], [libmodplug]) if test x$pkg_failed = xyes; then errors=`$PKG_CONFIG --errors-to-stdout --print-errors libmodplug` echo "$errors" >&AS_MESSAGE_LOG_FD AC_MSG_RESULT([no]) else if test x"$LIBMODPLUG_CFLAGS" = x; then LIBMODPLUG_CFLAGS=$pkg_cv_libmodplug_cflags fi if test x"$LIBMODPLUG_LIBS" = x; then LIBMODPLUG_LIBS=$pkg_cv_libmodplug_libs fi AC_MSG_RESULT([yes]) fi fi if test x"$LIBMODPLUG_CFLAGS" = x; then LIBMODPLUG_CFLAGS="-I$includedir/libmodplug" fi if test x"$LIBMODPLUG_LIBS" = x; then LIBMODPLUG_LIBS=-lmodplug fi AC_LANG_PUSH([C]) old_cflags=$CFLAGS old_libs=$LIBS CFLAGS="$LIBMODPLUG_CFLAGS $CFLAGS" LIBS="$LIBMODPLUG_LIBS $LIBS" _LIBMODPLUG_TEST CFLAGS=$old_cflags LIBS=$old_libs AC_LANG_POP([C]) if test x"$libmodplug_cv_works" = x"yes"; then AC_SUBST([LIBMODPLUG_CFLAGS]) AC_SUBST([LIBMODPLUG_LIBS]) ifelse([$1], [], [true], [$1]) else ifelse([$2], [], [AC_MSG_FAILURE([dnl libmodplug is required. The latest version can be obtained from http://modplug-xmms.sourceforge.net/. If libmodplug is installed but was not found by this configure script, consider adjusting LIBMODPLUG_CFLAGS and/or LIBMODPLUG_LIBS as necessary. If pkg-config is installed, it may help to adjust PKG_CONFIG_PATH if libmodplug is installed in a non-standard prefix. ])], [$2]) fi ])