153a5a1b3Sopenharmony_ci# Configure paths for libogg
253a5a1b3Sopenharmony_ci# Jack Moffitt <jack@icecast.org> 10-21-2000
353a5a1b3Sopenharmony_ci# Shamelessly stolen from Owen Taylor and Manish Singh
453a5a1b3Sopenharmony_ci
553a5a1b3Sopenharmony_cidnl XIPH_PATH_OGG([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
653a5a1b3Sopenharmony_cidnl Test for libogg, and define OGG_CFLAGS and OGG_LIBS
753a5a1b3Sopenharmony_cidnl
853a5a1b3Sopenharmony_ciAC_DEFUN([XIPH_PATH_OGG],
953a5a1b3Sopenharmony_ci[dnl 
1053a5a1b3Sopenharmony_cidnl Get the cflags and libraries
1153a5a1b3Sopenharmony_cidnl
1253a5a1b3Sopenharmony_ciAC_ARG_WITH(ogg,[  --with-ogg=PFX   Prefix where libogg is installed (optional)], ogg_prefix="$withval", ogg_prefix="")
1353a5a1b3Sopenharmony_ciAC_ARG_WITH(ogg-libraries,[  --with-ogg-libraries=DIR   Directory where libogg library is installed (optional)], ogg_libraries="$withval", ogg_libraries="")
1453a5a1b3Sopenharmony_ciAC_ARG_WITH(ogg-includes,[  --with-ogg-includes=DIR   Directory where libogg header files are installed (optional)], ogg_includes="$withval", ogg_includes="")
1553a5a1b3Sopenharmony_ciAC_ARG_ENABLE(oggtest, [  --disable-oggtest       Do not try to compile and run a test Ogg program],, enable_oggtest=yes)
1653a5a1b3Sopenharmony_ci
1753a5a1b3Sopenharmony_ci  if test "x$ogg_libraries" != "x" ; then
1853a5a1b3Sopenharmony_ci    OGG_LIBS="-L$ogg_libraries"
1953a5a1b3Sopenharmony_ci  elif test "x$ogg_prefix" != "x" ; then
2053a5a1b3Sopenharmony_ci    OGG_LIBS="-L$ogg_prefix/lib"
2153a5a1b3Sopenharmony_ci  elif test "x$prefix" != "xNONE" ; then
2253a5a1b3Sopenharmony_ci    OGG_LIBS="-L$prefix/lib"
2353a5a1b3Sopenharmony_ci  fi
2453a5a1b3Sopenharmony_ci
2553a5a1b3Sopenharmony_ci  OGG_LIBS="$OGG_LIBS -logg"
2653a5a1b3Sopenharmony_ci
2753a5a1b3Sopenharmony_ci  if test "x$ogg_includes" != "x" ; then
2853a5a1b3Sopenharmony_ci    OGG_CFLAGS="-I$ogg_includes"
2953a5a1b3Sopenharmony_ci  elif test "x$ogg_prefix" != "x" ; then
3053a5a1b3Sopenharmony_ci    OGG_CFLAGS="-I$ogg_prefix/include"
3153a5a1b3Sopenharmony_ci  elif test "x$prefix" != "xNONE"; then
3253a5a1b3Sopenharmony_ci    OGG_CFLAGS="-I$prefix/include"
3353a5a1b3Sopenharmony_ci  fi
3453a5a1b3Sopenharmony_ci
3553a5a1b3Sopenharmony_ci  AC_MSG_CHECKING(for Ogg)
3653a5a1b3Sopenharmony_ci  no_ogg=""
3753a5a1b3Sopenharmony_ci
3853a5a1b3Sopenharmony_ci
3953a5a1b3Sopenharmony_ci  if test "x$enable_oggtest" = "xyes" ; then
4053a5a1b3Sopenharmony_ci    ac_save_CFLAGS="$CFLAGS"
4153a5a1b3Sopenharmony_ci    ac_save_LIBS="$LIBS"
4253a5a1b3Sopenharmony_ci    CFLAGS="$CFLAGS $OGG_CFLAGS"
4353a5a1b3Sopenharmony_ci    LIBS="$LIBS $OGG_LIBS"
4453a5a1b3Sopenharmony_cidnl
4553a5a1b3Sopenharmony_cidnl Now check if the installed Ogg is sufficiently new.
4653a5a1b3Sopenharmony_cidnl
4753a5a1b3Sopenharmony_ci      rm -f conf.oggtest
4853a5a1b3Sopenharmony_ci      AC_TRY_RUN([
4953a5a1b3Sopenharmony_ci#include <stdio.h>
5053a5a1b3Sopenharmony_ci#include <stdlib.h>
5153a5a1b3Sopenharmony_ci#include <string.h>
5253a5a1b3Sopenharmony_ci#include <ogg/ogg.h>
5353a5a1b3Sopenharmony_ci
5453a5a1b3Sopenharmony_ciint main ()
5553a5a1b3Sopenharmony_ci{
5653a5a1b3Sopenharmony_ci  system("touch conf.oggtest");
5753a5a1b3Sopenharmony_ci  return 0;
5853a5a1b3Sopenharmony_ci}
5953a5a1b3Sopenharmony_ci
6053a5a1b3Sopenharmony_ci],, no_ogg=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
6153a5a1b3Sopenharmony_ci       CFLAGS="$ac_save_CFLAGS"
6253a5a1b3Sopenharmony_ci       LIBS="$ac_save_LIBS"
6353a5a1b3Sopenharmony_ci  fi
6453a5a1b3Sopenharmony_ci
6553a5a1b3Sopenharmony_ci  if test "x$no_ogg" = "x" ; then
6653a5a1b3Sopenharmony_ci     AC_MSG_RESULT(yes)
6753a5a1b3Sopenharmony_ci     ifelse([$1], , :, [$1])     
6853a5a1b3Sopenharmony_ci  else
6953a5a1b3Sopenharmony_ci     AC_MSG_RESULT(no)
7053a5a1b3Sopenharmony_ci     if test -f conf.oggtest ; then
7153a5a1b3Sopenharmony_ci       :
7253a5a1b3Sopenharmony_ci     else
7353a5a1b3Sopenharmony_ci       echo "*** Could not run Ogg test program, checking why..."
7453a5a1b3Sopenharmony_ci       CFLAGS="$CFLAGS $OGG_CFLAGS"
7553a5a1b3Sopenharmony_ci       LIBS="$LIBS $OGG_LIBS"
7653a5a1b3Sopenharmony_ci       AC_TRY_LINK([
7753a5a1b3Sopenharmony_ci#include <stdio.h>
7853a5a1b3Sopenharmony_ci#include <ogg/ogg.h>
7953a5a1b3Sopenharmony_ci],     [ return 0; ],
8053a5a1b3Sopenharmony_ci       [ echo "*** The test program compiled, but did not run. This usually means"
8153a5a1b3Sopenharmony_ci       echo "*** that the run-time linker is not finding Ogg or finding the wrong"
8253a5a1b3Sopenharmony_ci       echo "*** version of Ogg. If it is not finding Ogg, you'll need to set your"
8353a5a1b3Sopenharmony_ci       echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
8453a5a1b3Sopenharmony_ci       echo "*** to the installed location  Also, make sure you have run ldconfig if that"
8553a5a1b3Sopenharmony_ci       echo "*** is required on your system"
8653a5a1b3Sopenharmony_ci       echo "***"
8753a5a1b3Sopenharmony_ci       echo "*** If you have an old version installed, it is best to remove it, although"
8853a5a1b3Sopenharmony_ci       echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
8953a5a1b3Sopenharmony_ci       [ echo "*** The test program failed to compile or link. See the file config.log for the"
9053a5a1b3Sopenharmony_ci       echo "*** exact error that occured. This usually means Ogg was incorrectly installed"
9153a5a1b3Sopenharmony_ci       echo "*** or that you have moved Ogg since it was installed." ])
9253a5a1b3Sopenharmony_ci       CFLAGS="$ac_save_CFLAGS"
9353a5a1b3Sopenharmony_ci       LIBS="$ac_save_LIBS"
9453a5a1b3Sopenharmony_ci     fi
9553a5a1b3Sopenharmony_ci     OGG_CFLAGS=""
9653a5a1b3Sopenharmony_ci     OGG_LIBS=""
9753a5a1b3Sopenharmony_ci     ifelse([$2], , :, [$2])
9853a5a1b3Sopenharmony_ci  fi
9953a5a1b3Sopenharmony_ci  AC_SUBST(OGG_CFLAGS)
10053a5a1b3Sopenharmony_ci  AC_SUBST(OGG_LIBS)
10153a5a1b3Sopenharmony_ci  rm -f conf.oggtest
10253a5a1b3Sopenharmony_ci])
103