configure.ac 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934
  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=8
  21. OPUS_LT_REVISION=0
  22. OPUS_LT_AGE=8
  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([--disable-intrinsics], [Disable intrinsics optimizations])],,
  160. [enable_intrinsics=yes])
  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. AM_CONDITIONAL([HAVE_AVX], [false])
  317. m4_define([DEFAULT_X86_SSE_CFLAGS], [-msse])
  318. m4_define([DEFAULT_X86_SSE2_CFLAGS], [-msse2])
  319. m4_define([DEFAULT_X86_SSE4_1_CFLAGS], [-msse4.1])
  320. m4_define([DEFAULT_X86_AVX_CFLAGS], [-mavx])
  321. m4_define([DEFAULT_ARM_NEON_INTR_CFLAGS], [-mfpu=neon])
  322. # With GCC on ARM32 softfp architectures (e.g. Android, or older Ubuntu) you need to specify
  323. # -mfloat-abi=softfp for -mfpu=neon to work. However, on ARM32 hardfp architectures (e.g. newer Ubuntu),
  324. # this option will break things.
  325. # As a heuristic, if host matches arm*eabi* but not arm*hf*, it's probably soft-float.
  326. m4_define([DEFAULT_ARM_NEON_SOFTFP_INTR_CFLAGS], [-mfpu=neon -mfloat-abi=softfp])
  327. AS_CASE([$host],
  328. [arm*hf*], [AS_VAR_SET([RESOLVED_DEFAULT_ARM_NEON_INTR_CFLAGS], "DEFAULT_ARM_NEON_INTR_CFLAGS")],
  329. [arm*eabi*], [AS_VAR_SET([RESOLVED_DEFAULT_ARM_NEON_INTR_CFLAGS], "DEFAULT_ARM_NEON_SOFTFP_INTR_CFLAGS")],
  330. [AS_VAR_SET([RESOLVED_DEFAULT_ARM_NEON_INTR_CFLAGS], "DEFAULT_ARM_NEON_INTR_CFLAGS")])
  331. AC_ARG_VAR([X86_SSE_CFLAGS], [C compiler flags to compile SSE intrinsics @<:@default=]DEFAULT_X86_SSE_CFLAGS[@:>@])
  332. AC_ARG_VAR([X86_SSE2_CFLAGS], [C compiler flags to compile SSE2 intrinsics @<:@default=]DEFAULT_X86_SSE2_CFLAGS[@:>@])
  333. AC_ARG_VAR([X86_SSE4_1_CFLAGS], [C compiler flags to compile SSE4.1 intrinsics @<:@default=]DEFAULT_X86_SSE4_1_CFLAGS[@:>@])
  334. AC_ARG_VAR([X86_AVX_CFLAGS], [C compiler flags to compile AVX intrinsics @<:@default=]DEFAULT_X86_AVX_CFLAGS[@:>@])
  335. 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[@:>@])
  336. AS_VAR_SET_IF([X86_SSE_CFLAGS], [], [AS_VAR_SET([X86_SSE_CFLAGS], "DEFAULT_X86_SSE_CFLAGS")])
  337. AS_VAR_SET_IF([X86_SSE2_CFLAGS], [], [AS_VAR_SET([X86_SSE2_CFLAGS], "DEFAULT_X86_SSE2_CFLAGS")])
  338. AS_VAR_SET_IF([X86_SSE4_1_CFLAGS], [], [AS_VAR_SET([X86_SSE4_1_CFLAGS], "DEFAULT_X86_SSE4_1_CFLAGS")])
  339. AS_VAR_SET_IF([X86_AVX_CFLAGS], [], [AS_VAR_SET([X86_AVX_CFLAGS], "DEFAULT_X86_AVX_CFLAGS")])
  340. AS_VAR_SET_IF([ARM_NEON_INTR_CFLAGS], [], [AS_VAR_SET([ARM_NEON_INTR_CFLAGS], ["$RESOLVED_DEFAULT_ARM_NEON_INTR_CFLAGS"])])
  341. AC_DEFUN([OPUS_PATH_NE10],
  342. [
  343. AC_ARG_WITH(NE10,
  344. AC_HELP_STRING([--with-NE10=PFX],[Prefix where libNE10 is installed (optional)]),
  345. NE10_prefix="$withval", NE10_prefix="")
  346. AC_ARG_WITH(NE10-libraries,
  347. AC_HELP_STRING([--with-NE10-libraries=DIR],
  348. [Directory where libNE10 library is installed (optional)]),
  349. NE10_libraries="$withval", NE10_libraries="")
  350. AC_ARG_WITH(NE10-includes,
  351. AC_HELP_STRING([--with-NE10-includes=DIR],
  352. [Directory where libNE10 header files are installed (optional)]),
  353. NE10_includes="$withval", NE10_includes="")
  354. if test "x$NE10_libraries" != "x" ; then
  355. NE10_LIBS="-L$NE10_libraries"
  356. elif test "x$NE10_prefix" = "xno" || test "x$NE10_prefix" = "xyes" ; then
  357. NE10_LIBS=""
  358. elif test "x$NE10_prefix" != "x" ; then
  359. NE10_LIBS="-L$NE10_prefix/lib"
  360. elif test "x$prefix" != "xNONE" ; then
  361. NE10_LIBS="-L$prefix/lib"
  362. fi
  363. if test "x$NE10_prefix" != "xno" ; then
  364. NE10_LIBS="$NE10_LIBS -lNE10"
  365. fi
  366. if test "x$NE10_includes" != "x" ; then
  367. NE10_CFLAGS="-I$NE10_includes"
  368. elif test "x$NE10_prefix" = "xno" || test "x$NE10_prefix" = "xyes" ; then
  369. NE10_CFLAGS=""
  370. elif test "x$NE10_prefix" != "x" ; then
  371. NE10_CFLAGS="-I$NE10_prefix/include"
  372. elif test "x$prefix" != "xNONE"; then
  373. NE10_CFLAGS="-I$prefix/include"
  374. fi
  375. AC_MSG_CHECKING(for NE10)
  376. save_CFLAGS="$CFLAGS"; CFLAGS="$CFLAGS $NE10_CFLAGS"
  377. save_LIBS="$LIBS"; LIBS="$LIBS $NE10_LIBS $LIBM"
  378. AC_LINK_IFELSE(
  379. [
  380. AC_LANG_PROGRAM(
  381. [[#include <NE10_dsp.h>
  382. ]],
  383. [[
  384. ne10_fft_cfg_float32_t cfg;
  385. cfg = ne10_fft_alloc_c2c_float32_neon(480);
  386. ]]
  387. )
  388. ],[
  389. HAVE_ARM_NE10=1
  390. AC_MSG_RESULT([yes])
  391. ],[
  392. HAVE_ARM_NE10=0
  393. AC_MSG_RESULT([no])
  394. NE10_CFLAGS=""
  395. NE10_LIBS=""
  396. ]
  397. )
  398. CFLAGS="$save_CFLAGS"; LIBS="$save_LIBS"
  399. #Now we know if libNE10 is installed or not
  400. AS_IF([test x"$HAVE_ARM_NE10" = x"1"],
  401. [
  402. AC_DEFINE([HAVE_ARM_NE10], 1, [NE10 library is installed on host. Make sure it is on target!])
  403. AC_SUBST(HAVE_ARM_NE10)
  404. AC_SUBST(NE10_CFLAGS)
  405. AC_SUBST(NE10_LIBS)
  406. ]
  407. )
  408. ]
  409. )
  410. AS_IF([test x"$enable_intrinsics" = x"yes"],[
  411. intrinsics_support=""
  412. AS_CASE([$host_cpu],
  413. [arm*|aarch64*],
  414. [
  415. cpu_arm=yes
  416. OPUS_CHECK_INTRINSICS(
  417. [ARM Neon],
  418. [$ARM_NEON_INTR_CFLAGS],
  419. [OPUS_ARM_MAY_HAVE_NEON_INTR],
  420. [OPUS_ARM_PRESUME_NEON_INTR],
  421. [[#include <arm_neon.h>
  422. ]],
  423. [[
  424. static float32x4_t A0, A1, SUMM;
  425. SUMM = vmlaq_f32(SUMM, A0, A1);
  426. return (int)vgetq_lane_f32(SUMM, 0);
  427. ]]
  428. )
  429. AS_IF([test x"$OPUS_ARM_MAY_HAVE_NEON_INTR" = x"1" && test x"$OPUS_ARM_PRESUME_NEON_INTR" != x"1"],
  430. [
  431. OPUS_ARM_NEON_INTR_CFLAGS="$ARM_NEON_INTR_CFLAGS"
  432. AC_SUBST([OPUS_ARM_NEON_INTR_CFLAGS])
  433. ]
  434. )
  435. AS_IF([test x"$OPUS_ARM_MAY_HAVE_NEON_INTR" = x"1"],
  436. [
  437. AC_DEFINE([OPUS_ARM_MAY_HAVE_NEON_INTR], 1, [Compiler supports ARMv7/Aarch64 Neon Intrinsics])
  438. intrinsics_support="$intrinsics_support (NEON)"
  439. AS_IF([test x"$enable_rtcd" != x"no" && test x"$OPUS_ARM_PRESUME_NEON_INTR" != x"1"],
  440. [AS_IF([test x"$rtcd_support" = x"no"],
  441. [rtcd_support="ARM (NEON Intrinsics)"],
  442. [rtcd_support="$rtcd_support (NEON Intrinsics)"])])
  443. AS_IF([test x"$OPUS_ARM_PRESUME_NEON_INTR" = x"1"],
  444. [AC_DEFINE([OPUS_ARM_PRESUME_NEON_INTR], 1, [Define if binary requires NEON intrinsics support])])
  445. OPUS_PATH_NE10()
  446. AS_IF([test x"$NE10_LIBS" != x""],
  447. [
  448. intrinsics_support="$intrinsics_support (NE10)"
  449. AS_IF([test x"enable_rtcd" != x"" \
  450. && test x"$OPUS_ARM_PRESUME_NEON_INTR" != x"1"],
  451. [rtcd_support="$rtcd_support (NE10)"])
  452. ])
  453. OPUS_CHECK_INTRINSICS(
  454. [Aarch64 Neon],
  455. [$ARM_NEON_INTR_CFLAGS],
  456. [OPUS_ARM_MAY_HAVE_AARCH64_NEON_INTR],
  457. [OPUS_ARM_PRESUME_AARCH64_NEON_INTR],
  458. [[#include <arm_neon.h>
  459. ]],
  460. [[
  461. static int32_t IN;
  462. static int16_t OUT;
  463. OUT = vqmovns_s32(IN);
  464. ]]
  465. )
  466. AS_IF([test x"$OPUS_ARM_PRESUME_AARCH64_NEON_INTR" = x"1"],
  467. [
  468. AC_DEFINE([OPUS_ARM_PRESUME_AARCH64_NEON_INTR], 1, [Define if binary requires Aarch64 Neon Intrinsics])
  469. intrinsics_support="$intrinsics_support (NEON [Aarch64])"
  470. ])
  471. AS_IF([test x"$intrinsics_support" = x""],
  472. [intrinsics_support=no],
  473. [intrinsics_support="ARM$intrinsics_support"])
  474. ],
  475. [
  476. AC_MSG_WARN([Compiler does not support ARM intrinsics])
  477. intrinsics_support=no
  478. ])
  479. ],
  480. [i?86|x86_64],
  481. [
  482. OPUS_CHECK_INTRINSICS(
  483. [SSE],
  484. [$X86_SSE_CFLAGS],
  485. [OPUS_X86_MAY_HAVE_SSE],
  486. [OPUS_X86_PRESUME_SSE],
  487. [[#include <xmmintrin.h>
  488. #include <time.h>
  489. ]],
  490. [[
  491. __m128 mtest;
  492. mtest = _mm_set1_ps((float)time(NULL));
  493. mtest = _mm_mul_ps(mtest, mtest);
  494. return _mm_cvtss_si32(mtest);
  495. ]]
  496. )
  497. AS_IF([test x"$OPUS_X86_MAY_HAVE_SSE" = x"1" && test x"$OPUS_X86_PRESUME_SSE" != x"1"],
  498. [
  499. OPUS_X86_SSE_CFLAGS="$X86_SSE_CFLAGS"
  500. AC_SUBST([OPUS_X86_SSE_CFLAGS])
  501. ]
  502. )
  503. OPUS_CHECK_INTRINSICS(
  504. [SSE2],
  505. [$X86_SSE2_CFLAGS],
  506. [OPUS_X86_MAY_HAVE_SSE2],
  507. [OPUS_X86_PRESUME_SSE2],
  508. [[#include <emmintrin.h>
  509. #include <time.h>
  510. ]],
  511. [[
  512. __m128i mtest;
  513. mtest = _mm_set1_epi32((int)time(NULL));
  514. mtest = _mm_mul_epu32(mtest, mtest);
  515. return _mm_cvtsi128_si32(mtest);
  516. ]]
  517. )
  518. AS_IF([test x"$OPUS_X86_MAY_HAVE_SSE2" = x"1" && test x"$OPUS_X86_PRESUME_SSE2" != x"1"],
  519. [
  520. OPUS_X86_SSE2_CFLAGS="$X86_SSE2_CFLAGS"
  521. AC_SUBST([OPUS_X86_SSE2_CFLAGS])
  522. ]
  523. )
  524. OPUS_CHECK_INTRINSICS(
  525. [SSE4.1],
  526. [$X86_SSE4_1_CFLAGS],
  527. [OPUS_X86_MAY_HAVE_SSE4_1],
  528. [OPUS_X86_PRESUME_SSE4_1],
  529. [[#include <smmintrin.h>
  530. #include <time.h>
  531. ]],
  532. [[
  533. __m128i mtest;
  534. mtest = _mm_set1_epi32((int)time(NULL));
  535. mtest = _mm_mul_epi32(mtest, mtest);
  536. return _mm_cvtsi128_si32(mtest);
  537. ]]
  538. )
  539. AS_IF([test x"$OPUS_X86_MAY_HAVE_SSE4_1" = x"1" && test x"$OPUS_X86_PRESUME_SSE4_1" != x"1"],
  540. [
  541. OPUS_X86_SSE4_1_CFLAGS="$X86_SSE4_1_CFLAGS"
  542. AC_SUBST([OPUS_X86_SSE4_1_CFLAGS])
  543. ]
  544. )
  545. OPUS_CHECK_INTRINSICS(
  546. [AVX],
  547. [$X86_AVX_CFLAGS],
  548. [OPUS_X86_MAY_HAVE_AVX],
  549. [OPUS_X86_PRESUME_AVX],
  550. [[#include <immintrin.h>
  551. #include <time.h>
  552. ]],
  553. [[
  554. __m256 mtest;
  555. mtest = _mm256_set1_ps((float)time(NULL));
  556. mtest = _mm256_addsub_ps(mtest, mtest);
  557. return _mm_cvtss_si32(_mm256_extractf128_ps(mtest, 0));
  558. ]]
  559. )
  560. AS_IF([test x"$OPUS_X86_MAY_HAVE_AVX" = x"1" && test x"$OPUS_X86_PRESUME_AVX" != x"1"],
  561. [
  562. OPUS_X86_AVX_CFLAGS="$X86_AVX_CFLAGS"
  563. AC_SUBST([OPUS_X86_AVX_CFLAGS])
  564. ]
  565. )
  566. AS_IF([test x"$rtcd_support" = x"no"], [rtcd_support=""])
  567. AS_IF([test x"$OPUS_X86_MAY_HAVE_SSE" = x"1"],
  568. [
  569. AC_DEFINE([OPUS_X86_MAY_HAVE_SSE], 1, [Compiler supports X86 SSE Intrinsics])
  570. intrinsics_support="$intrinsics_support SSE"
  571. AS_IF([test x"$OPUS_X86_PRESUME_SSE" = x"1"],
  572. [AC_DEFINE([OPUS_X86_PRESUME_SSE], 1, [Define if binary requires SSE intrinsics support])],
  573. [rtcd_support="$rtcd_support SSE"])
  574. ],
  575. [
  576. AC_MSG_WARN([Compiler does not support SSE intrinsics])
  577. ])
  578. AS_IF([test x"$OPUS_X86_MAY_HAVE_SSE2" = x"1"],
  579. [
  580. AC_DEFINE([OPUS_X86_MAY_HAVE_SSE2], 1, [Compiler supports X86 SSE2 Intrinsics])
  581. intrinsics_support="$intrinsics_support SSE2"
  582. AS_IF([test x"$OPUS_X86_PRESUME_SSE2" = x"1"],
  583. [AC_DEFINE([OPUS_X86_PRESUME_SSE2], 1, [Define if binary requires SSE2 intrinsics support])],
  584. [rtcd_support="$rtcd_support SSE2"])
  585. ],
  586. [
  587. AC_MSG_WARN([Compiler does not support SSE2 intrinsics])
  588. ])
  589. AS_IF([test x"$OPUS_X86_MAY_HAVE_SSE4_1" = x"1"],
  590. [
  591. AC_DEFINE([OPUS_X86_MAY_HAVE_SSE4_1], 1, [Compiler supports X86 SSE4.1 Intrinsics])
  592. intrinsics_support="$intrinsics_support SSE4.1"
  593. AS_IF([test x"$OPUS_X86_PRESUME_SSE4_1" = x"1"],
  594. [AC_DEFINE([OPUS_X86_PRESUME_SSE4_1], 1, [Define if binary requires SSE4.1 intrinsics support])],
  595. [rtcd_support="$rtcd_support SSE4.1"])
  596. ],
  597. [
  598. AC_MSG_WARN([Compiler does not support SSE4.1 intrinsics])
  599. ])
  600. AS_IF([test x"$OPUS_X86_MAY_HAVE_AVX" = x"1"],
  601. [
  602. AC_DEFINE([OPUS_X86_MAY_HAVE_AVX], 1, [Compiler supports X86 AVX Intrinsics])
  603. intrinsics_support="$intrinsics_support AVX"
  604. AS_IF([test x"$OPUS_X86_PRESUME_AVX" = x"1"],
  605. [AC_DEFINE([OPUS_X86_PRESUME_AVX], 1, [Define if binary requires AVX intrinsics support])],
  606. [rtcd_support="$rtcd_support AVX"])
  607. ],
  608. [
  609. AC_MSG_WARN([Compiler does not support AVX intrinsics])
  610. ])
  611. AS_IF([test x"$intrinsics_support" = x""],
  612. [intrinsics_support=no],
  613. [intrinsics_support="x86$intrinsics_support"]
  614. )
  615. AS_IF([test x"$rtcd_support" = x""],
  616. [rtcd_support=no],
  617. [rtcd_support="x86$rtcd_support"],
  618. )
  619. AS_IF([test x"$enable_rtcd" = x"yes" && test x"$rtcd_support" != x""],[
  620. get_cpuid_by_asm="no"
  621. AC_MSG_CHECKING([How to get X86 CPU Info])
  622. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  623. #include <stdio.h>
  624. ]],[[
  625. unsigned int CPUInfo0;
  626. unsigned int CPUInfo1;
  627. unsigned int CPUInfo2;
  628. unsigned int CPUInfo3;
  629. unsigned int InfoType;
  630. __asm__ __volatile__ (
  631. "cpuid":
  632. "=a" (CPUInfo0),
  633. "=b" (CPUInfo1),
  634. "=c" (CPUInfo2),
  635. "=d" (CPUInfo3) :
  636. "a" (InfoType), "c" (0)
  637. );
  638. ]])],
  639. [get_cpuid_by_asm="yes"
  640. AC_MSG_RESULT([Inline Assembly])
  641. AC_DEFINE([CPU_INFO_BY_ASM], [1], [Get CPU Info by asm method])],
  642. [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  643. #include <cpuid.h>
  644. ]],[[
  645. unsigned int CPUInfo0;
  646. unsigned int CPUInfo1;
  647. unsigned int CPUInfo2;
  648. unsigned int CPUInfo3;
  649. unsigned int InfoType;
  650. __get_cpuid(InfoType, &CPUInfo0, &CPUInfo1, &CPUInfo2, &CPUInfo3);
  651. ]])],
  652. [AC_MSG_RESULT([C method])
  653. AC_DEFINE([CPU_INFO_BY_C], [1], [Get CPU Info by c method])],
  654. [AC_MSG_ERROR([no supported Get CPU Info method, please disable run-time CPU capabilities detection or intrinsics])])])])
  655. ],
  656. [
  657. AC_MSG_WARN([No intrinsics support for your architecture])
  658. intrinsics_support="no"
  659. ])
  660. ],
  661. [
  662. intrinsics_support="no"
  663. ])
  664. AM_CONDITIONAL([CPU_ARM], [test "$cpu_arm" = "yes"])
  665. AM_CONDITIONAL([HAVE_ARM_NEON_INTR],
  666. [test x"$OPUS_ARM_MAY_HAVE_NEON_INTR" = x"1"])
  667. AM_CONDITIONAL([HAVE_ARM_NE10],
  668. [test x"$HAVE_ARM_NE10" = x"1"])
  669. AM_CONDITIONAL([HAVE_SSE],
  670. [test x"$OPUS_X86_MAY_HAVE_SSE" = x"1"])
  671. AM_CONDITIONAL([HAVE_SSE2],
  672. [test x"$OPUS_X86_MAY_HAVE_SSE2" = x"1"])
  673. AM_CONDITIONAL([HAVE_SSE4_1],
  674. [test x"$OPUS_X86_MAY_HAVE_SSE4_1" = x"1"])
  675. AM_CONDITIONAL([HAVE_AVX],
  676. [test x"$OPUS_X86_MAY_HAVE_AVX" = x"1"])
  677. AS_IF([test x"$enable_rtcd" = x"yes"],[
  678. AS_IF([test x"$rtcd_support" != x"no"],[
  679. AC_DEFINE([OPUS_HAVE_RTCD], [1],
  680. [Use run-time CPU capabilities detection])
  681. OPUS_HAVE_RTCD=1
  682. AC_SUBST(OPUS_HAVE_RTCD)
  683. ])
  684. ],[
  685. rtcd_support="disabled"
  686. ])
  687. AC_ARG_ENABLE([assertions],
  688. [AS_HELP_STRING([--enable-assertions],[enable additional software error checking])],,
  689. [enable_assertions=no])
  690. AS_IF([test "$enable_assertions" = "yes"], [
  691. AC_DEFINE([ENABLE_ASSERTIONS], [1], [Assertions])
  692. ])
  693. AC_ARG_ENABLE([hardening],
  694. [AS_HELP_STRING([--disable-hardening],[disable run-time checks that are cheap and safe for use in production])],,
  695. [enable_hardening=yes])
  696. AS_IF([test "$enable_hardening" = "yes"], [
  697. AC_DEFINE([ENABLE_HARDENING], [1], [Hardening])
  698. ])
  699. AC_ARG_ENABLE([fuzzing],
  700. [AS_HELP_STRING([--enable-fuzzing],[causes the encoder to make random decisions (do not use in production)])],,
  701. [enable_fuzzing=no])
  702. AS_IF([test "$enable_fuzzing" = "yes"], [
  703. AC_DEFINE([FUZZING], [1], [Fuzzing])
  704. ])
  705. AC_ARG_ENABLE([check-asm],
  706. [AS_HELP_STRING([--enable-check-asm],
  707. [enable bit-exactness checks between optimized and c implementations])],,
  708. [enable_check_asm=no])
  709. AS_IF([test "$enable_check_asm" = "yes"], [
  710. AC_DEFINE([OPUS_CHECK_ASM], [1], [Run bit-exactness checks between optimized and c implementations])
  711. ])
  712. AC_ARG_ENABLE([doc],
  713. [AS_HELP_STRING([--disable-doc], [Do not build API documentation])],,
  714. [enable_doc=yes])
  715. AS_IF([test "$enable_doc" = "yes"], [
  716. AC_CHECK_PROG(HAVE_DOXYGEN, [doxygen], [yes], [no])
  717. AC_CHECK_PROG(HAVE_DOT, [dot], [yes], [no])
  718. ],[
  719. HAVE_DOXYGEN=no
  720. ])
  721. AM_CONDITIONAL([HAVE_DOXYGEN], [test "$HAVE_DOXYGEN" = "yes"])
  722. AC_ARG_ENABLE([extra-programs],
  723. [AS_HELP_STRING([--disable-extra-programs], [Do not build extra programs (demo and tests)])],,
  724. [enable_extra_programs=yes])
  725. AM_CONDITIONAL([EXTRA_PROGRAMS], [test "$enable_extra_programs" = "yes"])
  726. AC_ARG_ENABLE([rfc8251],
  727. AS_HELP_STRING([--disable-rfc8251], [Disable bitstream fixes from RFC 8251]),,
  728. [enable_rfc8251=yes])
  729. AS_IF([test "$enable_rfc8251" = "no"], [
  730. AC_DEFINE([DISABLE_UPDATE_DRAFT], [1], [Disable bitstream fixes from RFC 8251])
  731. ])
  732. saved_CFLAGS="$CFLAGS"
  733. CFLAGS="$CFLAGS -fvisibility=hidden"
  734. AC_MSG_CHECKING([if ${CC} supports -fvisibility=hidden])
  735. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[char foo;]])],
  736. [ AC_MSG_RESULT([yes]) ],
  737. [ AC_MSG_RESULT([no])
  738. CFLAGS="$saved_CFLAGS"
  739. ])
  740. on_x86=no
  741. case "$host_cpu" in
  742. i[[3456]]86 | x86_64)
  743. on_x86=yes
  744. ;;
  745. esac
  746. on_windows=no
  747. case $host in
  748. *cygwin*|*mingw*)
  749. on_windows=yes
  750. ;;
  751. esac
  752. dnl Enable stack-protector-all only on x86 where it's well supported.
  753. dnl on some platforms it causes crashes. Hopefully the OS's default's
  754. dnl include this on platforms that work but have been missed here.
  755. AC_ARG_ENABLE([stack-protector],
  756. [AS_HELP_STRING([--disable-stack-protector],[Disable compiler stack hardening])],,
  757. [
  758. AS_IF([test "$ac_cv_c_compiler_gnu" = "yes" && test "$on_x86" = "yes" && test "$on_windows" = "no"],
  759. [enable_stack_protector=yes],[enable_stack_protector=no])
  760. ])
  761. AS_IF([test "$enable_stack_protector" = "yes"],
  762. [
  763. saved_CFLAGS="$CFLAGS"
  764. CFLAGS="$CFLAGS -fstack-protector-strong"
  765. AC_MSG_CHECKING([if ${CC} supports -fstack-protector-strong])
  766. AC_LINK_IFELSE([AC_LANG_PROGRAM([],[[char foo;]])],
  767. [ AC_MSG_RESULT([yes]) ],
  768. [
  769. AC_MSG_RESULT([no])
  770. enable_stack_protector=no
  771. CFLAGS="$saved_CFLAGS"
  772. ])
  773. ])
  774. AS_IF([test x$ac_cv_c_compiler_gnu = xyes],
  775. [AX_ADD_FORTIFY_SOURCE]
  776. )
  777. CFLAGS="$CFLAGS -W"
  778. warn_CFLAGS="-Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes"
  779. saved_CFLAGS="$CFLAGS"
  780. CFLAGS="$CFLAGS $warn_CFLAGS"
  781. AC_MSG_CHECKING([if ${CC} supports ${warn_CFLAGS}])
  782. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[char foo;]])],
  783. [ AC_MSG_RESULT([yes]) ],
  784. [ AC_MSG_RESULT([no])
  785. CFLAGS="$saved_CFLAGS"
  786. ])
  787. saved_LIBS="$LIBS"
  788. LIBS="$LIBS $LIBM"
  789. AC_CHECK_FUNCS([lrintf])
  790. AC_CHECK_FUNCS([lrint])
  791. LIBS="$saved_LIBS"
  792. AC_CHECK_FUNCS([__malloc_hook])
  793. AC_SUBST([PC_BUILD])
  794. AC_CONFIG_FILES([
  795. Makefile
  796. opus.pc
  797. opus-uninstalled.pc
  798. celt/arm/armopts.s
  799. doc/Makefile
  800. doc/Doxyfile
  801. ])
  802. AC_CONFIG_HEADERS([config.h])
  803. AC_OUTPUT
  804. AC_MSG_NOTICE([
  805. ------------------------------------------------------------------------
  806. $PACKAGE_NAME $PACKAGE_VERSION: Automatic configuration OK.
  807. Compiler support:
  808. C99 var arrays: ................ ${has_var_arrays}
  809. C99 lrintf: .................... ${ac_cv_func_lrintf}
  810. Use alloca: .................... ${use_alloca}
  811. General configuration:
  812. Floating point support: ........ ${enable_float}
  813. Fast float approximations: ..... ${enable_float_approx}
  814. Fixed point debugging: ......... ${enable_fixed_point_debug}
  815. Inline Assembly Optimizations: . ${inline_optimization}
  816. External Assembly Optimizations: ${asm_optimization}
  817. Intrinsics Optimizations: ...... ${intrinsics_support}
  818. Run-time CPU detection: ........ ${rtcd_support}
  819. Custom modes: .................. ${enable_custom_modes}
  820. Assertion checking: ............ ${enable_assertions}
  821. Hardening: ..................... ${enable_hardening}
  822. Fuzzing: ....................... ${enable_fuzzing}
  823. Check ASM: ..................... ${enable_check_asm}
  824. API documentation: ............. ${enable_doc}
  825. Extra programs: ................ ${enable_extra_programs}
  826. ------------------------------------------------------------------------
  827. Type "make; make install" to compile and install
  828. Type "make check" to run the test suite
  829. ])