configure.ac 9.6 KB

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