gst-shout2.m4 3.42 KB
Newer Older
Wim Taymans's avatar
Wim Taymans committed
1 2 3 4 5
# Configure paths for libshout
# Jack Moffitt <jack@icecast.org> 08-06-2001
# Shamelessly stolen from Owen Taylor and Manish Singh

dnl AM_PATH_SHOUT2([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
6
dnl Test for libshout 2, and define SHOUT2_CFLAGS and SHOUT2_LIBS
Wim Taymans's avatar
Wim Taymans committed
7
dnl
8
AC_DEFUN([AM_PATH_SHOUT2],
Wim Taymans's avatar
Wim Taymans committed
9 10 11
[dnl 
dnl Get the cflags and libraries
dnl
12 13
AC_ARG_WITH(shout2-prefix,[  --with-shout2-prefix=PFX   Prefix where libshout2 is installed (optional)], shout2_prefix="$withval", shout2_prefix="")
AC_ARG_ENABLE(shout2test, [  --disable-shout2test       Do not try to compile and run a test shout2 program],, enable_shout2test=yes)
Wim Taymans's avatar
Wim Taymans committed
14 15 16 17

  if test "x$shout2_prefix" != "xNONE" ; then
    SHOUT2_CFLAGS="-I$shout2_prefix/include"
    SHOUT2_LIBS="-L$shout2_prefix/lib"
18
  elif test "x$prefix" != "x"; then
Wim Taymans's avatar
Wim Taymans committed
19 20 21 22 23 24 25 26 27 28 29
    SHOUT2_CFLAGS="-I$prefix/include"
    SHOUT2_LIBS="-L$prefix/lib"
  fi

  SHOUT2_LIBS="$SHOUT2_LIBS -lshout -lpthread"

  case $host in
  *-*-solaris*)
  	SHOUT2_LIBS="$SHOUT2_LIBS -lnsl -lsocket -lresolv"
  esac

30
  AC_MSG_CHECKING(for shout2)
Wim Taymans's avatar
Wim Taymans committed
31 32 33 34 35 36 37 38
  no_shout2=""

  if test "x$enable_shout2test" = "xyes" ; then
    ac_save_CFLAGS="$CFLAGS"
    ac_save_LIBS="$LIBS"
    CFLAGS="$CFLAGS $SHOUT2_CFLAGS $OGG_CFLAGS $VORBIS_CFLAGS"
    LIBS="$LIBS $SHOUT2_LIBS $OGG_LIBS $VORBIS_LIBS"
dnl
39
dnl Now check if the installed shout2 is sufficiently new.
Wim Taymans's avatar
Wim Taymans committed
40 41 42 43 44 45 46 47 48 49
dnl
      rm -f conf.shout2test
      AC_TRY_RUN([
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <shout/shout.h>

int main ()
{
50 51
  int major, minor, patch;

Wim Taymans's avatar
Wim Taymans committed
52
  system("touch conf.shout2test");
53 54 55
  shout_version(&major, &minor, &patch);
  if (major < 2)
    return 1;
Wim Taymans's avatar
Wim Taymans committed
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
  return 0;
}

],, no_shout2=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
       CFLAGS="$ac_save_CFLAGS"
       LIBS="$ac_save_LIBS"
  fi

  if test "x$no_shout2" = "x" ; then
     AC_MSG_RESULT(yes)
     ifelse([$1], , :, [$1])     
  else
     AC_MSG_RESULT(no)
     if test -f conf.shout2test ; then
       :
     else
       echo "*** Could not run Shout2 test program, checking why..."
       CFLAGS="$CFLAGS $SHOUT2_CFLAGS $OGG_CFLAGS $VORBIS_CFLAGS"
       LIBS="$LIBS $SHOUT2_LIBS $OGG_LIBS $VORBIS_LIBS"
       AC_TRY_LINK([
#include <stdio.h>
#include <shout/shout.h>
],     [ return 0; ],
       [ echo "*** The test program compiled, but did not run. This usually means"
       echo "*** that the run-time linker is not finding Shout2 or finding the wrong"
       echo "*** version of Shout2. If it is not finding Shout2, you'll need to set your"
       echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
       echo "*** to the installed location  Also, make sure you have run ldconfig if that"
       echo "*** is required on your system"
       echo "***"
       echo "*** If you have an old version installed, it is best to remove it, although"
       echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
       [ echo "*** The test program failed to compile or link. See the file config.log for the"
       echo "*** exact error that occured. This usually means Shout2 was incorrectly installed"
       echo "*** or that you have moved Shout2 since it was installed. In the latter case, you"
       echo "*** may want to edit the shout-config script: $SHOUT2_CONFIG" ])
       CFLAGS="$ac_save_CFLAGS"
       LIBS="$ac_save_LIBS"
     fi
     SHOUT2_CFLAGS=""
     SHOUT2_LIBS=""
     ifelse([$2], , :, [$2])
  fi
  AC_SUBST(SHOUT2_CFLAGS)
  AC_SUBST(SHOUT2_LIBS)
  rm -f conf.shout2test
])