configure.ac 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. #
  2. # iLBC - a library for the iLBC 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. #
  19. # $Id: configure.ac,v 1.1.1.1 2008/02/15 12:15:54 steveu Exp $
  20. # @start 1
  21. AC_INIT([ilbc], [0.0.1])
  22. CFLAGS="$CFLAGS $CONFIGURE_CFLAGS"
  23. CXXFLAGS="$CXXFLAGS $CONFIGURE_CXXFLAGS"
  24. LDFLAGS="$LDFLAGS $CONFIGURE_LDFLAGS"
  25. AC_DEFUN([AX_COMPILER_VENDOR],
  26. [
  27. AC_CACHE_CHECK([for _AC_LANG compiler vendor], ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor,
  28. [ax_cv_[]_AC_LANG_ABBREV[]_compiler_vendor=unknown
  29. # note: don't check for GCC first, since some other compilers define __GNUC__
  30. for ventest in intel:__ICC,__ECC,__INTEL_COMPILER ibm:__xlc__,__xlC__,__IBMC__,__IBMCPP__ gnu:__GNUC__ sun:__SUNPRO_C,__SUNPRO_CC hp:__HP_cc,__HP_aCC dec:__DECC,__DECCXX,__DECC_VER,__DECCXX_VER borland:__BORLANDC__,__TURBOC__ comeau:__COMO__ cray:_CRAYC kai:__KCC lcc:__LCC__ metrowerks:__MWERKS__ sgi:__sgi,sgi microsoft:_MSC_VER watcom:__WATCOMC__ portland:__PGI; do
  31. vencpp="defined("`echo $ventest | cut -d: -f2 | sed 's/,/) || defined(/g'`")"
  32. AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[
  33. #if !($vencpp)
  34. thisisanerror;
  35. #endif
  36. ])], [ax_cv_]_AC_LANG_ABBREV[_compiler_vendor=`echo $ventest | cut -d: -f1`; break])
  37. done
  38. ])
  39. ])
  40. ILBC_LT_CURRENT=0
  41. ILBC_LT_REVISION=2
  42. ILBC_LT_AGE=0
  43. AC_SUBST(ILBC_LT_CURRENT)
  44. AC_SUBST(ILBC_LT_REVISION)
  45. AC_SUBST(ILBC_LT_AGE)
  46. AC_CONFIG_SRCDIR([src/iLBC_encode.c])
  47. AC_CONFIG_AUX_DIR(config)
  48. AC_CONFIG_HEADERS([src/config.h:config-h.in])
  49. AM_INIT_AUTOMAKE
  50. AC_CANONICAL_HOST
  51. AC_CANONICAL_BUILD
  52. AC_PROG_CC
  53. AC_PROG_CXX
  54. AC_PROG_GCC_TRADITIONAL
  55. AC_PROG_LIBTOOL
  56. AC_PROG_INSTALL
  57. AC_LANG([C])
  58. AX_COMPILER_VENDOR
  59. if test "${build}" != "${host}"
  60. then
  61. # If we are doing a Canadian Cross, in which the host and build systems
  62. # are not the same, we set reasonable default values for the tools.
  63. CC=${CC-${host_alias}-gcc}
  64. CFLAGS=${CFLAGS-"-g -O2"}
  65. CXX=${CXX-${host_alias}-c++}
  66. CXXFLAGS=${CXXFLAGS-"-g -O2"}
  67. CC_FOR_BUILD=${CC_FOR_BUILD-gcc}
  68. else
  69. # Set reasonable default values for some tools even if not Canadian.
  70. # Of course, these are different reasonable default values, originally
  71. # specified directly in the Makefile.
  72. # We don't export, so that autoconf can do its job.
  73. # Note that all these settings are above the fragment inclusion point
  74. # in Makefile.in, so can still be overridden by fragments.
  75. # This is all going to change when we autoconfiscate...
  76. CC_FOR_BUILD="\$(CC)"
  77. AC_PROG_CC
  78. # We must set the default linker to the linker used by gcc for the correct
  79. # operation of libtool. If LD is not defined and we are using gcc, try to
  80. # set the LD default to the ld used by gcc.
  81. if test -z "$LD"
  82. then
  83. if test "$GCC" = yes
  84. then
  85. case $build in
  86. *-*-mingw*)
  87. gcc_prog_ld=`$CC -print-prog-name=ld 2>&1 | tr -d '\015'` ;;
  88. *)
  89. gcc_prog_ld=`$CC -print-prog-name=ld 2>&1` ;;
  90. esac
  91. case $gcc_prog_ld in
  92. # Accept absolute paths.
  93. [[\\/]* | [A-Za-z]:[\\/]*)]
  94. LD="$gcc_prog_ld" ;;
  95. esac
  96. fi
  97. fi
  98. CXX=${CXX-"c++"}
  99. CFLAGS=${CFLAGS-"-g -O2"}
  100. CXXFLAGS=${CXXFLAGS-"-g -O2"}
  101. fi
  102. AC_C_CONST
  103. AC_C_INLINE
  104. AC_C_VOLATILE
  105. AC_CHECK_TYPES(long long)
  106. AC_CHECK_TYPES(long double)
  107. AC_TYPE_SIGNAL
  108. AC_ARG_ENABLE(doc, [ --enable-doc Build the documentation])
  109. AC_ARG_ENABLE(tests, [ --enable-tests Build the test programs])
  110. AC_ARG_ENABLE(mmx, [ --enable-mmx Enable MMX support])
  111. AC_ARG_ENABLE(sse, [ --enable-sse Enable SSE support])
  112. AC_ARG_ENABLE(fixed_point, [ --enable-fixed-point Enable fixed point support])
  113. AC_FUNC_ERROR_AT_LINE
  114. AC_FUNC_VPRINTF
  115. AC_FUNC_MALLOC
  116. AC_FUNC_MEMCMP
  117. AC_FUNC_REALLOC
  118. AC_FUNC_SELECT_ARGTYPES
  119. AC_CHECK_FUNCS([memmove])
  120. AC_CHECK_FUNCS([memset])
  121. AC_CHECK_FUNCS([select])
  122. AC_CHECK_FUNCS([strcasecmp])
  123. AC_CHECK_FUNCS([strchr])
  124. AC_CHECK_FUNCS([strdup])
  125. AC_CHECK_FUNCS([strerror])
  126. AC_CHECK_FUNCS([strstr])
  127. AC_CHECK_FUNCS([strtol])
  128. AC_CHECK_FUNCS([gettimeofday])
  129. AC_HEADER_STDC
  130. AC_HEADER_SYS_WAIT
  131. AC_HEADER_TIME
  132. # Check for header files.
  133. AC_CHECK_HEADERS([socket.h])
  134. AC_CHECK_HEADERS([inttypes.h], [INSERT_INTTYPES_HEADER="#include <inttypes.h>"])
  135. AC_CHECK_HEADERS([stdint.h], [INSERT_STDINT_HEADER="#include <stdint.h>"])
  136. AC_CHECK_HEADERS([unistd.h])
  137. AC_CHECK_HEADERS([stdlib.h])
  138. AC_CHECK_HEADERS([string.h])
  139. AC_CHECK_HEADERS([strings.h])
  140. AC_CHECK_HEADERS([malloc.h])
  141. AC_CHECK_HEADERS([tgmath.h], [INSERT_TGMATH_HEADER="#include <tgmath.h>"])
  142. AC_CHECK_HEADERS([math.h], [INSERT_MATH_HEADER="#include <math.h>"])
  143. AC_CHECK_HEADERS([float.h])
  144. AC_CHECK_HEADERS([fcntl.h])
  145. AC_CHECK_HEADERS([sys/time.h])
  146. AC_CHECK_HEADERS([sys/select.h])
  147. AC_CHECK_HEADERS([sys/ioctl.h])
  148. AC_CHECK_HEADERS([sys/fcntl.h])
  149. AC_CHECK_HEADERS([audiofile.h])
  150. if test "${build}" = "${host}"
  151. then
  152. AC_CHECK_HEADERS([X11/X.h])
  153. fi
  154. AC_LANG([C++])
  155. if test "${build}" = "${host}"
  156. then
  157. case "${host}" in
  158. x86_64-*)
  159. AC_CHECK_FILE([${prefix}/lib64], libdir='$(exec_prefix)/lib64')
  160. ;;
  161. esac
  162. fi
  163. AC_LANG([C])
  164. if test "${build}" = "${host}"
  165. then
  166. case "${host}" in
  167. x86_64-*)
  168. # X86_64 Linux machines may have both 64 bit and 32 bit libraries. We need to choose the right set
  169. AC_CHECK_FILE([/usr/X11R6/lib64], [TESTLIBS="$TESTLIBS -L/usr/X11R6/lib64"], AC_CHECK_FILE([/usr/X11R6/lib], [TESTLIBS="$TESTLIBS -L/usr/X11R6/lib"]))
  170. ;;
  171. esac
  172. fi
  173. # Checks for libraries.
  174. AC_CHECK_LIB([m], [cos])
  175. AC_CHECK_LIB([m], [pow])
  176. AC_CHECK_LIB([m], [sqrt])
  177. if test -n "$enable_tests" ; then
  178. AC_LANG([C++])
  179. AC_LANG([C])
  180. 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?)"))
  181. AC_CHECK_LIB([fftw3], [fftw_plan_dft_1d], TESTLIBS="$TESTLIBS -lfftw3")
  182. AC_CHECK_LIB([fftw], [fftw_create_plan], TESTLIBS="$TESTLIBS -lfftw")
  183. fi
  184. AC_ARG_ENABLE([enable_64], [AS_HELP_STRING([--enable-64], [Enable 64bit compilation])], [enable_64="$enableval"], [enable_64="no"])
  185. case "${ax_cv_c_compiler_vendor}" in
  186. gnu)
  187. COMP_VENDOR_CFLAGS="-std=gnu99 -ffast-math -Wall -Wunused-variable -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes"
  188. if test "$enable_sse" = "yes" ; then
  189. COMP_VENDOR_CFLAGS="-msse $COMP_VENDOR_CFLAGS"
  190. fi
  191. if test "$enable_mmx" = "yes" ; then
  192. COMP_VENDOR_CFLAGS="-mmmx $COMP_VENDOR_CFLAGS"
  193. fi
  194. ;;
  195. sun)
  196. COMP_VENDOR_CFLAGS="-xc99=all -mt -xCC -D__FUNCTION__=__func__ -xvpara"
  197. if test "$enable_64" = "yes" ; then
  198. COMP_VENDOR_CFLAGS="-m64 $COMP_VENDOR_CFLAGS"
  199. fi
  200. ;;
  201. *)
  202. COMP_VENDOR_CFLAGS="-std=c99 -Wall -Wunused-variable -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes"
  203. ;;
  204. esac
  205. COMP_VENDOR_CFLAGS="-DNDEBUG $COMP_VENDOR_CFLAGS"
  206. AM_CONDITIONAL([COND_DOC], [test "$enable_doc" = yes])
  207. AM_CONDITIONAL([COND_TESTS], [test "$enable_tests" = yes])
  208. AM_CONDITIONAL([COND_MMX], [test "$enable_mmx" = yes])
  209. AM_CONDITIONAL([COND_SSE], [test "$enable_sse" = yes])
  210. if test "$enable_fixed_point" = "yes" ; then
  211. AC_DEFINE([ILBC_USE_FIXED_POINT], [1], [Enable fixed point processing, where possible, instead of floating point])
  212. ILBC_USE_FIXED_POINT="#define ILBC_USE_FIXED_POINT 1"
  213. else
  214. #
  215. # So far we deal with the embedded ARM, Blackfin, MIPS, TI DSP and XScale processors as
  216. # things which lack fast hardware floating point.
  217. #
  218. # Other candidates would be the small embedded Power PCs.
  219. #
  220. case $basic_machine in
  221. arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] \
  222. | bfin \
  223. | mips | mipsbe | mipseb | mipsel | mipsle \
  224. | tic54x | c54x* | tic55x | c55x* | tic6x | c6x* \
  225. | xscale | xscalee[bl] \
  226. | arm-* | armbe-* | armle-* | armeb-* | armv*-* \
  227. | bfin-* \
  228. | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
  229. | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
  230. | xscale-* | xscalee[bl]-* )
  231. AC_DEFINE([ILBC_USE_FIXED_POINT], [1], [Enable fixed point processing, where possible, instead of floating point])
  232. ILBC_USE_FIXED_POINT="#define ILBC_USE_FIXED_POINT 1"
  233. ;;
  234. *)
  235. ILBC_USE_FIXED_POINT="#undef ILBC_USE_FIXED_POINT"
  236. ;;
  237. esac
  238. fi
  239. AC_SUBST(CC_FOR_BUILD)
  240. AC_SUBST(COMP_VENDOR_CFLAGS)
  241. AC_SUBST(TESTLIBS)
  242. AC_SUBST(ILBC_USE_FIXED_POINT)
  243. AC_SUBST(INSERT_INTTYPES_HEADER)
  244. AC_SUBST(INSERT_STDINT_HEADER)
  245. AC_SUBST(INSERT_TGMATH_HEADER)
  246. AC_SUBST(INSERT_MATH_HEADER)
  247. AC_CONFIG_FILES([Makefile
  248. doc/Makefile
  249. localtests/Makefile
  250. src/Makefile
  251. src/ilbc.h
  252. tests/Makefile
  253. ilbc.spec])
  254. AC_OUTPUT
  255. # @end 1