1# ao.m4
2# Configure paths for libao
3# Jack Moffitt <jack@icecast.org> 10-21-2000
4# Shamelessly stolen from Owen Taylor and Manish Singh
5
6dnl AM_PATH_AO([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
7dnl Test for libao, and define AO_CFLAGS and AO_LIBS
8dnl
9AC_DEFUN(AM_PATH_AO,
10[dnl
11dnl Get the cflags and libraries
12dnl
13AC_ARG_WITH(ao-prefix,[  --with-ao-prefix=PFX   Prefix where libao is installed (optional)], ao_prefix="$withval", ao_prefix="")
14AC_ARG_ENABLE(aotest, [  --disable-aotest       Do not try to compile and run a test ao program],, enable_aotest=yes)
15
16  if test "x$ao_prefix" != "xNONE" ; then
17    ao_args="$ao_args --prefix=$ao_prefix"
18    AO_CFLAGS="-I$ao_prefix/include"
19    AO_LIBS="-L$ao_prefix/lib"
20  elif test "$prefix" != ""; then
21    ao_args="$ao_args --prefix=$prefix"
22    AO_CFLAGS="-I$prefix/include"
23    AO_LIBS="-L$prefix/lib"
24  fi
25
26  # see where dl* and friends live
27  AC_CHECK_FUNCS(dlopen, [AO_DL_LIBS=""], [
28    AC_CHECK_LIB(dl, dlopen, [AO_DL_LIBS="-ldl"], [
29      AC_MSG_ERROR([could not find dlopen() needed by libao sound drivers
30      your system may not be supported.])
31    ])
32  ])
33
34  AO_LIBS="$AO_LIBS -lao $AO_DL_LIBS"
35
36  AC_MSG_CHECKING(for ao)
37  no_ao=""
38
39
40  if test "x$enable_aotest" = "xyes" ; then
41    ac_save_CFLAGS="$CFLAGS"
42    ac_save_LIBS="$LIBS"
43    CFLAGS="$CFLAGS $AO_CFLAGS"
44    LIBS="$LIBS $AO_LIBS"
45dnl
46dnl Now check if the installed ao is sufficiently new.
47dnl
48      rm -f conf.aotest
49      AC_TRY_RUN([
50#include <stdio.h>
51#include <stdlib.h>
52#include <string.h>
53#include <ao/ao.h>
54
55int main ()
56{
57  system("touch conf.aotest");
58  return 0;
59}
60
61],, no_ao=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
62       CFLAGS="$ac_save_CFLAGS"
63       LIBS="$ac_save_LIBS"
64  fi
65
66  if test "x$no_ao" = "x" ; then
67     AC_MSG_RESULT(yes)
68     ifelse([$1], , :, [$1])
69  else
70     AC_MSG_RESULT(no)
71     if test -f conf.aotest ; then
72       :
73     else
74       echo "*** Could not run ao test program, checking why..."
75       CFLAGS="$CFLAGS $AO_CFLAGS"
76       LIBS="$LIBS $AO_LIBS"
77       AC_TRY_LINK([
78#include <stdio.h>
79#include <ao/ao.h>
80],     [ return 0; ],
81       [ echo "*** The test program compiled, but did not run. This usually means"
82       echo "*** that the run-time linker is not finding ao or finding the wrong"
83       echo "*** version of ao. If it is not finding ao, you'll need to set your"
84       echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
85       echo "*** to the installed location  Also, make sure you have run ldconfig if that"
86       echo "*** is required on your system"
87       echo "***"
88       echo "*** If you have an old version installed, it is best to remove it, although"
89       echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
90       [ echo "*** The test program failed to compile or link. See the file config.log for the"
91       echo "*** exact error that occured. This usually means ao was incorrectly installed"
92       echo "*** or that you have moved ao since it was installed." ])
93       CFLAGS="$ac_save_CFLAGS"
94       LIBS="$ac_save_LIBS"
95     fi
96     AO_CFLAGS=""
97     AO_LIBS=""
98     ifelse([$2], , :, [$2])
99  fi
100  AC_SUBST(AO_CFLAGS)
101  AC_SUBST(AO_LIBS)
102  rm -f conf.aotest
103])
104
105