Temporal VBR tuning
[opus.git] / configure.ac
1 dnl Process this file with autoconf to produce a configure script. -*-m4-*-
2
3 dnl The package_version file will be automatically synced to the git revision
4 dnl by the update_version script when configured in the repository, but will
5 dnl remain constant in tarball releases unless it is manually edited.
6 m4_define([CURRENT_VERSION],
7           m4_esyscmd([ if test -e package_version || ./update_version; then
8                            . ./package_version
9                            printf "$PACKAGE_VERSION"
10                        else
11                            printf "unknown"
12                        fi ]))
13
14 AC_INIT([opus],[CURRENT_VERSION],[opus@xiph.org])
15
16 AC_CONFIG_SRCDIR(src/opus_encoder.c)
17 AC_CONFIG_MACRO_DIR([m4])
18
19 dnl enable silent rules on automake 1.11 and later
20 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
21
22 # For libtool.
23 dnl Please update these for releases.
24 OPUS_LT_CURRENT=4
25 OPUS_LT_REVISION=0
26 OPUS_LT_AGE=4
27
28 AC_SUBST(OPUS_LT_CURRENT)
29 AC_SUBST(OPUS_LT_REVISION)
30 AC_SUBST(OPUS_LT_AGE)
31
32 AM_INIT_AUTOMAKE([no-define])
33 AM_MAINTAINER_MODE([enable])
34
35 AC_CANONICAL_HOST
36 AC_MINGW32
37 AM_PROG_LIBTOOL
38 AM_PROG_CC_C_O
39
40 AC_PROG_CC_C99
41 AC_C_CONST
42 AC_C_INLINE
43
44 AC_DEFINE([OPUS_BUILD], [], [This is a build of OPUS])
45
46 #Use a hacked up version of autoconf's AC_C_RESTRICT because it's not
47 #strong enough a test to detect old buggy versions of GCC (e.g. 2.95.3)
48 #Note: Both this and the test for variable-size arrays below are also
49 #      done by AC_PROG_CC_C99, but not thoroughly enough apparently.
50 AC_CACHE_CHECK([for C/C++ restrict keyword], ac_cv_c_restrict,
51   [ac_cv_c_restrict=no
52    # The order here caters to the fact that C++ does not require restrict.
53    for ac_kw in __restrict __restrict__ _Restrict restrict; do
54      AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
55       [[typedef int * int_ptr;
56         int foo (int_ptr $ac_kw ip, int * $ac_kw baz[]) {
57         return ip[0];
58        }]],
59       [[int s[1];
60         int * $ac_kw t = s;
61         t[0] = 0;
62         return foo(t, (void *)0)]])],
63       [ac_cv_c_restrict=$ac_kw])
64      test "$ac_cv_c_restrict" != no && break
65    done
66   ])
67
68 AH_VERBATIM([restrict],
69 [/* Define to the equivalent of the C99 'restrict' keyword, or to
70    nothing if this is not supported.  Do not define if restrict is
71    supported directly.  */
72 #undef restrict
73 /* Work around a bug in Sun C++: it does not support _Restrict or
74    __restrict__, even though the corresponding Sun C compiler ends up with
75    "#define restrict _Restrict" or "#define restrict __restrict__" in the
76    previous line.  Perhaps some future version of Sun C++ will work with
77    restrict; if so, hopefully it defines __RESTRICT like Sun C does.  */
78 #if defined __SUNPRO_CC && !defined __RESTRICT
79 # define _Restrict
80 # define __restrict__
81 #endif])
82
83 case $ac_cv_c_restrict in
84    restrict) ;;
85    no) AC_DEFINE([restrict], []) ;;
86    *)  AC_DEFINE_UNQUOTED([restrict], [$ac_cv_c_restrict]) ;;
87 esac
88
89 AC_MSG_CHECKING(for C99 variable-size arrays)
90 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
91                    [[static int x; char a[++x]; a[sizeof a - 1] = 0; int N; return a[0];]])],
92     [ has_var_arrays=yes
93       use_alloca="no (using var arrays)"
94       AC_DEFINE([VAR_ARRAYS], [1], [Use C99 variable-size arrays])
95     ],[
96       has_var_arrays=no
97     ])
98 AC_MSG_RESULT([$has_var_arrays])
99
100 AS_IF([test "$has_var_arrays" = "no"],
101   [
102    AC_CHECK_HEADERS([alloca.h])
103    AC_MSG_CHECKING(for alloca)
104    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <alloca.h>]],
105                                       [[int foo=10; int *array = alloca(foo);]])],
106      [ use_alloca=yes;
107        AC_DEFINE([USE_ALLOCA], [], [Make use of alloca])
108      ],[
109        use_alloca=no
110      ])
111    AC_MSG_RESULT([$use_alloca])
112   ])
113
114 LT_LIB_M
115
116 AC_ARG_ENABLE([fixed-point],
117     [AS_HELP_STRING([--enable-fixed-point],
118                     [compile without floating point (for machines without a fast enough FPU)])],,
119     [enable_fixed_point=no])
120
121 AS_IF([test "$enable_fixed_point" = "yes"],[
122   enable_float="no"
123   AC_DEFINE([FIXED_POINT], [1], [Compile as fixed-point (for machines without a fast enough FPU)])
124   PC_BUILD="fixed-point"
125 ],[
126   enable_float="yes";
127   PC_BUILD="floating-point"
128 ])
129
130 AM_CONDITIONAL([FIXED_POINT], [test "$enable_fixed_point" = "yes"])
131
132 AC_ARG_ENABLE([fixed-point-debug],
133     [AS_HELP_STRING([--enable-fixed-point-debug], [debug fixed-point implementation])],,
134     [enable_fixed_point_debug=no])
135
136 AS_IF([test "$enable_fixed_point_debug" = "yes"],[
137   AC_DEFINE([FIXED_DEBUG], [1], [Debug fixed-point implementation])
138 ])
139
140 AC_ARG_ENABLE([custom-modes],
141     [AS_HELP_STRING([--enable-custom-modes], [enable non-Opus modes, e.g. 44.1 kHz & 2^n frames])],,
142     [enable_custom_modes=no])
143
144 AS_IF([test "$enable_custom_modes" = "yes"],[
145   AC_DEFINE([CUSTOM_MODES], [1], [Custom modes])
146   PC_BUILD="$PC_BUILD, custom modes"
147 ])
148
149 AM_CONDITIONAL([CUSTOM_MODES], [test "$enable_custom_modes" = "yes"])
150
151 has_float_approx=no
152 #case "$host_cpu" in
153 #i[[3456]]86 | x86_64 | powerpc64 | powerpc32 | ia64)
154 #  has_float_approx=yes
155 #  ;;
156 #esac    
157
158 AC_ARG_ENABLE([float-approx],
159     [AS_HELP_STRING([--enable-float-approx], [enable fast approximations for floating point])],
160     [if test "$enable_float_approx" = "yes"; then
161        AC_WARN([Floating point approximations are not supported on all platforms.])
162      fi
163     ],
164     [enable_float_approx=$has_float_approx])
165
166 AS_IF([test "$enable_float_approx" = "yes"],[
167   AC_DEFINE([FLOAT_APPROX], [1], [Float approximations])
168 ])
169
170 AC_ARG_ENABLE([asm],
171     [AS_HELP_STRING([--disable-asm], [Disable assembly optimizations])],,
172     [enable_asm=yes])
173
174 rtcd_support=no
175 cpu_arm=no
176
177 AS_IF([test "$enable_asm" = "yes"],[
178     asm_optimization="no asm for your platform, please send patches"
179     case $host_cpu in
180     arm*)
181         cpu_arm=yes
182         AS_GCC_INLINE_ASSEMBLY([asm_optimization="ARM"],
183             [asm_optimization="disabled"])
184         if test "$asm_optimization" = "ARM" ; then
185             rtcd_support=yes
186             AC_DEFINE([ARMv4_ASM], 1, [Use generic ARMv4 asm optimizations])
187             AS_ASM_ARM_EDSP([ARMv5E_ASM=1],[ARMv5E_ASM=0])
188             if test "$ARMv5E_ASM" = "1" ; then
189                 AC_DEFINE([ARMv5E_ASM], [1], [Use ARMv5E asm optimizations])
190                 asm_optimization="$asm_optimization (EDSP)"
191             fi
192             AS_ASM_ARM_MEDIA([ARMv6_ASM=1],[ARMv6_ASM=0])
193             if test "$ARMv6_ASM" = "1" ; then
194                 AC_DEFINE([ARMv6_ASM], [1], [Use ARMv6 asm optimizations])
195                 asm_optimization="$asm_optimization (Media)"
196             fi
197             AS_ASM_ARM_NEON([ARM_HAVE_NEON=1],[ARM_HAVE_NEON=0])
198             if test "$ARM_HAVE_NEON" = "1" ; then
199               AC_DEFINE([ARM_HAVE_NEON], 1, [Use ARM NEON optimizations])
200               asm_optimization="$asm_optimization (NEON)"
201             fi
202         fi
203         ;;
204     esac
205 ],[
206     asm_optimization="disabled"
207 ])
208
209 AM_CONDITIONAL([CPU_ARM], [test "$cpu_arm" = "yes"])
210
211 AC_ARG_ENABLE([rtcd],
212     [AS_HELP_STRING([--disable-rtcd], [Disable run-time CPU capabilities detection])],,
213     [enable_rtcd=yes])
214
215 AS_IF([test "$enable_rtcd" = "yes"],[
216     AS_IF([test "$rtcd_support" = "yes"],[
217         AC_DEFINE([OPUS_HAVE_RTCD], [1], [Use run-time CPU capabilities detection])
218     ],[
219         rtcd_support="no rtcd for your platform, please send patches"
220     ])
221 ],[
222     rtcd_support="no"
223 ])
224
225 AC_ARG_ENABLE([assertions],
226     [AS_HELP_STRING([--enable-assertions],[enable additional software error checking])],,
227     [enable_assertions=no])
228
229 AS_IF([test "$enable_assertions" = "yes"], [
230   AC_DEFINE([ENABLE_ASSERTIONS], [1], [Assertions])
231 ])
232
233 AC_ARG_ENABLE([fuzzing],
234     [AS_HELP_STRING([--enable-fuzzing],[causes the encoder to make random decisions])],,
235     [enable_fuzzing=no])
236
237 AS_IF([test "$enable_fuzzing" = "yes"], [
238   AC_DEFINE([FUZZING], [1], [Fuzzing])
239 ])
240
241 AC_ARG_ENABLE([doc],
242     [AS_HELP_STRING([--disable-doc], [Do not build API documentation])],,
243     [enable_doc=yes])
244
245 AS_IF([test "$enable_doc" = "yes"], [
246   AC_CHECK_PROG(HAVE_DOXYGEN, [doxygen], [yes], [no])
247 ],[
248   HAVE_DOXYGEN=no
249 ])
250
251 AM_CONDITIONAL([HAVE_DOXYGEN], [test "$HAVE_DOXYGEN" = "yes"])
252
253 AC_ARG_ENABLE([extra-programs],
254     [AS_HELP_STRING([--disable-extra-programs], [Do not build extra programs (demo and tests)])],,
255     [enable_extra_programs=yes])
256
257 AM_CONDITIONAL([EXTRA_PROGRAMS], [test "$enable_extra_programs" = "yes"])
258
259
260 saved_CFLAGS="$CFLAGS"
261 CFLAGS="$CFLAGS -fvisibility=hidden"
262 AC_MSG_CHECKING([if ${CC} supports -fvisibility=hidden])
263 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[char foo;]])],
264     [ AC_MSG_RESULT([yes]) ],
265     [ AC_MSG_RESULT([no])
266       CFLAGS="$saved_CFLAGS"
267     ])
268
269 CFLAGS="$CFLAGS -W"
270
271 warn_CFLAGS="-Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes"
272 saved_CFLAGS="$CFLAGS"
273 CFLAGS="$CFLAGS $warn_CFLAGS"
274 AC_MSG_CHECKING([if ${CC} supports ${warn_CFLAGS}])
275 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[char foo;]])],
276     [ AC_MSG_RESULT([yes]) ],
277     [ AC_MSG_RESULT([no])
278       CFLAGS="$saved_CFLAGS"
279     ])
280
281 saved_LIBS="$LIBS"
282 LIBS="$LIBS $LIBM"
283 AC_CHECK_FUNCS([lrintf])
284 AC_CHECK_FUNCS([lrint])
285 LIBS="$saved_LIBS"
286
287 AC_CHECK_FUNCS([__malloc_hook])
288
289 AC_SUBST([PC_BUILD])
290
291
292 AC_CONFIG_FILES([Makefile opus.pc opus-uninstalled.pc
293                  doc/Makefile doc/Doxyfile])
294 AC_CONFIG_HEADERS([config.h])
295
296 AC_OUTPUT
297
298 AC_MSG_NOTICE([
299 ------------------------------------------------------------------------
300   $PACKAGE_NAME $PACKAGE_VERSION:  Automatic configuration OK.
301
302     Compiler support:
303
304       C99 var arrays: ................ ${has_var_arrays}
305       C99 lrintf: .................... ${ac_cv_func_lrintf}
306       Use alloca: .................... ${use_alloca}
307     
308     General configuration:
309     
310       Floating point support: ........ ${enable_float}
311       Fast float approximations: ..... ${enable_float_approx}
312       Fixed point debugging: ......... ${enable_fixed_point_debug}
313       Assembly optimization: ......... ${asm_optimization}
314       Run-time CPU detection: ........ ${rtcd_support}
315       Custom modes: .................. ${enable_custom_modes}
316       Assertion checking: ............ ${enable_assertions}
317       Fuzzing: ....................... ${enable_fuzzing}
318
319       API documentation: ............. ${enable_doc}
320       Extra programs: ................ ${enable_extra_programs}
321 ------------------------------------------------------------------------
322
323  Type "make; make install" to compile and install
324  Type "make check" to run the test suite
325 ])
326