speex.m4 2.28 KB
Newer Older
j's avatar
j committed
1 2 3 4 5 6 7 8 9 10
# Configure paths for libspeex
# updated by Karl Heyes 02-Feb-2004

dnl XIPH_PATH_SPEEX([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
dnl Test for libspeex, and define SPEEX_CFLAGS SPEEX_LIBS
dnl SPEEX_SPEEXENC_LIBS SPEEX_SPEEXFILE_LIBS SPEEX_LDFLAGS
dnl

AC_DEFUN([XIPH_PATH_SPEEX],
[
Karl Heyes's avatar
Karl Heyes committed
11
AC_REQUIRE([XIPH_PATH_OGG])
j's avatar
j committed
12 13 14 15 16 17 18 19 20 21

dnl Get the cflags and libraries for speex
dnl
AC_ARG_VAR([SPEEX],[path to speex installation])
AC_ARG_WITH(speex,
    AC_HELP_STRING([--with-speex=PREFIX],
        [Prefix where libspeex is installed (optional)]),
    speex_prefix="$withval",
    speex_prefix="$SPEEX_PREFIX"
    )
Karl Heyes's avatar
Karl Heyes committed
22 23 24 25
if test "x$with_speex" = "xno"
then
  AC_MSG_RESULT([Speex support disabled by request])
else
26
  if test "x$speex_prefix" = "x" -o "x$speex_prefix" = "xyes"; then
Karl Heyes's avatar
Karl Heyes committed
27 28 29 30 31 32
      if test "x$prefix" = "xNONE"; then
          speex_prefix="/usr/local"
      else
          speex_prefix="$prefix"
      fi
  fi
j's avatar
j committed
33

Karl Heyes's avatar
Karl Heyes committed
34 35 36 37 38 39 40 41
  SPEEX_CFLAGS="$OGG_CFLAGS"
  SPEEX_LDFLAGS="$OGG_LDFLAGS"
  if test "x$speex_prefix" != "x$ogg_prefix"; then
      XIPH_GCC_WARNING(-I"$speex_prefix/include",,
              [SPEEX_CFLAGS="$SPEEX_CFLAGS -I$speex_prefix/include"
              SPEEX_LDFLAGS="-L$speex_prefix/lib $SPEEX_LDFLAGS"
              ])
  fi
j's avatar
j committed
42

Karl Heyes's avatar
Karl Heyes committed
43
  SPEEX_LIBS="-lspeex"
j's avatar
j committed
44

Karl Heyes's avatar
Karl Heyes committed
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
  xt_save_LIBS="$LIBS"
  xt_save_LDFLAGS="$LDFLAGS"
  LDFLAGS="$LDFLAGS $SPEEX_LDFLAGS"
  LIBS="$LIBS $SPEEX_LIBS"
  xt_have_speex="yes"
  AC_MSG_CHECKING([for libspeex])
  AC_TRY_LINK_FUNC(ogg_stream_init, [AC_MSG_RESULT([ok])],
          [LIBS="$LIBS $OGG_LIBS"
          AC_TRY_LINK_FUNC(ogg_stream_init,
              [SPEEX_LIBS="$SPEEX_LIBS $OGG_LIBS"],
              [xt_have_speex="no"])
          ])
  if test "x$xt_have_speex" = "xyes"
  then
      AC_LINK_IFELSE([AC_LANG_PROGRAM(
                  [#include <speex/speex_header.h>],
                  [void *p = speex_packet_to_header;])],
              [],
              [xt_have_speex="no"])
  fi
j's avatar
j committed
65

Karl Heyes's avatar
Karl Heyes committed
66 67 68 69 70 71 72
  LIBS="$xt_save_LIBS"
  LDFLAGS="$xt_save_LDFLAGS"
  
  if test "x$xt_have_speex" = "xyes"
  then
      AC_MSG_RESULT([ok])
      AC_DEFINE([HAVE_SPEEX],[1],[Define if Speex support is available])
Karl Heyes's avatar
Karl Heyes committed
73
      $1
Karl Heyes's avatar
Karl Heyes committed
74 75 76 77 78 79 80 81 82
  else
      ifelse([$2], , AC_MSG_ERROR([Unable to link to libspeex]), [$2])
      SPEEX_CFLAGS=""
      SPEEX_LDFLAGS=""
      SPEEX_LIBS=""
  fi
  AC_SUBST(SPEEX_CFLAGS)
  AC_SUBST(SPEEX_LDFLAGS)
  AC_SUBST(SPEEX_LIBS)
j's avatar
j committed
83 84
fi
])