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