pad: fix alignment to non-power-of-two number of samples
[sox/ew.git] / m4 / sndfile.m4
blob8724d69593f62f255eb6115c524fb862d05b0487
1 dnl SOX_PATH_SNDFILE
2 dnl Based off of shout.m4 from xiph package.
3 dnl cbagwell@users.sourceforge.net 1-3-2007
4 dnl
5 dnl Original Authors:
6 dnl Jack Moffitt <jack@icecast.org> 08-06-2001
7 dnl Rewritten for libshout 2
8 dnl Brendan Cully <brendan@xiph.org> 20030612
9 dnl
10 # SOX_PATH_SNDFILE([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
11 # Test for libsndfile, and define SNDFILE_CFLAGS and SNDFILE_LIBS
12 AC_DEFUN([SOX_PATH_SNDFILE],
13 [dnl
14 # Step 1: Use pkg-config if available
15 m4_ifdef([PKG_CHECK_MODULES],
16   [# PKG_CHECK_MODULES available
17   PKG_CHECK_MODULES(SNDFILE, sndfile, have_sndfile="maybe", 
18                     have_sndfile="no")],
19   [# Step 2: use pkg-config manually if available
20   AC_PATH_PROG([PKGCONFIG], [pkg-config], [none])
21   if test "$PKGCONFIG" != "none" && `$PKGCONFIG --exists sndfile`
22   then
23     SNDFILE_CFLAGS=`$PKGCONFIG --cflags sndfile`" $ac_save_SNDFILE_CFLAGS $SNDFILE_CFLAGS"
24     SNDFILE_LIBS=`$PKGCONFIG --libs sndfile`" $ac_save_SNDFILE_LIBS $SNDFILE_LIBS"
25     have_sndfile="maybe"
26   else
27     have_sndfile="no"
28   fi
29   ])
31 # Step 3: Even if pkg-config says its not installed, user may have
32 # manually installed libraries with no -kg-config support.
33 if test "$have_sndfile" = "no"
34 then
35   # As a last resort, just hope that header and ilbrary can
36   # be found in default paths and that it doesn't need
37   # to link against any other libraries.
38   SNDFILE_LIBS="-lsndfile $SNDFILE_LIBS"
39   have_sndfile="maybe"
42 # Even if pkg-config or similar told us how to find library,
43 # do a safety check.
44 if test "$have_sndfile" != "no"
45 then
46   ac_save_CFLAGS="$CFLAGS"
47   ac_save_LIBS="$LIBS"
48   CFLAGS="$CFLAGS $SNDFILE_CFLAGS"
49   LIBS="$LIBS $SNDFILE_LIBS"
50   AC_CHECK_HEADER([sndfile.h], [
51     AC_DEFINE([HAVE_SNDFILE_H], 1, [Define if you have <sndfile.h>])
52     AC_CHECK_FUNC([sf_open_virtual], [
53       ifelse([$1], , :, [$1])
54       have_sndfile="yes"
55     ])
56     AC_CHECK_DECL([SF_FORMAT_OGG], AC_DEFINE([HAVE_SNDFILE_1_0_18], 1, [Define if you have libsndfile >= 1.0.18]),, [#include <sndfile.h>])
57     AC_CHECK_DECL([SFC_SET_SCALE_INT_FLOAT_WRITE], AC_DEFINE([HAVE_SFC_SET_SCALE_INT_FLOAT_WRITE], 1, [Define if you have libsndfile with SFC_SFC_SET_SCALE_INT_FLOAT_WRITE]),, [#include <sndfile.h>])
58   ])
59   CFLAGS="$ac_save_CFLAGS"
60   LIBS="$ac_save_LIBS"
63 if test "$have_sndfile" != "yes"
64 then
65   ifelse([$2], , :, [$2])
67 ])dnl SOX_PATH_SNDFILE