blob: bf132a24925c2ce90083219a00fc8769af915240 [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 -040040LIBOPUS_SUFFIX=0
Jean-Marc Valina0cbeca2010-07-08 11:27:20 -040041
Jean-Marc Valine05aaf22011-04-29 19:48:42 -040042OPUS_LT_CURRENT=0
43OPUS_LT_REVISION=0
44OPUS_LT_AGE=0
Jean-Marc Valina0cbeca2010-07-08 11:27:20 -040045
Jean-Marc Valine05aaf22011-04-29 19:48:42 -040046AC_SUBST(OPUS_LT_CURRENT)
47AC_SUBST(OPUS_LT_REVISION)
48AC_SUBST(OPUS_LT_AGE)
49AC_SUBST(LIBOPUS_SUFFIX)
50
Jean-Marc Valine05aaf22011-04-29 19:48:42 -040051AM_INIT_AUTOMAKE($PACKAGE, $VERSION, no-define)
52AM_MAINTAINER_MODE
53
54AC_CANONICAL_HOST
55AM_PROG_LIBTOOL
Ralph Giles2852cb12011-08-02 11:43:43 -070056AM_PROG_CC_C_O
Jean-Marc Valine05aaf22011-04-29 19:48:42 -040057
58AC_PROG_CC_C99
59AC_C_BIGENDIAN
Jean-Marc Valina0cbeca2010-07-08 11:27:20 -040060AC_C_CONST
61AC_C_INLINE
Gregory Maxwell8ecba1a2012-05-14 01:58:05 -040062
63#Use a hacked up version of autoconf's AC_C_RESTRICT because it's not
64#strong enough a test to detect old buggy versions of GCC (e.g. 2.95.3)
65AC_CACHE_CHECK([for C/C++ restrict keyword], ac_cv_c_restrict,
66 [ac_cv_c_restrict=no
67 # The order here caters to the fact that C++ does not require restrict.
68 for ac_kw in __restrict __restrict__ _Restrict restrict; do
69 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
70 [[typedef int * int_ptr;
71 int foo (int_ptr $ac_kw ip, int * $ac_kw baz[]) {
72 return ip[0];
73 }]],
74 [[int s[1];
75 int * $ac_kw t = s;
76 t[0] = 0;
77 return foo(t, (void *)0)]])],
78 [ac_cv_c_restrict=$ac_kw])
79 test "$ac_cv_c_restrict" != no && break
80 done
81 ])
82 AH_VERBATIM([restrict],
83[/* Define to the equivalent of the C99 'restrict' keyword, or to
84 nothing if this is not supported. Do not define if restrict is
85 supported directly. */
86#undef restrict
87/* Work around a bug in Sun C++: it does not support _Restrict or
88 __restrict__, even though the corresponding Sun C compiler ends up with
89 "#define restrict _Restrict" or "#define restrict __restrict__" in the
90 previous line. Perhaps some future version of Sun C++ will work with
91 restrict; if so, hopefully it defines __RESTRICT like Sun C does. */
92#if defined __SUNPRO_CC && !defined __RESTRICT
93# define _Restrict
94# define __restrict__
95#endif])
96 case $ac_cv_c_restrict in
97 restrict) ;;
98 no) AC_DEFINE([restrict], []) ;;
99 *) AC_DEFINE_UNQUOTED([restrict], [$ac_cv_c_restrict]) ;;
100 esac
Jean-Marc Valina0cbeca2010-07-08 11:27:20 -0400101
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400102AC_DEFINE([OPUS_BUILD], [], [This is a build of OPUS])
Jean-Marc Valin381c7062011-03-21 13:53:40 -0400103
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400104AC_MSG_CHECKING(for C99 variable-size arrays)
Gregory Maxwell8ecba1a2012-05-14 01:58:05 -0400105AC_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 -0400106[has_var_arrays=yes;AC_DEFINE([VAR_ARRAYS], [], [Use C99 variable-size arrays])
107],
108has_var_arrays=no
109)
110AC_MSG_RESULT($has_var_arrays)
Jean-Marc Valina0cbeca2010-07-08 11:27:20 -0400111
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400112AC_CHECK_HEADERS([alloca.h getopt.h])
113AC_MSG_CHECKING(for alloca)
114AC_TRY_COMPILE( [#include <alloca.h>], [
115int foo=10;
116int *array = alloca(foo);
117],
118[
119has_alloca=yes;
120if test x$has_var_arrays = "xno" ; then
121AC_DEFINE([USE_ALLOCA], [], [Make use of alloca])
122fi
123],
124has_alloca=no
125)
126AC_MSG_RESULT($has_alloca)
127
Gregory Maxwell6c83b0b2012-05-14 00:30:34 -0400128AC_CHECK_FUNC(exp,[fp_libm_not_needed=yes;LIBM=],[fp_libm_not_needed=dunno])
129if test x"$fp_libm_not_needed" = xdunno; then
130 AC_CHECK_LIB([m], [exp], [LIBS="-lm $LIBS"; LIBM="-lm"],[LIBM=])
131fi
132AC_SUBST([LIBM])
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400133
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400134has_float_approx=no
135#case "$host_cpu" in
136#i[[3456]]86 | x86_64 | powerpc64 | powerpc32 | ia64)
137# has_float_approx=yes
138# ;;
139#esac
140
141ac_enable_fixed="no";
142AC_ARG_ENABLE(fixed-point, [ --enable-fixed-point compile as fixed-point],
143[if test "$enableval" = yes; then
144 ac_enable_fixed="yes";
Jean-Marc Valin7009c722011-04-29 20:32:33 -0400145 AC_DEFINE([FIXED_POINT], [1], [Compile as fixed-point])
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400146else
147 AC_DEFINE([FLOATING_POINT], , [Compile as floating-point])
148fi],
149AC_DEFINE([FLOATING_POINT], , [Compile as floating-point]))
150
151ac_enable_fixed_debug="no"
152AC_ARG_ENABLE(fixed-point-debug, [ --enable-fixed-point-debug debug fixed-point implementation],
153[if test "$enableval" = yes; then
154 ac_enable_fixed_debug="yes"
155 AC_DEFINE([FIXED_DEBUG], , [Debug fixed-point implementation])
156fi])
157
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400158ac_enable_custom_modes="no"
159AC_ARG_ENABLE(custom-modes, [ --enable-custom-modes Enable non-Opus modes, like 44.1 kHz and powers of two ],
160[if test "$enableval" = yes; then
161 ac_enable_custom_modes="yes"
162 AC_DEFINE([CUSTOM_MODES], , [Custom modes])
163fi])
164
165float_approx=$has_float_approx
166AC_ARG_ENABLE(float-approx, [ --enable-float-approx enable fast approximations for floating point],
167 [ if test "$enableval" = yes; then
168 AC_WARN([Floating point approximations are not supported on all platforms.])
169 float_approx=yes
170 else
171 float_approx=no
172 fi], [ float_approx=$has_float_approx ])
173
174if test "x${float_approx}" = "xyes"; then
175 AC_DEFINE([FLOAT_APPROX], , [Float approximations])
176fi
177
178ac_enable_assertions="no"
179AC_ARG_ENABLE(assertions, [ --enable-assertions enable additional software error checking],
180[if test "$enableval" = yes; then
181 ac_enable_assertions="yes"
182 AC_DEFINE([ENABLE_ASSERTIONS], , [Assertions])
183fi])
184
Jean-Marc Valinf334c822011-08-11 16:21:58 -0400185ac_enable_fuzzing="no"
186AC_ARG_ENABLE(fuzzing, [ --enable-fuzzing causes the encoder to make random decisions],
187[if test "$enableval" = yes; then
188 ac_enable_fuzzing="yes"
189 AC_DEFINE([FUZZING], , [Fuzzing])
190fi])
191
Ralph Giles35d4fb72011-09-06 23:18:00 -0700192ac_enable_doc="yes"
193AC_ARG_ENABLE([doc],
194 AS_HELP_STRING([--disable-doc], [Do not build API documentation]),
195 [ac_enable_doc=$enableval])
196AC_CHECK_PROG(HAVE_DOXYGEN, [doxygen], [yes], [no])
197if test "$HAVE_DOXYGEN" != "yes" -o "$ac_enable_doc" != "yes"; then
198 HAVE_DOXYGEN="false"
199 ac_enable_doc="no"
200fi
201AM_CONDITIONAL(HAVE_DOXYGEN, [test $HAVE_DOXYGEN = yes])
202
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400203saved_CFLAGS="$CFLAGS"
204CFLAGS="$CFLAGS -fvisibility=hidden"
Gregory Maxwelle53ebd62011-10-21 14:21:53 -0400205AC_MSG_CHECKING([if ${CC} supports -fvisibility=hidden])
Gregory Maxwell6c83b0b2012-05-14 00:30:34 -0400206AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])],
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400207 [ AC_MSG_RESULT([yes])
208 SYMBOL_VISIBILITY="-fvisibility=hidden" ],
209 AC_MSG_RESULT([no]))
210CFLAGS="$saved_CFLAGS $SYMBOL_VISIBILITY"
211AC_SUBST(SYMBOL_VISIBILITY)
Gregory Maxwell6c83b0b2012-05-14 00:30:34 -0400212
213if test $ac_cv_c_compiler_gnu = yes ; then
Gregory Maxwelle53ebd62011-10-21 14:21:53 -0400214saved_CFLAGS="$CFLAGS"
215CFLAGS="$CFLAGS -fstack-protector-all"
216AC_MSG_CHECKING([if ${CC} supports -fstack-protector-all])
Gregory Maxwell6c83b0b2012-05-14 00:30:34 -0400217AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])],
Gregory Maxwelle53ebd62011-10-21 14:21:53 -0400218 [ AC_MSG_RESULT([yes])
219 STACK_PROTECTOR="-fstack-protector-all" ],
220 AC_MSG_RESULT([no]))
221CFLAGS="$saved_CFLAGS $STACK_PROTECTOR"
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400222fi
223
Gregory Maxwell6c83b0b2012-05-14 00:30:34 -0400224CFLAGS="$CFLAGS -W"
225
226saved_CFLAGS="$CFLAGS"
227CFLAGS="$CFLAGS -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes"
228AC_MSG_CHECKING([if ${CC} supports -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes])
229AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])],
230 [ AC_MSG_RESULT([yes])
231 EXTRA_WARNS="-Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes" ],
232 AC_MSG_RESULT([no]))
233CFLAGS="$saved_CFLAGS $EXTRA_WARNS"
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400234
235AC_CHECK_FUNCS([lrintf])
236AC_CHECK_FUNCS([lrint])
Ralph Gilesc19bc342011-10-28 07:14:58 -0700237AC_CHECK_FUNCS([__malloc_hook])
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400238
239AC_CHECK_SIZEOF(short)
240AC_CHECK_SIZEOF(int)
241AC_CHECK_SIZEOF(long)
242AC_CHECK_SIZEOF(long long)
243
244if test x$has_char16 = "xyes" ; then
245 case 1 in
246 $ac_cv_sizeof_short) SIZE16="short";;
247 $ac_cv_sizeof_int) SIZE16="int";;
248 esac
249else
250 case 2 in
251 $ac_cv_sizeof_short) SIZE16="short";;
252 $ac_cv_sizeof_int) SIZE16="int";;
253 esac
254fi
255
256if test x$has_char16 = "xyes" ; then
257 case 2 in
258 $ac_cv_sizeof_int) SIZE32="int";;
259 $ac_cv_sizeof_long) SIZE32="long";;
260 $ac_cv_sizeof_short) SIZE32="short";;
261 esac
262else
263 case 4 in
264 $ac_cv_sizeof_int) SIZE32="int";;
265 $ac_cv_sizeof_long) SIZE32="long";;
266 $ac_cv_sizeof_short) SIZE32="short";;
267 esac
268fi
269
270AC_SUBST(SIZE16)
271AC_SUBST(SIZE32)
272
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400273AM_CONDITIONAL([FIXED_POINT], [test x$ac_enable_fixed = xyes])
Jean-Marc Valin06237d72011-09-01 13:20:40 -0400274AM_CONDITIONAL([CUSTOM_MODES], [test x$ac_enable_custom_modes = xyes])
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400275
Gregory Maxwell9652f812011-10-26 23:55:33 -0400276AC_OUTPUT([Makefile opus.pc opus-uninstalled.pc
Ralph Giles35d4fb72011-09-06 23:18:00 -0700277 doc/Makefile doc/Doxyfile])
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400278
279AC_MSG_RESULT([
280------------------------------------------------------------------------
281 $PACKAGE $VERSION: Automatic configuration OK.
282
283 Compiler support:
284
285 C99 var arrays: ................ ${has_var_arrays}
286 C99 lrintf: .................... ${ac_cv_func_lrintf}
287 Alloca: ........................ ${has_alloca}
288
289 General configuration:
290
291 Fast float approximations: ..... ${float_approx}
292 Fixed point support: ........... ${ac_enable_fixed}
293 Fixed point debugging: ......... ${ac_enable_fixed_debug}
294 Custom modes: .................. ${ac_enable_custom_modes}
295 Assertion checking: ............ ${ac_enable_assertions}
Gregory Maxwell48069bf2011-09-15 11:33:18 -0400296 Fuzzing: ....................... ${ac_enable_fuzzing}
Ralph Giles35d4fb72011-09-06 23:18:00 -0700297
298 API documentation: ............. ${ac_enable_doc}
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400299------------------------------------------------------------------------
300])
301
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400302echo "Type \"make; make install\" to compile and install";
303echo "Type \"make check\" to run the test suite";