configure.ac 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718
  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. AS_IF([test x"$enable_intrinsics" = x"yes"],[
  338. intrinsics_support=""
  339. AS_CASE([$host_cpu],
  340. [arm*],
  341. [
  342. cpu_arm=yes
  343. OPUS_CHECK_INTRINSICS(
  344. [ARM Neon],
  345. [$ARM_NEON_INTR_CFLAGS],
  346. [OPUS_ARM_MAY_HAVE_NEON_INTR],
  347. [OPUS_ARM_PRESUME_NEON_INTR],
  348. [[#include <arm_neon.h>
  349. ]],
  350. [[
  351. static float32x4_t A0, A1, SUMM;
  352. SUMM = vmlaq_f32(SUMM, A0, A1);
  353. ]]
  354. )
  355. AS_IF([test x"$OPUS_ARM_MAY_HAVE_NEON_INTR" = x"1" && test x"$OPUS_ARM_PRESUME_NEON_INTR" != x"1"],
  356. [
  357. OPUS_ARM_NEON_INTR_CFLAGS="$ARM_NEON_INTR_CFLAGS"
  358. AC_SUBST([OPUS_ARM_NEON_INTR_CFLAGS])
  359. ]
  360. )
  361. #Currently we only have intrinsic optimizations for floating point
  362. AS_IF([test x"$enable_float" = x"yes"],
  363. [
  364. AS_IF([test x"$OPUS_ARM_MAY_HAVE_NEON_INTR" = x"1"],
  365. [
  366. AC_DEFINE([OPUS_ARM_MAY_HAVE_NEON_INTR], 1, [Compiler supports ARMv7 Neon Intrinsics])
  367. intrinsics_support="$intrinsics_support (Neon_Intrinsics)"
  368. AS_IF([test x"enable_rtcd" != x"" && test x"$OPUS_ARM_PRESUME_NEON_INTR" != x"1"],
  369. [rtcd_support="$rtcd_support (ARMv7_Neon_Intrinsics)"],[])
  370. AS_IF([test x"$OPUS_ARM_PRESUME_NEON_INTR" = x"1"],
  371. [AC_DEFINE([OPUS_ARM_PRESUME_NEON_INTR], 1, [Define if binary requires NEON intrinsics support])])
  372. AS_IF([test x"$rtcd_support" = x""],
  373. [rtcd_support=no])
  374. AS_IF([test x"$intrinsics_support" = x""],
  375. [intrinsics_support=no],
  376. [intrinsics_support="arm$intrinsics_support"])
  377. ],
  378. [
  379. AC_MSG_WARN([Compiler does not support ARM intrinsics])
  380. intrinsics_support=no
  381. ])
  382. ], [
  383. AC_MSG_WARN([Currently only have ARM intrinsics for float])
  384. intrinsics_support=no
  385. ])
  386. ],
  387. [i?86|x86_64],
  388. [
  389. OPUS_CHECK_INTRINSICS(
  390. [SSE],
  391. [$X86_SSE_CFLAGS],
  392. [OPUS_X86_MAY_HAVE_SSE],
  393. [OPUS_X86_PRESUME_SSE],
  394. [[#include <xmmintrin.h>
  395. ]],
  396. [[
  397. static __m128 mtest;
  398. mtest = _mm_setzero_ps();
  399. ]]
  400. )
  401. AS_IF([test x"$OPUS_X86_MAY_HAVE_SSE" = x"1" && test x"$OPUS_X86_PRESUME_SSE" != x"1"],
  402. [
  403. OPUS_X86_SSE_CFLAGS="$X86_SSE_CFLAGS"
  404. AC_SUBST([OPUS_X86_SSE_CFLAGS])
  405. ]
  406. )
  407. OPUS_CHECK_INTRINSICS(
  408. [SSE2],
  409. [$X86_SSE2_CFLAGS],
  410. [OPUS_X86_MAY_HAVE_SSE2],
  411. [OPUS_X86_PRESUME_SSE2],
  412. [[#include <emmintrin.h>
  413. ]],
  414. [[
  415. static __m128i mtest;
  416. mtest = _mm_setzero_si128();
  417. ]]
  418. )
  419. AS_IF([test x"$OPUS_X86_MAY_HAVE_SSE2" = x"1" && test x"$OPUS_X86_PRESUME_SSE2" != x"1"],
  420. [
  421. OPUS_X86_SSE2_CFLAGS="$X86_SSE2_CFLAGS"
  422. AC_SUBST([OPUS_X86_SSE2_CFLAGS])
  423. ]
  424. )
  425. OPUS_CHECK_INTRINSICS(
  426. [SSE4.1],
  427. [$X86_SSE4_1_CFLAGS],
  428. [OPUS_X86_MAY_HAVE_SSE4_1],
  429. [OPUS_X86_PRESUME_SSE4_1],
  430. [[#include <smmintrin.h>
  431. ]],
  432. [[
  433. static __m128i mtest;
  434. mtest = _mm_setzero_si128();
  435. mtest = _mm_cmpeq_epi64(mtest, mtest);
  436. ]]
  437. )
  438. AS_IF([test x"$OPUS_X86_MAY_HAVE_SSE4_1" = x"1" && test x"$OPUS_X86_PRESUME_SSE4_1" != x"1"],
  439. [
  440. OPUS_X86_SSE4_1_CFLAGS="$X86_SSE4_1_CFLAGS"
  441. AC_SUBST([OPUS_X86_SSE4_1_CFLAGS])
  442. ]
  443. )
  444. AS_IF([test x"$rtcd_support" = x"no"], [rtcd_support=""])
  445. AS_IF([test x"$OPUS_X86_MAY_HAVE_SSE" = x"1"],
  446. [
  447. AC_DEFINE([OPUS_X86_MAY_HAVE_SSE], 1, [Compiler supports X86 SSE Intrinsics])
  448. intrinsics_support="$intrinsics_support SSE"
  449. AS_IF([test x"$OPUS_X86_PRESUME_SSE" = x"1"],
  450. [AC_DEFINE([OPUS_X86_PRESUME_SSE], 1, [Define if binary requires SSE intrinsics support])],
  451. [rtcd_support="$rtcd_support SSE"])
  452. ],
  453. [
  454. AC_MSG_WARN([Compiler does not support SSE intrinsics])
  455. ])
  456. AS_IF([test x"$OPUS_X86_MAY_HAVE_SSE2" = x"1"],
  457. [
  458. AC_DEFINE([OPUS_X86_MAY_HAVE_SSE2], 1, [Compiler supports X86 SSE2 Intrinsics])
  459. intrinsics_support="$intrinsics_support SSE2"
  460. AS_IF([test x"$OPUS_X86_PRESUME_SSE2" = x"1"],
  461. [AC_DEFINE([OPUS_X86_PRESUME_SSE2], 1, [Define if binary requires SSE2 intrinsics support])],
  462. [rtcd_support="$rtcd_support SSE2"])
  463. ],
  464. [
  465. AC_MSG_WARN([Compiler does not support SSE2 intrinsics])
  466. ])
  467. AS_IF([test x"$OPUS_X86_MAY_HAVE_SSE4_1" = x"1"],
  468. [
  469. AC_DEFINE([OPUS_X86_MAY_HAVE_SSE4_1], 1, [Compiler supports X86 SSE4.1 Intrinsics])
  470. intrinsics_support="$intrinsics_support SSE4.1"
  471. AS_IF([test x"$OPUS_X86_PRESUME_SSE4_1" = x"1"],
  472. [AC_DEFINE([OPUS_X86_PRESUME_SSE4_1], 1, [Define if binary requires SSE4.1 intrinsics support])],
  473. [rtcd_support="$rtcd_support SSE4.1"])
  474. ],
  475. [
  476. AC_MSG_WARN([Compiler does not support SSE4.1 intrinsics])
  477. ])
  478. AS_IF([test x"$intrinsics_support" = x""],
  479. [intrinsics_support=no],
  480. [intrinsics_support="x86$intrinsics_support"]
  481. )
  482. AS_IF([test x"$rtcd_support" = x""],
  483. [rtcd_support=no],
  484. [rtcd_support="x86$rtcd_support"],
  485. )
  486. AS_IF([test x"$enable_rtcd" = x"yes" && test x"$rtcd_support" != x""],[
  487. get_cpuid_by_asm="no"
  488. AC_MSG_CHECKING([How to get X86 CPU Info])
  489. AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  490. #include <stdio.h>
  491. ]],[[
  492. unsigned int CPUInfo0;
  493. unsigned int CPUInfo1;
  494. unsigned int CPUInfo2;
  495. unsigned int CPUInfo3;
  496. unsigned int InfoType;
  497. __asm__ __volatile__ (
  498. "cpuid":
  499. "=a" (CPUInfo0),
  500. "=b" (CPUInfo1),
  501. "=c" (CPUInfo2),
  502. "=d" (CPUInfo3) :
  503. "a" (InfoType), "c" (0)
  504. );
  505. ]])],
  506. [get_cpuid_by_asm="yes"
  507. AC_MSG_RESULT([Inline Assembly])
  508. AC_DEFINE([CPU_INFO_BY_ASM], [1], [Get CPU Info by asm method])],
  509. [AC_LINK_IFELSE([AC_LANG_PROGRAM([[
  510. #include <cpuid.h>
  511. ]],[[
  512. unsigned int CPUInfo0;
  513. unsigned int CPUInfo1;
  514. unsigned int CPUInfo2;
  515. unsigned int CPUInfo3;
  516. unsigned int InfoType;
  517. __get_cpuid(InfoType, &CPUInfo0, &CPUInfo1, &CPUInfo2, &CPUInfo3);
  518. ]])],
  519. [AC_MSG_RESULT([C method])
  520. AC_DEFINE([CPU_INFO_BY_C], [1], [Get CPU Info by c method])],
  521. [AC_MSG_ERROR([no supported Get CPU Info method, please disable intrinsics])])])])
  522. ],
  523. [
  524. AC_MSG_WARN([No intrinsics support for your architecture])
  525. intrinsics_support="no"
  526. ])
  527. ],
  528. [
  529. intrinsics_support="no"
  530. ])
  531. AM_CONDITIONAL([CPU_ARM], [test "$cpu_arm" = "yes"])
  532. AM_CONDITIONAL([OPUS_ARM_NEON_INTR],
  533. [test x"$OPUS_ARM_MAY_HAVE_NEON_INTR" = x"1"])
  534. AM_CONDITIONAL([HAVE_SSE],
  535. [test x"$OPUS_X86_MAY_HAVE_SSE" = x"1"])
  536. AM_CONDITIONAL([HAVE_SSE2],
  537. [test x"$OPUS_X86_MAY_HAVE_SSE2" = x"1"])
  538. AM_CONDITIONAL([HAVE_SSE4_1],
  539. [test x"$OPUS_X86_MAY_HAVE_SSE4_1" = x"1"])
  540. AS_IF([test x"$enable_rtcd" = x"yes"],[
  541. AS_IF([test x"$rtcd_support" != x"no"],[
  542. AC_DEFINE([OPUS_HAVE_RTCD], [1],
  543. [Use run-time CPU capabilities detection])
  544. OPUS_HAVE_RTCD=1
  545. AC_SUBST(OPUS_HAVE_RTCD)
  546. ])
  547. ],[
  548. rtcd_support="disabled"
  549. ])
  550. AC_ARG_ENABLE([assertions],
  551. [AS_HELP_STRING([--enable-assertions],[enable additional software error checking])],,
  552. [enable_assertions=no])
  553. AS_IF([test "$enable_assertions" = "yes"], [
  554. AC_DEFINE([ENABLE_ASSERTIONS], [1], [Assertions])
  555. ])
  556. AC_ARG_ENABLE([fuzzing],
  557. [AS_HELP_STRING([--enable-fuzzing],[causes the encoder to make random decisions])],,
  558. [enable_fuzzing=no])
  559. AS_IF([test "$enable_fuzzing" = "yes"], [
  560. AC_DEFINE([FUZZING], [1], [Fuzzing])
  561. ])
  562. AC_ARG_ENABLE([doc],
  563. [AS_HELP_STRING([--disable-doc], [Do not build API documentation])],,
  564. [enable_doc=yes])
  565. AS_IF([test "$enable_doc" = "yes"], [
  566. AC_CHECK_PROG(HAVE_DOXYGEN, [doxygen], [yes], [no])
  567. ],[
  568. HAVE_DOXYGEN=no
  569. ])
  570. AM_CONDITIONAL([HAVE_DOXYGEN], [test "$HAVE_DOXYGEN" = "yes"])
  571. AC_ARG_ENABLE([extra-programs],
  572. [AS_HELP_STRING([--disable-extra-programs], [Do not build extra programs (demo and tests)])],,
  573. [enable_extra_programs=yes])
  574. AM_CONDITIONAL([EXTRA_PROGRAMS], [test "$enable_extra_programs" = "yes"])
  575. saved_CFLAGS="$CFLAGS"
  576. CFLAGS="$CFLAGS -fvisibility=hidden"
  577. AC_MSG_CHECKING([if ${CC} supports -fvisibility=hidden])
  578. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[char foo;]])],
  579. [ AC_MSG_RESULT([yes]) ],
  580. [ AC_MSG_RESULT([no])
  581. CFLAGS="$saved_CFLAGS"
  582. ])
  583. CFLAGS="$CFLAGS -W"
  584. warn_CFLAGS="-Wall -Wextra -Wcast-align -Wnested-externs -Wshadow -Wstrict-prototypes"
  585. saved_CFLAGS="$CFLAGS"
  586. CFLAGS="$CFLAGS $warn_CFLAGS"
  587. AC_MSG_CHECKING([if ${CC} supports ${warn_CFLAGS}])
  588. AC_COMPILE_IFELSE([AC_LANG_SOURCE([[char foo;]])],
  589. [ AC_MSG_RESULT([yes]) ],
  590. [ AC_MSG_RESULT([no])
  591. CFLAGS="$saved_CFLAGS"
  592. ])
  593. saved_LIBS="$LIBS"
  594. LIBS="$LIBS $LIBM"
  595. AC_CHECK_FUNCS([lrintf])
  596. AC_CHECK_FUNCS([lrint])
  597. LIBS="$saved_LIBS"
  598. AC_CHECK_FUNCS([__malloc_hook])
  599. AC_SUBST([PC_BUILD])
  600. AC_CONFIG_FILES([
  601. Makefile
  602. opus.pc
  603. opus-uninstalled.pc
  604. celt/arm/armopts.s
  605. doc/Makefile
  606. doc/Doxyfile
  607. ])
  608. AC_CONFIG_HEADERS([config.h])
  609. AC_OUTPUT
  610. AC_MSG_NOTICE([
  611. ------------------------------------------------------------------------
  612. $PACKAGE_NAME $PACKAGE_VERSION: Automatic configuration OK.
  613. Compiler support:
  614. C99 var arrays: ................ ${has_var_arrays}
  615. C99 lrintf: .................... ${ac_cv_func_lrintf}
  616. Use alloca: .................... ${use_alloca}
  617. General configuration:
  618. Floating point support: ........ ${enable_float}
  619. Fast float approximations: ..... ${enable_float_approx}
  620. Fixed point debugging: ......... ${enable_fixed_point_debug}
  621. Inline Assembly Optimizations: . ${inline_optimization}
  622. External Assembly Optimizations: ${asm_optimization}
  623. Intrinsics Optimizations.......: ${intrinsics_support}
  624. Run-time CPU detection: ........ ${rtcd_support}
  625. Custom modes: .................. ${enable_custom_modes}
  626. Assertion checking: ............ ${enable_assertions}
  627. Fuzzing: ....................... ${enable_fuzzing}
  628. API documentation: ............. ${enable_doc}
  629. Extra programs: ................ ${enable_extra_programs}
  630. ------------------------------------------------------------------------
  631. Type "make; make install" to compile and install
  632. Type "make check" to run the test suite
  633. ])