configure.ac 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  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. AC_CONFIG_MACRO_DIR([m4])
  15. dnl enable silent rules on automake 1.11 and later
  16. m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
  17. # For libtool.
  18. dnl Please update these for releases.
  19. OPUS_LT_CURRENT=4
  20. OPUS_LT_REVISION=0
  21. OPUS_LT_AGE=4
  22. AC_SUBST(OPUS_LT_CURRENT)
  23. AC_SUBST(OPUS_LT_REVISION)
  24. AC_SUBST(OPUS_LT_AGE)
  25. AM_INIT_AUTOMAKE([no-define])
  26. AM_MAINTAINER_MODE([enable])
  27. AC_CANONICAL_HOST
  28. AC_MINGW32
  29. AM_PROG_LIBTOOL
  30. AM_PROG_CC_C_O
  31. AC_PROG_CC_C99
  32. AC_C_CONST
  33. AC_C_INLINE
  34. #Use a hacked up version of autoconf's AC_C_RESTRICT because it's not
  35. #strong enough a test to detect old buggy versions of GCC (e.g. 2.95.3)
  36. AC_CACHE_CHECK([for C/C++ restrict keyword], ac_cv_c_restrict,
  37. [ac_cv_c_restrict=no
  38. # The order here caters to the fact that C++ does not require restrict.
  39. for ac_kw in __restrict __restrict__ _Restrict restrict; do
  40. AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
  41. [[typedef int * int_ptr;
  42. int foo (int_ptr $ac_kw ip, int * $ac_kw baz[]) {
  43. return ip[0];
  44. }]],
  45. [[int s[1];
  46. int * $ac_kw t = s;
  47. t[0] = 0;
  48. return foo(t, (void *)0)]])],
  49. [ac_cv_c_restrict=$ac_kw])
  50. test "$ac_cv_c_restrict" != no && break
  51. done
  52. ])
  53. AH_VERBATIM([restrict],
  54. [/* Define to the equivalent of the C99 'restrict' keyword, or to
  55. nothing if this is not supported. Do not define if restrict is
  56. supported directly. */
  57. #undef restrict
  58. /* Work around a bug in Sun C++: it does not support _Restrict or
  59. __restrict__, even though the corresponding Sun C compiler ends up with
  60. "#define restrict _Restrict" or "#define restrict __restrict__" in the
  61. previous line. Perhaps some future version of Sun C++ will work with
  62. restrict; if so, hopefully it defines __RESTRICT like Sun C does. */
  63. #if defined __SUNPRO_CC && !defined __RESTRICT
  64. # define _Restrict
  65. # define __restrict__
  66. #endif])
  67. case $ac_cv_c_restrict in
  68. restrict) ;;
  69. no) AC_DEFINE([restrict], []) ;;
  70. *) AC_DEFINE_UNQUOTED([restrict], [$ac_cv_c_restrict]) ;;
  71. esac
  72. AC_DEFINE([OPUS_BUILD], [], [This is a build of OPUS])
  73. AC_MSG_CHECKING(for C99 variable-size arrays)
  74. AC_TRY_COMPILE( [], [static int x; char a[++x]; a[sizeof a - 1] = 0; int N; return a[0];],
  75. [has_var_arrays=yes;AC_DEFINE([VAR_ARRAYS], [], [Use C99 variable-size arrays])
  76. ],
  77. has_var_arrays=no
  78. )
  79. AC_MSG_RESULT($has_var_arrays)
  80. AC_CHECK_HEADERS([alloca.h getopt.h])
  81. AC_MSG_CHECKING(for alloca)
  82. AC_TRY_COMPILE( [#include <alloca.h>], [
  83. int foo=10;
  84. int *array = alloca(foo);
  85. ],
  86. [
  87. has_alloca=yes;
  88. if test x$has_var_arrays = "xno" ; then
  89. AC_DEFINE([USE_ALLOCA], [], [Make use of alloca])
  90. fi
  91. ],
  92. has_alloca=no
  93. )
  94. AC_MSG_RESULT($has_alloca)
  95. AC_CHECK_FUNC(exp,[fp_libm_not_needed=yes;LIBM=],[fp_libm_not_needed=dunno])
  96. if test x"$fp_libm_not_needed" = xdunno; then
  97. AC_CHECK_LIB([m], [exp], [LIBS="-lm $LIBS"; LIBM="-lm"],[LIBM=])
  98. fi
  99. AC_SUBST([LIBM])
  100. has_float_approx=no
  101. #case "$host_cpu" in
  102. #i[[3456]]86 | x86_64 | powerpc64 | powerpc32 | ia64)
  103. # has_float_approx=yes
  104. # ;;
  105. #esac
  106. ac_enable_fixed="no";
  107. ac_enable_float="yes";
  108. AC_ARG_ENABLE(fixed-point, [ --enable-fixed-point compile without floating point (for machines without a fast enough FPU)],
  109. [if test "$enableval" = yes; then
  110. ac_enable_fixed="yes";
  111. ac_enable_float="no";
  112. AC_DEFINE([FIXED_POINT], [1], [Compile as fixed-point (for machines without a fast enough FPU)])
  113. fi])
  114. ac_enable_fixed_debug="no"
  115. AC_ARG_ENABLE(fixed-point-debug, [ --enable-fixed-point-debug debug fixed-point implementation],
  116. [if test "$enableval" = yes; then
  117. ac_enable_fixed_debug="yes"
  118. AC_DEFINE([FIXED_DEBUG], , [Debug fixed-point implementation])
  119. fi])
  120. ac_enable_custom_modes="no"
  121. AC_ARG_ENABLE(custom-modes, [ --enable-custom-modes enable non-Opus modes, e.g. 44.1 kHz & 2^n frames],
  122. [if test "$enableval" = yes; then
  123. ac_enable_custom_modes="yes"
  124. AC_DEFINE([CUSTOM_MODES], , [Custom modes])
  125. fi])
  126. float_approx=$has_float_approx
  127. AC_ARG_ENABLE(float-approx, [ --enable-float-approx enable fast approximations for floating point],
  128. [ if test "$enableval" = yes; then
  129. AC_WARN([Floating point approximations are not supported on all platforms.])
  130. float_approx=yes
  131. else
  132. float_approx=no
  133. fi], [ float_approx=$has_float_approx ])
  134. if test "x${float_approx}" = "xyes"; then
  135. AC_DEFINE([FLOAT_APPROX], , [Float approximations])
  136. fi
  137. rtcd_support=no
  138. cpu_arm=no
  139. AC_ARG_ENABLE(asm,
  140. AS_HELP_STRING([--disable-asm], [Disable assembly optimizations]),
  141. [ ac_enable_asm=$enableval ], [ ac_enable_asm=yes] )
  142. if test "x${ac_enable_asm}" = xyes ; then
  143. asm_optimization="no asm for your platform, please send patches"
  144. case $host_cpu in
  145. arm*)
  146. cpu_arm=yes
  147. AS_GCC_INLINE_ASSEMBLY([asm_optimization="ARM"],
  148. [asm_optimization="disabled"])
  149. if test "x${asm_optimization}" = "xARM" ; then
  150. rtcd_support=yes
  151. AC_DEFINE([ARMv4_ASM], 1, [Use generic ARMv4 asm optimizations])
  152. AS_ASM_ARM_EDSP([ARMv5E_ASM=1],[ARMv5E_ASM=0])
  153. if test "x${ARMv5E_ASM}" = "x1" ; then
  154. AC_DEFINE(ARMv5E_ASM, 1, [Use ARMv5E asm optimizations])
  155. asm_optimization="${asm_optimization} (EDSP)"
  156. fi
  157. AS_ASM_ARM_MEDIA([ARMv6_ASM=1],[ARMv6_ASM=0])
  158. if test "x${ARMv6_ASM}" = "x1" ; then
  159. AC_DEFINE(ARMv6_ASM, 1, [Use ARMv6 asm optimizations])
  160. asm_optimization="${asm_optimization} (Media)"
  161. fi
  162. AS_ASM_ARM_NEON([ARM_HAVE_NEON=1],[ARM_HAVE_NEON=0])
  163. if test "x${ARM_HAVE_NEON}" = "x1" ; then
  164. AC_DEFINE([ARM_HAVE_NEON], 1, [Use ARM NEON optimizations])
  165. asm_optimization="${asm_optimization} (NEON)"
  166. fi
  167. fi
  168. ;;
  169. esac
  170. else
  171. asm_optimization="disabled"
  172. fi
  173. AC_ARG_ENABLE(rtcd,
  174. AS_HELP_STRING([--disable-rtcd], [Disable run-time CPU capabilities detection]),
  175. [ ac_enable_rtcd=$enableval ], [ ac_enable_rtcd=yes] )
  176. if test "x${ac_enable_rtcd}" = xyes -a "x${rtcd_support}" = xyes ; then
  177. AC_DEFINE([OPUS_HAVE_RTCD], 1, [Use run-time CPU capabilities detection])
  178. elif test "x${rtcd_support}" = xno ; then
  179. rtcd_support="no rtcd for your platform, please send patches"
  180. else
  181. rtcd_support="no"
  182. fi
  183. ac_enable_assertions="no"
  184. AC_ARG_ENABLE(assertions, [ --enable-assertions enable additional software error checking],
  185. [if test "$enableval" = yes; then
  186. ac_enable_assertions="yes"
  187. AC_DEFINE([ENABLE_ASSERTIONS], , [Assertions])
  188. fi])
  189. ac_enable_fuzzing="no"
  190. AC_ARG_ENABLE(fuzzing, [ --enable-fuzzing causes the encoder to make random decisions],
  191. [if test "$enableval" = yes; then
  192. ac_enable_fuzzing="yes"
  193. AC_DEFINE([FUZZING], , [Fuzzing])
  194. fi])
  195. ac_enable_doc="yes"
  196. AC_ARG_ENABLE([doc],
  197. AS_HELP_STRING([--disable-doc], [Do not build API documentation]),
  198. [ac_enable_doc=$enableval])
  199. AC_CHECK_PROG(HAVE_DOXYGEN, [doxygen], [yes], [no])
  200. if test "$HAVE_DOXYGEN" != "yes" -o "$ac_enable_doc" != "yes"; then
  201. HAVE_DOXYGEN="false"
  202. ac_enable_doc="no"
  203. fi
  204. AM_CONDITIONAL(HAVE_DOXYGEN, [test $HAVE_DOXYGEN = yes])
  205. ac_enable_extra_programs="yes"
  206. AC_ARG_ENABLE([extra-programs],
  207. AS_HELP_STRING([--disable-extra-programs], [Do not build extra programs (demo and tests)]),
  208. [ac_enable_extra_programs=$enableval])
  209. if test "$ac_enable_extra_programs" != "yes"; then
  210. ac_enable_extra_progs="no"
  211. fi
  212. saved_CFLAGS="$CFLAGS"
  213. CFLAGS="$CFLAGS -fvisibility=hidden"
  214. AC_MSG_CHECKING([if ${CC} supports -fvisibility=hidden])
  215. AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])],
  216. [ AC_MSG_RESULT([yes])
  217. SYMBOL_VISIBILITY="-fvisibility=hidden" ],
  218. AC_MSG_RESULT([no]))
  219. CFLAGS="$saved_CFLAGS $SYMBOL_VISIBILITY"
  220. AC_SUBST(SYMBOL_VISIBILITY)
  221. CFLAGS="$CFLAGS -W"
  222. warn_CFLAGS="-Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes"
  223. saved_CFLAGS="$CFLAGS"
  224. CFLAGS="$CFLAGS $warn_CFLAGS"
  225. AC_MSG_CHECKING([if ${CC} supports ${warn_CFLAGS}])
  226. AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])],
  227. [ AC_MSG_RESULT([yes])
  228. EXTRA_WARNS=$warn_CFLAGS ],
  229. AC_MSG_RESULT([no]))
  230. CFLAGS="$saved_CFLAGS $EXTRA_WARNS"
  231. AC_CHECK_FUNCS([lrintf])
  232. AC_CHECK_FUNCS([lrint])
  233. AC_CHECK_FUNCS([__malloc_hook])
  234. AM_CONDITIONAL([FIXED_POINT], [test x$ac_enable_fixed = xyes])
  235. AM_CONDITIONAL([CUSTOM_MODES], [test x$ac_enable_custom_modes = xyes])
  236. AM_CONDITIONAL([EXTRA_PROGRAMS], [test x$ac_enable_extra_programs = xyes])
  237. AM_CONDITIONAL([CPU_ARM], [test x$cpu_arm = xyes])
  238. dnl subsitutions for the pkg-config files
  239. if test x$ac_enable_float = xyes; then
  240. PC_BUILD="floating-point"
  241. PC_LIBM=$LIBM
  242. else
  243. PC_BUILD="fixed-point"
  244. PC_LIBM=
  245. fi
  246. dnl opus_custom requires libm as well
  247. if test x$ac_enable_custom_modes = xyes; then
  248. PC_BUILD="${PC_BUILD}, custom modes"
  249. PC_LIBM=$LIBM
  250. fi
  251. AC_SUBST([PC_BUILD])
  252. AC_SUBST([PC_LIBM])
  253. AC_CONFIG_FILES([Makefile opus.pc opus-uninstalled.pc
  254. doc/Makefile doc/Doxyfile])
  255. AC_CONFIG_HEADERS([config.h])
  256. AC_OUTPUT
  257. AC_MSG_NOTICE([
  258. ------------------------------------------------------------------------
  259. $PACKAGE_NAME $PACKAGE_VERSION: Automatic configuration OK.
  260. Compiler support:
  261. C99 var arrays: ................ ${has_var_arrays}
  262. C99 lrintf: .................... ${ac_cv_func_lrintf}
  263. Alloca: ........................ ${has_alloca}
  264. General configuration:
  265. Floating point support: ........ ${ac_enable_float}
  266. Fast float approximations: ..... ${float_approx}
  267. Fixed point debugging: ......... ${ac_enable_fixed_debug}
  268. Assembly optimization: ......... ${asm_optimization}
  269. Run-time CPU detection: ........ ${rtcd_support}
  270. Custom modes: .................. ${ac_enable_custom_modes}
  271. Assertion checking: ............ ${ac_enable_assertions}
  272. Fuzzing: ....................... ${ac_enable_fuzzing}
  273. API documentation: ............. ${ac_enable_doc}
  274. Extra programs: ................ ${ac_enable_extra_programs}
  275. ------------------------------------------------------------------------
  276. Type "make; make install" to compile and install
  277. Type "make check" to run the test suite
  278. ])