configure.ac 9.3 KB

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