Jean-Marc Valin | e05aaf2 | 2011-04-29 19:48:42 -0400 | [diff] [blame] | 1 | dnl Process this file with autoconf to produce a configure script. -*-m4-*- |
Jean-Marc Valin | a0cbeca | 2010-07-08 11:27:20 -0400 | [diff] [blame] | 2 | |
Jean-Marc Valin | e05aaf2 | 2011-04-29 19:48:42 -0400 | [diff] [blame] | 3 | AC_INIT(src/opus_encoder.c) |
Jean-Marc Valin | a0cbeca | 2010-07-08 11:27:20 -0400 | [diff] [blame] | 4 | |
Jean-Marc Valin | 381c706 | 2011-03-21 13:53:40 -0400 | [diff] [blame] | 5 | AM_CONFIG_HEADER([config.h]) |
| 6 | |
Ralph Giles | 5ccc124 | 2011-07-29 00:55:56 -0700 | [diff] [blame] | 7 | dnl enable silent rules on automake 1.11 and later |
| 8 | m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) |
| 9 | |
Jean-Marc Valin | e05aaf2 | 2011-04-29 19:48:42 -0400 | [diff] [blame] | 10 | OPUS_MAJOR_VERSION=0 |
| 11 | OPUS_MINOR_VERSION=9 |
Jean-Marc Valin | 8858cac | 2012-05-17 19:45:10 -0400 | [diff] [blame] | 12 | OPUS_MICRO_VERSION=14 |
Jean-Marc Valin | e05aaf2 | 2011-04-29 19:48:42 -0400 | [diff] [blame] | 13 | OPUS_EXTRA_VERSION= |
Ralph Giles | 50f933b | 2011-08-02 09:34:55 -0700 | [diff] [blame] | 14 | |
| 15 | OPUS_VERSION="$OPUS_MAJOR_VERSION.$OPUS_MINOR_VERSION.$OPUS_MICRO_VERSION$OPUS_EXTRA_VERSION" |
| 16 | AC_MSG_CHECKING([git revision]) |
Jean-Marc Valin | a8ac44b | 2011-08-05 08:47:24 -0400 | [diff] [blame] | 17 | GIT_VERSION=$(git describe --tags --match 'v*' 2>/dev/null | sed 's/^v//') |
Ralph Giles | 50f933b | 2011-08-02 09:34:55 -0700 | [diff] [blame] | 18 | if test -z "$GIT_VERSION"; then |
| 19 | AC_MSG_RESULT([no]) |
| 20 | else |
| 21 | AC_MSG_RESULT([$GIT_VERSION]) |
| 22 | OPUS_VERSION="$GIT_VERSION" |
| 23 | fi |
| 24 | |
Ralph Giles | 3164fcf | 2012-05-18 11:47:58 -0700 | [diff] [blame^] | 25 | # For automake. |
| 26 | VERSION=$OPUS_VERSION |
| 27 | PACKAGE=opus |
| 28 | |
| 29 | # For our version string. |
| 30 | AC_SUBST(OPUS_VERSION) |
| 31 | |
| 32 | # For config.h |
| 33 | AC_DEFINE_UNQUOTED(OPUS_VERSION, "${OPUS_VERSION}", [Complete version string]) |
| 34 | AC_DEFINE_UNQUOTED(OPUS_MAJOR_VERSION, ${OPUS_MAJOR_VERSION}, [Version major]) |
| 35 | AC_DEFINE_UNQUOTED(OPUS_MINOR_VERSION, ${OPUS_MINOR_VERSION}, [Version minor]) |
| 36 | AC_DEFINE_UNQUOTED(OPUS_MICRO_VERSION, ${OPUS_MICRO_VERSION}, [Version micro]) |
| 37 | AC_DEFINE_UNQUOTED(OPUS_EXTRA_VERSION, "${OPUS_EXTRA_VERSION}", [Version extra]) |
| 38 | |
| 39 | # For libtool. |
Jean-Marc Valin | e05aaf2 | 2011-04-29 19:48:42 -0400 | [diff] [blame] | 40 | LIBOPUS_SUFFIX=0 |
Jean-Marc Valin | a0cbeca | 2010-07-08 11:27:20 -0400 | [diff] [blame] | 41 | |
Jean-Marc Valin | e05aaf2 | 2011-04-29 19:48:42 -0400 | [diff] [blame] | 42 | OPUS_LT_CURRENT=0 |
| 43 | OPUS_LT_REVISION=0 |
| 44 | OPUS_LT_AGE=0 |
Jean-Marc Valin | a0cbeca | 2010-07-08 11:27:20 -0400 | [diff] [blame] | 45 | |
Jean-Marc Valin | e05aaf2 | 2011-04-29 19:48:42 -0400 | [diff] [blame] | 46 | AC_SUBST(OPUS_LT_CURRENT) |
| 47 | AC_SUBST(OPUS_LT_REVISION) |
| 48 | AC_SUBST(OPUS_LT_AGE) |
| 49 | AC_SUBST(LIBOPUS_SUFFIX) |
| 50 | |
Jean-Marc Valin | e05aaf2 | 2011-04-29 19:48:42 -0400 | [diff] [blame] | 51 | AM_INIT_AUTOMAKE($PACKAGE, $VERSION, no-define) |
| 52 | AM_MAINTAINER_MODE |
| 53 | |
| 54 | AC_CANONICAL_HOST |
| 55 | AM_PROG_LIBTOOL |
Ralph Giles | 2852cb1 | 2011-08-02 11:43:43 -0700 | [diff] [blame] | 56 | AM_PROG_CC_C_O |
Jean-Marc Valin | e05aaf2 | 2011-04-29 19:48:42 -0400 | [diff] [blame] | 57 | |
| 58 | AC_PROG_CC_C99 |
| 59 | AC_C_BIGENDIAN |
Jean-Marc Valin | a0cbeca | 2010-07-08 11:27:20 -0400 | [diff] [blame] | 60 | AC_C_CONST |
| 61 | AC_C_INLINE |
Gregory Maxwell | 8ecba1a | 2012-05-14 01:58:05 -0400 | [diff] [blame] | 62 | |
| 63 | #Use a hacked up version of autoconf's AC_C_RESTRICT because it's not |
| 64 | #strong enough a test to detect old buggy versions of GCC (e.g. 2.95.3) |
| 65 | AC_CACHE_CHECK([for C/C++ restrict keyword], ac_cv_c_restrict, |
| 66 | [ac_cv_c_restrict=no |
| 67 | # The order here caters to the fact that C++ does not require restrict. |
| 68 | for ac_kw in __restrict __restrict__ _Restrict restrict; do |
| 69 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM( |
| 70 | [[typedef int * int_ptr; |
| 71 | int foo (int_ptr $ac_kw ip, int * $ac_kw baz[]) { |
| 72 | return ip[0]; |
| 73 | }]], |
| 74 | [[int s[1]; |
| 75 | int * $ac_kw t = s; |
| 76 | t[0] = 0; |
| 77 | return foo(t, (void *)0)]])], |
| 78 | [ac_cv_c_restrict=$ac_kw]) |
| 79 | test "$ac_cv_c_restrict" != no && break |
| 80 | done |
| 81 | ]) |
| 82 | AH_VERBATIM([restrict], |
| 83 | [/* Define to the equivalent of the C99 'restrict' keyword, or to |
| 84 | nothing if this is not supported. Do not define if restrict is |
| 85 | supported directly. */ |
| 86 | #undef restrict |
| 87 | /* Work around a bug in Sun C++: it does not support _Restrict or |
| 88 | __restrict__, even though the corresponding Sun C compiler ends up with |
| 89 | "#define restrict _Restrict" or "#define restrict __restrict__" in the |
| 90 | previous line. Perhaps some future version of Sun C++ will work with |
| 91 | restrict; if so, hopefully it defines __RESTRICT like Sun C does. */ |
| 92 | #if defined __SUNPRO_CC && !defined __RESTRICT |
| 93 | # define _Restrict |
| 94 | # define __restrict__ |
| 95 | #endif]) |
| 96 | case $ac_cv_c_restrict in |
| 97 | restrict) ;; |
| 98 | no) AC_DEFINE([restrict], []) ;; |
| 99 | *) AC_DEFINE_UNQUOTED([restrict], [$ac_cv_c_restrict]) ;; |
| 100 | esac |
Jean-Marc Valin | a0cbeca | 2010-07-08 11:27:20 -0400 | [diff] [blame] | 101 | |
Jean-Marc Valin | e05aaf2 | 2011-04-29 19:48:42 -0400 | [diff] [blame] | 102 | AC_DEFINE([OPUS_BUILD], [], [This is a build of OPUS]) |
Jean-Marc Valin | 381c706 | 2011-03-21 13:53:40 -0400 | [diff] [blame] | 103 | |
Jean-Marc Valin | e05aaf2 | 2011-04-29 19:48:42 -0400 | [diff] [blame] | 104 | AC_MSG_CHECKING(for C99 variable-size arrays) |
Gregory Maxwell | 8ecba1a | 2012-05-14 01:58:05 -0400 | [diff] [blame] | 105 | AC_TRY_COMPILE( [], [static int x; char a[++x]; a[sizeof a - 1] = 0; int N; return a[0];], |
Jean-Marc Valin | e05aaf2 | 2011-04-29 19:48:42 -0400 | [diff] [blame] | 106 | [has_var_arrays=yes;AC_DEFINE([VAR_ARRAYS], [], [Use C99 variable-size arrays]) |
| 107 | ], |
| 108 | has_var_arrays=no |
| 109 | ) |
| 110 | AC_MSG_RESULT($has_var_arrays) |
Jean-Marc Valin | a0cbeca | 2010-07-08 11:27:20 -0400 | [diff] [blame] | 111 | |
Jean-Marc Valin | e05aaf2 | 2011-04-29 19:48:42 -0400 | [diff] [blame] | 112 | AC_CHECK_HEADERS([alloca.h getopt.h]) |
| 113 | AC_MSG_CHECKING(for alloca) |
| 114 | AC_TRY_COMPILE( [#include <alloca.h>], [ |
| 115 | int foo=10; |
| 116 | int *array = alloca(foo); |
| 117 | ], |
| 118 | [ |
| 119 | has_alloca=yes; |
| 120 | if test x$has_var_arrays = "xno" ; then |
| 121 | AC_DEFINE([USE_ALLOCA], [], [Make use of alloca]) |
| 122 | fi |
| 123 | ], |
| 124 | has_alloca=no |
| 125 | ) |
| 126 | AC_MSG_RESULT($has_alloca) |
| 127 | |
Gregory Maxwell | 6c83b0b | 2012-05-14 00:30:34 -0400 | [diff] [blame] | 128 | AC_CHECK_FUNC(exp,[fp_libm_not_needed=yes;LIBM=],[fp_libm_not_needed=dunno]) |
| 129 | if test x"$fp_libm_not_needed" = xdunno; then |
| 130 | AC_CHECK_LIB([m], [exp], [LIBS="-lm $LIBS"; LIBM="-lm"],[LIBM=]) |
| 131 | fi |
| 132 | AC_SUBST([LIBM]) |
Jean-Marc Valin | e05aaf2 | 2011-04-29 19:48:42 -0400 | [diff] [blame] | 133 | |
Jean-Marc Valin | e05aaf2 | 2011-04-29 19:48:42 -0400 | [diff] [blame] | 134 | has_float_approx=no |
| 135 | #case "$host_cpu" in |
| 136 | #i[[3456]]86 | x86_64 | powerpc64 | powerpc32 | ia64) |
| 137 | # has_float_approx=yes |
| 138 | # ;; |
| 139 | #esac |
| 140 | |
| 141 | ac_enable_fixed="no"; |
| 142 | AC_ARG_ENABLE(fixed-point, [ --enable-fixed-point compile as fixed-point], |
| 143 | [if test "$enableval" = yes; then |
| 144 | ac_enable_fixed="yes"; |
Jean-Marc Valin | 7009c72 | 2011-04-29 20:32:33 -0400 | [diff] [blame] | 145 | AC_DEFINE([FIXED_POINT], [1], [Compile as fixed-point]) |
Jean-Marc Valin | e05aaf2 | 2011-04-29 19:48:42 -0400 | [diff] [blame] | 146 | else |
| 147 | AC_DEFINE([FLOATING_POINT], , [Compile as floating-point]) |
| 148 | fi], |
| 149 | AC_DEFINE([FLOATING_POINT], , [Compile as floating-point])) |
| 150 | |
| 151 | ac_enable_fixed_debug="no" |
| 152 | AC_ARG_ENABLE(fixed-point-debug, [ --enable-fixed-point-debug debug fixed-point implementation], |
| 153 | [if test "$enableval" = yes; then |
| 154 | ac_enable_fixed_debug="yes" |
| 155 | AC_DEFINE([FIXED_DEBUG], , [Debug fixed-point implementation]) |
| 156 | fi]) |
| 157 | |
Jean-Marc Valin | e05aaf2 | 2011-04-29 19:48:42 -0400 | [diff] [blame] | 158 | ac_enable_custom_modes="no" |
| 159 | AC_ARG_ENABLE(custom-modes, [ --enable-custom-modes Enable non-Opus modes, like 44.1 kHz and powers of two ], |
| 160 | [if test "$enableval" = yes; then |
| 161 | ac_enable_custom_modes="yes" |
| 162 | AC_DEFINE([CUSTOM_MODES], , [Custom modes]) |
| 163 | fi]) |
| 164 | |
| 165 | float_approx=$has_float_approx |
| 166 | AC_ARG_ENABLE(float-approx, [ --enable-float-approx enable fast approximations for floating point], |
| 167 | [ if test "$enableval" = yes; then |
| 168 | AC_WARN([Floating point approximations are not supported on all platforms.]) |
| 169 | float_approx=yes |
| 170 | else |
| 171 | float_approx=no |
| 172 | fi], [ float_approx=$has_float_approx ]) |
| 173 | |
| 174 | if test "x${float_approx}" = "xyes"; then |
| 175 | AC_DEFINE([FLOAT_APPROX], , [Float approximations]) |
| 176 | fi |
| 177 | |
| 178 | ac_enable_assertions="no" |
| 179 | AC_ARG_ENABLE(assertions, [ --enable-assertions enable additional software error checking], |
| 180 | [if test "$enableval" = yes; then |
| 181 | ac_enable_assertions="yes" |
| 182 | AC_DEFINE([ENABLE_ASSERTIONS], , [Assertions]) |
| 183 | fi]) |
| 184 | |
Jean-Marc Valin | f334c82 | 2011-08-11 16:21:58 -0400 | [diff] [blame] | 185 | ac_enable_fuzzing="no" |
| 186 | AC_ARG_ENABLE(fuzzing, [ --enable-fuzzing causes the encoder to make random decisions], |
| 187 | [if test "$enableval" = yes; then |
| 188 | ac_enable_fuzzing="yes" |
| 189 | AC_DEFINE([FUZZING], , [Fuzzing]) |
| 190 | fi]) |
| 191 | |
Ralph Giles | 35d4fb7 | 2011-09-06 23:18:00 -0700 | [diff] [blame] | 192 | ac_enable_doc="yes" |
| 193 | AC_ARG_ENABLE([doc], |
| 194 | AS_HELP_STRING([--disable-doc], [Do not build API documentation]), |
| 195 | [ac_enable_doc=$enableval]) |
| 196 | AC_CHECK_PROG(HAVE_DOXYGEN, [doxygen], [yes], [no]) |
| 197 | if test "$HAVE_DOXYGEN" != "yes" -o "$ac_enable_doc" != "yes"; then |
| 198 | HAVE_DOXYGEN="false" |
| 199 | ac_enable_doc="no" |
| 200 | fi |
| 201 | AM_CONDITIONAL(HAVE_DOXYGEN, [test $HAVE_DOXYGEN = yes]) |
| 202 | |
Jean-Marc Valin | e05aaf2 | 2011-04-29 19:48:42 -0400 | [diff] [blame] | 203 | saved_CFLAGS="$CFLAGS" |
| 204 | CFLAGS="$CFLAGS -fvisibility=hidden" |
Gregory Maxwell | e53ebd6 | 2011-10-21 14:21:53 -0400 | [diff] [blame] | 205 | AC_MSG_CHECKING([if ${CC} supports -fvisibility=hidden]) |
Gregory Maxwell | 6c83b0b | 2012-05-14 00:30:34 -0400 | [diff] [blame] | 206 | AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])], |
Jean-Marc Valin | e05aaf2 | 2011-04-29 19:48:42 -0400 | [diff] [blame] | 207 | [ AC_MSG_RESULT([yes]) |
| 208 | SYMBOL_VISIBILITY="-fvisibility=hidden" ], |
| 209 | AC_MSG_RESULT([no])) |
| 210 | CFLAGS="$saved_CFLAGS $SYMBOL_VISIBILITY" |
| 211 | AC_SUBST(SYMBOL_VISIBILITY) |
Gregory Maxwell | 6c83b0b | 2012-05-14 00:30:34 -0400 | [diff] [blame] | 212 | |
| 213 | if test $ac_cv_c_compiler_gnu = yes ; then |
Gregory Maxwell | e53ebd6 | 2011-10-21 14:21:53 -0400 | [diff] [blame] | 214 | saved_CFLAGS="$CFLAGS" |
| 215 | CFLAGS="$CFLAGS -fstack-protector-all" |
| 216 | AC_MSG_CHECKING([if ${CC} supports -fstack-protector-all]) |
Gregory Maxwell | 6c83b0b | 2012-05-14 00:30:34 -0400 | [diff] [blame] | 217 | AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])], |
Gregory Maxwell | e53ebd6 | 2011-10-21 14:21:53 -0400 | [diff] [blame] | 218 | [ AC_MSG_RESULT([yes]) |
| 219 | STACK_PROTECTOR="-fstack-protector-all" ], |
| 220 | AC_MSG_RESULT([no])) |
| 221 | CFLAGS="$saved_CFLAGS $STACK_PROTECTOR" |
Jean-Marc Valin | e05aaf2 | 2011-04-29 19:48:42 -0400 | [diff] [blame] | 222 | fi |
| 223 | |
Gregory Maxwell | 6c83b0b | 2012-05-14 00:30:34 -0400 | [diff] [blame] | 224 | CFLAGS="$CFLAGS -W" |
| 225 | |
| 226 | saved_CFLAGS="$CFLAGS" |
| 227 | CFLAGS="$CFLAGS -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes" |
| 228 | AC_MSG_CHECKING([if ${CC} supports -Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes]) |
| 229 | AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])], |
| 230 | [ AC_MSG_RESULT([yes]) |
| 231 | EXTRA_WARNS="-Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes" ], |
| 232 | AC_MSG_RESULT([no])) |
| 233 | CFLAGS="$saved_CFLAGS $EXTRA_WARNS" |
Jean-Marc Valin | e05aaf2 | 2011-04-29 19:48:42 -0400 | [diff] [blame] | 234 | |
| 235 | AC_CHECK_FUNCS([lrintf]) |
| 236 | AC_CHECK_FUNCS([lrint]) |
Ralph Giles | c19bc34 | 2011-10-28 07:14:58 -0700 | [diff] [blame] | 237 | AC_CHECK_FUNCS([__malloc_hook]) |
Jean-Marc Valin | e05aaf2 | 2011-04-29 19:48:42 -0400 | [diff] [blame] | 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 | |
Jean-Marc Valin | e05aaf2 | 2011-04-29 19:48:42 -0400 | [diff] [blame] | 273 | AM_CONDITIONAL([FIXED_POINT], [test x$ac_enable_fixed = xyes]) |
Jean-Marc Valin | 06237d7 | 2011-09-01 13:20:40 -0400 | [diff] [blame] | 274 | AM_CONDITIONAL([CUSTOM_MODES], [test x$ac_enable_custom_modes = xyes]) |
Jean-Marc Valin | e05aaf2 | 2011-04-29 19:48:42 -0400 | [diff] [blame] | 275 | |
Gregory Maxwell | 9652f81 | 2011-10-26 23:55:33 -0400 | [diff] [blame] | 276 | AC_OUTPUT([Makefile opus.pc opus-uninstalled.pc |
Ralph Giles | 35d4fb7 | 2011-09-06 23:18:00 -0700 | [diff] [blame] | 277 | doc/Makefile doc/Doxyfile]) |
Jean-Marc Valin | e05aaf2 | 2011-04-29 19:48:42 -0400 | [diff] [blame] | 278 | |
| 279 | AC_MSG_RESULT([ |
| 280 | ------------------------------------------------------------------------ |
| 281 | $PACKAGE $VERSION: Automatic configuration OK. |
| 282 | |
| 283 | Compiler support: |
| 284 | |
| 285 | C99 var arrays: ................ ${has_var_arrays} |
| 286 | C99 lrintf: .................... ${ac_cv_func_lrintf} |
| 287 | Alloca: ........................ ${has_alloca} |
| 288 | |
| 289 | General configuration: |
| 290 | |
| 291 | Fast float approximations: ..... ${float_approx} |
| 292 | Fixed point support: ........... ${ac_enable_fixed} |
| 293 | Fixed point debugging: ......... ${ac_enable_fixed_debug} |
| 294 | Custom modes: .................. ${ac_enable_custom_modes} |
| 295 | Assertion checking: ............ ${ac_enable_assertions} |
Gregory Maxwell | 48069bf | 2011-09-15 11:33:18 -0400 | [diff] [blame] | 296 | Fuzzing: ....................... ${ac_enable_fuzzing} |
Ralph Giles | 35d4fb7 | 2011-09-06 23:18:00 -0700 | [diff] [blame] | 297 | |
| 298 | API documentation: ............. ${ac_enable_doc} |
Jean-Marc Valin | e05aaf2 | 2011-04-29 19:48:42 -0400 | [diff] [blame] | 299 | ------------------------------------------------------------------------ |
| 300 | ]) |
| 301 | |
Jean-Marc Valin | e05aaf2 | 2011-04-29 19:48:42 -0400 | [diff] [blame] | 302 | echo "Type \"make; make install\" to compile and install"; |
| 303 | echo "Type \"make check\" to run the test suite"; |