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