configure.ac 14 KB

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