configure.ac 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803
  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=5
  21. OPUS_LT_REVISION=0
  22. OPUS_LT_AGE=5
  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. AC_ARG_ENABLE([intrinsics],
  159. [AS_HELP_STRING([--enable-intrinsics], [Enable intrinsics optimizations for ARM(float) X86(fixed)])],,
  160. [enable_intrinsics=no])
  161. rtcd_support=no
  162. cpu_arm=no
  163. AS_IF([test x"${enable_asm}" = x"yes"],[
  164. inline_optimization="No inline ASM for your platform, please send patches"
  165. case $host_cpu in
  166. arm*)
  167. dnl Currently we only have asm for fixed-point
  168. AS_IF([test "$enable_float" != "yes"],[
  169. cpu_arm=yes
  170. AC_DEFINE([OPUS_ARM_ASM], [], [Make use of ARM asm optimization])
  171. AS_GCC_INLINE_ASSEMBLY(
  172. [inline_optimization="ARM"],
  173. [inline_optimization="disabled"]
  174. )
  175. AS_ASM_ARM_EDSP([OPUS_ARM_INLINE_EDSP=1],[OPUS_ARM_INLINE_EDSP=0])
  176. AS_ASM_ARM_MEDIA([OPUS_ARM_INLINE_MEDIA=1],
  177. [OPUS_ARM_INLINE_MEDIA=0])
  178. AS_ASM_ARM_NEON([OPUS_ARM_INLINE_NEON=1],[OPUS_ARM_INLINE_NEON=0])
  179. AS_IF([test x"$inline_optimization" = x"ARM"],[
  180. AM_CONDITIONAL([OPUS_ARM_INLINE_ASM],[true])
  181. AC_DEFINE([OPUS_ARM_INLINE_ASM], 1,
  182. [Use generic ARMv4 inline asm optimizations])
  183. AS_IF([test x"$OPUS_ARM_INLINE_EDSP" = x"1"],[
  184. AC_DEFINE([OPUS_ARM_INLINE_EDSP], [1],
  185. [Use ARMv5E inline asm optimizations])
  186. inline_optimization="$inline_optimization (EDSP)"
  187. ])
  188. AS_IF([test x"$OPUS_ARM_INLINE_MEDIA" = x"1"],[
  189. AC_DEFINE([OPUS_ARM_INLINE_MEDIA], [1],
  190. [Use ARMv6 inline asm optimizations])
  191. inline_optimization="$inline_optimization (Media)"
  192. ])
  193. AS_IF([test x"$OPUS_ARM_INLINE_NEON" = x"1"],[
  194. AC_DEFINE([OPUS_ARM_INLINE_NEON], 1,
  195. [Use ARM NEON inline asm optimizations])
  196. inline_optimization="$inline_optimization (NEON)"
  197. ])
  198. ])
  199. dnl We need Perl to translate RVCT-syntax asm to gas syntax.
  200. AC_CHECK_PROG([HAVE_PERL], perl, yes, no)
  201. AS_IF([test x"$HAVE_PERL" = x"yes"],[
  202. AM_CONDITIONAL([OPUS_ARM_EXTERNAL_ASM],[true])
  203. asm_optimization="ARM"
  204. AS_IF([test x"$OPUS_ARM_INLINE_EDSP" = x"1"], [
  205. OPUS_ARM_PRESUME_EDSP=1
  206. OPUS_ARM_MAY_HAVE_EDSP=1
  207. ],
  208. [
  209. OPUS_ARM_PRESUME_EDSP=0
  210. OPUS_ARM_MAY_HAVE_EDSP=0
  211. ])
  212. AS_IF([test x"$OPUS_ARM_INLINE_MEDIA" = x"1"], [
  213. OPUS_ARM_PRESUME_MEDIA=1
  214. OPUS_ARM_MAY_HAVE_MEDIA=1
  215. ],
  216. [
  217. OPUS_ARM_PRESUME_MEDIA=0
  218. OPUS_ARM_MAY_HAVE_MEDIA=0
  219. ])
  220. AS_IF([test x"$OPUS_ARM_INLINE_NEON" = x"1"], [
  221. OPUS_ARM_PRESUME_NEON=1
  222. OPUS_ARM_MAY_HAVE_NEON=1
  223. ],
  224. [
  225. OPUS_ARM_PRESUME_NEON=0
  226. OPUS_ARM_MAY_HAVE_NEON=0
  227. ])
  228. AS_IF([test x"$enable_rtcd" = x"yes"],[
  229. AS_IF([test x"$OPUS_ARM_MAY_HAVE_EDSP" != x"1"],[
  230. AC_MSG_NOTICE(
  231. [Trying to force-enable armv5e EDSP instructions...])
  232. AS_ASM_ARM_EDSP_FORCE([OPUS_ARM_MAY_HAVE_EDSP=1])
  233. ])
  234. AS_IF([test x"$OPUS_ARM_MAY_HAVE_MEDIA" != x"1"],[
  235. AC_MSG_NOTICE(
  236. [Trying to force-enable ARMv6 media instructions...])
  237. AS_ASM_ARM_MEDIA_FORCE([OPUS_ARM_MAY_HAVE_MEDIA=1])
  238. ])
  239. AS_IF([test x"$OPUS_ARM_MAY_HAVE_NEON" != x"1"],[
  240. AC_MSG_NOTICE(
  241. [Trying to force-enable NEON instructions...])
  242. AS_ASM_ARM_NEON_FORCE([OPUS_ARM_MAY_HAVE_NEON=1])
  243. ])
  244. ])
  245. rtcd_support=
  246. AS_IF([test x"$OPUS_ARM_MAY_HAVE_EDSP" = x"1"],[
  247. AC_DEFINE(OPUS_ARM_MAY_HAVE_EDSP, 1,
  248. [Define if assembler supports EDSP instructions])
  249. AS_IF([test x"$OPUS_ARM_PRESUME_EDSP" = x"1"],[
  250. AC_DEFINE(OPUS_ARM_PRESUME_EDSP, 1,
  251. [Define if binary requires EDSP instruction support])
  252. asm_optimization="$asm_optimization (EDSP)"
  253. ],
  254. [rtcd_support="$rtcd_support (EDSP)"]
  255. )
  256. ])
  257. AC_SUBST(OPUS_ARM_MAY_HAVE_EDSP)
  258. AS_IF([test x"$OPUS_ARM_MAY_HAVE_MEDIA" = x"1"],[
  259. AC_DEFINE(OPUS_ARM_MAY_HAVE_MEDIA, 1,
  260. [Define if assembler supports ARMv6 media instructions])
  261. AS_IF([test x"$OPUS_ARM_PRESUME_MEDIA" = x"1"],[
  262. AC_DEFINE(OPUS_ARM_PRESUME_MEDIA, 1,
  263. [Define if binary requires ARMv6 media instruction support])
  264. asm_optimization="$asm_optimization (Media)"
  265. ],
  266. [rtcd_support="$rtcd_support (Media)"]
  267. )
  268. ])
  269. AC_SUBST(OPUS_ARM_MAY_HAVE_MEDIA)
  270. AS_IF([test x"$OPUS_ARM_MAY_HAVE_NEON" = x"1"],[
  271. AC_DEFINE(OPUS_ARM_MAY_HAVE_NEON, 1,
  272. [Define if compiler supports NEON instructions])
  273. AS_IF([test x"$OPUS_ARM_PRESUME_NEON" = x"1"], [
  274. AC_DEFINE(OPUS_ARM_PRESUME_NEON, 1,
  275. [Define if binary requires NEON instruction support])
  276. asm_optimization="$asm_optimization (NEON)"
  277. ],
  278. [rtcd_support="$rtcd_support (NEON)"]
  279. )
  280. ])
  281. AC_SUBST(OPUS_ARM_MAY_HAVE_NEON)
  282. dnl Make sure turning on RTCD gets us at least one
  283. dnl instruction set.
  284. AS_IF([test x"$rtcd_support" != x""],
  285. [rtcd_support=ARM"$rtcd_support"],
  286. [rtcd_support="no"]
  287. )
  288. AC_MSG_CHECKING([for apple style tools])
  289. AC_PREPROC_IFELSE([AC_LANG_PROGRAM([
  290. #ifndef __APPLE__
  291. #error 1
  292. #endif],[])],
  293. [AC_MSG_RESULT([yes]); ARM2GNU_PARAMS="--apple"],
  294. [AC_MSG_RESULT([no]); ARM2GNU_PARAMS=""])
  295. AC_SUBST(ARM2GNU_PARAMS)
  296. ],
  297. [
  298. AC_MSG_WARN(
  299. [*** ARM assembly requires perl -- disabling optimizations])
  300. asm_optimization="(missing perl dependency for ARM)"
  301. ])
  302. ])
  303. ;;
  304. esac
  305. ],[
  306. inline_optimization="disabled"
  307. asm_optimization="disabled"
  308. ])
  309. AM_CONDITIONAL([OPUS_ARM_INLINE_ASM],
  310. [test x"${inline_optimization%% *}" = x"ARM"])
  311. AM_CONDITIONAL([OPUS_ARM_EXTERNAL_ASM],
  312. [test x"${asm_optimization%% *}" = x"ARM"])
  313. AM_CONDITIONAL([HAVE_SSE], [false])
  314. AM_CONDITIONAL([HAVE_SSE2], [false])
  315. AM_CONDITIONAL([HAVE_SSE4_1], [false])
  316. m4_define([DEFAULT_X86_SSE_CFLAGS], [-msse])
  317. m4_define([DEFAULT_X86_SSE2_CFLAGS], [-msse2])
  318. m4_define([DEFAULT_X86_SSE4_1_CFLAGS], [-msse4.1])
  319. m4_define([DEFAULT_ARM_NEON_INTR_CFLAGS], [-mfpu=neon])
  320. # With GCC on ARM32 softfp architectures (e.g. Android, or older Ubuntu) you need to specify
  321. # -mfloat-abi=softfp for -mfpu=neon to work. However, on ARM32 hardfp architectures (e.g. newer Ubuntu),
  322. # this option will break things.
  323. # As a heuristic, if host matches arm*eabi* but not arm*hf*, it's probably soft-float.
  324. m4_define([DEFAULT_ARM_NEON_SOFTFP_INTR_CFLAGS], [-mfpu=neon -mfloat-abi=softfp])
  325. AS_CASE([$host],
  326. [arm*hf*], [AS_VAR_SET([RESOLVED_DEFAULT_ARM_NEON_INTR_CFLAGS], "DEFAULT_ARM_NEON_INTR_CFLAGS")],
  327. [arm*eabi*], [AS_VAR_SET([RESOLVED_DEFAULT_ARM_NEON_INTR_CFLAGS], "DEFAULT_ARM_NEON_SOFTFP_INTR_CFLAGS")],
  328. [AS_VAR_SET([RESOLVED_DEFAULT_ARM_NEON_INTR_CFLAGS], "DEFAULT_ARM_NEON_INTR_CFLAGS")])
  329. AC_ARG_VAR([X86_SSE_CFLAGS], [C compiler flags to compile SSE intrinsics @<:@default=]DEFAULT_X86_SSE_CFLAGS[@:>@])
  330. AC_ARG_VAR([X86_SSE2_CFLAGS], [C compiler flags to compile SSE2 intrinsics @<:@default=]DEFAULT_X86_SSE2_CFLAGS[@:>@])
  331. AC_ARG_VAR([X86_SSE4_1_CFLAGS], [C compiler flags to compile SSE4.1 intrinsics @<:@default=]DEFAULT_X86_SSE4_1_CFLAGS[@:>@])
  332. AC_ARG_VAR([ARM_NEON_INTR_CFLAGS], [C compiler flags to compile ARM NEON intrinsics @<:@default=]DEFAULT_ARM_NEON_INTR_CFLAGS / DEFAULT_ARM_NEON_SOFTFP_INTR_CFLAGS[@:>@])
  333. AS_VAR_SET_IF([X86_SSE_CFLAGS], [], [AS_VAR_SET([X86_SSE_CFLAGS], "DEFAULT_X86_SSE_CFLAGS")])
  334. AS_VAR_SET_IF([X86_SSE2_CFLAGS], [], [AS_VAR_SET([X86_SSE2_CFLAGS], "DEFAULT_X86_SSE2_CFLAGS")])
  335. AS_VAR_SET_IF([X86_SSE4_1_CFLAGS], [], [AS_VAR_SET([X86_SSE4_1_CFLAGS], "DEFAULT_X86_SSE4_1_CFLAGS")])
  336. AS_VAR_SET_IF([ARM_NEON_INTR_CFLAGS], [], [AS_VAR_SET([ARM_NEON_INTR_CFLAGS], ["$RESOLVED_DEFAULT_ARM_NEON_INTR_CFLAGS"])])
  337. AC_DEFUN([OPUS_PATH_NE10],
  338. [
  339. AC_ARG_WITH(NE10,
  340. AC_HELP_STRING([--with-NE10=PFX],[Prefix where libNE10 is installed (optional)]),
  341. NE10_prefix="$withval", NE10_prefix="")
  342. AC_ARG_WITH(NE10-libraries,
  343. AC_HELP_STRING([--with-NE10-libraries=DIR],
  344. [Directory where libNE10 library is installed (optional)]),
  345. NE10_libraries="$withval", NE10_libraries="")
  346. AC_ARG_WITH(NE10-includes,
  347. AC_HELP_STRING([--with-NE10-includes=DIR],
  348. [Directory where libNE10 header files are installed (optional)]),
  349. NE10_includes="$withval", NE10_includes="")
  350. if test "x$NE10_libraries" != "x" ; then
  351. NE10_LIBS="-L$NE10_libraries"
  352. elif test "x$NE10_prefix" = "xno" || test "x$NE10_prefix" = "xyes" ; then
  353. NE10_LIBS=""
  354. elif test "x$NE10_prefix" != "x" ; then
  355. NE10_LIBS="-L$NE10_prefix/lib"
  356. elif test "x$prefix" != "xNONE" ; then
  357. NE10_LIBS="-L$prefix/lib"
  358. fi
  359. if test "x$NE10_prefix" != "xno" ; then
  360. NE10_LIBS="$NE10_LIBS -lNE10"
  361. fi
  362. if test "x$NE10_includes" != "x" ; then
  363. NE10_CFLAGS="-I$NE10_includes"
  364. elif test "x$NE10_prefix" = "xno" || test "x$NE10_prefix" = "xyes" ; then
  365. NE10_CFLAGS=""
  366. elif test "x$ogg_prefix" != "x" ; then
  367. NE10_CFLAGS="-I$NE10_prefix/include"
  368. elif test "x$prefix" != "xNONE"; then
  369. NE10_CFLAGS="-I$prefix/include"
  370. fi
  371. AC_MSG_CHECKING(for NE10)
  372. save_CFLAGS="$CFLAGS"; CFLAGS="$NE10_CFLAGS"
  373. save_LIBS="$LIBS"; LIBS="$NE10_LIBS"
  374. AC_LINK_IFELSE(
  375. [
  376. AC_LANG_PROGRAM(
  377. [[#include <NE10_init.h>
  378. ]],
  379. [[
  380. ne10_fft_cfg_float32_t cfg;
  381. cfg = ne10_fft_alloc_c2c_float32_neon(480);
  382. ]]
  383. )
  384. ],[
  385. HAVE_ARM_NE10=1
  386. AC_MSG_RESULT([yes])
  387. ],[
  388. HAVE_ARM_NE10=0
  389. AC_MSG_RESULT([no])
  390. NE10_CFLAGS=""
  391. NE10_LIBS=""
  392. ]
  393. )
  394. CFLAGS="$save_CFLAGS"; LIBS="$save_LIBS"
  395. #Now we know if libNE10 is installed or not
  396. AS_IF([test x"$HAVE_ARM_NE10" = x"1"],
  397. [
  398. AC_DEFINE([HAVE_ARM_NE10], 1, [NE10 library is installed on host. Make sure it is on target!])
  399. AC_SUBST(HAVE_ARM_NE10)
  400. AC_SUBST(NE10_CFLAGS)
  401. AC_SUBST(NE10_LIBS)
  402. ],[]
  403. )
  404. ]
  405. )
  406. AS_IF([test x"$enable_intrinsics" = x"yes"],[
  407. intrinsics_support=""
  408. AS_CASE([$host_cpu],
  409. [arm*],
  410. [
  411. cpu_arm=yes
  412. OPUS_CHECK_INTRINSICS(
  413. [ARM Neon],
  414. [$ARM_NEON_INTR_CFLAGS],
  415. [OPUS_ARM_MAY_HAVE_NEON_INTR],
  416. [OPUS_ARM_PRESUME_NEON_INTR],
  417. [[#include <arm_neon.h>
  418. ]],
  419. [[
  420. static float32x4_t A0, A1, SUMM;
  421. SUMM = vmlaq_f32(SUMM, A0, A1);
  422. ]]
  423. )
  424. AS_IF([test x"$OPUS_ARM_MAY_HAVE_NEON_INTR" = x"1" && test x"$OPUS_ARM_PRESUME_NEON_INTR" != x"1"],
  425. [
  426. OPUS_ARM_NEON_INTR_CFLAGS="$ARM_NEON_INTR_CFLAGS"
  427. AC_SUBST([OPUS_ARM_NEON_INTR_CFLAGS])
  428. ]
  429. )
  430. #Currently we only have intrinsic optimizations for floating point
  431. AS_IF([test x"$enable_float" = x"yes"],
  432. [
  433. AS_IF([test x"$OPUS_ARM_MAY_HAVE_NEON_INTR" = x"1"],
  434. [
  435. AC_DEFINE([OPUS_ARM_MAY_HAVE_NEON_INTR], 1, [Compiler supports ARMv7 Neon Intrinsics])
  436. intrinsics_support="$intrinsics_support (Neon_Intrinsics)"
  437. AS_IF([test x"enable_rtcd" != x"" && test x"$OPUS_ARM_PRESUME_NEON_INTR" != x"1"],
  438. [rtcd_support="$rtcd_support (ARMv7_Neon_Intrinsics)"],[])
  439. AS_IF([test x"$OPUS_ARM_PRESUME_NEON_INTR" = x"1"],
  440. [AC_DEFINE([OPUS_ARM_PRESUME_NEON_INTR], 1, [Define if binary requires NEON intrinsics support])])
  441. OPUS_PATH_NE10()
  442. AS_IF([test x"$NE10_LIBS" != x""],
  443. [
  444. intrinsics_support="$intrinsics_support (NE10)"
  445. AS_IF([test x"enable_rtcd" != x"" \
  446. && test x"$OPUS_ARM_PRESUME_NEON_INTR" != x"1"],
  447. [rtcd_support="$rtcd_support (NE10)"],[])
  448. ])
  449. AS_IF([test x"$rtcd_support" = x""],
  450. [rtcd_support=no])
  451. AS_IF([test x"$intrinsics_support" = x""],
  452. [intrinsics_support=no],
  453. [intrinsics_support="arm$intrinsics_support"])
  454. ],
  455. [
  456. AC_MSG_WARN([Compiler does not support ARM intrinsics])
  457. intrinsics_support=no
  458. ])
  459. ], [
  460. AC_MSG_WARN([Currently only have ARM intrinsics for float])
  461. intrinsics_support=no
  462. ])
  463. ],
  464. [i?86|x86_64],
  465. [
  466. OPUS_CHECK_INTRINSICS(
  467. [SSE],
  468. [$X86_SSE_CFLAGS],
  469. [OPUS_X86_MAY_HAVE_SSE],
  470. [OPUS_X86_PRESUME_SSE],
  471. [[#include <xmmintrin.h>
  472. ]],
  473. [[
  474. static __m128 mtest;
  475. mtest = _mm_setzero_ps();
  476. ]]
  477. )
  478. AS_IF([test x"$OPUS_X86_MAY_HAVE_SSE" = x"1" && test x"$OPUS_X86_PRESUME_SSE" != x"1"],
  479. [
  480. OPUS_X86_SSE_CFLAGS="$X86_SSE_CFLAGS"
  481. AC_SUBST([OPUS_X86_SSE_CFLAGS])
  482. ]
  483. )
  484. OPUS_CHECK_INTRINSICS(
  485. [SSE2],
  486. [$X86_SSE2_CFLAGS],
  487. [OPUS_X86_MAY_HAVE_SSE2],
  488. [OPUS_X86_PRESUME_SSE2],
  489. [[#include <emmintrin.h>
  490. ]],
  491. [[
  492. static __m128i mtest;
  493. mtest = _mm_setzero_si128();
  494. ]]
  495. )
  496. AS_IF([test x"$OPUS_X86_MAY_HAVE_SSE2" = x"1" && test x"$OPUS_X86_PRESUME_SSE2" != x"1"],
  497. [
  498. OPUS_X86_SSE2_CFLAGS="$X86_SSE2_CFLAGS"
  499. AC_SUBST([OPUS_X86_SSE2_CFLAGS])
  500. ]
  501. )
  502. OPUS_CHECK_INTRINSICS(
  503. [SSE4.1],
  504. [$X86_SSE4_1_CFLAGS],
  505. [OPUS_X86_MAY_HAVE_SSE4_1],
  506. [OPUS_X86_PRESUME_SSE4_1],
  507. [[#include <smmintrin.h>
  508. ]],
  509. [[
  510. static __m128i mtest;
  511. mtest = _mm_setzero_si128();
  512. mtest = _mm_cmpeq_epi64(mtest, mtest);
  513. ]]
  514. )
  515. AS_IF([test x"$OPUS_X86_MAY_HAVE_SSE4_1" = x"1" && test x"$OPUS_X86_PRESUME_SSE4_1" != x"1"],
  516. [
  517. OPUS_X86_SSE4_1_CFLAGS="$X86_SSE4_1_CFLAGS"
  518. AC_SUBST([OPUS_X86_SSE4_1_CFLAGS])
  519. ]
  520. )
  521. AS_IF([test x"$rtcd_support" = x"no"], [rtcd_support=""])
  522. AS_IF([test x"$OPUS_X86_MAY_HAVE_SSE" = x"1"],
  523. [
  524. AC_DEFINE([OPUS_X86_MAY_HAVE_SSE], 1, [Compiler supports X86 SSE Intrinsics])
  525. intrinsics_support="$intrinsics_support SSE"
  526. AS_IF([test x"$OPUS_X86_PRESUME_SSE" = x"1"],
  527. [AC_DEFINE([OPUS_X86_PRESUME_SSE], 1, [Define if binary requires SSE intrinsics support])],
  528. [rtcd_support="$rtcd_support SSE"])
  529. ],
  530. [
  531. AC_MSG_WARN([Compiler does not support SSE intrinsics])
  532. ])
  533. AS_IF([test x"$OPUS_X86_MAY_HAVE_SSE2" = x"1"],
  534. [
  535. AC_DEFINE([OPUS_X86_MAY_HAVE_SSE2], 1, [Compiler supports X86 SSE2 Intrinsics])
  536. intrinsics_support="$intrinsics_support SSE2"
  537. AS_IF([test x"$OPUS_X86_PRESUME_SSE2" = x"1"],
  538. [AC_DEFINE([OPUS_X86_PRESUME_SSE2], 1, [Define if binary requires SSE2 intrinsics support])],
  539. [rtcd_support="$rtcd_support SSE2"])
  540. ],
  541. [
  542. AC_MSG_WARN([Compiler does not support SSE2 intrinsics])
  543. ])
  544. AS_IF([test x"$OPUS_X86_MAY_HAVE_SSE4_1" = x"1"],
  545. [
  546. AC_DEFINE([OPUS_X86_MAY_HAVE_SSE4_1], 1, [Compiler supports X86 SSE4.1 Intrinsics])
  547. intrinsics_support="$intrinsics_support SSE4.1"
  548. AS_IF([test x"$OPUS_X86_PRESUME_SSE4_1" = x"1"],
  549. [AC_DEFINE([OPUS_X86_PRESUME_SSE4_1], 1, [Define if binary requires SSE4.1 intrinsics support])],
  550. [rtcd_support="$rtcd_support SSE4.1"])
  551. ],
  552. [
  553. AC_MSG_WARN([Compiler does not support SSE4.1 intrinsics])
  554. ])
  555. AS_IF([test x"$intrinsics_support" = x""],
  556. [intrinsics_support=no],
  557. [intrinsics_support="x86$intrinsics_support"]
  558. )
  559. AS_IF([test x"$rtcd_support" = x""],
  560. [rtcd_support=no],
  561. [rtcd_support="x86$rtcd_support"],
  562. )
  563. AS_IF([test x"$enable_rtcd" = x"yes" && test x"$rtcd_support" != x""],[
  564. get_cpuid_by_asm="no"
  565. AC_MSG_CHECKING([How to get X86 CPU Info])
  566. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  567. #include <stdio.h>
  568. ]],[[
  569. unsigned int CPUInfo0;
  570. unsigned int CPUInfo1;
  571. unsigned int CPUInfo2;
  572. unsigned int CPUInfo3;
  573. unsigned int InfoType;
  574. __asm__ __volatile__ (
  575. "cpuid":
  576. "=a" (CPUInfo0),
  577. "=b" (CPUInfo1),
  578. "=c" (CPUInfo2),
  579. "=d" (CPUInfo3) :
  580. "a" (InfoType), "c" (0)
  581. );
  582. ]])],
  583. [get_cpuid_by_asm="yes"
  584. AC_MSG_RESULT([Inline Assembly])
  585. AC_DEFINE([CPU_INFO_BY_ASM], [1], [Get CPU Info by asm method])],
  586. [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  587. #include <cpuid.h>
  588. ]],[[
  589. unsigned int CPUInfo0;
  590. unsigned int CPUInfo1;
  591. unsigned int CPUInfo2;
  592. unsigned int CPUInfo3;
  593. unsigned int InfoType;
  594. __get_cpuid(InfoType, &CPUInfo0, &CPUInfo1, &CPUInfo2, &CPUInfo3);
  595. ]])],
  596. [AC_MSG_RESULT([C method])
  597. AC_DEFINE([CPU_INFO_BY_C], [1], [Get CPU Info by c method])],
  598. [AC_MSG_ERROR([no supported Get CPU Info method, please disable intrinsics])])])])
  599. ],
  600. [
  601. AC_MSG_WARN([No intrinsics support for your architecture])
  602. intrinsics_support="no"
  603. ])
  604. ],
  605. [
  606. intrinsics_support="no"
  607. ])
  608. AM_CONDITIONAL([CPU_ARM], [test "$cpu_arm" = "yes"])
  609. AM_CONDITIONAL([OPUS_ARM_NEON_INTR],
  610. [test x"$OPUS_ARM_MAY_HAVE_NEON_INTR" = x"1"])
  611. AM_CONDITIONAL([HAVE_ARM_NE10],
  612. [test x"$HAVE_ARM_NE10" = x"1"])
  613. AM_CONDITIONAL([HAVE_SSE],
  614. [test x"$OPUS_X86_MAY_HAVE_SSE" = x"1"])
  615. AM_CONDITIONAL([HAVE_SSE2],
  616. [test x"$OPUS_X86_MAY_HAVE_SSE2" = x"1"])
  617. AM_CONDITIONAL([HAVE_SSE4_1],
  618. [test x"$OPUS_X86_MAY_HAVE_SSE4_1" = x"1"])
  619. AS_IF([test x"$enable_rtcd" = x"yes"],[
  620. AS_IF([test x"$rtcd_support" != x"no"],[
  621. AC_DEFINE([OPUS_HAVE_RTCD], [1],
  622. [Use run-time CPU capabilities detection])
  623. OPUS_HAVE_RTCD=1
  624. AC_SUBST(OPUS_HAVE_RTCD)
  625. ])
  626. ],[
  627. rtcd_support="disabled"
  628. ])
  629. AC_ARG_ENABLE([assertions],
  630. [AS_HELP_STRING([--enable-assertions],[enable additional software error checking])],,
  631. [enable_assertions=no])
  632. AS_IF([test "$enable_assertions" = "yes"], [
  633. AC_DEFINE([ENABLE_ASSERTIONS], [1], [Assertions])
  634. ])
  635. AC_ARG_ENABLE([fuzzing],
  636. [AS_HELP_STRING([--enable-fuzzing],[causes the encoder to make random decisions])],,
  637. [enable_fuzzing=no])
  638. AS_IF([test "$enable_fuzzing" = "yes"], [
  639. AC_DEFINE([FUZZING], [1], [Fuzzing])
  640. ])
  641. AC_ARG_ENABLE([doc],
  642. [AS_HELP_STRING([--disable-doc], [Do not build API documentation])],,
  643. [enable_doc=yes])
  644. AS_IF([test "$enable_doc" = "yes"], [
  645. AC_CHECK_PROG(HAVE_DOXYGEN, [doxygen], [yes], [no])
  646. ],[
  647. HAVE_DOXYGEN=no
  648. ])
  649. AM_CONDITIONAL([HAVE_DOXYGEN], [test "$HAVE_DOXYGEN" = "yes"])
  650. AC_ARG_ENABLE([extra-programs],
  651. [AS_HELP_STRING([--disable-extra-programs], [Do not build extra programs (demo and tests)])],,
  652. [enable_extra_programs=yes])
  653. AM_CONDITIONAL([EXTRA_PROGRAMS], [test "$enable_extra_programs" = "yes"])
  654. saved_CFLAGS="$CFLAGS"
  655. CFLAGS="$CFLAGS -fvisibility=hidden"
  656. AC_MSG_CHECKING([if ${CC} supports -fvisibility=hidden])
  657. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[char foo;]])],
  658. [ AC_MSG_RESULT([yes]) ],
  659. [ AC_MSG_RESULT([no])
  660. CFLAGS="$saved_CFLAGS"
  661. ])
  662. CFLAGS="$CFLAGS -W"
  663. warn_CFLAGS="-Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes"
  664. saved_CFLAGS="$CFLAGS"
  665. CFLAGS="$CFLAGS $warn_CFLAGS"
  666. AC_MSG_CHECKING([if ${CC} supports ${warn_CFLAGS}])
  667. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[char foo;]])],
  668. [ AC_MSG_RESULT([yes]) ],
  669. [ AC_MSG_RESULT([no])
  670. CFLAGS="$saved_CFLAGS"
  671. ])
  672. saved_LIBS="$LIBS"
  673. LIBS="$LIBS $LIBM"
  674. AC_CHECK_FUNCS([lrintf])
  675. AC_CHECK_FUNCS([lrint])
  676. LIBS="$saved_LIBS"
  677. AC_CHECK_FUNCS([__malloc_hook])
  678. AC_SUBST([PC_BUILD])
  679. AC_CONFIG_FILES([
  680. Makefile
  681. opus.pc
  682. opus-uninstalled.pc
  683. celt/arm/armopts.s
  684. doc/Makefile
  685. doc/Doxyfile
  686. ])
  687. AC_CONFIG_HEADERS([config.h])
  688. AC_OUTPUT
  689. AC_MSG_NOTICE([
  690. ------------------------------------------------------------------------
  691. $PACKAGE_NAME $PACKAGE_VERSION: Automatic configuration OK.
  692. Compiler support:
  693. C99 var arrays: ................ ${has_var_arrays}
  694. C99 lrintf: .................... ${ac_cv_func_lrintf}
  695. Use alloca: .................... ${use_alloca}
  696. General configuration:
  697. Floating point support: ........ ${enable_float}
  698. Fast float approximations: ..... ${enable_float_approx}
  699. Fixed point debugging: ......... ${enable_fixed_point_debug}
  700. Inline Assembly Optimizations: . ${inline_optimization}
  701. External Assembly Optimizations: ${asm_optimization}
  702. Intrinsics Optimizations.......: ${intrinsics_support}
  703. Run-time CPU detection: ........ ${rtcd_support}
  704. Custom modes: .................. ${enable_custom_modes}
  705. Assertion checking: ............ ${enable_assertions}
  706. Fuzzing: ....................... ${enable_fuzzing}
  707. API documentation: ............. ${enable_doc}
  708. Extra programs: ................ ${enable_extra_programs}
  709. ------------------------------------------------------------------------
  710. Type "make; make install" to compile and install
  711. Type "make check" to run the test suite
  712. ])