1# Configure paths for libtheora
2# Karl Heyes 02-Feb-2004
3
4dnl XIPH_PATH_THEORA([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
5dnl Test for libtheora, and define THEORA_CFLAGS THEORA_LIBS
6dnl
7
8AC_DEFUN([XIPH_PATH_THEORA],
9[
10AC_REQUIRE([XIPH_PATH_OGG])
11
12dnl Get the cflags and libraries for theora
13dnl
14AC_ARG_VAR([THEORA],[path to theora installation])
15AC_ARG_WITH(theora,
16    AC_HELP_STRING([--with-theora=PREFIX],
17        [Prefix where libtheora is installed (optional)]),
18    theora_prefix="$withval",
19    theora_prefix="$THEORA_PREFIX"
20    )
21
22if test "x$with_theora" = "xno"
23then
24  AC_MSG_RESULT([Theora support disabled by request])
25else
26  if test "x$theora_prefix" = "x" -o "x$theora_prefix" = "xyes"; then
27    if test "x$prefix" = "xNONE"; then
28        theora_prefix="/usr/local"
29    else
30        theora_prefix="$prefix"
31    fi
32  fi
33
34  THEORA_CFLAGS="$OGG_CFLAGS"
35  THEORA_LDFLAGS="$OGG_LDFLAGS"
36  if test "x$theora_prefix" != "x$ogg_prefix"; then
37      XIPH_GCC_WARNING(-I"$theora_prefix/include",,
38              [THEORA_CFLAGS="$THEORA_CFLAGS -I$theora_prefix/include"
39              THEORA_LDFLAGS="-L$theora_prefix/lib $THEORA_LDFLAGS"
40              ])
41  fi
42
43  THEORA_LIBS="-ltheora -logg"
44
45  ac_save_LIBS="$LIBS"
46  ac_save_LDFLAGS="$LDFLAGS"
47  LDFLAGS="$LDFLAGS $THEORA_LDFLAGS"
48  LIBS="$LIBS $THEORA_LIBS"
49  AC_MSG_CHECKING([for libtheora])
50  AC_TRY_LINK_FUNC(theora_decode_header, [xt_have_theora="yes"],
51          [xt_have_theora="Not found"])
52  if test "x$xt_have_theora" = "xyes"
53  then
54    AC_TRY_LINK_FUNC(theora_packet_isheader, [xt_have_theora="yes"],
55          [xt_have_theora="newer version required"])
56  fi
57
58  LIBS="$ac_save_LIBS"
59  LDFLAGS="$ac_save_LDFLAGS"
60
61  if test "x$xt_have_theora" = "xyes"
62  then
63    AC_MSG_RESULT([ok])
64    AC_DEFINE([HAVE_THEORA],[1],[Define if Theora support is available])
65    $1
66  else
67    THEORA_CFLAGS=""
68    THEORA_LDFLAGS=""
69    THEORA_LIBS=""
70    AC_MSG_RESULT([$xt_have_theora])
71    $2
72  fi
73fi
74AC_SUBST(THEORA_CFLAGS)
75AC_SUBST(THEORA_LDFLAGS)
76AC_SUBST(THEORA_LIBS)
77])
78