1 dnl Process this file with autoconf to produce a configure script. -*-m4-*-
3 AC_INIT(src/opus_encoder.c)
5 AM_CONFIG_HEADER([config.h])
7 dnl enable silent rules on automake 1.11 and later
8 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
10 # Read our default version string from version.mk.
11 # Please update this file for releases.
12 AC_MSG_CHECKING([version.mk])
13 MK_VERSION=$(awk 'BEGIN { FS = "=" }
14 /OPUS_VERSION/ { ver = $2}
20 }' $srcdir/version.mk)
21 if test -z "$MK_VERSION"; then
24 AC_MSG_RESULT([$MK_VERSION])
25 OPUS_VERSION="$MK_VERSION"
28 # Override with the git version, if available.
29 AC_MSG_CHECKING([git revision])
30 GIT_VERSION=$(git describe --tags --match 'v*' 2>/dev/null | sed 's/^v//')
31 if test -z "$GIT_VERSION"; then
34 AC_MSG_RESULT([$GIT_VERSION])
35 OPUS_VERSION="$GIT_VERSION"
38 # Use 'unknown' if all else fails.
39 if test -z "$OPUS_VERSION"; then
40 OPUS_VERSION="unknown"
48 AC_SUBST(OPUS_VERSION)
51 AC_DEFINE_UNQUOTED([OPUS_VERSION], ["$OPUS_VERSION"],
52 [Opus library version string])
55 dnl Please update these for releases.
60 AC_SUBST(OPUS_LT_CURRENT)
61 AC_SUBST(OPUS_LT_REVISION)
64 AM_INIT_AUTOMAKE($PACKAGE, $VERSION, no-define)
77 #Use a hacked up version of autoconf's AC_C_RESTRICT because it's not
78 #strong enough a test to detect old buggy versions of GCC (e.g. 2.95.3)
79 AC_CACHE_CHECK([for C/C++ restrict keyword], ac_cv_c_restrict,
81 # The order here caters to the fact that C++ does not require restrict.
82 for ac_kw in __restrict __restrict__ _Restrict restrict; do
83 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
84 [[typedef int * int_ptr;
85 int foo (int_ptr $ac_kw ip, int * $ac_kw baz[]) {
91 return foo(t, (void *)0)]])],
92 [ac_cv_c_restrict=$ac_kw])
93 test "$ac_cv_c_restrict" != no && break
96 AH_VERBATIM([restrict],
97 [/* Define to the equivalent of the C99 'restrict' keyword, or to
98 nothing if this is not supported. Do not define if restrict is
99 supported directly. */
101 /* Work around a bug in Sun C++: it does not support _Restrict or
102 __restrict__, even though the corresponding Sun C compiler ends up with
103 "#define restrict _Restrict" or "#define restrict __restrict__" in the
104 previous line. Perhaps some future version of Sun C++ will work with
105 restrict; if so, hopefully it defines __RESTRICT like Sun C does. */
106 #if defined __SUNPRO_CC && !defined __RESTRICT
108 # define __restrict__
110 case $ac_cv_c_restrict in
112 no) AC_DEFINE([restrict], []) ;;
113 *) AC_DEFINE_UNQUOTED([restrict], [$ac_cv_c_restrict]) ;;
116 AC_DEFINE([OPUS_BUILD], [], [This is a build of OPUS])
118 AC_MSG_CHECKING(for C99 variable-size arrays)
119 AC_TRY_COMPILE( [], [static int x; char a[++x]; a[sizeof a - 1] = 0; int N; return a[0];],
120 [has_var_arrays=yes;AC_DEFINE([VAR_ARRAYS], [], [Use C99 variable-size arrays])
124 AC_MSG_RESULT($has_var_arrays)
126 AC_CHECK_HEADERS([alloca.h getopt.h])
127 AC_MSG_CHECKING(for alloca)
128 AC_TRY_COMPILE( [#include <alloca.h>], [
130 int *array = alloca(foo);
134 if test x$has_var_arrays = "xno" ; then
135 AC_DEFINE([USE_ALLOCA], [], [Make use of alloca])
140 AC_MSG_RESULT($has_alloca)
142 AC_CHECK_FUNC(exp,[fp_libm_not_needed=yes;LIBM=],[fp_libm_not_needed=dunno])
143 if test x"$fp_libm_not_needed" = xdunno; then
144 AC_CHECK_LIB([m], [exp], [LIBS="-lm $LIBS"; LIBM="-lm"],[LIBM=])
150 #i[[3456]]86 | x86_64 | powerpc64 | powerpc32 | ia64)
151 # has_float_approx=yes
155 ac_enable_fixed="no";
156 ac_enable_float="yes";
157 AC_ARG_ENABLE(fixed-point, [ --enable-fixed-point compile without floating point (for machines without a fast enough FPU)],
158 [if test "$enableval" = yes; then
159 ac_enable_fixed="yes";
160 ac_enable_float="no";
161 AC_DEFINE([FIXED_POINT], [1], [Compile as fixed-point (for machines without a fast enough FPU)])
163 AC_DEFINE([FLOATING_POINT], , [Compile as floating-point (for machines with a fast enough FPU)])
165 AC_DEFINE([FLOATING_POINT], , [Compile as floating-point (for machines with a fast enough FPU)]))
167 ac_enable_fixed_debug="no"
168 AC_ARG_ENABLE(fixed-point-debug, [ --enable-fixed-point-debug debug fixed-point implementation],
169 [if test "$enableval" = yes; then
170 ac_enable_fixed_debug="yes"
171 AC_DEFINE([FIXED_DEBUG], , [Debug fixed-point implementation])
174 ac_enable_custom_modes="no"
175 AC_ARG_ENABLE(custom-modes, [ --enable-custom-modes enable non-Opus modes, e.g. 44.1 kHz & 2^n frames],
176 [if test "$enableval" = yes; then
177 ac_enable_custom_modes="yes"
178 AC_DEFINE([CUSTOM_MODES], , [Custom modes])
181 float_approx=$has_float_approx
182 AC_ARG_ENABLE(float-approx, [ --enable-float-approx enable fast approximations for floating point],
183 [ if test "$enableval" = yes; then
184 AC_WARN([Floating point approximations are not supported on all platforms.])
188 fi], [ float_approx=$has_float_approx ])
190 if test "x${float_approx}" = "xyes"; then
191 AC_DEFINE([FLOAT_APPROX], , [Float approximations])
194 ac_enable_assertions="no"
195 AC_ARG_ENABLE(assertions, [ --enable-assertions enable additional software error checking],
196 [if test "$enableval" = yes; then
197 ac_enable_assertions="yes"
198 AC_DEFINE([ENABLE_ASSERTIONS], , [Assertions])
201 ac_enable_fuzzing="no"
202 AC_ARG_ENABLE(fuzzing, [ --enable-fuzzing causes the encoder to make random decisions],
203 [if test "$enableval" = yes; then
204 ac_enable_fuzzing="yes"
205 AC_DEFINE([FUZZING], , [Fuzzing])
210 AS_HELP_STRING([--disable-doc], [Do not build API documentation]),
211 [ac_enable_doc=$enableval])
212 AC_CHECK_PROG(HAVE_DOXYGEN, [doxygen], [yes], [no])
213 if test "$HAVE_DOXYGEN" != "yes" -o "$ac_enable_doc" != "yes"; then
217 AM_CONDITIONAL(HAVE_DOXYGEN, [test $HAVE_DOXYGEN = yes])
219 saved_CFLAGS="$CFLAGS"
220 CFLAGS="$CFLAGS -fvisibility=hidden"
221 AC_MSG_CHECKING([if ${CC} supports -fvisibility=hidden])
222 AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])],
223 [ AC_MSG_RESULT([yes])
224 SYMBOL_VISIBILITY="-fvisibility=hidden" ],
226 CFLAGS="$saved_CFLAGS $SYMBOL_VISIBILITY"
227 AC_SUBST(SYMBOL_VISIBILITY)
231 saved_CFLAGS="$CFLAGS"
232 CFLAGS="$CFLAGS -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes"
233 AC_MSG_CHECKING([if ${CC} supports -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes])
234 AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])],
235 [ AC_MSG_RESULT([yes])
236 EXTRA_WARNS="-Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes" ],
238 CFLAGS="$saved_CFLAGS $EXTRA_WARNS"
240 AC_CHECK_FUNCS([lrintf])
241 AC_CHECK_FUNCS([lrint])
242 AC_CHECK_FUNCS([__malloc_hook])
244 AC_CHECK_SIZEOF(short)
246 AC_CHECK_SIZEOF(long)
247 AC_CHECK_SIZEOF(long long)
249 if test x$has_char16 = "xyes" ; then
251 $ac_cv_sizeof_short) SIZE16="short";;
252 $ac_cv_sizeof_int) SIZE16="int";;
256 $ac_cv_sizeof_short) SIZE16="short";;
257 $ac_cv_sizeof_int) SIZE16="int";;
261 if test x$has_char16 = "xyes" ; then
263 $ac_cv_sizeof_int) SIZE32="int";;
264 $ac_cv_sizeof_long) SIZE32="long";;
265 $ac_cv_sizeof_short) SIZE32="short";;
269 $ac_cv_sizeof_int) SIZE32="int";;
270 $ac_cv_sizeof_long) SIZE32="long";;
271 $ac_cv_sizeof_short) SIZE32="short";;
278 AM_CONDITIONAL([FIXED_POINT], [test x$ac_enable_fixed = xyes])
279 AM_CONDITIONAL([CUSTOM_MODES], [test x$ac_enable_custom_modes = xyes])
281 AC_OUTPUT([Makefile opus.pc opus-uninstalled.pc
282 doc/Makefile doc/Doxyfile])
285 ------------------------------------------------------------------------
286 $PACKAGE $VERSION: Automatic configuration OK.
290 C99 var arrays: ................ ${has_var_arrays}
291 C99 lrintf: .................... ${ac_cv_func_lrintf}
292 Alloca: ........................ ${has_alloca}
294 General configuration:
296 Floating point support: ........ ${ac_enable_float}
297 Fast float approximations: ..... ${float_approx}
298 Fixed point debugging: ......... ${ac_enable_fixed_debug}
299 Custom modes: .................. ${ac_enable_custom_modes}
300 Assertion checking: ............ ${ac_enable_assertions}
301 Fuzzing: ....................... ${ac_enable_fuzzing}
303 API documentation: ............. ${ac_enable_doc}
304 ------------------------------------------------------------------------
307 echo "Type \"make; make install\" to compile and install";
308 echo "Type \"make check\" to run the test suite";