Blame vorbis.m4

Packit 06404a
# Configure paths for libvorbis
Packit 06404a
# Jack Moffitt <jack@icecast.org> 10-21-2000
Packit 06404a
# Shamelessly stolen from Owen Taylor and Manish Singh
Packit 06404a
# thomasvs added check for vorbis_bitrate_addblock which is new in rc3
Packit 06404a
Packit 06404a
dnl XIPH_PATH_VORBIS([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
Packit 06404a
dnl Test for libvorbis, and define VORBIS_CFLAGS and VORBIS_LIBS
Packit 06404a
dnl
Packit 06404a
AC_DEFUN([XIPH_PATH_VORBIS],
Packit 06404a
[dnl 
Packit 06404a
dnl Get the cflags and libraries
Packit 06404a
dnl
Packit 06404a
AC_ARG_WITH(vorbis,AC_HELP_STRING([--with-vorbis=PFX],[Prefix where libvorbis is installed (optional)]), vorbis_prefix="$withval", vorbis_prefix="")
Packit 06404a
AC_ARG_WITH(vorbis-libraries,AC_HELP_STRING([--with-vorbis-libraries=DIR],[Directory where libvorbis library is installed (optional)]), vorbis_libraries="$withval", vorbis_libraries="")
Packit 06404a
AC_ARG_WITH(vorbis-includes,AC_HELP_STRING([--with-vorbis-includes=DIR],[Directory where libvorbis header files are installed (optional)]), vorbis_includes="$withval", vorbis_includes="")
Packit 06404a
AC_ARG_ENABLE(vorbistest,AC_HELP_STRING([--disable-vorbistest],[Do not try to compile and run a test Vorbis program]),, enable_vorbistest=yes)
Packit 06404a
Packit 06404a
  if test "x$vorbis_libraries" != "x" ; then
Packit 06404a
    VORBIS_LIBS="-L$vorbis_libraries"
Packit 06404a
  elif test "x$vorbis_prefix" = "xno" || test "x$vorbis_prefix" = "xyes" ; then
Packit 06404a
    VORBIS_LIBS=""
Packit 06404a
  elif test "x$vorbis_prefix" != "x" ; then
Packit 06404a
    VORBIS_LIBS="-L$vorbis_prefix/lib"
Packit 06404a
  elif test "x$prefix" != "xNONE"; then
Packit 06404a
    VORBIS_LIBS="-L$prefix/lib"
Packit 06404a
  fi
Packit 06404a
Packit 06404a
  if test "x$vorbis_prefix" != "xno" ; then
Packit 06404a
    VORBIS_LIBS="$VORBIS_LIBS -lvorbis -lm"
Packit 06404a
  fi
Packit 06404a
  VORBISFILE_LIBS="-lvorbisfile"
Packit 06404a
  VORBISENC_LIBS="-lvorbisenc"
Packit 06404a
Packit 06404a
  if test "x$vorbis_includes" != "x" ; then
Packit 06404a
    VORBIS_CFLAGS="-I$vorbis_includes"
Packit 06404a
  elif test "x$vorbis_prefix" = "xno" || test "x$vorbis_prefix" = "xyes" ; then
Packit 06404a
    VORBIS_CFLAGS=""
Packit 06404a
  elif test "x$vorbis_prefix" != "x" ; then
Packit 06404a
    VORBIS_CFLAGS="-I$vorbis_prefix/include"
Packit 06404a
  elif test "x$prefix" != "xNONE"; then
Packit 06404a
    VORBIS_CFLAGS="-I$prefix/include"
Packit 06404a
  fi
Packit 06404a
Packit 06404a
Packit 06404a
  AC_MSG_CHECKING(for Vorbis)
Packit 06404a
  if test "x$vorbis_prefix" = "xno" ; then
Packit 06404a
    no_vorbis="disabled"
Packit 06404a
    enable_vorbistest="no"
Packit 06404a
  else
Packit 06404a
    no_vorbis=""
Packit 06404a
  fi
Packit 06404a
Packit 06404a
Packit 06404a
  if test "x$enable_vorbistest" = "xyes" ; then
Packit 06404a
    ac_save_CFLAGS="$CFLAGS"
Packit 06404a
    ac_save_LIBS="$LIBS"
Packit 06404a
    CFLAGS="$CFLAGS $VORBIS_CFLAGS $OGG_CFLAGS"
Packit 06404a
    LIBS="$LIBS $VORBIS_LIBS $VORBISENC_LIBS $OGG_LIBS"
Packit 06404a
dnl
Packit 06404a
dnl Now check if the installed Vorbis is sufficiently new.
Packit 06404a
dnl
Packit 06404a
      rm -f conf.vorbistest
Packit 06404a
      AC_TRY_RUN([
Packit 06404a
#include <stdio.h>
Packit 06404a
#include <stdlib.h>
Packit 06404a
#include <string.h>
Packit 06404a
#include <vorbis/codec.h>
Packit 06404a
#include <vorbis/vorbisenc.h>
Packit 06404a
Packit 06404a
int main ()
Packit 06404a
{
Packit 06404a
    vorbis_block 	vb;
Packit 06404a
    vorbis_dsp_state	vd;
Packit 06404a
    vorbis_info		vi;
Packit 06404a
Packit 06404a
    vorbis_info_init (&vi;;
Packit 06404a
    vorbis_encode_init (&vi, 2, 44100, -1, 128000, -1);
Packit 06404a
    vorbis_analysis_init (&vd, &vi;;
Packit 06404a
    vorbis_block_init (&vd, &vb;;
Packit 06404a
    /* this function was added in 1.0rc3, so this is what we're testing for */
Packit 06404a
    vorbis_bitrate_addblock (&vb;;
Packit 06404a
Packit 06404a
    system("touch conf.vorbistest");
Packit 06404a
    return 0;
Packit 06404a
}
Packit 06404a
Packit 06404a
],, no_vorbis=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
Packit 06404a
       CFLAGS="$ac_save_CFLAGS"
Packit 06404a
       LIBS="$ac_save_LIBS"
Packit 06404a
  fi
Packit 06404a
Packit 06404a
  if test "x$no_vorbis" = "xdisabled" ; then
Packit 06404a
     AC_MSG_RESULT(no)
Packit 06404a
     ifelse([$2], , :, [$2])
Packit 06404a
  elif test "x$no_vorbis" = "x" ; then
Packit 06404a
     AC_MSG_RESULT(yes)
Packit 06404a
     ifelse([$1], , :, [$1])
Packit 06404a
  else
Packit 06404a
     AC_MSG_RESULT(no)
Packit 06404a
     if test -f conf.vorbistest ; then
Packit 06404a
       :
Packit 06404a
     else
Packit 06404a
       echo "*** Could not run Vorbis test program, checking why..."
Packit 06404a
       CFLAGS="$CFLAGS $VORBIS_CFLAGS"
Packit 06404a
       LIBS="$LIBS $VORBIS_LIBS $OGG_LIBS"
Packit 06404a
       AC_TRY_LINK([
Packit 06404a
#include <stdio.h>
Packit 06404a
#include <vorbis/codec.h>
Packit 06404a
],     [ return 0; ],
Packit 06404a
       [ echo "*** The test program compiled, but did not run. This usually means"
Packit 06404a
       echo "*** that the run-time linker is not finding Vorbis or finding the wrong"
Packit 06404a
       echo "*** version of Vorbis. If it is not finding Vorbis, you'll need to set your"
Packit 06404a
       echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
Packit 06404a
       echo "*** to the installed location  Also, make sure you have run ldconfig if that"
Packit 06404a
       echo "*** is required on your system"
Packit 06404a
       echo "***"
Packit 06404a
       echo "*** If you have an old version installed, it is best to remove it, although"
Packit 06404a
       echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
Packit 06404a
       [ echo "*** The test program failed to compile or link. See the file config.log for the"
Packit 06404a
       echo "*** exact error that occured. This usually means Vorbis was incorrectly installed"
Packit 06404a
       echo "*** or that you have moved Vorbis since it was installed." ])
Packit 06404a
       CFLAGS="$ac_save_CFLAGS"
Packit 06404a
       LIBS="$ac_save_LIBS"
Packit 06404a
     fi
Packit 06404a
     VORBIS_CFLAGS=""
Packit 06404a
     VORBIS_LIBS=""
Packit 06404a
     VORBISFILE_LIBS=""
Packit 06404a
     VORBISENC_LIBS=""
Packit 06404a
     ifelse([$2], , :, [$2])
Packit 06404a
  fi
Packit 06404a
  AC_SUBST(VORBIS_CFLAGS)
Packit 06404a
  AC_SUBST(VORBIS_LIBS)
Packit 06404a
  AC_SUBST(VORBISFILE_LIBS)
Packit 06404a
  AC_SUBST(VORBISENC_LIBS)
Packit 06404a
  rm -f conf.vorbistest
Packit 06404a
])