1dnl Process this file with autoconf to produce a configure script.
2AC_INIT([audiofile], [0.3.6])
3AC_CONFIG_SRCDIR([libaudiofile/AIFF.cpp])
4
5dnl Set libtool version information.
6AUDIOFILE_VERSION_INFO=1:0:0
7AUDIOFILE_VERSION=$PACKAGE_VERSION
8
9AC_SUBST(AUDIOFILE_VERSION)
10AC_SUBST(AUDIOFILE_VERSION_INFO)
11
12AM_INIT_AUTOMAKE($PACKAGE_NAME, $PACKAGE_VERSION)
13AC_CONFIG_HEADER([config.h])
14
15dnl Checks for programs.
16AC_PROG_CC_C99
17AC_PROG_CXX
18AC_PROG_INSTALL
19AM_PROG_LIBTOOL
20
21dnl Checks for header files.
22AC_HEADER_STDC
23AC_CHECK_HEADERS(fcntl.h unistd.h)
24
25dnl Checks for typedefs, structures, and compiler characteristics.
26AC_C_CONST
27AC_C_BIGENDIAN
28
29dnl Enable large file support by default.
30AC_SYS_LARGEFILE
31AC_TYPE_OFF_T
32AC_TYPE_SIZE_T
33
34dnl Set up platform specific stuff
35platform=none
36AC_MSG_CHECKING([for platform specific tests to compile])
37case "$host_os" in
38  linux*)
39    TEST_BIN="linuxtest alsaplay"
40    platform=linux
41    ;;
42  irix5* | irix6*)
43    TEST_BIN="irixread irixtestloop"
44    platform=irix
45    ;;
46  darwin*)
47    if test -e /System/Library/Frameworks/CoreAudio.framework; then
48      TEST_BIN="osxplay"
49      platform="Mac OS X"
50    fi
51    ;;
52esac
53AC_MSG_RESULT($platform)
54AC_SUBST(TEST_BIN)
55
56AC_ARG_ENABLE(werror,
57	AS_HELP_STRING([--enable-werror], [treat compiler warnings as errors]),
58	[enable_werror=$enableval],
59	[enable_werror=no])
60AM_CONDITIONAL(ENABLE_WERROR, [test "$enable_werror" = "yes"])
61
62AS_IF([test "$enable_werror" = "yes"],
63	[WERROR_CFLAGS="-Werror"
64	AC_SUBST(WERROR_CFLAGS)])
65
66AC_ARG_ENABLE(coverage,
67	AS_HELP_STRING([--enable-coverage], [enable code coverage]),
68	[enable_coverage=$enableval],
69	[enable_coverage=no])
70AM_CONDITIONAL(ENABLE_COVERAGE, [test "$enable_coverage" = "yes"])
71
72AS_IF([test "$enable_coverage" = "yes"],
73	[COVERAGE_CFLAGS="-fprofile-arcs -ftest-coverage"
74	COVERAGE_LIBS="-lgcov"
75	AC_SUBST(COVERAGE_CFLAGS)
76	AC_SUBST(COVERAGE_LIBS)
77
78	AC_PATH_PROG(LCOV, lcov, :)
79	AC_PATH_PROG(GENHTML, genhtml, :)
80	AC_SUBST(LCOV)
81	AC_SUBST(GENHTML)
82	AS_IF([test "$LCOV" = :],
83		[AC_MSG_ERROR([lcov must be installed for code coverage: http://ltp.sourceforge.net/coverage/lcov.php])]
84	)]
85)
86
87AC_ARG_ENABLE(valgrind,
88	AS_HELP_STRING([--enable-valgrind], [enable testing with Valgrind]),
89	[enable_valgrind=$enableval],
90	[enable_valgrind=no])
91AM_CONDITIONAL(ENABLE_VALGRIND, [test "$enable_valgrind" = "yes"])
92
93AS_IF([test "$enable_valgrind" = "yes"],
94	[AC_PATH_PROG(VALGRIND, valgrind, :)
95	AC_SUBST(VALGRIND)
96	AS_IF([test "$VALGRIND" = :],
97		[AC_MSG_ERROR([Could not find Valgrind.])]
98	)]
99)
100
101AC_ARG_ENABLE(docs,
102	AS_HELP_STRING([--disable-docs], [disable documentation]),
103	[enable_documentation=$enableval],
104	[enable_documentation=yes])
105
106AM_CONDITIONAL(ENABLE_DOCUMENTATION, [test "$enable_documentation" = "yes"])
107
108AS_IF([test "$enable_documentation" = "yes"],
109	[AC_PATH_PROG(A2X, a2x, :)
110	AC_PATH_PROG(ASCIIDOC, asciidoc, :)
111	AS_IF([test "$A2X" = :],
112		[AC_MSG_WARN([Could not find a2x.])]
113	)
114	AS_IF([test "$ASCIIDOC" = :],
115		[AC_MSG_WARN([Could not find asciidoc.])]
116	)]
117)
118
119AC_ARG_ENABLE(examples,
120	AS_HELP_STRING([--disable-examples], [disable examples]),
121		[enable_examples=$enableval],
122		[enable_examples=yes])
123AS_IF([test "$enable_examples" != "yes"], [TEST_BIN=""])
124
125AC_ARG_ENABLE(flac,
126	AS_HELP_STRING([--disable-flac], [disable FLAC]),
127	[enable_flac=$enableval],
128	[enable_flac=yes])
129
130PKG_PROG_PKG_CONFIG
131
132FLAC_CFLAGS=""
133FLAC_LIBS=""
134
135if test -n "$PKG_CONFIG" ; then
136	if test "$enable_flac" = "yes" ; then
137		PKG_CHECK_MODULES([FLAC], [flac >= 1.2.1], [ac_cv_flac=yes], [ac_cv_flac=no])
138		FLAC_CFLAGS=`echo $FLAC_CFLAGS | $SED "s/FLAC$//"`
139		if test "$ac_cv_flac" = "no" ; then
140			enable_flac=no
141		fi
142	fi
143else
144	enable_flac=no
145fi
146
147AC_SUBST(FLAC_CFLAGS)
148AC_SUBST(FLAC_LIBS)
149
150AM_CONDITIONAL(ENABLE_FLAC, [test "$enable_flac" = "yes"])
151if test "$enable_flac" = "yes" ; then
152	AC_DEFINE_UNQUOTED([ENABLE_FLAC], [1], [Whether FLAC is enabled.])
153else
154	AC_DEFINE_UNQUOTED([ENABLE_FLAC], [0], [Whether FLAC is enabled.])
155fi
156
157AC_CONFIG_FILES([
158	audiofile.spec
159	audiofile.pc
160	audiofile-uninstalled.pc
161	sfcommands/Makefile
162	test/Makefile
163	gtest/Makefile
164	examples/Makefile
165	libaudiofile/Makefile
166	libaudiofile/alac/Makefile
167	libaudiofile/modules/Makefile
168	docs/Makefile
169	Makefile])
170AC_OUTPUT
171