1# Configure paths for libogg
2# Jack Moffitt <jack@icecast.org> 10-21-2000
3# Shamelessly stolen from Owen Taylor and Manish Singh
4
5dnl XIPH_PATH_OGG([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
6dnl Test for libogg, and define OGG_CFLAGS and OGG_LIBS
7dnl
8AC_DEFUN([XIPH_PATH_OGG],
9[dnl
10dnl Get the cflags and libraries
11dnl
12AC_ARG_WITH(ogg,
13	    AS_HELP_STRING([--with-ogg=PFX],
14	    		   [Prefix where libogg is installed (optional)]),
15	    [ogg_prefix="$withval"], [ogg_prefix=""])
16AC_ARG_WITH(ogg-libraries,
17	    AS_HELP_STRING([--with-ogg-libraries=DIR],
18	    		   [Directory where libogg library is installed (optional)]),
19	    [ogg_libraries="$withval"], [ogg_libraries=""])
20AC_ARG_WITH(ogg-includes,
21	    AS_HELP_STRING([--with-ogg-includes=DIR],
22	    		   [Directory where libogg header files are installed (optional)]),
23	    [ogg_includes="$withval"], [ogg_includes=""])
24AC_ARG_ENABLE(oggtest,
25	      AS_HELP_STRING([--disable-oggtest],
26	      		     [Do not try to compile and run a test Ogg program]),,
27	      [enable_oggtest=yes])
28
29  if test "x$ogg_libraries" != "x" ; then
30    OGG_LIBS="-L$ogg_libraries"
31  elif test "x$ogg_prefix" != "x" ; then
32    OGG_LIBS="-L$ogg_prefix/lib"
33  elif test "x$prefix" != "xNONE" ; then
34    OGG_LIBS="-L$prefix/lib"
35  fi
36
37  OGG_LIBS="$OGG_LIBS -logg"
38
39  if test "x$ogg_includes" != "x" ; then
40    OGG_CFLAGS="-I$ogg_includes"
41  elif test "x$ogg_prefix" != "x" ; then
42    OGG_CFLAGS="-I$ogg_prefix/include"
43  elif test "x$prefix" != "xNONE"; then
44    OGG_CFLAGS="-I$prefix/include"
45  fi
46
47  AC_MSG_CHECKING(for Ogg)
48  no_ogg=""
49
50
51  if test "x$enable_oggtest" = "xyes" ; then
52    ac_save_CFLAGS="$CFLAGS"
53    ac_save_LIBS="$LIBS"
54    CFLAGS="$CFLAGS $OGG_CFLAGS"
55    LIBS="$LIBS $OGG_LIBS"
56dnl
57dnl Now check if the installed Ogg is sufficiently new.
58dnl
59      rm -f conf.oggtest
60      AC_TRY_RUN([
61#include <stdio.h>
62#include <stdlib.h>
63#include <string.h>
64#include <ogg/ogg.h>
65
66int main ()
67{
68  system("touch conf.oggtest");
69  return 0;
70}
71
72],, no_ogg=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
73       CFLAGS="$ac_save_CFLAGS"
74       LIBS="$ac_save_LIBS"
75  fi
76
77  if test "x$no_ogg" = "x" ; then
78     AC_MSG_RESULT(yes)
79     ifelse([$1], , :, [$1])
80  else
81     AC_MSG_RESULT(no)
82     if test -f conf.oggtest ; then
83       :
84     else
85       echo "*** Could not run Ogg test program, checking why..."
86       CFLAGS="$CFLAGS $OGG_CFLAGS"
87       LIBS="$LIBS $OGG_LIBS"
88       AC_TRY_LINK([
89#include <stdio.h>
90#include <ogg/ogg.h>
91],     [ return 0; ],
92       [ echo "*** The test program compiled, but did not run. This usually means"
93       echo "*** that the run-time linker is not finding Ogg or finding the wrong"
94       echo "*** version of Ogg. If it is not finding Ogg, you'll need to set your"
95       echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
96       echo "*** to the installed location  Also, make sure you have run ldconfig if that"
97       echo "*** is required on your system"
98       echo "***"
99       echo "*** If you have an old version installed, it is best to remove it, although"
100       echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
101       [ echo "*** The test program failed to compile or link. See the file config.log for the"
102       echo "*** exact error that occured. This usually means Ogg was incorrectly installed"
103       echo "*** or that you have moved Ogg since it was installed." ])
104       CFLAGS="$ac_save_CFLAGS"
105       LIBS="$ac_save_LIBS"
106     fi
107     OGG_CFLAGS=""
108     OGG_LIBS=""
109     ifelse([$2], , :, [$2])
110  fi
111  AC_SUBST(OGG_CFLAGS)
112  AC_SUBST(OGG_LIBS)
113  rm -f conf.oggtest
114])
115