ogg.m4 3.86 KB
Newer Older
1 2 3 4
# Configure paths for libogg
# Jack Moffitt <jack@icecast.org> 10-21-2000
# Shamelessly stolen from Owen Taylor and Manish Singh

5
dnl XIPH_PATH_OGG([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
6 7
dnl Test for libogg, and define OGG_CFLAGS and OGG_LIBS
dnl
8
AC_DEFUN([XIPH_PATH_OGG],
Ralph Giles's avatar
Ralph Giles committed
9
[dnl
10
dnl Get the cflags and libraries
11
dnl
12 13 14 15
AC_ARG_WITH(ogg,AC_HELP_STRING([--with-ogg=PFX],[Prefix where libogg is installed (optional)]), ogg_prefix="$withval", ogg_prefix="")
AC_ARG_WITH(ogg-libraries,AC_HELP_STRING([--with-ogg-libraries=DIR],[Directory where libogg library is installed (optional)]), ogg_libraries="$withval", ogg_libraries="")
AC_ARG_WITH(ogg-includes,AC_HELP_STRING([--with-ogg-includes=DIR],[Directory where libogg header files are installed (optional)]), ogg_includes="$withval", ogg_includes="")
AC_ARG_ENABLE(oggtest,AC_HELP_STRING([--disable-oggtest],[Do not try to compile and run a test Ogg program]),, enable_oggtest=yes)
16

17 18
  if test "x$ogg_libraries" != "x" ; then
    OGG_LIBS="-L$ogg_libraries"
19 20
  elif test "x$ogg_prefix" = "xno" || test "x$ogg_prefix" = "xyes" ; then
    OGG_LIBS=""
21
  elif test "x$ogg_prefix" != "x" ; then
22
    OGG_LIBS="-L$ogg_prefix/lib"
23
  elif test "x$prefix" != "xNONE" ; then
24
    OGG_LIBS="-L$prefix/lib"
25 26
  fi

27 28 29
  if test "x$ogg_prefix" != "xno" ; then
    OGG_LIBS="$OGG_LIBS -logg"
  fi
30

31 32
  if test "x$ogg_includes" != "x" ; then
    OGG_CFLAGS="-I$ogg_includes"
33 34
  elif test "x$ogg_prefix" = "xno" || test "x$ogg_prefix" = "xyes" ; then
    OGG_CFLAGS=""
Stan Seibert's avatar
Stan Seibert committed
35
  elif test "x$ogg_prefix" != "x" ; then
36
    OGG_CFLAGS="-I$ogg_prefix/include"
37
  elif test "x$prefix" != "xNONE"; then
38 39 40
    OGG_CFLAGS="-I$prefix/include"
  fi

41
  AC_MSG_CHECKING(for Ogg)
42 43 44 45 46 47
  if test "x$ogg_prefix" = "xno" ; then
    no_ogg="disabled"
    enable_oggtest="no"
  else
    no_ogg=""
  fi
48

49 50 51 52 53 54

  if test "x$enable_oggtest" = "xyes" ; then
    ac_save_CFLAGS="$CFLAGS"
    ac_save_LIBS="$LIBS"
    CFLAGS="$CFLAGS $OGG_CFLAGS"
    LIBS="$LIBS $OGG_LIBS"
55
dnl
56
dnl Now check if the installed Ogg is sufficiently new.
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
dnl
      rm -f conf.oggtest
      AC_TRY_RUN([
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ogg/ogg.h>

int main ()
{
  system("touch conf.oggtest");
  return 0;
}

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

76 77 78 79
  if test "x$no_ogg" = "xdisabled" ; then
     AC_MSG_RESULT(no)
     ifelse([$2], , :, [$2])
  elif test "x$no_ogg" = "x" ; then
80
     AC_MSG_RESULT(yes)
81
     ifelse([$1], , :, [$1])
82 83
  else
     AC_MSG_RESULT(no)
84 85
     if test -f conf.oggtest ; then
       :
86
     else
87 88 89 90
       echo "*** Could not run Ogg test program, checking why..."
       CFLAGS="$CFLAGS $OGG_CFLAGS"
       LIBS="$LIBS $OGG_LIBS"
       AC_TRY_LINK([
91 92
#include <stdio.h>
#include <ogg/ogg.h>
93 94 95 96 97 98 99 100 101 102 103 104
],     [ return 0; ],
       [ echo "*** The test program compiled, but did not run. This usually means"
       echo "*** that the run-time linker is not finding Ogg or finding the wrong"
       echo "*** version of Ogg. If it is not finding Ogg, 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 Ogg was incorrectly installed"
Michael Smith's avatar
Michael Smith committed
105
       echo "*** or that you have moved Ogg since it was installed." ])
106 107
       CFLAGS="$ac_save_CFLAGS"
       LIBS="$ac_save_LIBS"
108 109 110
     fi
     OGG_CFLAGS=""
     OGG_LIBS=""
111
     ifelse([$2], , :, [$2])
112 113 114 115 116
  fi
  AC_SUBST(OGG_CFLAGS)
  AC_SUBST(OGG_LIBS)
  rm -f conf.oggtest
])