configure.ac 9.0 KB

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