blob: c722556b475f29590a8025a05cb54d7517b0a684 [file] [log] [blame]
Jean-Marc Valine05aaf22011-04-29 19:48:42 -04001dnl Process this file with autoconf to produce a configure script. -*-m4-*-
Jean-Marc Valina0cbeca2010-07-08 11:27:20 -04002
Ron2f2f9d62013-05-11 02:05:24 +09303dnl 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],
Roncfe8e2b2013-07-13 17:23:04 +09307 m4_esyscmd([ ./update_version 2>/dev/null || true
8 if test -e package_version; then
Ron918acd12013-05-18 16:11:18 +09309 . ./package_version
10 printf "$PACKAGE_VERSION"
11 else
12 printf "unknown"
13 fi ]))
Jean-Marc Valina0cbeca2010-07-08 11:27:20 -040014
Ron2f2f9d62013-05-11 02:05:24 +093015AC_INIT([opus],[CURRENT_VERSION],[opus@xiph.org])
16
17AC_CONFIG_SRCDIR(src/opus_encoder.c)
Ron50b395b2013-05-20 12:31:48 +093018AC_CONFIG_MACRO_DIR([m4])
Jean-Marc Valin381c7062011-03-21 13:53:40 -040019
Ralph Giles5ccc1242011-07-29 00:55:56 -070020dnl enable silent rules on automake 1.11 and later
21m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
22
Ralph Giles3164fcf2012-05-18 11:47:58 -070023# For libtool.
Ralph Giles59c5a822012-08-16 11:39:56 -070024dnl Please update these for releases.
Jean-Marc Valin65471dd2013-12-04 18:25:34 -050025OPUS_LT_CURRENT=5
Jean-Marc Valin9efa7792016-01-12 13:13:13 -050026OPUS_LT_REVISION=2
Jean-Marc Valin65471dd2013-12-04 18:25:34 -050027OPUS_LT_AGE=5
Jean-Marc Valina0cbeca2010-07-08 11:27:20 -040028
Jean-Marc Valine05aaf22011-04-29 19:48:42 -040029AC_SUBST(OPUS_LT_CURRENT)
30AC_SUBST(OPUS_LT_REVISION)
31AC_SUBST(OPUS_LT_AGE)
Jean-Marc Valine05aaf22011-04-29 19:48:42 -040032
Ron2f2f9d62013-05-11 02:05:24 +093033AM_INIT_AUTOMAKE([no-define])
Ralph Giles14454c42012-11-14 12:42:19 -080034AM_MAINTAINER_MODE([enable])
Jean-Marc Valine05aaf22011-04-29 19:48:42 -040035
36AC_CANONICAL_HOST
Gregory Maxwell417679c2012-08-09 08:39:15 -040037AC_MINGW32
Jean-Marc Valine05aaf22011-04-29 19:48:42 -040038AM_PROG_LIBTOOL
Ralph Giles2852cb12011-08-02 11:43:43 -070039AM_PROG_CC_C_O
Jean-Marc Valine05aaf22011-04-29 19:48:42 -040040
41AC_PROG_CC_C99
Jean-Marc Valina0cbeca2010-07-08 11:27:20 -040042AC_C_CONST
43AC_C_INLINE
Gregory Maxwell8ecba1a2012-05-14 01:58:05 -040044
Timothy B. Terriberry39386e02013-11-18 13:30:13 -050045AM_PROG_AS
46
Ron5bac4f22013-06-29 02:06:53 +093047AC_DEFINE([OPUS_BUILD], [], [This is a build of OPUS])
48
Gregory Maxwell8ecba1a2012-05-14 01:58:05 -040049#Use a hacked up version of autoconf's AC_C_RESTRICT because it's not
50#strong enough a test to detect old buggy versions of GCC (e.g. 2.95.3)
Ron5bac4f22013-06-29 02:06:53 +093051#Note: Both this and the test for variable-size arrays below are also
52# done by AC_PROG_CC_C99, but not thoroughly enough apparently.
Gregory Maxwell8ecba1a2012-05-14 01:58:05 -040053AC_CACHE_CHECK([for C/C++ restrict keyword], ac_cv_c_restrict,
54 [ac_cv_c_restrict=no
55 # The order here caters to the fact that C++ does not require restrict.
56 for ac_kw in __restrict __restrict__ _Restrict restrict; do
57 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
58 [[typedef int * int_ptr;
Timothy B. Terriberry39386e02013-11-18 13:30:13 -050059 int foo (int_ptr $ac_kw ip, int * $ac_kw baz[]) {
60 return ip[0];
Gregory Maxwell8ecba1a2012-05-14 01:58:05 -040061 }]],
62 [[int s[1];
Timothy B. Terriberry39386e02013-11-18 13:30:13 -050063 int * $ac_kw t = s;
64 t[0] = 0;
65 return foo(t, (void *)0)]])],
Gregory Maxwell8ecba1a2012-05-14 01:58:05 -040066 [ac_cv_c_restrict=$ac_kw])
67 test "$ac_cv_c_restrict" != no && break
68 done
69 ])
Ron5bac4f22013-06-29 02:06:53 +093070
71AH_VERBATIM([restrict],
Gregory Maxwell8ecba1a2012-05-14 01:58:05 -040072[/* Define to the equivalent of the C99 'restrict' keyword, or to
73 nothing if this is not supported. Do not define if restrict is
74 supported directly. */
75#undef restrict
76/* Work around a bug in Sun C++: it does not support _Restrict or
77 __restrict__, even though the corresponding Sun C compiler ends up with
78 "#define restrict _Restrict" or "#define restrict __restrict__" in the
79 previous line. Perhaps some future version of Sun C++ will work with
80 restrict; if so, hopefully it defines __RESTRICT like Sun C does. */
81#if defined __SUNPRO_CC && !defined __RESTRICT
82# define _Restrict
83# define __restrict__
84#endif])
Ron5bac4f22013-06-29 02:06:53 +093085
86case $ac_cv_c_restrict in
Gregory Maxwell8ecba1a2012-05-14 01:58:05 -040087 restrict) ;;
88 no) AC_DEFINE([restrict], []) ;;
89 *) AC_DEFINE_UNQUOTED([restrict], [$ac_cv_c_restrict]) ;;
Ron5bac4f22013-06-29 02:06:53 +093090esac
Jean-Marc Valin381c7062011-03-21 13:53:40 -040091
Jean-Marc Valine05aaf22011-04-29 19:48:42 -040092AC_MSG_CHECKING(for C99 variable-size arrays)
Ron5bac4f22013-06-29 02:06:53 +093093AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
94 [[static int x; char a[++x]; a[sizeof a - 1] = 0; int N; return a[0];]])],
95 [ has_var_arrays=yes
96 use_alloca="no (using var arrays)"
97 AC_DEFINE([VAR_ARRAYS], [1], [Use C99 variable-size arrays])
98 ],[
99 has_var_arrays=no
100 ])
101AC_MSG_RESULT([$has_var_arrays])
Jean-Marc Valina0cbeca2010-07-08 11:27:20 -0400102
Ron5bac4f22013-06-29 02:06:53 +0930103AS_IF([test "$has_var_arrays" = "no"],
104 [
105 AC_CHECK_HEADERS([alloca.h])
106 AC_MSG_CHECKING(for alloca)
107 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <alloca.h>]],
108 [[int foo=10; int *array = alloca(foo);]])],
109 [ use_alloca=yes;
110 AC_DEFINE([USE_ALLOCA], [], [Make use of alloca])
111 ],[
112 use_alloca=no
113 ])
114 AC_MSG_RESULT([$use_alloca])
115 ])
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400116
Ron5bac4f22013-06-29 02:06:53 +0930117LT_LIB_M
118
119AC_ARG_ENABLE([fixed-point],
120 [AS_HELP_STRING([--enable-fixed-point],
121 [compile without floating point (for machines without a fast enough FPU)])],,
122 [enable_fixed_point=no])
123
124AS_IF([test "$enable_fixed_point" = "yes"],[
125 enable_float="no"
126 AC_DEFINE([FIXED_POINT], [1], [Compile as fixed-point (for machines without a fast enough FPU)])
127 PC_BUILD="fixed-point"
128],[
129 enable_float="yes";
130 PC_BUILD="floating-point"
Ron5bac4f22013-06-29 02:06:53 +0930131])
132
133AM_CONDITIONAL([FIXED_POINT], [test "$enable_fixed_point" = "yes"])
134
135AC_ARG_ENABLE([fixed-point-debug],
136 [AS_HELP_STRING([--enable-fixed-point-debug], [debug fixed-point implementation])],,
137 [enable_fixed_point_debug=no])
138
139AS_IF([test "$enable_fixed_point_debug" = "yes"],[
140 AC_DEFINE([FIXED_DEBUG], [1], [Debug fixed-point implementation])
141])
142
Jean-Marc Valind814c5d2013-11-04 12:26:50 -0500143AC_ARG_ENABLE([float_api],
144 [AS_HELP_STRING([--disable-float-api],
145 [compile without the floating point API (for machines with no float library)])],,
146 [enable_float_api=yes])
147
148AM_CONDITIONAL([DISABLE_FLOAT_API], [test "$enable_float_api" = "no"])
149
150AS_IF([test "$enable_float_api" = "no"],[
151 AC_DEFINE([DISABLE_FLOAT_API], [1], [Do not build the float API])
152])
153
Ron5bac4f22013-06-29 02:06:53 +0930154AC_ARG_ENABLE([custom-modes],
155 [AS_HELP_STRING([--enable-custom-modes], [enable non-Opus modes, e.g. 44.1 kHz & 2^n frames])],,
156 [enable_custom_modes=no])
157
158AS_IF([test "$enable_custom_modes" = "yes"],[
159 AC_DEFINE([CUSTOM_MODES], [1], [Custom modes])
160 PC_BUILD="$PC_BUILD, custom modes"
Ron5bac4f22013-06-29 02:06:53 +0930161])
162
163AM_CONDITIONAL([CUSTOM_MODES], [test "$enable_custom_modes" = "yes"])
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400164
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400165has_float_approx=no
166#case "$host_cpu" in
167#i[[3456]]86 | x86_64 | powerpc64 | powerpc32 | ia64)
168# has_float_approx=yes
169# ;;
Timothy B. Terriberry39386e02013-11-18 13:30:13 -0500170#esac
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400171
Ron5bac4f22013-06-29 02:06:53 +0930172AC_ARG_ENABLE([float-approx],
173 [AS_HELP_STRING([--enable-float-approx], [enable fast approximations for floating point])],
174 [if test "$enable_float_approx" = "yes"; then
175 AC_WARN([Floating point approximations are not supported on all platforms.])
176 fi
177 ],
178 [enable_float_approx=$has_float_approx])
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400179
Ron5bac4f22013-06-29 02:06:53 +0930180AS_IF([test "$enable_float_approx" = "yes"],[
181 AC_DEFINE([FLOAT_APPROX], [1], [Float approximations])
182])
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400183
Ron5bac4f22013-06-29 02:06:53 +0930184AC_ARG_ENABLE([asm],
Jean-Marc Valin17dcb272013-12-03 13:31:24 -0500185 [AS_HELP_STRING([--disable-asm], [Disable assembly optimizations])],,
186 [enable_asm=yes])
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400187
Ron5bac4f22013-06-29 02:06:53 +0930188AC_ARG_ENABLE([rtcd],
189 [AS_HELP_STRING([--disable-rtcd], [Disable run-time CPU capabilities detection])],,
190 [enable_rtcd=yes])
191
xiangmingzhuc95c9a02014-04-30 15:48:07 +0800192AC_ARG_ENABLE([intrinsics],
Viswanath Puttagunta0b0a2b42014-12-19 17:25:55 -0600193 [AS_HELP_STRING([--enable-intrinsics], [Enable intrinsics optimizations for ARM(float) X86(fixed)])],,
xiangmingzhuc95c9a02014-04-30 15:48:07 +0800194 [enable_intrinsics=no])
195
Timothy B. Terriberry39386e02013-11-18 13:30:13 -0500196rtcd_support=no
197cpu_arm=no
198
199AS_IF([test x"${enable_asm}" = x"yes"],[
Viswanath Puttagunta0b0a2b42014-12-19 17:25:55 -0600200 inline_optimization="No inline ASM for your platform, please send patches"
Timothy B. Terriberry39386e02013-11-18 13:30:13 -0500201 case $host_cpu in
202 arm*)
203 dnl Currently we only have asm for fixed-point
204 AS_IF([test "$enable_float" != "yes"],[
205 cpu_arm=yes
206 AC_DEFINE([OPUS_ARM_ASM], [], [Make use of ARM asm optimization])
207 AS_GCC_INLINE_ASSEMBLY(
208 [inline_optimization="ARM"],
209 [inline_optimization="disabled"]
210 )
211 AS_ASM_ARM_EDSP([OPUS_ARM_INLINE_EDSP=1],[OPUS_ARM_INLINE_EDSP=0])
212 AS_ASM_ARM_MEDIA([OPUS_ARM_INLINE_MEDIA=1],
213 [OPUS_ARM_INLINE_MEDIA=0])
214 AS_ASM_ARM_NEON([OPUS_ARM_INLINE_NEON=1],[OPUS_ARM_INLINE_NEON=0])
215 AS_IF([test x"$inline_optimization" = x"ARM"],[
216 AM_CONDITIONAL([OPUS_ARM_INLINE_ASM],[true])
217 AC_DEFINE([OPUS_ARM_INLINE_ASM], 1,
218 [Use generic ARMv4 inline asm optimizations])
219 AS_IF([test x"$OPUS_ARM_INLINE_EDSP" = x"1"],[
220 AC_DEFINE([OPUS_ARM_INLINE_EDSP], [1],
221 [Use ARMv5E inline asm optimizations])
222 inline_optimization="$inline_optimization (EDSP)"
223 ])
224 AS_IF([test x"$OPUS_ARM_INLINE_MEDIA" = x"1"],[
225 AC_DEFINE([OPUS_ARM_INLINE_MEDIA], [1],
226 [Use ARMv6 inline asm optimizations])
227 inline_optimization="$inline_optimization (Media)"
228 ])
229 AS_IF([test x"$OPUS_ARM_INLINE_NEON" = x"1"],[
230 AC_DEFINE([OPUS_ARM_INLINE_NEON], 1,
231 [Use ARM NEON inline asm optimizations])
232 inline_optimization="$inline_optimization (NEON)"
233 ])
234 ])
235 dnl We need Perl to translate RVCT-syntax asm to gas syntax.
236 AC_CHECK_PROG([HAVE_PERL], perl, yes, no)
237 AS_IF([test x"$HAVE_PERL" = x"yes"],[
238 AM_CONDITIONAL([OPUS_ARM_EXTERNAL_ASM],[true])
239 asm_optimization="ARM"
240 AS_IF([test x"$OPUS_ARM_INLINE_EDSP" = x"1"], [
241 OPUS_ARM_PRESUME_EDSP=1
242 OPUS_ARM_MAY_HAVE_EDSP=1
243 ],
244 [
245 OPUS_ARM_PRESUME_EDSP=0
246 OPUS_ARM_MAY_HAVE_EDSP=0
247 ])
248 AS_IF([test x"$OPUS_ARM_INLINE_MEDIA" = x"1"], [
249 OPUS_ARM_PRESUME_MEDIA=1
250 OPUS_ARM_MAY_HAVE_MEDIA=1
251 ],
252 [
253 OPUS_ARM_PRESUME_MEDIA=0
254 OPUS_ARM_MAY_HAVE_MEDIA=0
255 ])
256 AS_IF([test x"$OPUS_ARM_INLINE_NEON" = x"1"], [
257 OPUS_ARM_PRESUME_NEON=1
258 OPUS_ARM_MAY_HAVE_NEON=1
259 ],
260 [
261 OPUS_ARM_PRESUME_NEON=0
262 OPUS_ARM_MAY_HAVE_NEON=0
263 ])
264 AS_IF([test x"$enable_rtcd" = x"yes"],[
265 AS_IF([test x"$OPUS_ARM_MAY_HAVE_EDSP" != x"1"],[
266 AC_MSG_NOTICE(
267 [Trying to force-enable armv5e EDSP instructions...])
268 AS_ASM_ARM_EDSP_FORCE([OPUS_ARM_MAY_HAVE_EDSP=1])
269 ])
270 AS_IF([test x"$OPUS_ARM_MAY_HAVE_MEDIA" != x"1"],[
271 AC_MSG_NOTICE(
272 [Trying to force-enable ARMv6 media instructions...])
273 AS_ASM_ARM_MEDIA_FORCE([OPUS_ARM_MAY_HAVE_MEDIA=1])
274 ])
275 AS_IF([test x"$OPUS_ARM_MAY_HAVE_NEON" != x"1"],[
276 AC_MSG_NOTICE(
277 [Trying to force-enable NEON instructions...])
278 AS_ASM_ARM_NEON_FORCE([OPUS_ARM_MAY_HAVE_NEON=1])
279 ])
280 ])
281 rtcd_support=
282 AS_IF([test x"$OPUS_ARM_MAY_HAVE_EDSP" = x"1"],[
283 AC_DEFINE(OPUS_ARM_MAY_HAVE_EDSP, 1,
284 [Define if assembler supports EDSP instructions])
285 AS_IF([test x"$OPUS_ARM_PRESUME_EDSP" = x"1"],[
286 AC_DEFINE(OPUS_ARM_PRESUME_EDSP, 1,
287 [Define if binary requires EDSP instruction support])
288 asm_optimization="$asm_optimization (EDSP)"
289 ],
290 [rtcd_support="$rtcd_support (EDSP)"]
291 )
292 ])
293 AC_SUBST(OPUS_ARM_MAY_HAVE_EDSP)
294 AS_IF([test x"$OPUS_ARM_MAY_HAVE_MEDIA" = x"1"],[
295 AC_DEFINE(OPUS_ARM_MAY_HAVE_MEDIA, 1,
296 [Define if assembler supports ARMv6 media instructions])
297 AS_IF([test x"$OPUS_ARM_PRESUME_MEDIA" = x"1"],[
298 AC_DEFINE(OPUS_ARM_PRESUME_MEDIA, 1,
299 [Define if binary requires ARMv6 media instruction support])
300 asm_optimization="$asm_optimization (Media)"
301 ],
302 [rtcd_support="$rtcd_support (Media)"]
303 )
304 ])
305 AC_SUBST(OPUS_ARM_MAY_HAVE_MEDIA)
306 AS_IF([test x"$OPUS_ARM_MAY_HAVE_NEON" = x"1"],[
307 AC_DEFINE(OPUS_ARM_MAY_HAVE_NEON, 1,
308 [Define if compiler supports NEON instructions])
309 AS_IF([test x"$OPUS_ARM_PRESUME_NEON" = x"1"], [
310 AC_DEFINE(OPUS_ARM_PRESUME_NEON, 1,
311 [Define if binary requires NEON instruction support])
312 asm_optimization="$asm_optimization (NEON)"
313 ],
314 [rtcd_support="$rtcd_support (NEON)"]
315 )
316 ])
317 AC_SUBST(OPUS_ARM_MAY_HAVE_NEON)
318 dnl Make sure turning on RTCD gets us at least one
319 dnl instruction set.
320 AS_IF([test x"$rtcd_support" != x""],
321 [rtcd_support=ARM"$rtcd_support"],
322 [rtcd_support="no"]
323 )
Martin Storsjo76e831d2014-03-19 21:36:39 +0200324 AC_MSG_CHECKING([for apple style tools])
325 AC_PREPROC_IFELSE([AC_LANG_PROGRAM([
326#ifndef __APPLE__
327#error 1
328#endif],[])],
329 [AC_MSG_RESULT([yes]); ARM2GNU_PARAMS="--apple"],
330 [AC_MSG_RESULT([no]); ARM2GNU_PARAMS=""])
331 AC_SUBST(ARM2GNU_PARAMS)
Timothy B. Terriberry39386e02013-11-18 13:30:13 -0500332 ],
333 [
334 AC_MSG_WARN(
335 [*** ARM assembly requires perl -- disabling optimizations])
336 asm_optimization="(missing perl dependency for ARM)"
337 ])
338 ])
339 ;;
340 esac
341],[
342 inline_optimization="disabled"
343 asm_optimization="disabled"
344])
345
Timothy B. Terriberry39386e02013-11-18 13:30:13 -0500346AM_CONDITIONAL([OPUS_ARM_INLINE_ASM],
Peter Korsgaard253e15f2013-12-08 11:05:41 +0100347 [test x"${inline_optimization%% *}" = x"ARM"])
Timothy B. Terriberry39386e02013-11-18 13:30:13 -0500348AM_CONDITIONAL([OPUS_ARM_EXTERNAL_ASM],
Peter Korsgaard253e15f2013-12-08 11:05:41 +0100349 [test x"${asm_optimization%% *}" = x"ARM"])
Timothy B. Terriberry39386e02013-11-18 13:30:13 -0500350
Jonathan Lennoxcb0875e2015-08-03 17:04:26 -0400351AM_CONDITIONAL([HAVE_SSE], [false])
xiangmingzhuc95c9a02014-04-30 15:48:07 +0800352AM_CONDITIONAL([HAVE_SSE2], [false])
Jonathan Lennoxb4aa5dc2015-08-03 17:04:20 -0400353AM_CONDITIONAL([HAVE_SSE4_1], [false])
Radu Velea16321522015-10-27 12:21:36 +0200354AM_CONDITIONAL([HAVE_AVX], [false])
Jonathan Lennoxb4aa5dc2015-08-03 17:04:20 -0400355
Jonathan Lennoxcb0875e2015-08-03 17:04:26 -0400356m4_define([DEFAULT_X86_SSE_CFLAGS], [-msse])
Jonathan Lennoxb4aa5dc2015-08-03 17:04:20 -0400357m4_define([DEFAULT_X86_SSE2_CFLAGS], [-msse2])
358m4_define([DEFAULT_X86_SSE4_1_CFLAGS], [-msse4.1])
Radu Velea16321522015-10-27 12:21:36 +0200359m4_define([DEFAULT_X86_AVX_CFLAGS], [-mavx])
Jonathan Lennoxb4aa5dc2015-08-03 17:04:20 -0400360m4_define([DEFAULT_ARM_NEON_INTR_CFLAGS], [-mfpu=neon])
361# With GCC on ARM32 softfp architectures (e.g. Android, or older Ubuntu) you need to specify
362# -mfloat-abi=softfp for -mfpu=neon to work. However, on ARM32 hardfp architectures (e.g. newer Ubuntu),
363# this option will break things.
364
365# As a heuristic, if host matches arm*eabi* but not arm*hf*, it's probably soft-float.
366m4_define([DEFAULT_ARM_NEON_SOFTFP_INTR_CFLAGS], [-mfpu=neon -mfloat-abi=softfp])
367
368AS_CASE([$host],
369 [arm*hf*], [AS_VAR_SET([RESOLVED_DEFAULT_ARM_NEON_INTR_CFLAGS], "DEFAULT_ARM_NEON_INTR_CFLAGS")],
370 [arm*eabi*], [AS_VAR_SET([RESOLVED_DEFAULT_ARM_NEON_INTR_CFLAGS], "DEFAULT_ARM_NEON_SOFTFP_INTR_CFLAGS")],
371 [AS_VAR_SET([RESOLVED_DEFAULT_ARM_NEON_INTR_CFLAGS], "DEFAULT_ARM_NEON_INTR_CFLAGS")])
372
Jonathan Lennoxcb0875e2015-08-03 17:04:26 -0400373AC_ARG_VAR([X86_SSE_CFLAGS], [C compiler flags to compile SSE intrinsics @<:@default=]DEFAULT_X86_SSE_CFLAGS[@:>@])
Jonathan Lennoxb4aa5dc2015-08-03 17:04:20 -0400374AC_ARG_VAR([X86_SSE2_CFLAGS], [C compiler flags to compile SSE2 intrinsics @<:@default=]DEFAULT_X86_SSE2_CFLAGS[@:>@])
375AC_ARG_VAR([X86_SSE4_1_CFLAGS], [C compiler flags to compile SSE4.1 intrinsics @<:@default=]DEFAULT_X86_SSE4_1_CFLAGS[@:>@])
Radu Velea16321522015-10-27 12:21:36 +0200376AC_ARG_VAR([X86_AVX_CFLAGS], [C compiler flags to compile AVX intrinsics @<:@default=]DEFAULT_X86_AVX_CFLAGS[@:>@])
Jonathan Lennoxb4aa5dc2015-08-03 17:04:20 -0400377AC_ARG_VAR([ARM_NEON_INTR_CFLAGS], [C compiler flags to compile ARM NEON intrinsics @<:@default=]DEFAULT_ARM_NEON_INTR_CFLAGS / DEFAULT_ARM_NEON_SOFTFP_INTR_CFLAGS[@:>@])
378
Jonathan Lennoxcb0875e2015-08-03 17:04:26 -0400379AS_VAR_SET_IF([X86_SSE_CFLAGS], [], [AS_VAR_SET([X86_SSE_CFLAGS], "DEFAULT_X86_SSE_CFLAGS")])
Jonathan Lennoxb4aa5dc2015-08-03 17:04:20 -0400380AS_VAR_SET_IF([X86_SSE2_CFLAGS], [], [AS_VAR_SET([X86_SSE2_CFLAGS], "DEFAULT_X86_SSE2_CFLAGS")])
381AS_VAR_SET_IF([X86_SSE4_1_CFLAGS], [], [AS_VAR_SET([X86_SSE4_1_CFLAGS], "DEFAULT_X86_SSE4_1_CFLAGS")])
Radu Velea16321522015-10-27 12:21:36 +0200382AS_VAR_SET_IF([X86_AVX_CFLAGS], [], [AS_VAR_SET([X86_AVX_CFLAGS], "DEFAULT_X86_AVX_CFLAGS")])
Jonathan Lennoxb4aa5dc2015-08-03 17:04:20 -0400383AS_VAR_SET_IF([ARM_NEON_INTR_CFLAGS], [], [AS_VAR_SET([ARM_NEON_INTR_CFLAGS], ["$RESOLVED_DEFAULT_ARM_NEON_INTR_CFLAGS"])])
Viswanath Puttagunta0b0a2b42014-12-19 17:25:55 -0600384
Viswanath Puttaguntaf48abe82015-05-15 12:42:19 -0500385AC_DEFUN([OPUS_PATH_NE10],
386 [
387 AC_ARG_WITH(NE10,
388 AC_HELP_STRING([--with-NE10=PFX],[Prefix where libNE10 is installed (optional)]),
389 NE10_prefix="$withval", NE10_prefix="")
390 AC_ARG_WITH(NE10-libraries,
391 AC_HELP_STRING([--with-NE10-libraries=DIR],
392 [Directory where libNE10 library is installed (optional)]),
393 NE10_libraries="$withval", NE10_libraries="")
394 AC_ARG_WITH(NE10-includes,
395 AC_HELP_STRING([--with-NE10-includes=DIR],
396 [Directory where libNE10 header files are installed (optional)]),
397 NE10_includes="$withval", NE10_includes="")
398
399 if test "x$NE10_libraries" != "x" ; then
400 NE10_LIBS="-L$NE10_libraries"
401 elif test "x$NE10_prefix" = "xno" || test "x$NE10_prefix" = "xyes" ; then
402 NE10_LIBS=""
403 elif test "x$NE10_prefix" != "x" ; then
404 NE10_LIBS="-L$NE10_prefix/lib"
405 elif test "x$prefix" != "xNONE" ; then
406 NE10_LIBS="-L$prefix/lib"
407 fi
408
409 if test "x$NE10_prefix" != "xno" ; then
410 NE10_LIBS="$NE10_LIBS -lNE10"
411 fi
412
413 if test "x$NE10_includes" != "x" ; then
414 NE10_CFLAGS="-I$NE10_includes"
415 elif test "x$NE10_prefix" = "xno" || test "x$NE10_prefix" = "xyes" ; then
416 NE10_CFLAGS=""
417 elif test "x$ogg_prefix" != "x" ; then
418 NE10_CFLAGS="-I$NE10_prefix/include"
419 elif test "x$prefix" != "xNONE"; then
420 NE10_CFLAGS="-I$prefix/include"
421 fi
422
423 AC_MSG_CHECKING(for NE10)
424 save_CFLAGS="$CFLAGS"; CFLAGS="$NE10_CFLAGS"
425 save_LIBS="$LIBS"; LIBS="$NE10_LIBS $LIBM"
426 AC_LINK_IFELSE(
427 [
428 AC_LANG_PROGRAM(
429 [[#include <NE10_init.h>
430 ]],
431 [[
432 ne10_fft_cfg_float32_t cfg;
433 cfg = ne10_fft_alloc_c2c_float32_neon(480);
434 ]]
435 )
436 ],[
437 HAVE_ARM_NE10=1
438 AC_MSG_RESULT([yes])
439 ],[
440 HAVE_ARM_NE10=0
441 AC_MSG_RESULT([no])
442 NE10_CFLAGS=""
443 NE10_LIBS=""
444 ]
445 )
446 CFLAGS="$save_CFLAGS"; LIBS="$save_LIBS"
447 #Now we know if libNE10 is installed or not
448 AS_IF([test x"$HAVE_ARM_NE10" = x"1"],
449 [
450 AC_DEFINE([HAVE_ARM_NE10], 1, [NE10 library is installed on host. Make sure it is on target!])
451 AC_SUBST(HAVE_ARM_NE10)
452 AC_SUBST(NE10_CFLAGS)
453 AC_SUBST(NE10_LIBS)
Timothy B. Terriberry57842da2015-10-16 13:02:24 -0700454 ]
Viswanath Puttaguntaf48abe82015-05-15 12:42:19 -0500455 )
456 ]
457)
458
xiangmingzhuc95c9a02014-04-30 15:48:07 +0800459AS_IF([test x"$enable_intrinsics" = x"yes"],[
Jonathan Lennoxb4aa5dc2015-08-03 17:04:20 -0400460 intrinsics_support=""
461 AS_CASE([$host_cpu],
462 [arm*],
463 [
Viswanath Puttagunta0b0a2b42014-12-19 17:25:55 -0600464 cpu_arm=yes
Jonathan Lennoxb4aa5dc2015-08-03 17:04:20 -0400465 OPUS_CHECK_INTRINSICS(
466 [ARM Neon],
467 [$ARM_NEON_INTR_CFLAGS],
468 [OPUS_ARM_MAY_HAVE_NEON_INTR],
469 [OPUS_ARM_PRESUME_NEON_INTR],
470 [[#include <arm_neon.h>
471 ]],
472 [[
473 static float32x4_t A0, A1, SUMM;
474 SUMM = vmlaq_f32(SUMM, A0, A1);
Jonathan Lennoxdc92dab2016-05-31 15:52:36 -0400475 return (int)vgetq_lane_f32(SUMM, 0);
Jonathan Lennoxb4aa5dc2015-08-03 17:04:20 -0400476 ]]
Viswanath Puttagunta0b0a2b42014-12-19 17:25:55 -0600477 )
Jonathan Lennoxb4aa5dc2015-08-03 17:04:20 -0400478 AS_IF([test x"$OPUS_ARM_MAY_HAVE_NEON_INTR" = x"1" && test x"$OPUS_ARM_PRESUME_NEON_INTR" != x"1"],
479 [
480 OPUS_ARM_NEON_INTR_CFLAGS="$ARM_NEON_INTR_CFLAGS"
481 AC_SUBST([OPUS_ARM_NEON_INTR_CFLAGS])
482 ]
483 )
Viswanath Puttagunta0b0a2b42014-12-19 17:25:55 -0600484
Viswanath Puttaguntaba8713c2015-05-15 12:42:25 -0500485 AS_IF([test x"$OPUS_ARM_MAY_HAVE_NEON_INTR" = x"1"],
Viswanath Puttagunta0b0a2b42014-12-19 17:25:55 -0600486 [
Viswanath Puttaguntaba8713c2015-05-15 12:42:25 -0500487 AC_DEFINE([OPUS_ARM_MAY_HAVE_NEON_INTR], 1, [Compiler supports ARMv7 Neon Intrinsics])
488 intrinsics_support="$intrinsics_support (Neon_Intrinsics)"
489
490 AS_IF([test x"enable_rtcd" != x"" && test x"$OPUS_ARM_PRESUME_NEON_INTR" != x"1"],
Timothy B. Terriberry57842da2015-10-16 13:02:24 -0700491 [rtcd_support="$rtcd_support (ARMv7_Neon_Intrinsics)"])
Viswanath Puttaguntaba8713c2015-05-15 12:42:25 -0500492
493 AS_IF([test x"$OPUS_ARM_PRESUME_NEON_INTR" = x"1"],
494 [AC_DEFINE([OPUS_ARM_PRESUME_NEON_INTR], 1, [Define if binary requires NEON intrinsics support])])
495
496 OPUS_PATH_NE10()
497 AS_IF([test x"$NE10_LIBS" != x""],
Viswanath Puttagunta0b0a2b42014-12-19 17:25:55 -0600498 [
Viswanath Puttaguntaba8713c2015-05-15 12:42:25 -0500499 intrinsics_support="$intrinsics_support (NE10)"
500 AS_IF([test x"enable_rtcd" != x"" \
501 && test x"$OPUS_ARM_PRESUME_NEON_INTR" != x"1"],
Timothy B. Terriberry57842da2015-10-16 13:02:24 -0700502 [rtcd_support="$rtcd_support (NE10)"])
Viswanath Puttagunta0b0a2b42014-12-19 17:25:55 -0600503 ])
Viswanath Puttaguntaba8713c2015-05-15 12:42:25 -0500504
505 AS_IF([test x"$rtcd_support" = x""],
506 [rtcd_support=no])
507
508 AS_IF([test x"$intrinsics_support" = x""],
509 [intrinsics_support=no],
510 [intrinsics_support="arm$intrinsics_support"])
511 ],
512 [
513 AC_MSG_WARN([Compiler does not support ARM intrinsics])
514 intrinsics_support=no
Viswanath Puttagunta0b0a2b42014-12-19 17:25:55 -0600515 ])
Jonathan Lennoxb4aa5dc2015-08-03 17:04:20 -0400516 ],
517 [i?86|x86_64],
518 [
519 OPUS_CHECK_INTRINSICS(
Jonathan Lennoxcb0875e2015-08-03 17:04:26 -0400520 [SSE],
521 [$X86_SSE_CFLAGS],
522 [OPUS_X86_MAY_HAVE_SSE],
523 [OPUS_X86_PRESUME_SSE],
524 [[#include <xmmintrin.h>
Jonathan Lennoxdc92dab2016-05-31 15:52:36 -0400525 #include <time.h>
Jonathan Lennoxcb0875e2015-08-03 17:04:26 -0400526 ]],
527 [[
Jonathan Lennoxdc92dab2016-05-31 15:52:36 -0400528 __m128 mtest;
529 mtest = _mm_set1_ps((float)time(NULL));
530 mtest = _mm_mul_ps(mtest, mtest);
531 return _mm_cvtss_si32(mtest);
Jonathan Lennoxcb0875e2015-08-03 17:04:26 -0400532 ]]
533 )
534 AS_IF([test x"$OPUS_X86_MAY_HAVE_SSE" = x"1" && test x"$OPUS_X86_PRESUME_SSE" != x"1"],
535 [
536 OPUS_X86_SSE_CFLAGS="$X86_SSE_CFLAGS"
537 AC_SUBST([OPUS_X86_SSE_CFLAGS])
538 ]
539 )
540 OPUS_CHECK_INTRINSICS(
Jonathan Lennoxb4aa5dc2015-08-03 17:04:20 -0400541 [SSE2],
542 [$X86_SSE2_CFLAGS],
543 [OPUS_X86_MAY_HAVE_SSE2],
544 [OPUS_X86_PRESUME_SSE2],
545 [[#include <emmintrin.h>
Jonathan Lennoxdc92dab2016-05-31 15:52:36 -0400546 #include <time.h>
Jonathan Lennoxb4aa5dc2015-08-03 17:04:20 -0400547 ]],
548 [[
Jonathan Lennoxdc92dab2016-05-31 15:52:36 -0400549 __m128i mtest;
550 mtest = _mm_set1_epi32((int)time(NULL));
551 mtest = _mm_mul_epu32(mtest, mtest);
552 return _mm_cvtsi128_si32(mtest);
Jonathan Lennoxb4aa5dc2015-08-03 17:04:20 -0400553 ]]
554 )
555 AS_IF([test x"$OPUS_X86_MAY_HAVE_SSE2" = x"1" && test x"$OPUS_X86_PRESUME_SSE2" != x"1"],
556 [
557 OPUS_X86_SSE2_CFLAGS="$X86_SSE2_CFLAGS"
558 AC_SUBST([OPUS_X86_SSE2_CFLAGS])
559 ]
560 )
561 OPUS_CHECK_INTRINSICS(
562 [SSE4.1],
563 [$X86_SSE4_1_CFLAGS],
564 [OPUS_X86_MAY_HAVE_SSE4_1],
565 [OPUS_X86_PRESUME_SSE4_1],
566 [[#include <smmintrin.h>
Jonathan Lennoxdc92dab2016-05-31 15:52:36 -0400567 #include <time.h>
Jonathan Lennoxb4aa5dc2015-08-03 17:04:20 -0400568 ]],
569 [[
Jonathan Lennoxdc92dab2016-05-31 15:52:36 -0400570 __m128i mtest;
571 mtest = _mm_set1_epi32((int)time(NULL));
572 mtest = _mm_mul_epi32(mtest, mtest);
573 return _mm_cvtsi128_si32(mtest);
Jonathan Lennoxb4aa5dc2015-08-03 17:04:20 -0400574 ]]
575 )
576 AS_IF([test x"$OPUS_X86_MAY_HAVE_SSE4_1" = x"1" && test x"$OPUS_X86_PRESUME_SSE4_1" != x"1"],
577 [
578 OPUS_X86_SSE4_1_CFLAGS="$X86_SSE4_1_CFLAGS"
579 AC_SUBST([OPUS_X86_SSE4_1_CFLAGS])
580 ]
581 )
Radu Velea16321522015-10-27 12:21:36 +0200582 OPUS_CHECK_INTRINSICS(
583 [AVX],
584 [$X86_AVX_CFLAGS],
585 [OPUS_X86_MAY_HAVE_AVX],
586 [OPUS_X86_PRESUME_AVX],
587 [[#include <immintrin.h>
Jonathan Lennoxdc92dab2016-05-31 15:52:36 -0400588 #include <time.h>
Radu Velea16321522015-10-27 12:21:36 +0200589 ]],
590 [[
Jonathan Lennoxdc92dab2016-05-31 15:52:36 -0400591 __m256 mtest;
592 mtest = _mm256_set1_ps((float)time(NULL));
593 mtest = _mm256_addsub_ps(mtest, mtest);
594 return _mm_cvtss_si32(_mm256_extractf128_ps(mtest, 0));
Radu Velea16321522015-10-27 12:21:36 +0200595 ]]
596 )
597 AS_IF([test x"$OPUS_X86_MAY_HAVE_AVX" = x"1" && test x"$OPUS_X86_PRESUME_AVX" != x"1"],
598 [
599 OPUS_X86_AVX_CFLAGS="$X86_AVX_CFLAGS"
600 AC_SUBST([OPUS_X86_AVX_CFLAGS])
601 ]
602 )
Jonathan Lennoxb4aa5dc2015-08-03 17:04:20 -0400603 AS_IF([test x"$rtcd_support" = x"no"], [rtcd_support=""])
Jonathan Lennoxcb0875e2015-08-03 17:04:26 -0400604 AS_IF([test x"$OPUS_X86_MAY_HAVE_SSE" = x"1"],
605 [
606 AC_DEFINE([OPUS_X86_MAY_HAVE_SSE], 1, [Compiler supports X86 SSE Intrinsics])
607 intrinsics_support="$intrinsics_support SSE"
608
609 AS_IF([test x"$OPUS_X86_PRESUME_SSE" = x"1"],
610 [AC_DEFINE([OPUS_X86_PRESUME_SSE], 1, [Define if binary requires SSE intrinsics support])],
611 [rtcd_support="$rtcd_support SSE"])
612 ],
613 [
614 AC_MSG_WARN([Compiler does not support SSE intrinsics])
615 ])
616
Jonathan Lennoxb4aa5dc2015-08-03 17:04:20 -0400617 AS_IF([test x"$OPUS_X86_MAY_HAVE_SSE2" = x"1"],
618 [
619 AC_DEFINE([OPUS_X86_MAY_HAVE_SSE2], 1, [Compiler supports X86 SSE2 Intrinsics])
620 intrinsics_support="$intrinsics_support SSE2"
621
622 AS_IF([test x"$OPUS_X86_PRESUME_SSE2" = x"1"],
623 [AC_DEFINE([OPUS_X86_PRESUME_SSE2], 1, [Define if binary requires SSE2 intrinsics support])],
624 [rtcd_support="$rtcd_support SSE2"])
625 ],
626 [
627 AC_MSG_WARN([Compiler does not support SSE2 intrinsics])
628 ])
629
630 AS_IF([test x"$OPUS_X86_MAY_HAVE_SSE4_1" = x"1"],
631 [
632 AC_DEFINE([OPUS_X86_MAY_HAVE_SSE4_1], 1, [Compiler supports X86 SSE4.1 Intrinsics])
633 intrinsics_support="$intrinsics_support SSE4.1"
634
635 AS_IF([test x"$OPUS_X86_PRESUME_SSE4_1" = x"1"],
636 [AC_DEFINE([OPUS_X86_PRESUME_SSE4_1], 1, [Define if binary requires SSE4.1 intrinsics support])],
637 [rtcd_support="$rtcd_support SSE4.1"])
638 ],
639 [
640 AC_MSG_WARN([Compiler does not support SSE4.1 intrinsics])
641 ])
Radu Velea16321522015-10-27 12:21:36 +0200642 AS_IF([test x"$OPUS_X86_MAY_HAVE_AVX" = x"1"],
643 [
644 AC_DEFINE([OPUS_X86_MAY_HAVE_AVX], 1, [Compiler supports X86 AVX Intrinsics])
645 intrinsics_support="$intrinsics_support AVX"
646
647 AS_IF([test x"$OPUS_X86_PRESUME_AVX" = x"1"],
648 [AC_DEFINE([OPUS_X86_PRESUME_AVX], 1, [Define if binary requires AVX intrinsics support])],
649 [rtcd_support="$rtcd_support AVX"])
650 ],
651 [
652 AC_MSG_WARN([Compiler does not support AVX intrinsics])
653 ])
654
Jonathan Lennoxb4aa5dc2015-08-03 17:04:20 -0400655 AS_IF([test x"$intrinsics_support" = x""],
656 [intrinsics_support=no],
657 [intrinsics_support="x86$intrinsics_support"]
658 )
659 AS_IF([test x"$rtcd_support" = x""],
660 [rtcd_support=no],
661 [rtcd_support="x86$rtcd_support"],
662 )
Jonathan Lennoxb4aa5dc2015-08-03 17:04:20 -0400663
664 AS_IF([test x"$enable_rtcd" = x"yes" && test x"$rtcd_support" != x""],[
xiangmingzhuc95c9a02014-04-30 15:48:07 +0800665 get_cpuid_by_asm="no"
Jonathan Lennoxb4aa5dc2015-08-03 17:04:20 -0400666 AC_MSG_CHECKING([How to get X86 CPU Info])
Ron7424bb02014-12-20 19:46:20 +1030667 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
xiangmingzhuc95c9a02014-04-30 15:48:07 +0800668 #include <stdio.h>
Ron7424bb02014-12-20 19:46:20 +1030669 ]],[[
xiangmingzhuc95c9a02014-04-30 15:48:07 +0800670 unsigned int CPUInfo0;
671 unsigned int CPUInfo1;
672 unsigned int CPUInfo2;
673 unsigned int CPUInfo3;
674 unsigned int InfoType;
675 __asm__ __volatile__ (
Jonathan Lennoxee6ec632015-08-03 17:04:22 -0400676 "cpuid":
xiangmingzhuc95c9a02014-04-30 15:48:07 +0800677 "=a" (CPUInfo0),
678 "=b" (CPUInfo1),
679 "=c" (CPUInfo2),
680 "=d" (CPUInfo3) :
681 "a" (InfoType), "c" (0)
682 );
Ron7424bb02014-12-20 19:46:20 +1030683 ]])],
xiangmingzhuc95c9a02014-04-30 15:48:07 +0800684 [get_cpuid_by_asm="yes"
Jonathan Lennoxb4aa5dc2015-08-03 17:04:20 -0400685 AC_MSG_RESULT([Inline Assembly])
686 AC_DEFINE([CPU_INFO_BY_ASM], [1], [Get CPU Info by asm method])],
Ron7424bb02014-12-20 19:46:20 +1030687 [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
xiangmingzhuc95c9a02014-04-30 15:48:07 +0800688 #include <cpuid.h>
Ron7424bb02014-12-20 19:46:20 +1030689 ]],[[
xiangmingzhuc95c9a02014-04-30 15:48:07 +0800690 unsigned int CPUInfo0;
691 unsigned int CPUInfo1;
692 unsigned int CPUInfo2;
693 unsigned int CPUInfo3;
694 unsigned int InfoType;
695 __get_cpuid(InfoType, &CPUInfo0, &CPUInfo1, &CPUInfo2, &CPUInfo3);
Ron7424bb02014-12-20 19:46:20 +1030696 ]])],
Jonathan Lennoxb4aa5dc2015-08-03 17:04:20 -0400697 [AC_MSG_RESULT([C method])
698 AC_DEFINE([CPU_INFO_BY_C], [1], [Get CPU Info by c method])],
699 [AC_MSG_ERROR([no supported Get CPU Info method, please disable intrinsics])])])])
700 ],
701 [
Viswanath Puttagunta0b0a2b42014-12-19 17:25:55 -0600702 AC_MSG_WARN([No intrinsics support for your architecture])
Jonathan Lennoxb4aa5dc2015-08-03 17:04:20 -0400703 intrinsics_support="no"
704 ])
705],
706[
707 intrinsics_support="no"
xiangmingzhuc95c9a02014-04-30 15:48:07 +0800708])
Viswanath Puttagunta0b0a2b42014-12-19 17:25:55 -0600709
710AM_CONDITIONAL([CPU_ARM], [test "$cpu_arm" = "yes"])
711AM_CONDITIONAL([OPUS_ARM_NEON_INTR],
Jonathan Lennoxb4aa5dc2015-08-03 17:04:20 -0400712 [test x"$OPUS_ARM_MAY_HAVE_NEON_INTR" = x"1"])
Viswanath Puttaguntaf48abe82015-05-15 12:42:19 -0500713AM_CONDITIONAL([HAVE_ARM_NE10],
714 [test x"$HAVE_ARM_NE10" = x"1"])
Jonathan Lennoxcb0875e2015-08-03 17:04:26 -0400715AM_CONDITIONAL([HAVE_SSE],
716 [test x"$OPUS_X86_MAY_HAVE_SSE" = x"1"])
Jonathan Lennoxb4aa5dc2015-08-03 17:04:20 -0400717AM_CONDITIONAL([HAVE_SSE2],
718 [test x"$OPUS_X86_MAY_HAVE_SSE2" = x"1"])
719AM_CONDITIONAL([HAVE_SSE4_1],
720 [test x"$OPUS_X86_MAY_HAVE_SSE4_1" = x"1"])
Radu Velea16321522015-10-27 12:21:36 +0200721AM_CONDITIONAL([HAVE_AVX],
722 [test x"$OPUS_X86_MAY_HAVE_AVX" = x"1"])
xiangmingzhuc95c9a02014-04-30 15:48:07 +0800723
Timothy B. Terriberry39386e02013-11-18 13:30:13 -0500724AS_IF([test x"$enable_rtcd" = x"yes"],[
725 AS_IF([test x"$rtcd_support" != x"no"],[
726 AC_DEFINE([OPUS_HAVE_RTCD], [1],
727 [Use run-time CPU capabilities detection])
728 OPUS_HAVE_RTCD=1
729 AC_SUBST(OPUS_HAVE_RTCD)
Ron5bac4f22013-06-29 02:06:53 +0930730 ])
731],[
Timothy B. Terriberry39386e02013-11-18 13:30:13 -0500732 rtcd_support="disabled"
Ron5bac4f22013-06-29 02:06:53 +0930733])
Aurélien Zanellicd4c8242013-05-31 15:07:00 +0200734
Ron5bac4f22013-06-29 02:06:53 +0930735AC_ARG_ENABLE([assertions],
736 [AS_HELP_STRING([--enable-assertions],[enable additional software error checking])],,
737 [enable_assertions=no])
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400738
Ron5bac4f22013-06-29 02:06:53 +0930739AS_IF([test "$enable_assertions" = "yes"], [
740 AC_DEFINE([ENABLE_ASSERTIONS], [1], [Assertions])
741])
Jean-Marc Valinf334c822011-08-11 16:21:58 -0400742
Ron5bac4f22013-06-29 02:06:53 +0930743AC_ARG_ENABLE([fuzzing],
744 [AS_HELP_STRING([--enable-fuzzing],[causes the encoder to make random decisions])],,
745 [enable_fuzzing=no])
746
747AS_IF([test "$enable_fuzzing" = "yes"], [
748 AC_DEFINE([FUZZING], [1], [Fuzzing])
749])
750
Ralph Giles35d4fb72011-09-06 23:18:00 -0700751AC_ARG_ENABLE([doc],
Ron5bac4f22013-06-29 02:06:53 +0930752 [AS_HELP_STRING([--disable-doc], [Do not build API documentation])],,
753 [enable_doc=yes])
Ralph Giles35d4fb72011-09-06 23:18:00 -0700754
Ron5bac4f22013-06-29 02:06:53 +0930755AS_IF([test "$enable_doc" = "yes"], [
756 AC_CHECK_PROG(HAVE_DOXYGEN, [doxygen], [yes], [no])
757],[
758 HAVE_DOXYGEN=no
759])
760
761AM_CONDITIONAL([HAVE_DOXYGEN], [test "$HAVE_DOXYGEN" = "yes"])
762
Aurélien Zanellifaec6732013-05-26 22:08:02 +0200763AC_ARG_ENABLE([extra-programs],
Ron5bac4f22013-06-29 02:06:53 +0930764 [AS_HELP_STRING([--disable-extra-programs], [Do not build extra programs (demo and tests)])],,
765 [enable_extra_programs=yes])
766
767AM_CONDITIONAL([EXTRA_PROGRAMS], [test "$enable_extra_programs" = "yes"])
768
Aurélien Zanellifaec6732013-05-26 22:08:02 +0200769
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400770saved_CFLAGS="$CFLAGS"
771CFLAGS="$CFLAGS -fvisibility=hidden"
Gregory Maxwelle53ebd62011-10-21 14:21:53 -0400772AC_MSG_CHECKING([if ${CC} supports -fvisibility=hidden])
Ron5bac4f22013-06-29 02:06:53 +0930773AC_COMPILE_IFELSE([AC_LANG_SOURCE([[char foo;]])],
774 [ AC_MSG_RESULT([yes]) ],
775 [ AC_MSG_RESULT([no])
776 CFLAGS="$saved_CFLAGS"
777 ])
Gregory Maxwell6c83b0b2012-05-14 00:30:34 -0400778
Gregory Maxwell6c83b0b2012-05-14 00:30:34 -0400779CFLAGS="$CFLAGS -W"
780
Ralph Giles99e8a932013-03-12 22:57:00 -0700781warn_CFLAGS="-Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes"
Gregory Maxwell6c83b0b2012-05-14 00:30:34 -0400782saved_CFLAGS="$CFLAGS"
Ralph Giles42f39c52013-03-11 10:59:13 -0700783CFLAGS="$CFLAGS $warn_CFLAGS"
784AC_MSG_CHECKING([if ${CC} supports ${warn_CFLAGS}])
Ron5bac4f22013-06-29 02:06:53 +0930785AC_COMPILE_IFELSE([AC_LANG_SOURCE([[char foo;]])],
786 [ AC_MSG_RESULT([yes]) ],
787 [ AC_MSG_RESULT([no])
788 CFLAGS="$saved_CFLAGS"
789 ])
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400790
Ron5bac4f22013-06-29 02:06:53 +0930791saved_LIBS="$LIBS"
792LIBS="$LIBS $LIBM"
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400793AC_CHECK_FUNCS([lrintf])
794AC_CHECK_FUNCS([lrint])
Ron5bac4f22013-06-29 02:06:53 +0930795LIBS="$saved_LIBS"
796
Ralph Gilesc19bc342011-10-28 07:14:58 -0700797AC_CHECK_FUNCS([__malloc_hook])
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400798
Ralph Gilesd47ddfb2012-09-16 23:09:21 -0700799AC_SUBST([PC_BUILD])
Ralph Gilesd47ddfb2012-09-16 23:09:21 -0700800
Timothy B. Terriberry39386e02013-11-18 13:30:13 -0500801AC_CONFIG_FILES([
802 Makefile
803 opus.pc
804 opus-uninstalled.pc
805 celt/arm/armopts.s
806 doc/Makefile
807 doc/Doxyfile
808])
Ron2f2f9d62013-05-11 02:05:24 +0930809AC_CONFIG_HEADERS([config.h])
Ronc40d5002012-09-19 07:56:17 +0930810
811AC_OUTPUT
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400812
Ron4a7bb1f2013-06-09 00:57:02 +0930813AC_MSG_NOTICE([
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400814------------------------------------------------------------------------
Ron2f2f9d62013-05-11 02:05:24 +0930815 $PACKAGE_NAME $PACKAGE_VERSION: Automatic configuration OK.
816
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400817 Compiler support:
818
819 C99 var arrays: ................ ${has_var_arrays}
820 C99 lrintf: .................... ${ac_cv_func_lrintf}
Ron5bac4f22013-06-29 02:06:53 +0930821 Use alloca: .................... ${use_alloca}
Timothy B. Terriberry39386e02013-11-18 13:30:13 -0500822
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400823 General configuration:
Timothy B. Terriberry39386e02013-11-18 13:30:13 -0500824
Ron5bac4f22013-06-29 02:06:53 +0930825 Floating point support: ........ ${enable_float}
826 Fast float approximations: ..... ${enable_float_approx}
827 Fixed point debugging: ......... ${enable_fixed_point_debug}
Timothy B. Terriberry39386e02013-11-18 13:30:13 -0500828 Inline Assembly Optimizations: . ${inline_optimization}
829 External Assembly Optimizations: ${asm_optimization}
Jonathan Lennoxb4aa5dc2015-08-03 17:04:20 -0400830 Intrinsics Optimizations.......: ${intrinsics_support}
Aurélien Zanellicd4c8242013-05-31 15:07:00 +0200831 Run-time CPU detection: ........ ${rtcd_support}
Ron5bac4f22013-06-29 02:06:53 +0930832 Custom modes: .................. ${enable_custom_modes}
833 Assertion checking: ............ ${enable_assertions}
834 Fuzzing: ....................... ${enable_fuzzing}
Ralph Giles35d4fb72011-09-06 23:18:00 -0700835
Ron5bac4f22013-06-29 02:06:53 +0930836 API documentation: ............. ${enable_doc}
837 Extra programs: ................ ${enable_extra_programs}
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400838------------------------------------------------------------------------
Ron4a7bb1f2013-06-09 00:57:02 +0930839
840 Type "make; make install" to compile and install
841 Type "make check" to run the test suite
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400842])
843