blob: 0f23ade439ac479b4ad63dfaabde1645ada717d7 [file] [log] [blame]
Jean-Marc Valine05aaf22011-04-29 19:48:42 -04001dnl Process this file with autoconf to produce a configure script. -*-m4-*-
Jean-Marc Valina0cbeca2010-07-08 11:27:20 -04002
Jean-Marc Valine05aaf22011-04-29 19:48:42 -04003AC_INIT(src/opus_encoder.c)
Jean-Marc Valina0cbeca2010-07-08 11:27:20 -04004
Jean-Marc Valin381c7062011-03-21 13:53:40 -04005AM_CONFIG_HEADER([config.h])
6
Ralph Giles5ccc1242011-07-29 00:55:56 -07007dnl enable silent rules on automake 1.11 and later
8m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
9
Jean-Marc Valine05aaf22011-04-29 19:48:42 -040010OPUS_MAJOR_VERSION=0
11OPUS_MINOR_VERSION=9
Jean-Marc Valin8858cac2012-05-17 19:45:10 -040012OPUS_MICRO_VERSION=14
Jean-Marc Valine05aaf22011-04-29 19:48:42 -040013OPUS_EXTRA_VERSION=
Ralph Giles50f933b2011-08-02 09:34:55 -070014
15OPUS_VERSION="$OPUS_MAJOR_VERSION.$OPUS_MINOR_VERSION.$OPUS_MICRO_VERSION$OPUS_EXTRA_VERSION"
16AC_MSG_CHECKING([git revision])
Jean-Marc Valina8ac44b2011-08-05 08:47:24 -040017GIT_VERSION=$(git describe --tags --match 'v*' 2>/dev/null | sed 's/^v//')
Ralph Giles50f933b2011-08-02 09:34:55 -070018if test -z "$GIT_VERSION"; then
19 AC_MSG_RESULT([no])
20else
21 AC_MSG_RESULT([$GIT_VERSION])
22 OPUS_VERSION="$GIT_VERSION"
23fi
24
Ralph Giles3164fcf2012-05-18 11:47:58 -070025# For automake.
26VERSION=$OPUS_VERSION
27PACKAGE=opus
28
29# For our version string.
30AC_SUBST(OPUS_VERSION)
31
32# For config.h
33AC_DEFINE_UNQUOTED(OPUS_VERSION, "${OPUS_VERSION}", [Complete version string])
34AC_DEFINE_UNQUOTED(OPUS_MAJOR_VERSION, ${OPUS_MAJOR_VERSION}, [Version major])
35AC_DEFINE_UNQUOTED(OPUS_MINOR_VERSION, ${OPUS_MINOR_VERSION}, [Version minor])
36AC_DEFINE_UNQUOTED(OPUS_MICRO_VERSION, ${OPUS_MICRO_VERSION}, [Version micro])
37AC_DEFINE_UNQUOTED(OPUS_EXTRA_VERSION, "${OPUS_EXTRA_VERSION}", [Version extra])
38
39# For libtool.
Jean-Marc Valine05aaf22011-04-29 19:48:42 -040040OPUS_LT_CURRENT=0
41OPUS_LT_REVISION=0
42OPUS_LT_AGE=0
Jean-Marc Valina0cbeca2010-07-08 11:27:20 -040043
Jean-Marc Valine05aaf22011-04-29 19:48:42 -040044AC_SUBST(OPUS_LT_CURRENT)
45AC_SUBST(OPUS_LT_REVISION)
46AC_SUBST(OPUS_LT_AGE)
Jean-Marc Valine05aaf22011-04-29 19:48:42 -040047
Jean-Marc Valine05aaf22011-04-29 19:48:42 -040048AM_INIT_AUTOMAKE($PACKAGE, $VERSION, no-define)
49AM_MAINTAINER_MODE
50
51AC_CANONICAL_HOST
52AM_PROG_LIBTOOL
Ralph Giles2852cb12011-08-02 11:43:43 -070053AM_PROG_CC_C_O
Jean-Marc Valine05aaf22011-04-29 19:48:42 -040054
55AC_PROG_CC_C99
56AC_C_BIGENDIAN
Jean-Marc Valina0cbeca2010-07-08 11:27:20 -040057AC_C_CONST
58AC_C_INLINE
Gregory Maxwell8ecba1a2012-05-14 01:58:05 -040059
60#Use a hacked up version of autoconf's AC_C_RESTRICT because it's not
61#strong enough a test to detect old buggy versions of GCC (e.g. 2.95.3)
62AC_CACHE_CHECK([for C/C++ restrict keyword], ac_cv_c_restrict,
63 [ac_cv_c_restrict=no
64 # The order here caters to the fact that C++ does not require restrict.
65 for ac_kw in __restrict __restrict__ _Restrict restrict; do
66 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
67 [[typedef int * int_ptr;
68 int foo (int_ptr $ac_kw ip, int * $ac_kw baz[]) {
69 return ip[0];
70 }]],
71 [[int s[1];
72 int * $ac_kw t = s;
73 t[0] = 0;
74 return foo(t, (void *)0)]])],
75 [ac_cv_c_restrict=$ac_kw])
76 test "$ac_cv_c_restrict" != no && break
77 done
78 ])
79 AH_VERBATIM([restrict],
80[/* Define to the equivalent of the C99 'restrict' keyword, or to
81 nothing if this is not supported. Do not define if restrict is
82 supported directly. */
83#undef restrict
84/* Work around a bug in Sun C++: it does not support _Restrict or
85 __restrict__, even though the corresponding Sun C compiler ends up with
86 "#define restrict _Restrict" or "#define restrict __restrict__" in the
87 previous line. Perhaps some future version of Sun C++ will work with
88 restrict; if so, hopefully it defines __RESTRICT like Sun C does. */
89#if defined __SUNPRO_CC && !defined __RESTRICT
90# define _Restrict
91# define __restrict__
92#endif])
93 case $ac_cv_c_restrict in
94 restrict) ;;
95 no) AC_DEFINE([restrict], []) ;;
96 *) AC_DEFINE_UNQUOTED([restrict], [$ac_cv_c_restrict]) ;;
97 esac
Jean-Marc Valina0cbeca2010-07-08 11:27:20 -040098
Jean-Marc Valine05aaf22011-04-29 19:48:42 -040099AC_DEFINE([OPUS_BUILD], [], [This is a build of OPUS])
Jean-Marc Valin381c7062011-03-21 13:53:40 -0400100
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400101AC_MSG_CHECKING(for C99 variable-size arrays)
Gregory Maxwell8ecba1a2012-05-14 01:58:05 -0400102AC_TRY_COMPILE( [], [static int x; char a[++x]; a[sizeof a - 1] = 0; int N; return a[0];],
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400103[has_var_arrays=yes;AC_DEFINE([VAR_ARRAYS], [], [Use C99 variable-size arrays])
104],
105has_var_arrays=no
106)
107AC_MSG_RESULT($has_var_arrays)
Jean-Marc Valina0cbeca2010-07-08 11:27:20 -0400108
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400109AC_CHECK_HEADERS([alloca.h getopt.h])
110AC_MSG_CHECKING(for alloca)
111AC_TRY_COMPILE( [#include <alloca.h>], [
112int foo=10;
113int *array = alloca(foo);
114],
115[
116has_alloca=yes;
117if test x$has_var_arrays = "xno" ; then
118AC_DEFINE([USE_ALLOCA], [], [Make use of alloca])
119fi
120],
121has_alloca=no
122)
123AC_MSG_RESULT($has_alloca)
124
Gregory Maxwell6c83b0b2012-05-14 00:30:34 -0400125AC_CHECK_FUNC(exp,[fp_libm_not_needed=yes;LIBM=],[fp_libm_not_needed=dunno])
126if test x"$fp_libm_not_needed" = xdunno; then
127 AC_CHECK_LIB([m], [exp], [LIBS="-lm $LIBS"; LIBM="-lm"],[LIBM=])
128fi
129AC_SUBST([LIBM])
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400130
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400131has_float_approx=no
132#case "$host_cpu" in
133#i[[3456]]86 | x86_64 | powerpc64 | powerpc32 | ia64)
134# has_float_approx=yes
135# ;;
136#esac
137
138ac_enable_fixed="no";
139AC_ARG_ENABLE(fixed-point, [ --enable-fixed-point compile as fixed-point],
140[if test "$enableval" = yes; then
141 ac_enable_fixed="yes";
Jean-Marc Valin7009c722011-04-29 20:32:33 -0400142 AC_DEFINE([FIXED_POINT], [1], [Compile as fixed-point])
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400143else
144 AC_DEFINE([FLOATING_POINT], , [Compile as floating-point])
145fi],
146AC_DEFINE([FLOATING_POINT], , [Compile as floating-point]))
147
148ac_enable_fixed_debug="no"
149AC_ARG_ENABLE(fixed-point-debug, [ --enable-fixed-point-debug debug fixed-point implementation],
150[if test "$enableval" = yes; then
151 ac_enable_fixed_debug="yes"
152 AC_DEFINE([FIXED_DEBUG], , [Debug fixed-point implementation])
153fi])
154
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400155ac_enable_custom_modes="no"
156AC_ARG_ENABLE(custom-modes, [ --enable-custom-modes Enable non-Opus modes, like 44.1 kHz and powers of two ],
157[if test "$enableval" = yes; then
158 ac_enable_custom_modes="yes"
159 AC_DEFINE([CUSTOM_MODES], , [Custom modes])
160fi])
161
162float_approx=$has_float_approx
163AC_ARG_ENABLE(float-approx, [ --enable-float-approx enable fast approximations for floating point],
164 [ if test "$enableval" = yes; then
165 AC_WARN([Floating point approximations are not supported on all platforms.])
166 float_approx=yes
167 else
168 float_approx=no
169 fi], [ float_approx=$has_float_approx ])
170
171if test "x${float_approx}" = "xyes"; then
172 AC_DEFINE([FLOAT_APPROX], , [Float approximations])
173fi
174
175ac_enable_assertions="no"
176AC_ARG_ENABLE(assertions, [ --enable-assertions enable additional software error checking],
177[if test "$enableval" = yes; then
178 ac_enable_assertions="yes"
179 AC_DEFINE([ENABLE_ASSERTIONS], , [Assertions])
180fi])
181
Jean-Marc Valinf334c822011-08-11 16:21:58 -0400182ac_enable_fuzzing="no"
183AC_ARG_ENABLE(fuzzing, [ --enable-fuzzing causes the encoder to make random decisions],
184[if test "$enableval" = yes; then
185 ac_enable_fuzzing="yes"
186 AC_DEFINE([FUZZING], , [Fuzzing])
187fi])
188
Ralph Giles35d4fb72011-09-06 23:18:00 -0700189ac_enable_doc="yes"
190AC_ARG_ENABLE([doc],
191 AS_HELP_STRING([--disable-doc], [Do not build API documentation]),
192 [ac_enable_doc=$enableval])
193AC_CHECK_PROG(HAVE_DOXYGEN, [doxygen], [yes], [no])
194if test "$HAVE_DOXYGEN" != "yes" -o "$ac_enable_doc" != "yes"; then
195 HAVE_DOXYGEN="false"
196 ac_enable_doc="no"
197fi
198AM_CONDITIONAL(HAVE_DOXYGEN, [test $HAVE_DOXYGEN = yes])
199
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400200saved_CFLAGS="$CFLAGS"
201CFLAGS="$CFLAGS -fvisibility=hidden"
Gregory Maxwelle53ebd62011-10-21 14:21:53 -0400202AC_MSG_CHECKING([if ${CC} supports -fvisibility=hidden])
Gregory Maxwell6c83b0b2012-05-14 00:30:34 -0400203AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])],
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400204 [ AC_MSG_RESULT([yes])
205 SYMBOL_VISIBILITY="-fvisibility=hidden" ],
206 AC_MSG_RESULT([no]))
207CFLAGS="$saved_CFLAGS $SYMBOL_VISIBILITY"
208AC_SUBST(SYMBOL_VISIBILITY)
Gregory Maxwell6c83b0b2012-05-14 00:30:34 -0400209
210if test $ac_cv_c_compiler_gnu = yes ; then
Gregory Maxwelle53ebd62011-10-21 14:21:53 -0400211saved_CFLAGS="$CFLAGS"
212CFLAGS="$CFLAGS -fstack-protector-all"
213AC_MSG_CHECKING([if ${CC} supports -fstack-protector-all])
Gregory Maxwell6c83b0b2012-05-14 00:30:34 -0400214AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])],
Gregory Maxwelle53ebd62011-10-21 14:21:53 -0400215 [ AC_MSG_RESULT([yes])
216 STACK_PROTECTOR="-fstack-protector-all" ],
217 AC_MSG_RESULT([no]))
218CFLAGS="$saved_CFLAGS $STACK_PROTECTOR"
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400219fi
220
Gregory Maxwell6c83b0b2012-05-14 00:30:34 -0400221CFLAGS="$CFLAGS -W"
222
223saved_CFLAGS="$CFLAGS"
224CFLAGS="$CFLAGS -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes"
225AC_MSG_CHECKING([if ${CC} supports -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes])
226AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])],
227 [ AC_MSG_RESULT([yes])
228 EXTRA_WARNS="-Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes" ],
229 AC_MSG_RESULT([no]))
230CFLAGS="$saved_CFLAGS $EXTRA_WARNS"
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400231
232AC_CHECK_FUNCS([lrintf])
233AC_CHECK_FUNCS([lrint])
Ralph Gilesc19bc342011-10-28 07:14:58 -0700234AC_CHECK_FUNCS([__malloc_hook])
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400235
236AC_CHECK_SIZEOF(short)
237AC_CHECK_SIZEOF(int)
238AC_CHECK_SIZEOF(long)
239AC_CHECK_SIZEOF(long long)
240
241if test x$has_char16 = "xyes" ; then
242 case 1 in
243 $ac_cv_sizeof_short) SIZE16="short";;
244 $ac_cv_sizeof_int) SIZE16="int";;
245 esac
246else
247 case 2 in
248 $ac_cv_sizeof_short) SIZE16="short";;
249 $ac_cv_sizeof_int) SIZE16="int";;
250 esac
251fi
252
253if test x$has_char16 = "xyes" ; then
254 case 2 in
255 $ac_cv_sizeof_int) SIZE32="int";;
256 $ac_cv_sizeof_long) SIZE32="long";;
257 $ac_cv_sizeof_short) SIZE32="short";;
258 esac
259else
260 case 4 in
261 $ac_cv_sizeof_int) SIZE32="int";;
262 $ac_cv_sizeof_long) SIZE32="long";;
263 $ac_cv_sizeof_short) SIZE32="short";;
264 esac
265fi
266
267AC_SUBST(SIZE16)
268AC_SUBST(SIZE32)
269
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400270AM_CONDITIONAL([FIXED_POINT], [test x$ac_enable_fixed = xyes])
Jean-Marc Valin06237d72011-09-01 13:20:40 -0400271AM_CONDITIONAL([CUSTOM_MODES], [test x$ac_enable_custom_modes = xyes])
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400272
Gregory Maxwell9652f812011-10-26 23:55:33 -0400273AC_OUTPUT([Makefile opus.pc opus-uninstalled.pc
Ralph Giles35d4fb72011-09-06 23:18:00 -0700274 doc/Makefile doc/Doxyfile])
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400275
276AC_MSG_RESULT([
277------------------------------------------------------------------------
278 $PACKAGE $VERSION: Automatic configuration OK.
279
280 Compiler support:
281
282 C99 var arrays: ................ ${has_var_arrays}
283 C99 lrintf: .................... ${ac_cv_func_lrintf}
284 Alloca: ........................ ${has_alloca}
285
286 General configuration:
287
288 Fast float approximations: ..... ${float_approx}
289 Fixed point support: ........... ${ac_enable_fixed}
290 Fixed point debugging: ......... ${ac_enable_fixed_debug}
291 Custom modes: .................. ${ac_enable_custom_modes}
292 Assertion checking: ............ ${ac_enable_assertions}
Gregory Maxwell48069bf2011-09-15 11:33:18 -0400293 Fuzzing: ....................... ${ac_enable_fuzzing}
Ralph Giles35d4fb72011-09-06 23:18:00 -0700294
295 API documentation: ............. ${ac_enable_doc}
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400296------------------------------------------------------------------------
297])
298
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400299echo "Type \"make; make install\" to compile and install";
300echo "Type \"make check\" to run the test suite";