blob: 2d4896bdd4a90c8587816dd8d64dcce82b224b6f [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 Valin80c48342013-05-09 16:52:26 -040025OPUS_LT_CURRENT=4
Jean-Marc Valine05aaf22011-04-29 19:48:42 -040026OPUS_LT_REVISION=0
Jean-Marc Valin80c48342013-05-09 16:52:26 -040027OPUS_LT_AGE=4
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
Ron5bac4f22013-06-29 02:06:53 +093045AC_DEFINE([OPUS_BUILD], [], [This is a build of OPUS])
46
Gregory Maxwell8ecba1a2012-05-14 01:58:05 -040047#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)
Ron5bac4f22013-06-29 02:06:53 +093049#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.
Gregory Maxwell8ecba1a2012-05-14 01:58:05 -040051AC_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 ])
Ron5bac4f22013-06-29 02:06:53 +093068
69AH_VERBATIM([restrict],
Gregory Maxwell8ecba1a2012-05-14 01:58:05 -040070[/* 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])
Ron5bac4f22013-06-29 02:06:53 +093083
84case $ac_cv_c_restrict in
Gregory Maxwell8ecba1a2012-05-14 01:58:05 -040085 restrict) ;;
86 no) AC_DEFINE([restrict], []) ;;
87 *) AC_DEFINE_UNQUOTED([restrict], [$ac_cv_c_restrict]) ;;
Ron5bac4f22013-06-29 02:06:53 +093088esac
Jean-Marc Valin381c7062011-03-21 13:53:40 -040089
Jean-Marc Valine05aaf22011-04-29 19:48:42 -040090AC_MSG_CHECKING(for C99 variable-size arrays)
Ron5bac4f22013-06-29 02:06:53 +093091AC_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 ])
99AC_MSG_RESULT([$has_var_arrays])
Jean-Marc Valina0cbeca2010-07-08 11:27:20 -0400100
Ron5bac4f22013-06-29 02:06:53 +0930101AS_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 ])
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400114
Ron5bac4f22013-06-29 02:06:53 +0930115LT_LIB_M
116
117AC_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
122AS_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"
Ron5bac4f22013-06-29 02:06:53 +0930129])
130
131AM_CONDITIONAL([FIXED_POINT], [test "$enable_fixed_point" = "yes"])
132
133AC_ARG_ENABLE([fixed-point-debug],
134 [AS_HELP_STRING([--enable-fixed-point-debug], [debug fixed-point implementation])],,
135 [enable_fixed_point_debug=no])
136
137AS_IF([test "$enable_fixed_point_debug" = "yes"],[
138 AC_DEFINE([FIXED_DEBUG], [1], [Debug fixed-point implementation])
139])
140
141AC_ARG_ENABLE([custom-modes],
142 [AS_HELP_STRING([--enable-custom-modes], [enable non-Opus modes, e.g. 44.1 kHz & 2^n frames])],,
143 [enable_custom_modes=no])
144
145AS_IF([test "$enable_custom_modes" = "yes"],[
146 AC_DEFINE([CUSTOM_MODES], [1], [Custom modes])
147 PC_BUILD="$PC_BUILD, custom modes"
Ron5bac4f22013-06-29 02:06:53 +0930148])
149
150AM_CONDITIONAL([CUSTOM_MODES], [test "$enable_custom_modes" = "yes"])
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400151
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400152has_float_approx=no
153#case "$host_cpu" in
154#i[[3456]]86 | x86_64 | powerpc64 | powerpc32 | ia64)
155# has_float_approx=yes
156# ;;
157#esac
158
Ron5bac4f22013-06-29 02:06:53 +0930159AC_ARG_ENABLE([float-approx],
160 [AS_HELP_STRING([--enable-float-approx], [enable fast approximations for floating point])],
161 [if test "$enable_float_approx" = "yes"; then
162 AC_WARN([Floating point approximations are not supported on all platforms.])
163 fi
164 ],
165 [enable_float_approx=$has_float_approx])
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400166
Ron5bac4f22013-06-29 02:06:53 +0930167AS_IF([test "$enable_float_approx" = "yes"],[
168 AC_DEFINE([FLOAT_APPROX], [1], [Float approximations])
169])
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400170
Ron5bac4f22013-06-29 02:06:53 +0930171AC_ARG_ENABLE([asm],
172 [AS_HELP_STRING([--disable-asm], [Disable assembly optimizations])],,
173 [enable_asm=yes])
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400174
Aurélien Zanellicd4c8242013-05-31 15:07:00 +0200175rtcd_support=no
Timothy B. Terriberry972a34e2013-05-19 17:11:17 -0700176cpu_arm=no
Ron5bac4f22013-06-29 02:06:53 +0930177
178AS_IF([test "$enable_asm" = "yes"],[
Timothy B. Terriberry972a34e2013-05-19 17:11:17 -0700179 asm_optimization="no asm for your platform, please send patches"
180 case $host_cpu in
181 arm*)
182 cpu_arm=yes
183 AS_GCC_INLINE_ASSEMBLY([asm_optimization="ARM"],
184 [asm_optimization="disabled"])
Ron5bac4f22013-06-29 02:06:53 +0930185 if test "$asm_optimization" = "ARM" ; then
Aurélien Zanellicd4c8242013-05-31 15:07:00 +0200186 rtcd_support=yes
Timothy B. Terriberry33511f72013-05-22 16:15:30 -0700187 AC_DEFINE([ARMv4_ASM], 1, [Use generic ARMv4 asm optimizations])
Timothy B. Terriberry972a34e2013-05-19 17:11:17 -0700188 AS_ASM_ARM_EDSP([ARMv5E_ASM=1],[ARMv5E_ASM=0])
Ron5bac4f22013-06-29 02:06:53 +0930189 if test "$ARMv5E_ASM" = "1" ; then
190 AC_DEFINE([ARMv5E_ASM], [1], [Use ARMv5E asm optimizations])
191 asm_optimization="$asm_optimization (EDSP)"
Timothy B. Terriberry972a34e2013-05-19 17:11:17 -0700192 fi
193 AS_ASM_ARM_MEDIA([ARMv6_ASM=1],[ARMv6_ASM=0])
Ron5bac4f22013-06-29 02:06:53 +0930194 if test "$ARMv6_ASM" = "1" ; then
195 AC_DEFINE([ARMv6_ASM], [1], [Use ARMv6 asm optimizations])
196 asm_optimization="$asm_optimization (Media)"
Timothy B. Terriberry972a34e2013-05-19 17:11:17 -0700197 fi
Aurélien Zanellicd4c8242013-05-31 15:07:00 +0200198 AS_ASM_ARM_NEON([ARM_HAVE_NEON=1],[ARM_HAVE_NEON=0])
Ron5bac4f22013-06-29 02:06:53 +0930199 if test "$ARM_HAVE_NEON" = "1" ; then
Aurélien Zanellicd4c8242013-05-31 15:07:00 +0200200 AC_DEFINE([ARM_HAVE_NEON], 1, [Use ARM NEON optimizations])
Ron5bac4f22013-06-29 02:06:53 +0930201 asm_optimization="$asm_optimization (NEON)"
Aurélien Zanellicd4c8242013-05-31 15:07:00 +0200202 fi
Timothy B. Terriberry972a34e2013-05-19 17:11:17 -0700203 fi
204 ;;
205 esac
Ron5bac4f22013-06-29 02:06:53 +0930206],[
Timothy B. Terriberry972a34e2013-05-19 17:11:17 -0700207 asm_optimization="disabled"
Ron5bac4f22013-06-29 02:06:53 +0930208])
Timothy B. Terriberry972a34e2013-05-19 17:11:17 -0700209
Ron5bac4f22013-06-29 02:06:53 +0930210AM_CONDITIONAL([CPU_ARM], [test "$cpu_arm" = "yes"])
211
212AC_ARG_ENABLE([rtcd],
213 [AS_HELP_STRING([--disable-rtcd], [Disable run-time CPU capabilities detection])],,
214 [enable_rtcd=yes])
215
216AS_IF([test "$enable_rtcd" = "yes"],[
217 AS_IF([test "$rtcd_support" = "yes"],[
218 AC_DEFINE([OPUS_HAVE_RTCD], [1], [Use run-time CPU capabilities detection])
219 ],[
220 rtcd_support="no rtcd for your platform, please send patches"
221 ])
222],[
Aurélien Zanellicd4c8242013-05-31 15:07:00 +0200223 rtcd_support="no"
Ron5bac4f22013-06-29 02:06:53 +0930224])
Aurélien Zanellicd4c8242013-05-31 15:07:00 +0200225
Ron5bac4f22013-06-29 02:06:53 +0930226AC_ARG_ENABLE([assertions],
227 [AS_HELP_STRING([--enable-assertions],[enable additional software error checking])],,
228 [enable_assertions=no])
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400229
Ron5bac4f22013-06-29 02:06:53 +0930230AS_IF([test "$enable_assertions" = "yes"], [
231 AC_DEFINE([ENABLE_ASSERTIONS], [1], [Assertions])
232])
Jean-Marc Valinf334c822011-08-11 16:21:58 -0400233
Ron5bac4f22013-06-29 02:06:53 +0930234AC_ARG_ENABLE([fuzzing],
235 [AS_HELP_STRING([--enable-fuzzing],[causes the encoder to make random decisions])],,
236 [enable_fuzzing=no])
237
238AS_IF([test "$enable_fuzzing" = "yes"], [
239 AC_DEFINE([FUZZING], [1], [Fuzzing])
240])
241
Ralph Giles35d4fb72011-09-06 23:18:00 -0700242AC_ARG_ENABLE([doc],
Ron5bac4f22013-06-29 02:06:53 +0930243 [AS_HELP_STRING([--disable-doc], [Do not build API documentation])],,
244 [enable_doc=yes])
Ralph Giles35d4fb72011-09-06 23:18:00 -0700245
Ron5bac4f22013-06-29 02:06:53 +0930246AS_IF([test "$enable_doc" = "yes"], [
247 AC_CHECK_PROG(HAVE_DOXYGEN, [doxygen], [yes], [no])
248],[
249 HAVE_DOXYGEN=no
250])
251
252AM_CONDITIONAL([HAVE_DOXYGEN], [test "$HAVE_DOXYGEN" = "yes"])
253
Aurélien Zanellifaec6732013-05-26 22:08:02 +0200254AC_ARG_ENABLE([extra-programs],
Ron5bac4f22013-06-29 02:06:53 +0930255 [AS_HELP_STRING([--disable-extra-programs], [Do not build extra programs (demo and tests)])],,
256 [enable_extra_programs=yes])
257
258AM_CONDITIONAL([EXTRA_PROGRAMS], [test "$enable_extra_programs" = "yes"])
259
Aurélien Zanellifaec6732013-05-26 22:08:02 +0200260
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400261saved_CFLAGS="$CFLAGS"
262CFLAGS="$CFLAGS -fvisibility=hidden"
Gregory Maxwelle53ebd62011-10-21 14:21:53 -0400263AC_MSG_CHECKING([if ${CC} supports -fvisibility=hidden])
Ron5bac4f22013-06-29 02:06:53 +0930264AC_COMPILE_IFELSE([AC_LANG_SOURCE([[char foo;]])],
265 [ AC_MSG_RESULT([yes]) ],
266 [ AC_MSG_RESULT([no])
267 CFLAGS="$saved_CFLAGS"
268 ])
Gregory Maxwell6c83b0b2012-05-14 00:30:34 -0400269
Gregory Maxwell6c83b0b2012-05-14 00:30:34 -0400270CFLAGS="$CFLAGS -W"
271
Ralph Giles99e8a932013-03-12 22:57:00 -0700272warn_CFLAGS="-Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes"
Gregory Maxwell6c83b0b2012-05-14 00:30:34 -0400273saved_CFLAGS="$CFLAGS"
Ralph Giles42f39c52013-03-11 10:59:13 -0700274CFLAGS="$CFLAGS $warn_CFLAGS"
275AC_MSG_CHECKING([if ${CC} supports ${warn_CFLAGS}])
Ron5bac4f22013-06-29 02:06:53 +0930276AC_COMPILE_IFELSE([AC_LANG_SOURCE([[char foo;]])],
277 [ AC_MSG_RESULT([yes]) ],
278 [ AC_MSG_RESULT([no])
279 CFLAGS="$saved_CFLAGS"
280 ])
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400281
Ron5bac4f22013-06-29 02:06:53 +0930282saved_LIBS="$LIBS"
283LIBS="$LIBS $LIBM"
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400284AC_CHECK_FUNCS([lrintf])
285AC_CHECK_FUNCS([lrint])
Ron5bac4f22013-06-29 02:06:53 +0930286LIBS="$saved_LIBS"
287
Ralph Gilesc19bc342011-10-28 07:14:58 -0700288AC_CHECK_FUNCS([__malloc_hook])
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400289
Ralph Gilesd47ddfb2012-09-16 23:09:21 -0700290AC_SUBST([PC_BUILD])
Ralph Gilesd47ddfb2012-09-16 23:09:21 -0700291
Ronc40d5002012-09-19 07:56:17 +0930292
Ronc40d5002012-09-19 07:56:17 +0930293AC_CONFIG_FILES([Makefile opus.pc opus-uninstalled.pc
294 doc/Makefile doc/Doxyfile])
Ron2f2f9d62013-05-11 02:05:24 +0930295AC_CONFIG_HEADERS([config.h])
Ronc40d5002012-09-19 07:56:17 +0930296
297AC_OUTPUT
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400298
Ron4a7bb1f2013-06-09 00:57:02 +0930299AC_MSG_NOTICE([
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400300------------------------------------------------------------------------
Ron2f2f9d62013-05-11 02:05:24 +0930301 $PACKAGE_NAME $PACKAGE_VERSION: Automatic configuration OK.
302
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400303 Compiler support:
304
305 C99 var arrays: ................ ${has_var_arrays}
306 C99 lrintf: .................... ${ac_cv_func_lrintf}
Ron5bac4f22013-06-29 02:06:53 +0930307 Use alloca: .................... ${use_alloca}
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400308
309 General configuration:
310
Ron5bac4f22013-06-29 02:06:53 +0930311 Floating point support: ........ ${enable_float}
312 Fast float approximations: ..... ${enable_float_approx}
313 Fixed point debugging: ......... ${enable_fixed_point_debug}
Timothy B. Terriberry972a34e2013-05-19 17:11:17 -0700314 Assembly optimization: ......... ${asm_optimization}
Aurélien Zanellicd4c8242013-05-31 15:07:00 +0200315 Run-time CPU detection: ........ ${rtcd_support}
Ron5bac4f22013-06-29 02:06:53 +0930316 Custom modes: .................. ${enable_custom_modes}
317 Assertion checking: ............ ${enable_assertions}
318 Fuzzing: ....................... ${enable_fuzzing}
Ralph Giles35d4fb72011-09-06 23:18:00 -0700319
Ron5bac4f22013-06-29 02:06:53 +0930320 API documentation: ............. ${enable_doc}
321 Extra programs: ................ ${enable_extra_programs}
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400322------------------------------------------------------------------------
Ron4a7bb1f2013-06-09 00:57:02 +0930323
324 Type "make; make install" to compile and install
325 Type "make check" to run the test suite
Jean-Marc Valine05aaf22011-04-29 19:48:42 -0400326])
327