Merges the 4th order FIR with the first order FIR in pitch_downsample()
[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 cpu_arm=no
159 AC_ARG_ENABLE(asm,
160     AS_HELP_STRING([--disable-asm], [Disable assembly optimizations]),
161     [ ac_enable_asm=$enableval ], [ ac_enable_asm=yes] )
162 if test "x${ac_enable_asm}" = xyes ; then
163     asm_optimization="no asm for your platform, please send patches"
164     case $host_cpu in
165     arm*)
166         cpu_arm=yes
167         AS_GCC_INLINE_ASSEMBLY([asm_optimization="ARM"],
168             [asm_optimization="disabled"])
169         if test "x${asm_optimization}" = "xARM" ; then
170             AC_DEFINE([ARMv4_ASM], 1, [Use generic ARMv4 asm optimizations])
171             AS_ASM_ARM_EDSP([ARMv5E_ASM=1],[ARMv5E_ASM=0])
172             if test "x${ARMv5E_ASM}" = "x1" ; then
173                 AC_DEFINE(ARMv5E_ASM, 1, [Use ARMv5E asm optimizations])
174                 asm_optimization="${asm_optimization} (EDSP)"
175             fi
176             AS_ASM_ARM_MEDIA([ARMv6_ASM=1],[ARMv6_ASM=0])
177             if test "x${ARMv6_ASM}" = "x1" ; then
178                 AC_DEFINE(ARMv6_ASM, 1, [Use ARMv6 asm optimizations])
179                 asm_optimization="${asm_optimization} (Media)"
180             fi
181         fi
182         ;;
183     esac
184 else
185     asm_optimization="disabled"
186 fi
187
188 ac_enable_assertions="no"
189 AC_ARG_ENABLE(assertions, [  --enable-assertions        enable additional software error checking],
190 [if test "$enableval" = yes; then
191   ac_enable_assertions="yes"
192   AC_DEFINE([ENABLE_ASSERTIONS], , [Assertions])
193 fi])
194
195 ac_enable_fuzzing="no"
196 AC_ARG_ENABLE(fuzzing, [  --enable-fuzzing           causes the encoder to make random decisions],
197 [if test "$enableval" = yes; then
198   ac_enable_fuzzing="yes"
199   AC_DEFINE([FUZZING], , [Fuzzing])
200 fi])
201
202 ac_enable_doc="yes"
203 AC_ARG_ENABLE([doc],
204   AS_HELP_STRING([--disable-doc], [Do not build API documentation]),
205                  [ac_enable_doc=$enableval])
206 AC_CHECK_PROG(HAVE_DOXYGEN, [doxygen], [yes], [no])
207 if test "$HAVE_DOXYGEN" != "yes" -o "$ac_enable_doc" != "yes"; then
208   HAVE_DOXYGEN="false"
209   ac_enable_doc="no"
210 fi
211 AM_CONDITIONAL(HAVE_DOXYGEN, [test $HAVE_DOXYGEN = yes])
212
213 saved_CFLAGS="$CFLAGS"
214 CFLAGS="$CFLAGS -fvisibility=hidden"
215 AC_MSG_CHECKING([if ${CC} supports -fvisibility=hidden])
216 AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])],
217       [ AC_MSG_RESULT([yes])
218         SYMBOL_VISIBILITY="-fvisibility=hidden" ],
219         AC_MSG_RESULT([no]))
220 CFLAGS="$saved_CFLAGS $SYMBOL_VISIBILITY"
221 AC_SUBST(SYMBOL_VISIBILITY)
222
223 CFLAGS="$CFLAGS -W"
224
225 warn_CFLAGS="-Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes"
226 saved_CFLAGS="$CFLAGS"
227 CFLAGS="$CFLAGS $warn_CFLAGS"
228 AC_MSG_CHECKING([if ${CC} supports ${warn_CFLAGS}])
229 AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])],
230       [ AC_MSG_RESULT([yes])
231         EXTRA_WARNS=$warn_CFLAGS ],
232         AC_MSG_RESULT([no]))
233 CFLAGS="$saved_CFLAGS $EXTRA_WARNS"
234
235 AC_CHECK_FUNCS([lrintf])
236 AC_CHECK_FUNCS([lrint])
237 AC_CHECK_FUNCS([__malloc_hook])
238
239 AC_CHECK_SIZEOF(short)
240 AC_CHECK_SIZEOF(int)
241 AC_CHECK_SIZEOF(long)
242 AC_CHECK_SIZEOF(long long)
243
244 if 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
249 else
250         case 2 in
251                 $ac_cv_sizeof_short) SIZE16="short";;
252                 $ac_cv_sizeof_int) SIZE16="int";;
253         esac
254 fi
255
256 if 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
262 else
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
268 fi
269
270 AC_SUBST(SIZE16)
271 AC_SUBST(SIZE32)
272
273 AM_CONDITIONAL([FIXED_POINT], [test x$ac_enable_fixed = xyes])
274 AM_CONDITIONAL([CUSTOM_MODES], [test x$ac_enable_custom_modes = xyes])
275
276 dnl subsitutions for the pkg-config files
277 if test x$ac_enable_float = xyes; then
278   PC_BUILD="floating-point"
279   PC_LIBM=$LIBM
280 else
281   PC_BUILD="fixed-point"
282   PC_LIBM=
283 fi
284 dnl opus_custom requires libm as well
285 if test x$ac_enable_custom_modes = xyes; then
286   PC_BUILD="${PC_BUILD}, custom modes"
287   PC_LIBM=$LIBM
288 fi
289 AC_SUBST([PC_BUILD])
290 AC_SUBST([PC_LIBM])
291
292
293 AC_CONFIG_FILES([Makefile opus.pc opus-uninstalled.pc
294                  doc/Makefile doc/Doxyfile])
295 AC_CONFIG_HEADERS([config.h])
296
297 AC_OUTPUT
298
299 AC_MSG_RESULT([
300 ------------------------------------------------------------------------
301   $PACKAGE_NAME $PACKAGE_VERSION:  Automatic configuration OK.
302
303     Compiler support:
304
305       C99 var arrays: ................ ${has_var_arrays}
306       C99 lrintf: .................... ${ac_cv_func_lrintf}
307       Alloca: ........................ ${has_alloca}
308     
309     General configuration:
310     
311       Floating point support: ........ ${ac_enable_float}
312       Fast float approximations: ..... ${float_approx}
313       Fixed point debugging: ......... ${ac_enable_fixed_debug}
314       Assembly optimization: ......... ${asm_optimization}
315       Custom modes: .................. ${ac_enable_custom_modes}
316       Assertion checking: ............ ${ac_enable_assertions}
317       Fuzzing: ....................... ${ac_enable_fuzzing}
318
319       API documentation: ............. ${ac_enable_doc}
320 ------------------------------------------------------------------------
321 ])
322
323 echo "Type \"make; make install\" to compile and install";
324 echo "Type \"make check\" to run the test suite";