blob: 0546fa491d0c27734da566f5dbea4baa063186c5 [file] [log] [blame]
Alexandre Lision744f7422013-09-25 11:39:37 -04001dnl Process this file with autoconf to produce a configure script. -*-m4-*-
2
3dnl The package_version file will be automatically synced to the git revision
4dnl by the update_version script when configured in the repository, but will
5dnl remain constant in tarball releases unless it is manually edited.
6m4_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
14AC_INIT([opus],[CURRENT_VERSION],[opus@xiph.org])
15
16AC_CONFIG_SRCDIR(src/opus_encoder.c)
17
18dnl enable silent rules on automake 1.11 and later
19m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
20
21
22# For libtool.
23dnl Please update these for releases.
24OPUS_LT_CURRENT=4
25OPUS_LT_REVISION=0
26OPUS_LT_AGE=4
27
28AC_SUBST(OPUS_LT_CURRENT)
29AC_SUBST(OPUS_LT_REVISION)
30AC_SUBST(OPUS_LT_AGE)
31
32AM_INIT_AUTOMAKE([no-define])
33AM_MAINTAINER_MODE([enable])
34
35AC_CANONICAL_HOST
36AC_MINGW32
37AM_PROG_LIBTOOL
38AM_PROG_CC_C_O
39
40AC_PROG_CC_C99
41AC_C_CONST
42AC_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)
46AC_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
83AC_DEFINE([OPUS_BUILD], [], [This is a build of OPUS])
84
85AC_MSG_CHECKING(for C99 variable-size arrays)
86AC_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],
89has_var_arrays=no
90)
91AC_MSG_RESULT($has_var_arrays)
92
93AC_CHECK_HEADERS([alloca.h getopt.h])
94AC_MSG_CHECKING(for alloca)
95AC_TRY_COMPILE( [#include <alloca.h>], [
96int foo=10;
97int *array = alloca(foo);
98],
99[
100has_alloca=yes;
101if test x$has_var_arrays = "xno" ; then
102AC_DEFINE([USE_ALLOCA], [], [Make use of alloca])
103fi
104],
105has_alloca=no
106)
107AC_MSG_RESULT($has_alloca)
108
109AC_CHECK_FUNC(exp,[fp_libm_not_needed=yes;LIBM=],[fp_libm_not_needed=dunno])
110if test x"$fp_libm_not_needed" = xdunno; then
111 AC_CHECK_LIB([m], [exp], [LIBS="-lm $LIBS"; LIBM="-lm"],[LIBM=])
112fi
113AC_SUBST([LIBM])
114
115has_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
122ac_enable_fixed="no";
123ac_enable_float="yes";
124AC_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)])
129fi])
130
131ac_enable_fixed_debug="no"
132AC_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])
136fi])
137
138ac_enable_custom_modes="no"
139AC_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])
143fi])
144
145float_approx=$has_float_approx
146AC_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
154if test "x${float_approx}" = "xyes"; then
155 AC_DEFINE([FLOAT_APPROX], , [Float approximations])
156fi
157
158ac_enable_assertions="no"
159AC_ARG_ENABLE(assertions, [ --enable-assertions enable additional software error checking],
160[if test "$enableval" = yes; then
161 ac_enable_assertions="yes"
162 AC_DEFINE([ENABLE_ASSERTIONS], , [Assertions])
163fi])
164
165ac_enable_fuzzing="no"
166AC_ARG_ENABLE(fuzzing, [ --enable-fuzzing causes the encoder to make random decisions],
167[if test "$enableval" = yes; then
168 ac_enable_fuzzing="yes"
169 AC_DEFINE([FUZZING], , [Fuzzing])
170fi])
171
172ac_enable_doc="yes"
173AC_ARG_ENABLE([doc],
174 AS_HELP_STRING([--disable-doc], [Do not build API documentation]),
175 [ac_enable_doc=$enableval])
176AC_CHECK_PROG(HAVE_DOXYGEN, [doxygen], [yes], [no])
177if test "$HAVE_DOXYGEN" != "yes" -o "$ac_enable_doc" != "yes"; then
178 HAVE_DOXYGEN="false"
179 ac_enable_doc="no"
180fi
181AM_CONDITIONAL(HAVE_DOXYGEN, [test $HAVE_DOXYGEN = yes])
182
183saved_CFLAGS="$CFLAGS"
184CFLAGS="$CFLAGS -fvisibility=hidden"
185AC_MSG_CHECKING([if ${CC} supports -fvisibility=hidden])
186AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])],
187 [ AC_MSG_RESULT([yes])
188 SYMBOL_VISIBILITY="-fvisibility=hidden" ],
189 AC_MSG_RESULT([no]))
190CFLAGS="$saved_CFLAGS $SYMBOL_VISIBILITY"
191AC_SUBST(SYMBOL_VISIBILITY)
192
193CFLAGS="$CFLAGS -W"
194
195saved_CFLAGS="$CFLAGS"
196CFLAGS="$CFLAGS -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes"
197AC_MSG_CHECKING([if ${CC} supports -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes])
198AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])],
199 [ AC_MSG_RESULT([yes])
200 EXTRA_WARNS="-Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes" ],
201 AC_MSG_RESULT([no]))
202CFLAGS="$saved_CFLAGS $EXTRA_WARNS"
203
204AC_CHECK_FUNCS([lrintf])
205AC_CHECK_FUNCS([lrint])
206AC_CHECK_FUNCS([__malloc_hook])
207
208AC_CHECK_SIZEOF(short)
209AC_CHECK_SIZEOF(int)
210AC_CHECK_SIZEOF(long)
211AC_CHECK_SIZEOF(long long)
212
213if test x$has_char16 = "xyes" ; then
214 case 1 in
215 $ac_cv_sizeof_short) SIZE16="short";;
216 $ac_cv_sizeof_int) SIZE16="int";;
217 esac
218else
219 case 2 in
220 $ac_cv_sizeof_short) SIZE16="short";;
221 $ac_cv_sizeof_int) SIZE16="int";;
222 esac
223fi
224
225if test x$has_char16 = "xyes" ; then
226 case 2 in
227 $ac_cv_sizeof_int) SIZE32="int";;
228 $ac_cv_sizeof_long) SIZE32="long";;
229 $ac_cv_sizeof_short) SIZE32="short";;
230 esac
231else
232 case 4 in
233 $ac_cv_sizeof_int) SIZE32="int";;
234 $ac_cv_sizeof_long) SIZE32="long";;
235 $ac_cv_sizeof_short) SIZE32="short";;
236 esac
237fi
238
239AC_SUBST(SIZE16)
240AC_SUBST(SIZE32)
241
242AM_CONDITIONAL([FIXED_POINT], [test x$ac_enable_fixed = xyes])
243AM_CONDITIONAL([CUSTOM_MODES], [test x$ac_enable_custom_modes = xyes])
244
245dnl subsitutions for the pkg-config files
246if test x$ac_enable_float = xyes; then
247 PC_BUILD="floating-point"
248 PC_LIBM=$LIBM
249else
250 PC_BUILD="fixed-point"
251 PC_LIBM=
252fi
253dnl opus_custom requires libm as well
254if test x$ac_enable_custom_modes = xyes; then
255 PC_BUILD="${PC_BUILD}, custom modes"
256 PC_LIBM=$LIBM
257fi
258AC_SUBST([PC_BUILD])
259AC_SUBST([PC_LIBM])
260
261
262AC_CONFIG_FILES([Makefile opus.pc opus-uninstalled.pc
263 doc/Makefile doc/Doxyfile])
264AC_CONFIG_HEADERS([config.h])
265
266AC_OUTPUT
267
268AC_MSG_RESULT([
269------------------------------------------------------------------------
270 $PACKAGE_NAME $PACKAGE_VERSION: Automatic configuration OK.
271
272 Compiler support:
273
274 C99 var arrays: ................ ${has_var_arrays}
275 C99 lrintf: .................... ${ac_cv_func_lrintf}
276 Alloca: ........................ ${has_alloca}
277
278 General configuration:
279
280 Floating point support: ........ ${ac_enable_float}
281 Fast float approximations: ..... ${float_approx}
282 Fixed point debugging: ......... ${ac_enable_fixed_debug}
283 Custom modes: .................. ${ac_enable_custom_modes}
284 Assertion checking: ............ ${ac_enable_assertions}
285 Fuzzing: ....................... ${ac_enable_fuzzing}
286
287 API documentation: ............. ${ac_enable_doc}
288------------------------------------------------------------------------
289])
290
291echo "Type \"make; make install\" to compile and install";
292echo "Type \"make check\" to run the test suite";