configure.ac 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378
  1. #
  2. # g722_1 - a library for the G.722_1 codec
  3. #
  4. # configure.ac -- Process this file with autoconf to produce configure
  5. #
  6. # This program is free software; you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License version 2, as
  8. # published by the Free Software Foundation.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. # @start 1
  19. AC_INIT([g722_1], [0.2.0])
  20. m4_include(config/ax_compiler_vendor.m4)
  21. m4_include(config/ax_check_real_file.m4)
  22. m4_include(config/ax_fixed_point_machine.m4)
  23. m4_include(config/ax_misaligned_access_fails.m4)
  24. m4_include(config/ax_c99_features.m4)
  25. G722_1_MAJOR_VERSION=0
  26. G722_1_MINOR_VERSION=0
  27. G722_1_MICRO_VERSION=1
  28. G722_1_LT_CURRENT=0
  29. G722_1_LT_REVISION=2
  30. G722_1_LT_AGE=0
  31. VERSION=$G722_1_MAJOR_VERSION.$G722_1_MINOR_VERSION.$G722_1_MICRO_VERSION
  32. PACKAGE=g722_1
  33. AC_SUBST(G722_1_LT_CURRENT)
  34. AC_SUBST(G722_1_LT_REVISION)
  35. AC_SUBST(G722_1_LT_AGE)
  36. AC_CONFIG_SRCDIR([src/encoder.c])
  37. AC_CONFIG_AUX_DIR(config)
  38. AC_CONFIG_HEADERS([src/config.h:config-h.in])
  39. AM_INIT_AUTOMAKE
  40. AC_CANONICAL_HOST
  41. #AC_CANONICAL_BUILD
  42. AC_PROG_CC
  43. AC_PROG_CXX
  44. AC_PROG_GCC_TRADITIONAL
  45. AC_PROG_LIBTOOL
  46. AC_LANG([C])
  47. AX_COMPILER_VENDOR
  48. if test "${build}" != "${host}"
  49. then
  50. # If we are doing a Canadian Cross, in which the host and build systems
  51. # are not the same, we set reasonable default values for the tools.
  52. CC_FOR_BUILD=${CC_FOR_BUILD-gcc}
  53. CPPFLAGS_FOR_BUILD="\$(CPPFLAGS)"
  54. CC=${CC-${host_alias}-gcc}
  55. CFLAGS=${CFLAGS-"-g -O2"}
  56. CXX=${CXX-${host_alias}-c++}
  57. CXXFLAGS=${CXXFLAGS-"-g -O2"}
  58. else
  59. # Set reasonable default values for some tools even if not Canadian.
  60. # Of course, these are different reasonable default values, originally
  61. # specified directly in the Makefile.
  62. # We don't export, so that autoconf can do its job.
  63. # Note that all these settings are above the fragment inclusion point
  64. # in Makefile.in, so can still be overridden by fragments.
  65. # This is all going to change when we autoconfiscate...
  66. CC_FOR_BUILD="\$(CC)"
  67. CPPFLAGS_FOR_BUILD="\$(CPPFLAGS)"
  68. AC_PROG_CC
  69. # We must set the default linker to the linker used by gcc for the correct
  70. # operation of libtool. If LD is not defined and we are using gcc, try to
  71. # set the LD default to the ld used by gcc.
  72. if test -z "$LD"
  73. then
  74. if test "$GCC" = yes
  75. then
  76. case $build in
  77. *-*-mingw*)
  78. gcc_prog_ld=`$CC -print-prog-name=ld 2>&1 | tr -d '\015'` ;;
  79. *)
  80. gcc_prog_ld=`$CC -print-prog-name=ld 2>&1` ;;
  81. esac
  82. case $gcc_prog_ld in
  83. # Accept absolute paths.
  84. [[\\/]* | [A-Za-z]:[\\/]*)]
  85. LD="$gcc_prog_ld" ;;
  86. esac
  87. fi
  88. fi
  89. CXX=${CXX-"c++"}
  90. CFLAGS=${CFLAGS-"-g -O2"}
  91. CXXFLAGS=${CXXFLAGS-"-g -O2"}
  92. fi
  93. AC_DEFUN([REMOVE_FROM_VAR],[
  94. new_val=""
  95. removed=0
  96. for i in $$1; do
  97. if test "x$i" != "x$2"; then
  98. new_val="$new_val $i"
  99. else
  100. removed=1
  101. fi
  102. done
  103. if test $removed = "1"; then
  104. echo " removed \"$2\" from $1"
  105. $1=$new_val
  106. fi
  107. ])
  108. AC_C_CONST
  109. AC_C_INLINE
  110. AC_C_VOLATILE
  111. AC_CHECK_TYPES(long long)
  112. AC_CHECK_TYPES(long double)
  113. AC_TYPE_SIGNAL
  114. AC_ARG_ENABLE(doc, [ --enable-doc Build the documentation])
  115. AC_ARG_ENABLE(tests, [ --enable-tests Build the test programs])
  116. AC_ARG_ENABLE(mmx, [ --enable-mmx Enable MMX support])
  117. AC_ARG_ENABLE(sse, [ --enable-sse Enable SSE support])
  118. AC_ARG_ENABLE(sse2, [ --enable-sse2 Enable SSE2 support])
  119. AC_ARG_ENABLE(sse3, [ --enable-sse3 Enable SSE3 support])
  120. AC_ARG_ENABLE(sse3, [ --enable-sse3 Enable SSE3 support])
  121. AC_ARG_ENABLE(sse4_1, [ --enable-sse4-1 Enable SSE4.1 support])
  122. AC_ARG_ENABLE(sse4_2, [ --enable-sse4-2 Enable SSE4.2 support])
  123. AC_ARG_ENABLE(sse4a, [ --enable-sse4a Enable SSE4A support])
  124. AC_ARG_ENABLE(sse5, [ --enable-sse5 Enable SSE5 support])
  125. AC_ARG_ENABLE(fixed_point, [ --enable-fixed-point Enable fixed point support])
  126. AC_FUNC_ERROR_AT_LINE
  127. AC_FUNC_VPRINTF
  128. AC_FUNC_MALLOC
  129. AC_FUNC_MEMCMP
  130. AC_FUNC_REALLOC
  131. AC_FUNC_SELECT_ARGTYPES
  132. AX_C99_FUNC_LRINT
  133. AX_C99_FUNC_LRINTF
  134. AX_C99_FUNC_LLRINT
  135. AX_C99_FUNC_LLRINTF
  136. if test "x$ac_cv_c99_lrint" = "xno" ; then
  137. if test "x$ac_cv_c99_lrintf" = "xno" ; then
  138. AC_MSG_WARN([[*** Missing C99 standard functions lrint() and lrintf().]])
  139. AC_MSG_WARN([[*** This may cause benign compiler warnings on some systems (ie Solaris).]])
  140. fi
  141. fi
  142. AX_C99_FLEXIBLE_ARRAY
  143. AC_CHECK_FUNCS([memmove])
  144. AC_CHECK_FUNCS([memset])
  145. AC_CHECK_FUNCS([select])
  146. AC_CHECK_FUNCS([strcasecmp])
  147. AC_CHECK_FUNCS([strchr])
  148. AC_CHECK_FUNCS([strdup])
  149. AC_CHECK_FUNCS([strerror])
  150. AC_CHECK_FUNCS([strstr])
  151. AC_CHECK_FUNCS([strtol])
  152. AC_CHECK_FUNCS([gettimeofday])
  153. AC_HEADER_STDC
  154. AC_HEADER_SYS_WAIT
  155. AC_HEADER_TIME
  156. # Check for header files.
  157. AC_CHECK_HEADERS([socket.h])
  158. AC_CHECK_HEADERS([inttypes.h], [INSERT_INTTYPES_HEADER="#include <inttypes.h>"])
  159. AC_CHECK_HEADERS([stdint.h], [INSERT_STDINT_HEADER="#include <stdint.h>"])
  160. AC_CHECK_HEADERS([unistd.h])
  161. AC_CHECK_HEADERS([stdlib.h])
  162. AC_CHECK_HEADERS([string.h])
  163. AC_CHECK_HEADERS([strings.h])
  164. AC_CHECK_HEADERS([malloc.h])
  165. AC_CHECK_HEADERS([tgmath.h], [INSERT_TGMATH_HEADER="#include <tgmath.h>"])
  166. AC_CHECK_HEADERS([math.h], [INSERT_MATH_HEADER="#include <math.h>"])
  167. AC_CHECK_HEADERS([float.h])
  168. AC_CHECK_HEADERS([fcntl.h])
  169. AC_CHECK_HEADERS([sys/time.h])
  170. AC_CHECK_HEADERS([sys/select.h])
  171. AC_CHECK_HEADERS([sys/ioctl.h])
  172. AC_CHECK_HEADERS([sys/fcntl.h])
  173. AC_CHECK_HEADERS([audiofile.h])
  174. AC_LANG([C])
  175. if test "${build}" = "${host}"
  176. then
  177. case "${host}" in
  178. x86_64-*)
  179. AX_CHECK_REAL_FILE([${prefix}/lib64], libdir='$(exec_prefix)/lib64')
  180. ;;
  181. esac
  182. fi
  183. # Checks for libraries.
  184. AC_CHECK_LIB([m], [cos])
  185. # Some platforms still seem to lack the basic single precision trig and power related function.
  186. AC_SEARCH_LIBS([sinf], [m], AC_DEFINE([HAVE_SINF], [1], [Define to 1 if you have the sinf() function.]))
  187. AC_SEARCH_LIBS([cosf], [m], AC_DEFINE([HAVE_COSF], [1], [Define to 1 if you have the cosf() function.]))
  188. AC_SEARCH_LIBS([tanf], [m], AC_DEFINE([HAVE_TANF], [1], [Define to 1 if you have the tanf() function.]))
  189. AC_SEARCH_LIBS([asinf], [m], AC_DEFINE([HAVE_ASINF], [1], [Define to 1 if you have the asinf() function.]))
  190. AC_SEARCH_LIBS([acosf], [m], AC_DEFINE([HAVE_ACOSF], [1], [Define to 1 if you have the acosf() function.]))
  191. AC_SEARCH_LIBS([atanf], [m], AC_DEFINE([HAVE_ATANF], [1], [Define to 1 if you have the atanf() function.]))
  192. AC_SEARCH_LIBS([atan2f], [m], AC_DEFINE([HAVE_ATAN2F], [1], [Define to 1 if you have the atan2f() function.]))
  193. AC_SEARCH_LIBS([ceilf], [m], AC_DEFINE([HAVE_CEILF], [1], [Define to 1 if you have the ceilf() function.]))
  194. AC_SEARCH_LIBS([floorf], [m], AC_DEFINE([HAVE_FLOORF], [1], [Define to 1 if you have the floorf() function.]))
  195. AC_SEARCH_LIBS([powf], [m], AC_DEFINE([HAVE_POWF], [1], [Define to 1 if you have the powf() function.]))
  196. AC_SEARCH_LIBS([expf], [m], AC_DEFINE([HAVE_EXPF], [1], [Define to 1 if you have the expf() function.]))
  197. AC_SEARCH_LIBS([logf], [m], AC_DEFINE([HAVE_LOGF], [1], [Define to 1 if you have the logf() function.]))
  198. AC_SEARCH_LIBS([log10f], [m], AC_DEFINE([HAVE_LOG10F], [1], [Define to 1 if you have the log10f() function.]))
  199. if test -n "$enable_tests" ; then
  200. AC_CHECK_LIB([audiofile], [afOpenFile], TESTLIBS="$TESTLIBS -laudiofile", AC_MSG_ERROR("Can't make tests without libaudiofile (does your system require a libaudiofile-devel package?)"))
  201. fi
  202. case "${ax_cv_c_compiler_vendor}" in
  203. gnu)
  204. COMP_VENDOR_CFLAGS="-std=gnu99 -ffast-math -Wall -Wunused-variable -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes"
  205. if test "$enable_sse5" = "yes" ; then
  206. COMP_VENDOR_CFLAGS="-msse5 $COMP_VENDOR_CFLAGS"
  207. fi
  208. if test "$enable_sse4a" = "yes" ; then
  209. COMP_VENDOR_CFLAGS="-msse4a $COMP_VENDOR_CFLAGS"
  210. fi
  211. if test "$enable_sse4_2" = "yes" ; then
  212. COMP_VENDOR_CFLAGS="-msse42 $COMP_VENDOR_CFLAGS"
  213. fi
  214. if test "$enable_sse4_1" = "yes" ; then
  215. COMP_VENDOR_CFLAGS="-msse41 $COMP_VENDOR_CFLAGS"
  216. fi
  217. if test "$enable_sse3" = "yes" ; then
  218. COMP_VENDOR_CFLAGS="-msse3 $COMP_VENDOR_CFLAGS"
  219. fi
  220. if test "$enable_sse2" = "yes" ; then
  221. COMP_VENDOR_CFLAGS="-msse2 $COMP_VENDOR_CFLAGS"
  222. fi
  223. if test "$enable_sse" = "yes" ; then
  224. COMP_VENDOR_CFLAGS="-msse $COMP_VENDOR_CFLAGS"
  225. fi
  226. if test "$enable_mmx" = "yes" ; then
  227. COMP_VENDOR_CFLAGS="-mmmx $COMP_VENDOR_CFLAGS"
  228. fi
  229. case $host_os in
  230. mingw* | cygwin*)
  231. COMP_VENDOR_LDFLAGS="-no-undefined"
  232. ;;
  233. *)
  234. COMP_VENDOR_LDFLAGS=
  235. ;;
  236. esac
  237. ;;
  238. sun)
  239. COMP_VENDOR_CFLAGS="-xc99=all -mt -xCC -errwarn=%all -xvpara"
  240. if test "$enable_sse3" = "yes" ; then
  241. COMP_VENDOR_CFLAGS="-native -fast $COMP_VENDOR_CFLAGS"
  242. fi
  243. if test "$enable_sse2" = "yes" ; then
  244. COMP_VENDOR_CFLAGS="-native -fast $COMP_VENDOR_CFLAGS"
  245. fi
  246. if test "$enable_sse" = "yes" ; then
  247. COMP_VENDOR_CFLAGS="-native -fast $COMP_VENDOR_CFLAGS"
  248. fi
  249. if test "$enable_mmx" = "yes" ; then
  250. COMP_VENDOR_CFLAGS="-native -fast $COMP_VENDOR_CFLAGS"
  251. fi
  252. COMP_VENDOR_LDFLAGS=
  253. REMOVE_FROM_VAR(CFLAGS, -Xc)
  254. ;;
  255. *)
  256. COMP_VENDOR_CFLAGS="-std=c99 -Wall -Wunused-variable -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes"
  257. COMP_VENDOR_LDFLAGS=
  258. ;;
  259. esac
  260. COMP_VENDOR_CFLAGS="-DNDEBUG $COMP_VENDOR_CFLAGS"
  261. AM_CONDITIONAL([COND_DOC], [test "$enable_doc" = yes])
  262. AM_CONDITIONAL([COND_TESTS], [test "$enable_tests" = yes])
  263. AM_CONDITIONAL([COND_TESTDATA], [test "$enable_test_data" = yes])
  264. AM_CONDITIONAL([COND_MMX], [test "$enable_mmx" = yes])
  265. AM_CONDITIONAL([COND_SSE], [test "$enable_sse" = yes])
  266. AM_CONDITIONAL([COND_SSE2], [test "$enable_sse2" = yes])
  267. AM_CONDITIONAL([COND_SSE3], [test "$enable_sse3" = yes])
  268. AM_CONDITIONAL([COND_SSE4_1], [test "$enable_sse4_1" = yes])
  269. AM_CONDITIONAL([COND_SSE4_2], [test "$enable_sse4_2" = yes])
  270. AM_CONDITIONAL([COND_SSE4A], [test "$enable_sse4a" = yes])
  271. AM_CONDITIONAL([COND_SSE5], [test "$enable_sse5" = yes])
  272. if test "$enable_fixed_point" = "yes" ; then
  273. AC_DEFINE([G722_1_USE_FIXED_POINT], [1], [Enable fixed point processing, where possible, instead of floating point])
  274. G722_1_USE_FIXED_POINT="#define G722_1_USE_FIXED_POINT 1"
  275. G722_1_VECTORS_FOR_TESTS="fixed"
  276. else
  277. AX_FIXED_POINT_MACHINE([$host],
  278. [AC_DEFINE([G722_1_USE_FIXED_POINT], [1], [Enable fixed point processing, where possible, instead of floating point])
  279. G722_1_USE_FIXED_POINT="#define G722_1_USE_FIXED_POINT 1"],
  280. [G722_1_USE_FIXED_POINT="#undef G722_1_USE_FIXED_POINT"])
  281. G722_1_VECTORS_FOR_TESTS="floating"
  282. fi
  283. AX_MISALIGNED_ACCESS_FAILS([$host],
  284. [AC_DEFINE([G722_1_MISALIGNED_ACCESS_FAILS], [1], [Do not expect a misaligned memory access to work correctly])
  285. G722_1_MISALIGNED_ACCESS_FAILS="#define G722_1_MISALIGNED_ACCESS_FAILS 1"],
  286. [G722_1_MISALIGNED_ACCESS_FAILS="#undef G722_1_MISALIGNED_ACCESS_FAILS"])
  287. if test "$enable_sse5" = "yes" ; then
  288. AC_DEFINE([SPANDSP_USE_SSE5], [1], [Use the SSE5 instruction set (i386 and x86_64 only).])
  289. enable_sse4a="yes"
  290. fi
  291. if test "$enable_sse4a" = "yes" ; then
  292. AC_DEFINE([SPANDSP_USE_SSE4A], [1], [Use the SSE4A instruction set (i386 and x86_64 only).])
  293. enable_sse4_2="yes"
  294. fi
  295. if test "$enable_sse4_2" = "yes" ; then
  296. AC_DEFINE([SPANDSP_USE_SSE4_2], [1], [Use the SSE4.2 instruction set (i386 and x86_64 only).])
  297. enable_sse4_1="yes"
  298. fi
  299. if test "$enable_sse4_1" = "yes" ; then
  300. AC_DEFINE([SPANDSP_USE_SSE4_1], [1], [Use the SSE4.1 instruction set (i386 and x86_64 only).])
  301. enable_sse3="yes"
  302. fi
  303. if test "$enable_sse3" = "yes" ; then
  304. AC_DEFINE([SPANDSP_USE_SSE3], [1], [Use the SSE3 instruction set (i386 and x86_64 only).])
  305. enable_sse2="yes"
  306. fi
  307. if test "$enable_sse2" = "yes" ; then
  308. AC_DEFINE([SPANDSP_USE_SSE2], [1], [Use the SSE2 instruction set (i386 and x86_64 only).])
  309. enable_sse="yes"
  310. fi
  311. if test "$enable_sse" = "yes" ; then
  312. AC_DEFINE([SPANDSP_USE_SSE], [1], [Use the SSE instruction set (i386 and x86_64 only).])
  313. enable_mmx="yes"
  314. fi
  315. if test "$enable_mmx" = "yes" ; then
  316. AC_DEFINE([SPANDSP_USE_MMX], [1], [Use the MMX instruction set (i386 and x86_64 only).])
  317. fi
  318. AC_SUBST(CC_FOR_BUILD)
  319. AC_SUBST(COMP_VENDOR_CFLAGS)
  320. AC_SUBST(COMP_VENDOR_LDFLAGS)
  321. AC_SUBST(TESTLIBS)
  322. AC_SUBST(G722_1_USE_FIXED_POINT)
  323. AC_SUBST(G722_1_VECTORS_FOR_TESTS)
  324. AC_SUBST(INSERT_INTTYPES_HEADER)
  325. AC_SUBST(INSERT_STDINT_HEADER)
  326. AC_SUBST(INSERT_TGMATH_HEADER)
  327. AC_SUBST(INSERT_MATH_HEADER)
  328. AC_CONFIG_FILES([Makefile
  329. doc/Makefile
  330. test-data/Makefile
  331. test-data/local/Makefile
  332. test-data/itu/Makefile
  333. src/Makefile
  334. src/g722_1.h
  335. tests/Makefile
  336. g722_1.pc
  337. g722_1.spec])
  338. AC_CONFIG_FILES([tests/regression_tests.sh], [chmod +x tests/regression_tests.sh])
  339. AC_OUTPUT
  340. # @end 1