1 dnl Copyright (C) 2009 Nick Bowler
2 dnl Copying and distribution of this file, with or without modification,
3 dnl are permitted in any medium without royalty provided the copyright
4 dnl notice and this notice are preserved. This file is offered as-is,
5 dnl without any warranty.
7 AC_DEFUN([_LIBMODPLUG_TEST], [dnl
8 AC_CACHE_CHECK([whether libmodplug works],
10 [AC_LINK_IFELSE([AC_LANG_PROGRAM([dnl
13 unsigned char buf@<:@128@:>@ = {0};
14 ModPlugFile *f = ModPlug_Load(buf, sizeof buf);
16 ])], [libmodplug_cv_works=yes], [libmodplug_cv_works=no])])
19 dnl CHECK_LIBMODPLUG([action-if-ok], [action-if-fail])
20 AC_DEFUN([CHECK_LIBMODPLUG],
21 [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
22 AC_ARG_VAR([LIBMODPLUG_CFLAGS], [C compiler flags for libmodplug])dnl
23 AC_ARG_VAR([LIBMODPLUG_LIBS], [linker flags for libmodplug])dnl
25 if test x"$PKG_CONFIG" != x; then
26 AC_MSG_CHECKING([pkg-config database for libmodplug])
27 _PKG_CONFIG([libmodplug_cflags], [cflags], [libmodplug])
28 _PKG_CONFIG([libmodplug_libs], [libs], [libmodplug])
29 if test x$pkg_failed = xyes; then
30 errors=`$PKG_CONFIG --errors-to-stdout --print-errors libmodplug`
31 echo "$errors" >&AS_MESSAGE_LOG_FD
34 if test x"$LIBMODPLUG_CFLAGS" = x; then
35 LIBMODPLUG_CFLAGS=$pkg_cv_libmodplug_cflags
37 if test x"$LIBMODPLUG_LIBS" = x; then
38 LIBMODPLUG_LIBS=$pkg_cv_libmodplug_libs
45 if test x"$LIBMODPLUG_CFLAGS" = x; then
46 LIBMODPLUG_CFLAGS="-I$includedir/libmodplug"
49 if test x"$LIBMODPLUG_LIBS" = x; then
50 LIBMODPLUG_LIBS=-lmodplug
56 CFLAGS="$LIBMODPLUG_CFLAGS $CFLAGS"
57 LIBS="$LIBMODPLUG_LIBS $LIBS"
65 if test x"$libmodplug_cv_works" = x"yes"; then
66 AC_SUBST([LIBMODPLUG_CFLAGS])
67 AC_SUBST([LIBMODPLUG_LIBS])
68 ifelse([$1], [], [true], [$1])
70 ifelse([$2], [], [AC_MSG_FAILURE([dnl
71 libmodplug is required. The latest version can be
72 obtained from http://modplug-xmms.sourceforge.net/.
74 If libmodplug is installed but was not found by this configure script,
75 consider adjusting LIBMODPLUG_CFLAGS and/or LIBMODPLUG_LIBS as necessary.
77 If pkg-config is installed, it may help to adjust PKG_CONFIG_PATH
78 if libmodplug is installed in a non-standard prefix.