configure.ac 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  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([ ./update_version 2>/dev/null || true
  7. if test -e package_version; then
  8. . ./package_version
  9. printf "$PACKAGE_VERSION"
  10. else
  11. printf "unknown"
  12. fi ]))
  13. AC_INIT([opus],[CURRENT_VERSION],[opus@xiph.org])
  14. AC_CONFIG_SRCDIR(src/opus_encoder.c)
  15. AC_CONFIG_MACRO_DIR([m4])
  16. dnl enable silent rules on automake 1.11 and later
  17. m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
  18. # For libtool.
  19. dnl Please update these for releases.
  20. OPUS_LT_CURRENT=4
  21. OPUS_LT_REVISION=0
  22. OPUS_LT_AGE=4
  23. AC_SUBST(OPUS_LT_CURRENT)
  24. AC_SUBST(OPUS_LT_REVISION)
  25. AC_SUBST(OPUS_LT_AGE)
  26. AM_INIT_AUTOMAKE([no-define])
  27. AM_MAINTAINER_MODE([enable])
  28. AC_CANONICAL_HOST
  29. AC_MINGW32
  30. AM_PROG_LIBTOOL
  31. AM_PROG_CC_C_O
  32. AC_PROG_CC_C99
  33. AC_C_CONST
  34. AC_C_INLINE
  35. AM_PROG_AS
  36. AC_DEFINE([OPUS_BUILD], [], [This is a build of OPUS])
  37. #Use a hacked up version of autoconf's AC_C_RESTRICT because it's not
  38. #strong enough a test to detect old buggy versions of GCC (e.g. 2.95.3)
  39. #Note: Both this and the test for variable-size arrays below are also
  40. # done by AC_PROG_CC_C99, but not thoroughly enough apparently.
  41. AC_CACHE_CHECK([for C/C++ restrict keyword], ac_cv_c_restrict,
  42. [ac_cv_c_restrict=no
  43. # The order here caters to the fact that C++ does not require restrict.
  44. for ac_kw in __restrict __restrict__ _Restrict restrict; do
  45. AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
  46. [[typedef int * int_ptr;
  47. int foo (int_ptr $ac_kw ip, int * $ac_kw baz[]) {
  48. return ip[0];
  49. }]],
  50. [[int s[1];
  51. int * $ac_kw t = s;
  52. t[0] = 0;
  53. return foo(t, (void *)0)]])],
  54. [ac_cv_c_restrict=$ac_kw])
  55. test "$ac_cv_c_restrict" != no && break
  56. done
  57. ])
  58. AH_VERBATIM([restrict],
  59. [/* Define to the equivalent of the C99 'restrict' keyword, or to
  60. nothing if this is not supported. Do not define if restrict is
  61. supported directly. */
  62. #undef restrict
  63. /* Work around a bug in Sun C++: it does not support _Restrict or
  64. __restrict__, even though the corresponding Sun C compiler ends up with
  65. "#define restrict _Restrict" or "#define restrict __restrict__" in the
  66. previous line. Perhaps some future version of Sun C++ will work with
  67. restrict; if so, hopefully it defines __RESTRICT like Sun C does. */
  68. #if defined __SUNPRO_CC && !defined __RESTRICT
  69. # define _Restrict
  70. # define __restrict__
  71. #endif])
  72. case $ac_cv_c_restrict in
  73. restrict) ;;
  74. no) AC_DEFINE([restrict], []) ;;
  75. *) AC_DEFINE_UNQUOTED([restrict], [$ac_cv_c_restrict]) ;;
  76. esac
  77. AC_MSG_CHECKING(for C99 variable-size arrays)
  78. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
  79. [[static int x; char a[++x]; a[sizeof a - 1] = 0; int N; return a[0];]])],
  80. [ has_var_arrays=yes
  81. use_alloca="no (using var arrays)"
  82. AC_DEFINE([VAR_ARRAYS], [1], [Use C99 variable-size arrays])
  83. ],[
  84. has_var_arrays=no
  85. ])
  86. AC_MSG_RESULT([$has_var_arrays])
  87. AS_IF([test "$has_var_arrays" = "no"],
  88. [
  89. AC_CHECK_HEADERS([alloca.h])
  90. AC_MSG_CHECKING(for alloca)
  91. AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <alloca.h>]],
  92. [[int foo=10; int *array = alloca(foo);]])],
  93. [ use_alloca=yes;
  94. AC_DEFINE([USE_ALLOCA], [], [Make use of alloca])
  95. ],[
  96. use_alloca=no
  97. ])
  98. AC_MSG_RESULT([$use_alloca])
  99. ])
  100. LT_LIB_M
  101. AC_ARG_ENABLE([fixed-point],
  102. [AS_HELP_STRING([--enable-fixed-point],
  103. [compile without floating point (for machines without a fast enough FPU)])],,
  104. [enable_fixed_point=no])
  105. AS_IF([test "$enable_fixed_point" = "yes"],[
  106. enable_float="no"
  107. AC_DEFINE([FIXED_POINT], [1], [Compile as fixed-point (for machines without a fast enough FPU)])
  108. PC_BUILD="fixed-point"
  109. ],[
  110. enable_float="yes";
  111. PC_BUILD="floating-point"
  112. ])
  113. AM_CONDITIONAL([FIXED_POINT], [test "$enable_fixed_point" = "yes"])
  114. AC_ARG_ENABLE([fixed-point-debug],
  115. [AS_HELP_STRING([--enable-fixed-point-debug], [debug fixed-point implementation])],,
  116. [enable_fixed_point_debug=no])
  117. AS_IF([test "$enable_fixed_point_debug" = "yes"],[
  118. AC_DEFINE([FIXED_DEBUG], [1], [Debug fixed-point implementation])
  119. ])
  120. AC_ARG_ENABLE([float_api],
  121. [AS_HELP_STRING([--disable-float-api],
  122. [compile without the floating point API (for machines with no float library)])],,
  123. [enable_float_api=yes])
  124. AM_CONDITIONAL([DISABLE_FLOAT_API], [test "$enable_float_api" = "no"])
  125. AS_IF([test "$enable_float_api" = "no"],[
  126. AC_DEFINE([DISABLE_FLOAT_API], [1], [Do not build the float API])
  127. ])
  128. AC_ARG_ENABLE([custom-modes],
  129. [AS_HELP_STRING([--enable-custom-modes], [enable non-Opus modes, e.g. 44.1 kHz & 2^n frames])],,
  130. [enable_custom_modes=no])
  131. AS_IF([test "$enable_custom_modes" = "yes"],[
  132. AC_DEFINE([CUSTOM_MODES], [1], [Custom modes])
  133. PC_BUILD="$PC_BUILD, custom modes"
  134. ])
  135. AM_CONDITIONAL([CUSTOM_MODES], [test "$enable_custom_modes" = "yes"])
  136. has_float_approx=no
  137. #case "$host_cpu" in
  138. #i[[3456]]86 | x86_64 | powerpc64 | powerpc32 | ia64)
  139. # has_float_approx=yes
  140. # ;;
  141. #esac
  142. AC_ARG_ENABLE([float-approx],
  143. [AS_HELP_STRING([--enable-float-approx], [enable fast approximations for floating point])],
  144. [if test "$enable_float_approx" = "yes"; then
  145. AC_WARN([Floating point approximations are not supported on all platforms.])
  146. fi
  147. ],
  148. [enable_float_approx=$has_float_approx])
  149. AS_IF([test "$enable_float_approx" = "yes"],[
  150. AC_DEFINE([FLOAT_APPROX], [1], [Float approximations])
  151. ])
  152. AC_ARG_ENABLE([asm],
  153. [AS_HELP_STRING([--disable-asm], [Disable assembly optimizations])],,
  154. [enable_asm=yes])
  155. AC_ARG_ENABLE([rtcd],
  156. [AS_HELP_STRING([--disable-rtcd], [Disable run-time CPU capabilities detection])],,
  157. [enable_rtcd=yes])
  158. rtcd_support=no
  159. cpu_arm=no
  160. AS_IF([test x"${enable_asm}" = x"yes"],[
  161. inline_optimization="No ASM for your platform, please send patches"
  162. case $host_cpu in
  163. arm*)
  164. dnl Currently we only have asm for fixed-point
  165. AS_IF([test "$enable_float" != "yes"],[
  166. cpu_arm=yes
  167. AC_DEFINE([OPUS_ARM_ASM], [], [Make use of ARM asm optimization])
  168. AS_GCC_INLINE_ASSEMBLY(
  169. [inline_optimization="ARM"],
  170. [inline_optimization="disabled"]
  171. )
  172. AS_ASM_ARM_EDSP([OPUS_ARM_INLINE_EDSP=1],[OPUS_ARM_INLINE_EDSP=0])
  173. AS_ASM_ARM_MEDIA([OPUS_ARM_INLINE_MEDIA=1],
  174. [OPUS_ARM_INLINE_MEDIA=0])
  175. AS_ASM_ARM_NEON([OPUS_ARM_INLINE_NEON=1],[OPUS_ARM_INLINE_NEON=0])
  176. AS_IF([test x"$inline_optimization" = x"ARM"],[
  177. AM_CONDITIONAL([OPUS_ARM_INLINE_ASM],[true])
  178. AC_DEFINE([OPUS_ARM_INLINE_ASM], 1,
  179. [Use generic ARMv4 inline asm optimizations])
  180. AS_IF([test x"$OPUS_ARM_INLINE_EDSP" = x"1"],[
  181. AC_DEFINE([OPUS_ARM_INLINE_EDSP], [1],
  182. [Use ARMv5E inline asm optimizations])
  183. inline_optimization="$inline_optimization (EDSP)"
  184. ])
  185. AS_IF([test x"$OPUS_ARM_INLINE_MEDIA" = x"1"],[
  186. AC_DEFINE([OPUS_ARM_INLINE_MEDIA], [1],
  187. [Use ARMv6 inline asm optimizations])
  188. inline_optimization="$inline_optimization (Media)"
  189. ])
  190. AS_IF([test x"$OPUS_ARM_INLINE_NEON" = x"1"],[
  191. AC_DEFINE([OPUS_ARM_INLINE_NEON], 1,
  192. [Use ARM NEON inline asm optimizations])
  193. inline_optimization="$inline_optimization (NEON)"
  194. ])
  195. ])
  196. dnl We need Perl to translate RVCT-syntax asm to gas syntax.
  197. AC_CHECK_PROG([HAVE_PERL], perl, yes, no)
  198. AS_IF([test x"$HAVE_PERL" = x"yes"],[
  199. AM_CONDITIONAL([OPUS_ARM_EXTERNAL_ASM],[true])
  200. asm_optimization="ARM"
  201. AS_IF([test x"$OPUS_ARM_INLINE_EDSP" = x"1"], [
  202. OPUS_ARM_PRESUME_EDSP=1
  203. OPUS_ARM_MAY_HAVE_EDSP=1
  204. ],
  205. [
  206. OPUS_ARM_PRESUME_EDSP=0
  207. OPUS_ARM_MAY_HAVE_EDSP=0
  208. ])
  209. AS_IF([test x"$OPUS_ARM_INLINE_MEDIA" = x"1"], [
  210. OPUS_ARM_PRESUME_MEDIA=1
  211. OPUS_ARM_MAY_HAVE_MEDIA=1
  212. ],
  213. [
  214. OPUS_ARM_PRESUME_MEDIA=0
  215. OPUS_ARM_MAY_HAVE_MEDIA=0
  216. ])
  217. AS_IF([test x"$OPUS_ARM_INLINE_NEON" = x"1"], [
  218. OPUS_ARM_PRESUME_NEON=1
  219. OPUS_ARM_MAY_HAVE_NEON=1
  220. ],
  221. [
  222. OPUS_ARM_PRESUME_NEON=0
  223. OPUS_ARM_MAY_HAVE_NEON=0
  224. ])
  225. AS_IF([test x"$enable_rtcd" = x"yes"],[
  226. AS_IF([test x"$OPUS_ARM_MAY_HAVE_EDSP" != x"1"],[
  227. AC_MSG_NOTICE(
  228. [Trying to force-enable armv5e EDSP instructions...])
  229. AS_ASM_ARM_EDSP_FORCE([OPUS_ARM_MAY_HAVE_EDSP=1])
  230. ])
  231. AS_IF([test x"$OPUS_ARM_MAY_HAVE_MEDIA" != x"1"],[
  232. AC_MSG_NOTICE(
  233. [Trying to force-enable ARMv6 media instructions...])
  234. AS_ASM_ARM_MEDIA_FORCE([OPUS_ARM_MAY_HAVE_MEDIA=1])
  235. ])
  236. AS_IF([test x"$OPUS_ARM_MAY_HAVE_NEON" != x"1"],[
  237. AC_MSG_NOTICE(
  238. [Trying to force-enable NEON instructions...])
  239. AS_ASM_ARM_NEON_FORCE([OPUS_ARM_MAY_HAVE_NEON=1])
  240. ])
  241. ])
  242. rtcd_support=
  243. AS_IF([test x"$OPUS_ARM_MAY_HAVE_EDSP" = x"1"],[
  244. AC_DEFINE(OPUS_ARM_MAY_HAVE_EDSP, 1,
  245. [Define if assembler supports EDSP instructions])
  246. AS_IF([test x"$OPUS_ARM_PRESUME_EDSP" = x"1"],[
  247. AC_DEFINE(OPUS_ARM_PRESUME_EDSP, 1,
  248. [Define if binary requires EDSP instruction support])
  249. asm_optimization="$asm_optimization (EDSP)"
  250. ],
  251. [rtcd_support="$rtcd_support (EDSP)"]
  252. )
  253. ])
  254. AC_SUBST(OPUS_ARM_MAY_HAVE_EDSP)
  255. AS_IF([test x"$OPUS_ARM_MAY_HAVE_MEDIA" = x"1"],[
  256. AC_DEFINE(OPUS_ARM_MAY_HAVE_MEDIA, 1,
  257. [Define if assembler supports ARMv6 media instructions])
  258. AS_IF([test x"$OPUS_ARM_PRESUME_MEDIA" = x"1"],[
  259. AC_DEFINE(OPUS_ARM_PRESUME_MEDIA, 1,
  260. [Define if binary requires ARMv6 media instruction support])
  261. asm_optimization="$asm_optimization (Media)"
  262. ],
  263. [rtcd_support="$rtcd_support (Media)"]
  264. )
  265. ])
  266. AC_SUBST(OPUS_ARM_MAY_HAVE_MEDIA)
  267. AS_IF([test x"$OPUS_ARM_MAY_HAVE_NEON" = x"1"],[
  268. AC_DEFINE(OPUS_ARM_MAY_HAVE_NEON, 1,
  269. [Define if compiler supports NEON instructions])
  270. AS_IF([test x"$OPUS_ARM_PRESUME_NEON" = x"1"], [
  271. AC_DEFINE(OPUS_ARM_PRESUME_NEON, 1,
  272. [Define if binary requires NEON instruction support])
  273. asm_optimization="$asm_optimization (NEON)"
  274. ],
  275. [rtcd_support="$rtcd_support (NEON)"]
  276. )
  277. ])
  278. AC_SUBST(OPUS_ARM_MAY_HAVE_NEON)
  279. dnl Make sure turning on RTCD gets us at least one
  280. dnl instruction set.
  281. AS_IF([test x"$rtcd_support" != x""],
  282. [rtcd_support=ARM"$rtcd_support"],
  283. [rtcd_support="no"]
  284. )
  285. ],
  286. [
  287. AC_MSG_WARN(
  288. [*** ARM assembly requires perl -- disabling optimizations])
  289. asm_optimization="(missing perl dependency for ARM)"
  290. ])
  291. ])
  292. ;;
  293. esac
  294. ],[
  295. inline_optimization="disabled"
  296. asm_optimization="disabled"
  297. ])
  298. AM_CONDITIONAL([CPU_ARM], [test "$cpu_arm" = "yes"])
  299. AM_CONDITIONAL([OPUS_ARM_INLINE_ASM],
  300. [test x"${inline_optimization:0:3}" = x"ARM"])
  301. AM_CONDITIONAL([OPUS_ARM_EXTERNAL_ASM],
  302. [test x"${asm_optimization:0:3}" = x"ARM"])
  303. AS_IF([test x"$enable_rtcd" = x"yes"],[
  304. AS_IF([test x"$rtcd_support" != x"no"],[
  305. AC_DEFINE([OPUS_HAVE_RTCD], [1],
  306. [Use run-time CPU capabilities detection])
  307. OPUS_HAVE_RTCD=1
  308. AC_SUBST(OPUS_HAVE_RTCD)
  309. ])
  310. ],[
  311. rtcd_support="disabled"
  312. ])
  313. AC_ARG_ENABLE([assertions],
  314. [AS_HELP_STRING([--enable-assertions],[enable additional software error checking])],,
  315. [enable_assertions=no])
  316. AS_IF([test "$enable_assertions" = "yes"], [
  317. AC_DEFINE([ENABLE_ASSERTIONS], [1], [Assertions])
  318. ])
  319. AC_ARG_ENABLE([fuzzing],
  320. [AS_HELP_STRING([--enable-fuzzing],[causes the encoder to make random decisions])],,
  321. [enable_fuzzing=no])
  322. AS_IF([test "$enable_fuzzing" = "yes"], [
  323. AC_DEFINE([FUZZING], [1], [Fuzzing])
  324. ])
  325. AC_ARG_ENABLE([doc],
  326. [AS_HELP_STRING([--disable-doc], [Do not build API documentation])],,
  327. [enable_doc=yes])
  328. AS_IF([test "$enable_doc" = "yes"], [
  329. AC_CHECK_PROG(HAVE_DOXYGEN, [doxygen], [yes], [no])
  330. ],[
  331. HAVE_DOXYGEN=no
  332. ])
  333. AM_CONDITIONAL([HAVE_DOXYGEN], [test "$HAVE_DOXYGEN" = "yes"])
  334. AC_ARG_ENABLE([extra-programs],
  335. [AS_HELP_STRING([--disable-extra-programs], [Do not build extra programs (demo and tests)])],,
  336. [enable_extra_programs=yes])
  337. AM_CONDITIONAL([EXTRA_PROGRAMS], [test "$enable_extra_programs" = "yes"])
  338. saved_CFLAGS="$CFLAGS"
  339. CFLAGS="$CFLAGS -fvisibility=hidden"
  340. AC_MSG_CHECKING([if ${CC} supports -fvisibility=hidden])
  341. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[char foo;]])],
  342. [ AC_MSG_RESULT([yes]) ],
  343. [ AC_MSG_RESULT([no])
  344. CFLAGS="$saved_CFLAGS"
  345. ])
  346. CFLAGS="$CFLAGS -W"
  347. warn_CFLAGS="-Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes"
  348. saved_CFLAGS="$CFLAGS"
  349. CFLAGS="$CFLAGS $warn_CFLAGS"
  350. AC_MSG_CHECKING([if ${CC} supports ${warn_CFLAGS}])
  351. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[char foo;]])],
  352. [ AC_MSG_RESULT([yes]) ],
  353. [ AC_MSG_RESULT([no])
  354. CFLAGS="$saved_CFLAGS"
  355. ])
  356. saved_LIBS="$LIBS"
  357. LIBS="$LIBS $LIBM"
  358. AC_CHECK_FUNCS([lrintf])
  359. AC_CHECK_FUNCS([lrint])
  360. LIBS="$saved_LIBS"
  361. AC_CHECK_FUNCS([__malloc_hook])
  362. AC_SUBST([PC_BUILD])
  363. AC_CONFIG_FILES([
  364. Makefile
  365. opus.pc
  366. opus-uninstalled.pc
  367. celt/arm/armopts.s
  368. doc/Makefile
  369. doc/Doxyfile
  370. ])
  371. AC_CONFIG_HEADERS([config.h])
  372. AC_OUTPUT
  373. AC_MSG_NOTICE([
  374. ------------------------------------------------------------------------
  375. $PACKAGE_NAME $PACKAGE_VERSION: Automatic configuration OK.
  376. Compiler support:
  377. C99 var arrays: ................ ${has_var_arrays}
  378. C99 lrintf: .................... ${ac_cv_func_lrintf}
  379. Use alloca: .................... ${use_alloca}
  380. General configuration:
  381. Floating point support: ........ ${enable_float}
  382. Fast float approximations: ..... ${enable_float_approx}
  383. Fixed point debugging: ......... ${enable_fixed_point_debug}
  384. Inline Assembly Optimizations: . ${inline_optimization}
  385. External Assembly Optimizations: ${asm_optimization}
  386. Run-time CPU detection: ........ ${rtcd_support}
  387. Custom modes: .................. ${enable_custom_modes}
  388. Assertion checking: ............ ${enable_assertions}
  389. Fuzzing: ....................... ${enable_fuzzing}
  390. API documentation: ............. ${enable_doc}
  391. Extra programs: ................ ${enable_extra_programs}
  392. ------------------------------------------------------------------------
  393. Type "make; make install" to compile and install
  394. Type "make check" to run the test suite
  395. ])