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