blob: 3091a73402d574f4dad5feebbb0f671b9e11eeb2 [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
Ralph Giles59c5a822012-08-16 11:39:56 -070010# Read our default version string from version.mk.
11# Please update this file for releases.
12AC_MSG_CHECKING([version.mk])
13MK_VERSION=$(awk 'BEGIN { FS = "=" }
14 /OPUS_VERSION/ { ver = $2}
15 END {
16 gsub(/"/, "", ver);
17 gsub(/^ /, "", ver);
18 gsub(/ $/, "", ver);
19 print ver;
20 }' $srcdir/version.mk)
21if test -z "$MK_VERSION"; then
22 AC_MSG_RESULT([no])
23else
24 AC_MSG_RESULT([$MK_VERSION])
25 OPUS_VERSION="$MK_VERSION"
26fi
Ralph Giles50f933b2011-08-02 09:34:55 -070027
Ralph Giles59c5a822012-08-16 11:39:56 -070028# Override with the git version, if available.
Ralph Giles50f933b2011-08-02 09:34:55 -070029AC_MSG_CHECKING([git revision])
Jean-Marc Valina8ac44b2011-08-05 08:47:24 -040030GIT_VERSION=$(git describe --tags --match 'v*' 2>/dev/null | sed 's/^v//')
Ralph Giles50f933b2011-08-02 09:34:55 -070031if test -z "$GIT_VERSION"; then
32 AC_MSG_RESULT([no])
33else
34 AC_MSG_RESULT([$GIT_VERSION])
35 OPUS_VERSION="$GIT_VERSION"
36fi
37
Ralph Giles59c5a822012-08-16 11:39:56 -070038# Use 'unknown' if all else fails.
39if test -z "$OPUS_VERSION"; then
40 OPUS_VERSION="unknown"
41fi
Ralph Giles3164fcf2012-05-18 11:47:58 -070042
Ralph Giles59c5a822012-08-16 11:39:56 -070043# For automake.
44PACKAGE=opus
45VERSION=$OPUS_VERSION
46
Ralph Giles11dd5522012-08-21 11:22:08 -070047# For autoconf
Ralph Giles3164fcf2012-05-18 11:47:58 -070048AC_SUBST(OPUS_VERSION)
Ralph Giles11dd5522012-08-21 11:22:08 -070049
50# For config.h.
Ralph Gilesd6067372012-08-21 10:49:43 -070051AC_DEFINE_UNQUOTED([OPUS_VERSION], ["$OPUS_VERSION"],
52 [Opus library version string])
Ralph Giles3164fcf2012-05-18 11:47:58 -070053
Ralph Giles3164fcf2012-05-18 11:47:58 -070054# For libtool.
Ralph Giles59c5a822012-08-16 11:39:56 -070055dnl Please update these for releases.
Gregory Maxwell8d2e9ad2012-08-10 17:21:28 -040056OPUS_LT_CURRENT=2
Jean-Marc Valine05aaf22011-04-29 19:48:42 -040057OPUS_LT_REVISION=0
Gregory Maxwell8d2e9ad2012-08-10 17:21:28 -040058OPUS_LT_AGE=2
Jean-Marc Valina0cbeca2010-07-08 11:27:20 -040059
Jean-Marc Valine05aaf22011-04-29 19:48:42 -040060AC_SUBST(OPUS_LT_CURRENT)
61AC_SUBST(OPUS_LT_REVISION)
62AC_SUBST(OPUS_LT_AGE)
Jean-Marc Valine05aaf22011-04-29 19:48:42 -040063
Jean-Marc Valine05aaf22011-04-29 19:48:42 -040064AM_INIT_AUTOMAKE($PACKAGE, $VERSION, no-define)
65AM_MAINTAINER_MODE
66
67AC_CANONICAL_HOST
Gregory Maxwell417679c2012-08-09 08:39:15 -040068AC_MINGW32
Jean-Marc Valine05aaf22011-04-29 19:48:42 -040069AM_PROG_LIBTOOL
Ralph Giles2852cb12011-08-02 11:43:43 -070070AM_PROG_CC_C_O
Jean-Marc Valine05aaf22011-04-29 19:48:42 -040071
72AC_PROG_CC_C99
73AC_C_BIGENDIAN
Jean-Marc Valina0cbeca2010-07-08 11:27:20 -040074AC_C_CONST
75AC_C_INLINE
Gregory Maxwell8ecba1a2012-05-14 01:58:05 -040076
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)
79AC_CACHE_CHECK([for C/C++ restrict keyword], ac_cv_c_restrict,
80 [ac_cv_c_restrict=no
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[]) {
86 return ip[0];
87 }]],
88 [[int s[1];
89 int * $ac_kw t = s;
90 t[0] = 0;
91 return foo(t, (void *)0)]])],
92 [ac_cv_c_restrict=$ac_kw])
93 test "$ac_cv_c_restrict" != no && break
94 done
95 ])
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. */
100#undef restrict
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
107# define _Restrict
108# define __restrict__
109#endif])
110 case $ac_cv_c_restrict in
111 restrict) ;;
112 no) AC_DEFINE([restrict], []) ;;
113 *) AC_DEFINE_UNQUOTED([restrict], [$ac_cv_c_restrict]) ;;
114 esac
Jean-Marc Valina0cbeca2010-07-08 11:27:20 -0400115
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400116AC_DEFINE([OPUS_BUILD], [], [This is a build of OPUS])
Jean-Marc Valin381c7062011-03-21 13:53:40 -0400117
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400118AC_MSG_CHECKING(for C99 variable-size arrays)
Gregory Maxwell8ecba1a2012-05-14 01:58:05 -0400119AC_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 -0400120[has_var_arrays=yes;AC_DEFINE([VAR_ARRAYS], [], [Use C99 variable-size arrays])
121],
122has_var_arrays=no
123)
124AC_MSG_RESULT($has_var_arrays)
Jean-Marc Valina0cbeca2010-07-08 11:27:20 -0400125
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400126AC_CHECK_HEADERS([alloca.h getopt.h])
127AC_MSG_CHECKING(for alloca)
128AC_TRY_COMPILE( [#include <alloca.h>], [
129int foo=10;
130int *array = alloca(foo);
131],
132[
133has_alloca=yes;
134if test x$has_var_arrays = "xno" ; then
135AC_DEFINE([USE_ALLOCA], [], [Make use of alloca])
136fi
137],
138has_alloca=no
139)
140AC_MSG_RESULT($has_alloca)
141
Gregory Maxwell6c83b0b2012-05-14 00:30:34 -0400142AC_CHECK_FUNC(exp,[fp_libm_not_needed=yes;LIBM=],[fp_libm_not_needed=dunno])
143if test x"$fp_libm_not_needed" = xdunno; then
144 AC_CHECK_LIB([m], [exp], [LIBS="-lm $LIBS"; LIBM="-lm"],[LIBM=])
145fi
146AC_SUBST([LIBM])
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400147
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400148has_float_approx=no
149#case "$host_cpu" in
150#i[[3456]]86 | x86_64 | powerpc64 | powerpc32 | ia64)
151# has_float_approx=yes
152# ;;
153#esac
154
155ac_enable_fixed="no";
Gregory Maxwellde9b4372012-06-11 19:19:55 -0400156ac_enable_float="yes";
Jean-Marc Valin12190652012-08-31 23:35:12 -0400157AC_ARG_ENABLE(fixed-point, [ --enable-fixed-point compile without floating point (for machines without a fast enough FPU)],
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400158[if test "$enableval" = yes; then
159 ac_enable_fixed="yes";
Gregory Maxwellde9b4372012-06-11 19:19:55 -0400160 ac_enable_float="no";
Jean-Marc Valin12190652012-08-31 23:35:12 -0400161 AC_DEFINE([FIXED_POINT], [1], [Compile as fixed-point (for machines without a fast enough FPU)])
Ralph Gilesa66642a2012-09-16 23:15:37 -0700162fi])
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400163
164ac_enable_fixed_debug="no"
Gregory Maxwellde9b4372012-06-11 19:19:55 -0400165AC_ARG_ENABLE(fixed-point-debug, [ --enable-fixed-point-debug debug fixed-point implementation],
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400166[if test "$enableval" = yes; then
167 ac_enable_fixed_debug="yes"
168 AC_DEFINE([FIXED_DEBUG], , [Debug fixed-point implementation])
169fi])
170
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400171ac_enable_custom_modes="no"
Gregory Maxwellde9b4372012-06-11 19:19:55 -0400172AC_ARG_ENABLE(custom-modes, [ --enable-custom-modes enable non-Opus modes, e.g. 44.1 kHz & 2^n frames],
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400173[if test "$enableval" = yes; then
174 ac_enable_custom_modes="yes"
175 AC_DEFINE([CUSTOM_MODES], , [Custom modes])
176fi])
177
178float_approx=$has_float_approx
Gregory Maxwellde9b4372012-06-11 19:19:55 -0400179AC_ARG_ENABLE(float-approx, [ --enable-float-approx enable fast approximations for floating point],
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400180 [ if test "$enableval" = yes; then
181 AC_WARN([Floating point approximations are not supported on all platforms.])
182 float_approx=yes
183 else
184 float_approx=no
185 fi], [ float_approx=$has_float_approx ])
186
187if test "x${float_approx}" = "xyes"; then
188 AC_DEFINE([FLOAT_APPROX], , [Float approximations])
189fi
190
191ac_enable_assertions="no"
Gregory Maxwellde9b4372012-06-11 19:19:55 -0400192AC_ARG_ENABLE(assertions, [ --enable-assertions enable additional software error checking],
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400193[if test "$enableval" = yes; then
194 ac_enable_assertions="yes"
195 AC_DEFINE([ENABLE_ASSERTIONS], , [Assertions])
196fi])
197
Jean-Marc Valinf334c822011-08-11 16:21:58 -0400198ac_enable_fuzzing="no"
Gregory Maxwellde9b4372012-06-11 19:19:55 -0400199AC_ARG_ENABLE(fuzzing, [ --enable-fuzzing causes the encoder to make random decisions],
Jean-Marc Valinf334c822011-08-11 16:21:58 -0400200[if test "$enableval" = yes; then
201 ac_enable_fuzzing="yes"
202 AC_DEFINE([FUZZING], , [Fuzzing])
203fi])
204
Ralph Giles35d4fb72011-09-06 23:18:00 -0700205ac_enable_doc="yes"
206AC_ARG_ENABLE([doc],
207 AS_HELP_STRING([--disable-doc], [Do not build API documentation]),
208 [ac_enable_doc=$enableval])
209AC_CHECK_PROG(HAVE_DOXYGEN, [doxygen], [yes], [no])
210if test "$HAVE_DOXYGEN" != "yes" -o "$ac_enable_doc" != "yes"; then
211 HAVE_DOXYGEN="false"
212 ac_enable_doc="no"
213fi
214AM_CONDITIONAL(HAVE_DOXYGEN, [test $HAVE_DOXYGEN = yes])
215
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400216saved_CFLAGS="$CFLAGS"
217CFLAGS="$CFLAGS -fvisibility=hidden"
Gregory Maxwelle53ebd62011-10-21 14:21:53 -0400218AC_MSG_CHECKING([if ${CC} supports -fvisibility=hidden])
Gregory Maxwell6c83b0b2012-05-14 00:30:34 -0400219AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])],
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400220 [ AC_MSG_RESULT([yes])
221 SYMBOL_VISIBILITY="-fvisibility=hidden" ],
222 AC_MSG_RESULT([no]))
223CFLAGS="$saved_CFLAGS $SYMBOL_VISIBILITY"
224AC_SUBST(SYMBOL_VISIBILITY)
Gregory Maxwell6c83b0b2012-05-14 00:30:34 -0400225
Gregory Maxwell6c83b0b2012-05-14 00:30:34 -0400226CFLAGS="$CFLAGS -W"
227
228saved_CFLAGS="$CFLAGS"
229CFLAGS="$CFLAGS -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes"
230AC_MSG_CHECKING([if ${CC} supports -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes])
231AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])],
232 [ AC_MSG_RESULT([yes])
233 EXTRA_WARNS="-Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes" ],
234 AC_MSG_RESULT([no]))
235CFLAGS="$saved_CFLAGS $EXTRA_WARNS"
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400236
237AC_CHECK_FUNCS([lrintf])
238AC_CHECK_FUNCS([lrint])
Ralph Gilesc19bc342011-10-28 07:14:58 -0700239AC_CHECK_FUNCS([__malloc_hook])
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400240
241AC_CHECK_SIZEOF(short)
242AC_CHECK_SIZEOF(int)
243AC_CHECK_SIZEOF(long)
244AC_CHECK_SIZEOF(long long)
245
246if test x$has_char16 = "xyes" ; then
247 case 1 in
248 $ac_cv_sizeof_short) SIZE16="short";;
249 $ac_cv_sizeof_int) SIZE16="int";;
250 esac
251else
252 case 2 in
253 $ac_cv_sizeof_short) SIZE16="short";;
254 $ac_cv_sizeof_int) SIZE16="int";;
255 esac
256fi
257
258if test x$has_char16 = "xyes" ; then
259 case 2 in
260 $ac_cv_sizeof_int) SIZE32="int";;
261 $ac_cv_sizeof_long) SIZE32="long";;
262 $ac_cv_sizeof_short) SIZE32="short";;
263 esac
264else
265 case 4 in
266 $ac_cv_sizeof_int) SIZE32="int";;
267 $ac_cv_sizeof_long) SIZE32="long";;
268 $ac_cv_sizeof_short) SIZE32="short";;
269 esac
270fi
271
272AC_SUBST(SIZE16)
273AC_SUBST(SIZE32)
274
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400275AM_CONDITIONAL([FIXED_POINT], [test x$ac_enable_fixed = xyes])
Jean-Marc Valin06237d72011-09-01 13:20:40 -0400276AM_CONDITIONAL([CUSTOM_MODES], [test x$ac_enable_custom_modes = xyes])
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400277
Gregory Maxwell9652f812011-10-26 23:55:33 -0400278AC_OUTPUT([Makefile opus.pc opus-uninstalled.pc
Ralph Giles35d4fb72011-09-06 23:18:00 -0700279 doc/Makefile doc/Doxyfile])
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400280
281AC_MSG_RESULT([
282------------------------------------------------------------------------
283 $PACKAGE $VERSION: Automatic configuration OK.
284
285 Compiler support:
286
287 C99 var arrays: ................ ${has_var_arrays}
288 C99 lrintf: .................... ${ac_cv_func_lrintf}
289 Alloca: ........................ ${has_alloca}
290
291 General configuration:
292
Gregory Maxwellde9b4372012-06-11 19:19:55 -0400293 Floating point support: ........ ${ac_enable_float}
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400294 Fast float approximations: ..... ${float_approx}
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400295 Fixed point debugging: ......... ${ac_enable_fixed_debug}
296 Custom modes: .................. ${ac_enable_custom_modes}
297 Assertion checking: ............ ${ac_enable_assertions}
Gregory Maxwell48069bf2011-09-15 11:33:18 -0400298 Fuzzing: ....................... ${ac_enable_fuzzing}
Ralph Giles35d4fb72011-09-06 23:18:00 -0700299
300 API documentation: ............. ${ac_enable_doc}
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400301------------------------------------------------------------------------
302])
303
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400304echo "Type \"make; make install\" to compile and install";
305echo "Type \"make check\" to run the test suite";