configure.ac 9.5 KB

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