Drop the stdint size tests that we never use anywhere
[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 #Use a hacked up version of autoconf's AC_C_RESTRICT because it's not
45 #strong enough a test to detect old buggy versions of GCC (e.g. 2.95.3)
46 AC_CACHE_CHECK([for C/C++ restrict keyword], ac_cv_c_restrict,
47   [ac_cv_c_restrict=no
48    # The order here caters to the fact that C++ does not require restrict.
49    for ac_kw in __restrict __restrict__ _Restrict restrict; do
50      AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
51       [[typedef int * int_ptr;
52         int foo (int_ptr $ac_kw ip, int * $ac_kw baz[]) {
53         return ip[0];
54        }]],
55       [[int s[1];
56         int * $ac_kw t = s;
57         t[0] = 0;
58         return foo(t, (void *)0)]])],
59       [ac_cv_c_restrict=$ac_kw])
60      test "$ac_cv_c_restrict" != no && break
61    done
62   ])
63  AH_VERBATIM([restrict],
64 [/* Define to the equivalent of the C99 'restrict' keyword, or to
65    nothing if this is not supported.  Do not define if restrict is
66    supported directly.  */
67 #undef restrict
68 /* Work around a bug in Sun C++: it does not support _Restrict or
69    __restrict__, even though the corresponding Sun C compiler ends up with
70    "#define restrict _Restrict" or "#define restrict __restrict__" in the
71    previous line.  Perhaps some future version of Sun C++ will work with
72    restrict; if so, hopefully it defines __RESTRICT like Sun C does.  */
73 #if defined __SUNPRO_CC && !defined __RESTRICT
74 # define _Restrict
75 # define __restrict__
76 #endif])
77  case $ac_cv_c_restrict in
78    restrict) ;;
79    no) AC_DEFINE([restrict], []) ;;
80    *)  AC_DEFINE_UNQUOTED([restrict], [$ac_cv_c_restrict]) ;;
81  esac
82
83 AC_DEFINE([OPUS_BUILD], [], [This is a build of OPUS])
84
85 AC_MSG_CHECKING(for C99 variable-size arrays)
86 AC_TRY_COMPILE( [], [static int x; char a[++x]; a[sizeof a - 1] = 0; int N; return a[0];],
87 [has_var_arrays=yes;AC_DEFINE([VAR_ARRAYS], [], [Use C99 variable-size arrays])
88 ],
89 has_var_arrays=no
90 )
91 AC_MSG_RESULT($has_var_arrays)
92
93 AC_CHECK_HEADERS([alloca.h getopt.h])
94 AC_MSG_CHECKING(for alloca)
95 AC_TRY_COMPILE( [#include <alloca.h>], [
96 int foo=10;
97 int *array = alloca(foo);
98 ],
99 [
100 has_alloca=yes;
101 if test x$has_var_arrays = "xno" ; then
102 AC_DEFINE([USE_ALLOCA], [], [Make use of alloca])
103 fi
104 ],
105 has_alloca=no
106 )
107 AC_MSG_RESULT($has_alloca)
108
109 AC_CHECK_FUNC(exp,[fp_libm_not_needed=yes;LIBM=],[fp_libm_not_needed=dunno])
110 if test x"$fp_libm_not_needed" = xdunno; then
111   AC_CHECK_LIB([m], [exp], [LIBS="-lm $LIBS"; LIBM="-lm"],[LIBM=])
112 fi
113 AC_SUBST([LIBM])
114
115 has_float_approx=no
116 #case "$host_cpu" in
117 #i[[3456]]86 | x86_64 | powerpc64 | powerpc32 | ia64)
118 #  has_float_approx=yes
119 #  ;;
120 #esac    
121
122 ac_enable_fixed="no";
123 ac_enable_float="yes";
124 AC_ARG_ENABLE(fixed-point, [  --enable-fixed-point       compile without floating point (for machines without a fast enough FPU)],
125 [if test "$enableval" = yes; then
126   ac_enable_fixed="yes";
127   ac_enable_float="no";
128   AC_DEFINE([FIXED_POINT], [1], [Compile as fixed-point (for machines without a fast enough FPU)])
129 fi])
130
131 ac_enable_fixed_debug="no"
132 AC_ARG_ENABLE(fixed-point-debug, [  --enable-fixed-point-debug debug fixed-point implementation],
133 [if test "$enableval" = yes; then
134   ac_enable_fixed_debug="yes"
135   AC_DEFINE([FIXED_DEBUG], , [Debug fixed-point implementation])
136 fi])
137
138 ac_enable_custom_modes="no"
139 AC_ARG_ENABLE(custom-modes, [  --enable-custom-modes      enable non-Opus modes, e.g. 44.1 kHz & 2^n frames],
140 [if test "$enableval" = yes; then
141   ac_enable_custom_modes="yes"
142   AC_DEFINE([CUSTOM_MODES], , [Custom modes])
143 fi])
144
145 float_approx=$has_float_approx
146 AC_ARG_ENABLE(float-approx, [  --enable-float-approx      enable fast approximations for floating point],
147     [ if test "$enableval" = yes; then
148     AC_WARN([Floating point approximations are not supported on all platforms.])
149     float_approx=yes
150     else
151     float_approx=no
152     fi], [ float_approx=$has_float_approx ])
153
154 if test "x${float_approx}" = "xyes"; then
155     AC_DEFINE([FLOAT_APPROX], , [Float approximations])
156 fi
157
158 rtcd_support=no
159 cpu_arm=no
160 AC_ARG_ENABLE(asm,
161     AS_HELP_STRING([--disable-asm], [Disable assembly optimizations]),
162     [ ac_enable_asm=$enableval ], [ ac_enable_asm=yes] )
163 if test "x${ac_enable_asm}" = xyes ; then
164     asm_optimization="no asm for your platform, please send patches"
165     case $host_cpu in
166     arm*)
167         cpu_arm=yes
168         AS_GCC_INLINE_ASSEMBLY([asm_optimization="ARM"],
169             [asm_optimization="disabled"])
170         if test "x${asm_optimization}" = "xARM" ; then
171             rtcd_support=yes
172             AC_DEFINE([ARMv4_ASM], 1, [Use generic ARMv4 asm optimizations])
173             AS_ASM_ARM_EDSP([ARMv5E_ASM=1],[ARMv5E_ASM=0])
174             if test "x${ARMv5E_ASM}" = "x1" ; then
175                 AC_DEFINE(ARMv5E_ASM, 1, [Use ARMv5E asm optimizations])
176                 asm_optimization="${asm_optimization} (EDSP)"
177             fi
178             AS_ASM_ARM_MEDIA([ARMv6_ASM=1],[ARMv6_ASM=0])
179             if test "x${ARMv6_ASM}" = "x1" ; then
180                 AC_DEFINE(ARMv6_ASM, 1, [Use ARMv6 asm optimizations])
181                 asm_optimization="${asm_optimization} (Media)"
182             fi
183             AS_ASM_ARM_NEON([ARM_HAVE_NEON=1],[ARM_HAVE_NEON=0])
184             if test "x${ARM_HAVE_NEON}" = "x1" ; then
185               AC_DEFINE([ARM_HAVE_NEON], 1, [Use ARM NEON optimizations])
186               asm_optimization="${asm_optimization} (NEON)"
187             fi
188         fi
189         ;;
190     esac
191 else
192     asm_optimization="disabled"
193 fi
194
195 AC_ARG_ENABLE(rtcd,
196     AS_HELP_STRING([--disable-rtcd], [Disable run-time CPU capabilities detection]),
197     [ ac_enable_rtcd=$enableval ], [ ac_enable_rtcd=yes] )
198 if test "x${ac_enable_rtcd}" = xyes -a "x${rtcd_support}" = xyes ; then
199     AC_DEFINE([OPUS_HAVE_RTCD], 1, [Use run-time CPU capabilities detection])
200 elif test "x${rtcd_support}" = xno ; then
201     rtcd_support="no rtcd for your platform, please send patches"
202 else
203     rtcd_support="no"
204 fi
205
206 ac_enable_assertions="no"
207 AC_ARG_ENABLE(assertions, [  --enable-assertions        enable additional software error checking],
208 [if test "$enableval" = yes; then
209   ac_enable_assertions="yes"
210   AC_DEFINE([ENABLE_ASSERTIONS], , [Assertions])
211 fi])
212
213 ac_enable_fuzzing="no"
214 AC_ARG_ENABLE(fuzzing, [  --enable-fuzzing           causes the encoder to make random decisions],
215 [if test "$enableval" = yes; then
216   ac_enable_fuzzing="yes"
217   AC_DEFINE([FUZZING], , [Fuzzing])
218 fi])
219
220 ac_enable_doc="yes"
221 AC_ARG_ENABLE([doc],
222   AS_HELP_STRING([--disable-doc], [Do not build API documentation]),
223                  [ac_enable_doc=$enableval])
224 AC_CHECK_PROG(HAVE_DOXYGEN, [doxygen], [yes], [no])
225 if test "$HAVE_DOXYGEN" != "yes" -o "$ac_enable_doc" != "yes"; then
226   HAVE_DOXYGEN="false"
227   ac_enable_doc="no"
228 fi
229 AM_CONDITIONAL(HAVE_DOXYGEN, [test $HAVE_DOXYGEN = yes])
230
231 ac_enable_extra_programs="yes"
232 AC_ARG_ENABLE([extra-programs],
233               AS_HELP_STRING([--disable-extra-programs], [Do not build extra programs (demo and tests)]),
234               [ac_enable_extra_programs=$enableval])
235 if test "$ac_enable_extra_programs" != "yes"; then
236   ac_enable_extra_progs="no"
237 fi
238
239 saved_CFLAGS="$CFLAGS"
240 CFLAGS="$CFLAGS -fvisibility=hidden"
241 AC_MSG_CHECKING([if ${CC} supports -fvisibility=hidden])
242 AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])],
243       [ AC_MSG_RESULT([yes])
244         SYMBOL_VISIBILITY="-fvisibility=hidden" ],
245         AC_MSG_RESULT([no]))
246 CFLAGS="$saved_CFLAGS $SYMBOL_VISIBILITY"
247 AC_SUBST(SYMBOL_VISIBILITY)
248
249 CFLAGS="$CFLAGS -W"
250
251 warn_CFLAGS="-Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes"
252 saved_CFLAGS="$CFLAGS"
253 CFLAGS="$CFLAGS $warn_CFLAGS"
254 AC_MSG_CHECKING([if ${CC} supports ${warn_CFLAGS}])
255 AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])],
256       [ AC_MSG_RESULT([yes])
257         EXTRA_WARNS=$warn_CFLAGS ],
258         AC_MSG_RESULT([no]))
259 CFLAGS="$saved_CFLAGS $EXTRA_WARNS"
260
261 AC_CHECK_FUNCS([lrintf])
262 AC_CHECK_FUNCS([lrint])
263 AC_CHECK_FUNCS([__malloc_hook])
264
265 AM_CONDITIONAL([FIXED_POINT], [test x$ac_enable_fixed = xyes])
266 AM_CONDITIONAL([CUSTOM_MODES], [test x$ac_enable_custom_modes = xyes])
267 AM_CONDITIONAL([EXTRA_PROGRAMS], [test x$ac_enable_extra_programs = xyes])
268 AM_CONDITIONAL([CPU_ARM], [test x$cpu_arm = xyes])
269
270 dnl subsitutions for the pkg-config files
271 if test x$ac_enable_float = xyes; then
272   PC_BUILD="floating-point"
273   PC_LIBM=$LIBM
274 else
275   PC_BUILD="fixed-point"
276   PC_LIBM=
277 fi
278 dnl opus_custom requires libm as well
279 if test x$ac_enable_custom_modes = xyes; then
280   PC_BUILD="${PC_BUILD}, custom modes"
281   PC_LIBM=$LIBM
282 fi
283 AC_SUBST([PC_BUILD])
284 AC_SUBST([PC_LIBM])
285
286
287 AC_CONFIG_FILES([Makefile opus.pc opus-uninstalled.pc
288                  doc/Makefile doc/Doxyfile])
289 AC_CONFIG_HEADERS([config.h])
290
291 AC_OUTPUT
292
293 AC_MSG_NOTICE([
294 ------------------------------------------------------------------------
295   $PACKAGE_NAME $PACKAGE_VERSION:  Automatic configuration OK.
296
297     Compiler support:
298
299       C99 var arrays: ................ ${has_var_arrays}
300       C99 lrintf: .................... ${ac_cv_func_lrintf}
301       Alloca: ........................ ${has_alloca}
302     
303     General configuration:
304     
305       Floating point support: ........ ${ac_enable_float}
306       Fast float approximations: ..... ${float_approx}
307       Fixed point debugging: ......... ${ac_enable_fixed_debug}
308       Assembly optimization: ......... ${asm_optimization}
309       Run-time CPU detection: ........ ${rtcd_support}
310       Custom modes: .................. ${ac_enable_custom_modes}
311       Assertion checking: ............ ${ac_enable_assertions}
312       Fuzzing: ....................... ${ac_enable_fuzzing}
313
314       API documentation: ............. ${ac_enable_doc}
315       Extra programs: ................ ${ac_enable_extra_programs}
316 ------------------------------------------------------------------------
317
318  Type "make; make install" to compile and install
319  Type "make check" to run the test suite
320 ])
321