821c861e22584dfeabb69a52a33ce8856233c2d2
[platform/upstream/gstreamer.git] / m4 / gst-shout2.m4
1 # Configure paths for libshout
2 # Jack Moffitt <jack@icecast.org> 08-06-2001
3 # Shamelessly stolen from Owen Taylor and Manish Singh
4
5 dnl AM_PATH_SHOUT2([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
6 dnl Test for libshout, and define SHOUT2_CFLAGS and SHOUT2_LIBS
7 dnl
8 AC_DEFUN(AM_PATH_SHOUT2,
9 [dnl 
10 dnl Get the cflags and libraries
11 dnl
12 AC_ARG_WITH(shout-prefix,[  --with-shout2-prefix=PFX   Prefix where libshout2 is installed (optional)], shout2_prefix="$withval", shout2_prefix="")
13 AC_ARG_ENABLE(shout2test, [  --disable-shout2test       Do not try to compile and run a test Shout2 program],, enable_shout2test=yes)
14
15   if test "x$shout2_prefix" != "xNONE" ; then
16     shout2_args="$shout2_args --prefix=$shout2_prefix"
17     SHOUT2_CFLAGS="-I$shout2_prefix/include"
18     SHOUT2_LIBS="-L$shout2_prefix/lib"
19   elif test "$prefix" != ""; then
20     shout2_args="$shout2_args --prefix=$prefix"
21     SHOUT2_CFLAGS="-I$prefix/include"
22     SHOUT2_LIBS="-L$prefix/lib"
23   fi
24
25   SHOUT2_LIBS="$SHOUT2_LIBS -lshout -lpthread"
26
27   case $host in
28   *-*-solaris*)
29         SHOUT2_LIBS="$SHOUT2_LIBS -lnsl -lsocket -lresolv"
30   esac
31
32   AC_MSG_CHECKING(for Shout2)
33   no_shout2=""
34
35   if test "x$enable_shout2test" = "xyes" ; then
36     ac_save_CFLAGS="$CFLAGS"
37     ac_save_LIBS="$LIBS"
38     CFLAGS="$CFLAGS $SHOUT2_CFLAGS $OGG_CFLAGS $VORBIS_CFLAGS"
39     LIBS="$LIBS $SHOUT2_LIBS $OGG_LIBS $VORBIS_LIBS"
40 dnl
41 dnl Now check if the installed Shout2 is sufficiently new.
42 dnl
43       rm -f conf.shout2test
44       AC_TRY_RUN([
45 #include <stdio.h>
46 #include <stdlib.h>
47 #include <string.h>
48 #include <shout/shout.h>
49
50 int main ()
51 {
52   system("touch conf.shout2test");
53   return 0;
54 }
55
56 ],, no_shout2=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
57        CFLAGS="$ac_save_CFLAGS"
58        LIBS="$ac_save_LIBS"
59   fi
60
61   if test "x$no_shout2" = "x" ; then
62      AC_MSG_RESULT(yes)
63      ifelse([$1], , :, [$1])     
64   else
65      AC_MSG_RESULT(no)
66      if test -f conf.shout2test ; then
67        :
68      else
69        echo "*** Could not run Shout2 test program, checking why..."
70        CFLAGS="$CFLAGS $SHOUT2_CFLAGS $OGG_CFLAGS $VORBIS_CFLAGS"
71        LIBS="$LIBS $SHOUT2_LIBS $OGG_LIBS $VORBIS_LIBS"
72        AC_TRY_LINK([
73 #include <stdio.h>
74 #include <shout/shout.h>
75 ],     [ return 0; ],
76        [ echo "*** The test program compiled, but did not run. This usually means"
77        echo "*** that the run-time linker is not finding Shout2 or finding the wrong"
78        echo "*** version of Shout2. If it is not finding Shout2, you'll need to set your"
79        echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
80        echo "*** to the installed location  Also, make sure you have run ldconfig if that"
81        echo "*** is required on your system"
82        echo "***"
83        echo "*** If you have an old version installed, it is best to remove it, although"
84        echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
85        [ echo "*** The test program failed to compile or link. See the file config.log for the"
86        echo "*** exact error that occured. This usually means Shout2 was incorrectly installed"
87        echo "*** or that you have moved Shout2 since it was installed. In the latter case, you"
88        echo "*** may want to edit the shout-config script: $SHOUT2_CONFIG" ])
89        CFLAGS="$ac_save_CFLAGS"
90        LIBS="$ac_save_LIBS"
91      fi
92      SHOUT2_CFLAGS=""
93      SHOUT2_LIBS=""
94      ifelse([$2], , :, [$2])
95   fi
96   AC_SUBST(SHOUT2_CFLAGS)
97   AC_SUBST(SHOUT2_LIBS)
98   rm -f conf.shout2test
99 ])