a52.m4 3.61 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
dnl
dnl A52_CHECK-LIBHEADER(FEATURE-NAME, LIB-NAME, LIB-FUNCTION, HEADER-NAME,
dnl                     ACTION-IF-FOUND, ACTION-IF-NOT-FOUND,
dnl                     EXTRA-LDFLAGS, EXTRA-CPPFLAGS)
dnl
dnl FEATURE-NAME        - feature name; library and header files are treated
dnl                       as feature, which we look for
dnl LIB-NAME            - library name as in AC_CHECK_LIB macro
dnl LIB-FUNCTION        - library symbol as in AC_CHECK_LIB macro
dnl HEADER-NAME         - header file name as in AC_CHECK_HEADER
dnl ACTION-IF-FOUND     - when feature is found then execute given action
dnl ACTION-IF-NOT-FOUND - when feature is not found then execute given action
dnl EXTRA-LDFLAGS       - extra linker flags (-L or -l)
dnl EXTRA-CPPFLAGS      - extra C preprocessor flags, i.e. -I/usr/X11R6/include
dnl
dnl Based on GST_CHECK_LIBHEADER from gstreamer plugins 0.3.1.
dnl
18
AC_DEFUN([A52_CHECK_LIBHEADER],
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
[
  AC_CHECK_LIB([$2], [$3], HAVE_[$1]=yes, HAVE_[$1]=no, [$7])
  check_libheader_feature_name=translit([$1], A-Z, a-z)

  if test "x$HAVE_[$1]" = "xyes"; then
    check_libheader_save_CPPFLAGS=$CPPFLAGS
    CPPFLAGS="[$8] $CPPFLAGS"
    AC_CHECK_HEADER([$4], :, HAVE_[$1]=no)
    CPPFLAGS=$check_libheader_save_CPPFLAGS
  fi

  if test "x$HAVE_[$1]" = "xyes"; then
    ifelse([$5], , :, [$5])
  else
    ifelse([$6], , :, [$6])
  fi
]
)

dnl
dnl AC_CHECK_A52DEC(ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
dnl
dnl ACTION-IF-FOUND     - when feature is found then execute given action
dnl ACTION-IF-NOT-FOUND - when feature is not found then execute given action
dnl
dnl Defines HAVE_A52DEC to yes if liba52 is found
dnl
dnl CFLAGS and LDFLAGS for the library are stored in A52DEC_CFLAGS and
dnl A52DEC_LIBS, respectively
dnl
dnl Based on GST_CHECK_A52DEC from gstreamer plugins 0.3.3.1
dnl Thomas Vander Stichele <thomas@apestaart.org>, Andy Wingo <wingo@pobox.com>
dnl
52
AC_DEFUN([AC_CHECK_A52DEC], 
53 54
[dnl
AC_ARG_WITH(a52dec-prefix,
55 56
    AC_HELP_STRING([--with-a52dec-prefix=PFX],
                   [prefix where a52dec is installed (optional)]),
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
    a52dec_config_prefix="$withval", a52dec_config_prefix="")

if test x$a52dec_config_prefix = x ; then
    A52_CHECK_LIBHEADER(A52DEC, a52, a52_init, a52dec/a52.h,
        A52DEC_LIBS="-la52 -lm", , -lm)
else
    A52_CHECK_LIBHEADER(A52DEC, a52, a52_init, a52dec/a52.h, [
            A52DEC_LIBS="-la52 -L$a52dec_config_prefix/lib -lm"
            A52DEC_CFLAGS="-I$a52dec_config_prefix/include"
        ], , -L$a52dec_config_prefix/lib, -I$a52dec_config_prefix/include)
fi

if test $HAVE_A52DEC = "yes"; then
    ac_save_CFLAGS="$CFLAGS"
    ac_save_LIBS="$LIBS"
    CFLAGS="$CFLAGS $A52DEC_CFLAGS"
    LIBS="$A52DEC_LIBS $LIBS"
    AC_TRY_RUN([
#include <inttypes.h>
#include <a52dec/a52.h>

int 
main ()
{
  a52_state_t *state;
82 83
  state = a52_init (0);
  a52_free (state);
84 85 86 87 88
  return 0;
}
        ],, HAVE_A52DEC=no, [echo $ac_n "cross compiling; assumed OK... $ac_c"])

    if test HAVE_A52DEC = "no"; then
89
        echo "*** Your a52dec is borked somehow. Please update to 0.7.4."
90 91 92 93 94 95 96 97
    else
        AC_TRY_RUN([
#include <inttypes.h>
#include <a52dec/a52.h>

int 
main ()
{
98
  int i = sizeof (a52_state_t);
99 100
  if ( i )
    return 0;
101 102 103 104
}
            ], HAVE_A52DEC=no,, [echo $ac_n "cross compiling; assumed OK... $ac_c"])

        if test HAVE_A52DEC = "no"; then
105
            echo "*** Your a52dec is too old. Please update to 0.7.4."
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
        fi
    fi
    CFLAGS="$ac_save_CFLAGS"
    LIBS="$ac_save_LIBS"
fi

if test HAVE_A52DEC = "no"; then
    A52DEC_CFLAGS=""
    A52DEC_LIBS=""
fi

if test "x$HAVE_A52DEC" = "xyes"; then
  ifelse([$1], , :, [$1])
else
  ifelse([$2], , :, [$2])
fi

AC_SUBST(A52DEC_CFLAGS)
AC_SUBST(A52DEC_LIBS)
])