You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

359 lines
10KB

  1. # Copyright (C) 2002-2011 Erik de Castro Lopo (erikd AT mega-nerd DOT com).
  2. dnl Require autoconf version
  3. AC_PREREQ(2.57)
  4. AC_INIT([libsamplerate],[0.1.9],[erikd@mega-nerd.com],
  5. [libsamplerate],[http://www.mega-nerd.com/libsamplerate/])
  6. # Put config stuff in Cfg.
  7. AC_CONFIG_AUX_DIR(Cfg)
  8. AC_CONFIG_SRCDIR([src/samplerate.c])
  9. AC_CANONICAL_TARGET([])
  10. AC_CONFIG_MACRO_DIR([M4])
  11. AC_CONFIG_HEADERS([src/config.h])
  12. AM_INIT_AUTOMAKE($PACKAGE_NAME,$PACKAGE_VERSION)
  13. AM_SILENT_RULES([yes])
  14. dnl Add parameters for aclocal
  15. AC_SUBST(ACLOCAL_AMFLAGS, "-I M4")
  16. AC_LANG([C])
  17. AC_PROG_CC
  18. AM_PROG_CC_C_O
  19. AC_PROG_CXX
  20. AC_PROG_SED
  21. # Do not check for F77.
  22. define([AC_LIBTOOL_LANG_F77_CONFIG], [:])dnl
  23. AM_PROG_LIBTOOL
  24. LT_PROG_RC
  25. AC_PROG_INSTALL
  26. AC_PROG_LN_S
  27. #------------------------------------------------------------------------------------
  28. # Rules for library version information:
  29. #
  30. # 1. Start with version information of `0:0:0' for each libtool library.
  31. # 2. Update the version information only immediately before a public release of
  32. # your software. More frequent updates are unnecessary, and only guarantee
  33. # that the current interface number gets larger faster.
  34. # 3. If the library source code has changed at all since the last update, then
  35. # increment revision (`c:r:a' becomes `c:r+1:a').
  36. # 4. If any interfaces have been added, removed, or changed since the last update,
  37. # increment current, and set revision to 0.
  38. # 5. If any interfaces have been added since the last public release, then increment
  39. # age.
  40. # 6. If any interfaces have been removed since the last public release, then set age
  41. # to 0.
  42. SHARED_VERSION_INFO="1:8:1"
  43. AC_PROG_MAKE_SET
  44. AC_PROG_LN_S
  45. AC_PROG_MKDIR_P
  46. if test "x-$build_os-$host_os-$target_os" = x-mingw32-mingw32-mingw32 ; then
  47. AC_CHECK_PROG(DLLTOOL, dlltool, dlltool)
  48. AC_CHECK_PROG(DLLWRAP, dllwrap, dllwrap)
  49. AC_CHECK_PROG(PEXPORTS, pexports, pexports)
  50. fi
  51. AC_HEADER_STDC
  52. AC_CHECK_HEADERS(stdint.h sys/times.h)
  53. #====================================================================================
  54. # Couple of initializations here. Fill in real values later.
  55. SHLIB_VERSION_ARG=""
  56. #====================================================================================
  57. # Finished checking, handle options.
  58. AC_ARG_ENABLE(gcc-werror,
  59. AC_HELP_STRING([--enable-gcc-werror], [enable -Werror in all Makefiles]),
  60. ac_arg_gcc_werror=yes, ac_arg_gcc_werror=no)
  61. AC_ARG_ENABLE(gcc-pipe,
  62. AC_HELP_STRING([--disable-gcc-pipe], [disable gcc -pipe option ]),
  63. ac_arg_gcc_pipe="N", ac_arg_gcc_pipe="Y")
  64. AC_ARG_ENABLE(gcc-opt,
  65. AC_HELP_STRING([--disable-gcc-opt], [disable gcc optimisations ]),
  66. ac_arg_gcc_opt="N", ac_arg_gcc_opt="Y")
  67. AC_ARG_ENABLE(fftw,
  68. AC_HELP_STRING([--disable-fftw], [disable usage of FFTW ]),
  69. ac_arg_fftw="N", ac_arg_fftw="Y")
  70. AC_ARG_ENABLE(cpu-clip,
  71. AC_HELP_STRING([--disable-cpu-clip], [disable tricky cpu specific clipper]),
  72. ac_arg_cpu_clip="N", ac_arg_cpu_clip="Y")
  73. #====================================================================================
  74. # Check types and their sizes.
  75. AC_CHECK_SIZEOF(int,0)
  76. AC_CHECK_SIZEOF(long,0)
  77. AC_CHECK_SIZEOF(float,4)
  78. AC_CHECK_SIZEOF(double,8)
  79. #====================================================================================
  80. # Determine endian-ness of target processor.
  81. AC_C_FIND_ENDIAN
  82. AC_DEFINE_UNQUOTED(CPU_IS_BIG_ENDIAN, ${ac_cv_c_big_endian},
  83. [Target processor is big endian.])
  84. AC_DEFINE_UNQUOTED(CPU_IS_LITTLE_ENDIAN, ${ac_cv_c_little_endian},
  85. [Target processor is little endian.])
  86. #====================================================================================
  87. # Check for functions.
  88. AC_CHECK_FUNCS(malloc calloc free memcpy memmove alarm signal)
  89. AC_CHECK_LIB([m],floor)
  90. AC_CHECK_FUNCS(floor ceil fmod)
  91. AC_CHECK_SIGNAL(SIGALRM)
  92. AC_C99_FUNC_LRINT
  93. AC_C99_FUNC_LRINTF
  94. # AC_C99_FUNC_LLRINT Don't need this (yet?).
  95. case "x$ac_cv_c99_lrint$ac_cv_c99_lrintf" in
  96. xyesyes)
  97. ;;
  98. *)
  99. AC_MSG_WARN([[*** Missing C99 standard functions lrint() and lrintf().]])
  100. AC_MSG_WARN([[*** This may cause benign compiler warnings on some systems (ie Solaris).]])
  101. ;;
  102. esac
  103. #====================================================================================
  104. # Determine if the processor can do clipping on float to int conversions.
  105. if test x$ac_arg_cpu_clip = "xY" ; then
  106. AC_C_CLIP_MODE
  107. else
  108. echo "checking processor clipping capabilities... disabled"
  109. ac_cv_c_clip_positive=0
  110. ac_cv_c_clip_negative=0
  111. fi
  112. AC_DEFINE_UNQUOTED(CPU_CLIPS_POSITIVE, ${ac_cv_c_clip_positive},
  113. [Target processor clips on positive float to int conversion.])
  114. AC_DEFINE_UNQUOTED(CPU_CLIPS_NEGATIVE, ${ac_cv_c_clip_negative},
  115. [Target processor clips on negative float to int conversion.])
  116. #====================================================================================
  117. # Check for libsndfile which is required for the test and example programs.
  118. AC_ARG_ENABLE(sndfile,
  119. AC_HELP_STRING([--disable-sndfile], [disable support for sndfile (default=autodetect)]),
  120. [ enable_sndfile=$enableval ], [ enable_sndfile=yes ])
  121. # Check for pkg-config outside the if statement.
  122. PKG_PROG_PKG_CONFIG
  123. if test "x$enable_sndfile" = "xyes"; then
  124. PKG_CHECK_MODULES(SNDFILE, sndfile >= 1.0.6, ac_cv_sndfile=1, ac_cv_sndfile=0)
  125. else
  126. ac_cv_sndfile=0
  127. fi
  128. AC_DEFINE_UNQUOTED([HAVE_SNDFILE],$ac_cv_sndfile,[Set to 1 if you have libsndfile.])
  129. if test x$ac_cv_sndfile = x1 ; then
  130. ac_cv_sndfile=yes
  131. HAVE_SNDFILE=1
  132. else
  133. ac_cv_sndfile=no
  134. HAVE_SNDFILE=0
  135. fi
  136. #====================================================================================
  137. # Check for ALSA.
  138. ALSA_LIBS=""
  139. if test x$enable_alsa != xno ; then
  140. AC_CHECK_HEADERS(alsa/asoundlib.h)
  141. if test x$ac_cv_header_alsa_asoundlib_h = xyes ; then
  142. ALSA_LIBS="-lasound"
  143. enable_alsa=yes
  144. fi
  145. fi
  146. #====================================================================================
  147. # Check for libfftw3 which is required for the test and example programs.
  148. if test $ac_arg_fftw = "Y" ; then
  149. PKG_CHECK_MODULES(FFTW3, fftw3 >= 0.15.0, ac_cv_fftw3=1, ac_cv_fftw3=0)
  150. AC_DEFINE_UNQUOTED([HAVE_FFTW3],$ac_cv_fftw3,[Set to 1 if you have libfftw3.])
  151. if test x$ac_cv_fftw3 = x1 ; then
  152. ac_cv_fftw3=yes
  153. HAVE_FFTW3=1
  154. fi
  155. fi
  156. if test x$ac_cv_fftw3 != xyes ; then
  157. ac_cv_fftw3=no
  158. HAVE_FFTW3=0
  159. fi
  160. #====================================================================================
  161. # GCC stuff.
  162. if test $ac_cv_c_compiler_gnu = yes ; then
  163. CFLAGS="$CFLAGS -std=gnu99 -W -Wstrict-prototypes -Wmissing-prototypes -Wall -Waggregate-return -Wcast-align -Wcast-qual -Wnested-externs -Wshadow -Wpointer-arith"
  164. # -Wundef -Wbad-function-cast -Wmissing-declarations -Wconversion -Winline"
  165. if test "$ac_arg_gcc_opt" = "N" ; then
  166. temp_CFLAGS=`echo $CFLAGS | sed "s/O2/O0/"`
  167. CFLAGS=$temp_CFLAGS
  168. AC_MSG_WARN([[*** Compiler optimisations switched off. ***]])
  169. fi
  170. # Disable -Wall for Apple Darwin/Rhapsody.
  171. # System headers on these systems are broken.
  172. case "$target_os" in
  173. darwin* | rhapsody*)
  174. temp_CFLAGS=`echo $CFLAGS | sed "s/-Wall//"`
  175. CFLAGS=$temp_CFLAGS
  176. ;;
  177. linux*|kfreebsd*-gnu*|gnu*)
  178. SHLIB_VERSION_ARG="-Wl,--version-script=Version_script"
  179. ;;
  180. *)
  181. ;;
  182. esac
  183. if test x$ac_arg_gcc_pipe != "xN" ; then
  184. CFLAGS="$CFLAGS -pipe"
  185. fi
  186. if test x$ac_arg_gcc_werror = "xyes" ; then
  187. CFLAGS="-Werror $CFLAGS"
  188. fi
  189. AC_DEFINE([COMPILER_IS_GCC],1, [Set to 1 if the compile is GNU GCC.])
  190. GCC_MAJOR_VERSION=`$CC -dumpversion | sed "s/\..*//"`
  191. AC_DEFINE_UNQUOTED([GCC_MAJOR_VERSION],${GCC_MAJOR_VERSION}, [Major version of GCC or 3 otherwise.])
  192. fi
  193. #====================================================================================
  194. # Find known target OS.
  195. OS_SPECIFIC_INCLUDES=""
  196. os_is_win32=0
  197. case "$target_os" in
  198. darwin* | rhapsody*)
  199. OS_SPECIFIC_INCLUDES="-fpascal-strings -I/Developer/Headers/FlatCarbon"
  200. OS_SPECIFIC_LINKS="-framework CoreAudio"
  201. ;;
  202. mingw32*)
  203. OS_SPECIFIC_LINKS="-lwinmm"
  204. os_is_win32=1
  205. ;;
  206. *)
  207. OS_SPECIFIC_INCLUDES=""
  208. OS_SPECIFIC_LINKS=""
  209. ;;
  210. esac
  211. htmldocdir=$prefix/share/doc/libsamplerate0-dev/html
  212. if test $prefix = "NONE" ; then
  213. htmldocdir=/usr/local/share/doc/libsamplerate0-dev/html
  214. else
  215. htmldocdir=$prefix/share/doc/libsamplerate0-dev/html
  216. fi
  217. #====================================================================================
  218. # Now use the information from the checking stage.
  219. AC_DEFINE_UNQUOTED(OS_IS_WIN32, ${os_is_win32}, [Set to 1 if compiling for Win32])
  220. AC_SUBST(htmldocdir)
  221. AC_SUBST(SHLIB_VERSION_ARG)
  222. AC_SUBST(SHARED_VERSION_INFO)
  223. AC_SUBST(OS_SPECIFIC_INCLUDES)
  224. AC_SUBST(OS_SPECIFIC_LINKS)
  225. AC_SUBST(COMPILER_IS_GCC)
  226. AC_SUBST(GCC_MAJOR_VERSION)
  227. AC_SUBST(HAVE_FFTW3)
  228. AC_SUBST(FFTW3_CFLAGS)
  229. AC_SUBST(FFTW3_LIBS)
  230. AC_SUBST(HAVE_SNDFILE)
  231. AC_SUBST(SNDFILE_CFLAGS)
  232. AC_SUBST(SNDFILE_LIBS)
  233. AC_SUBST(ALSA_LIBS)
  234. AC_CONFIG_FILES([Makefile M4/Makefile src/Version_script \
  235. Win32/Makefile Win32/Makefile.mingw \
  236. src/Makefile examples/Makefile tests/Makefile doc/Makefile \
  237. libsamplerate.spec samplerate.pc])
  238. AC_OUTPUT
  239. #====================================================================================
  240. AC_MSG_RESULT([
  241. -=-=-=-=-=-=-=-=-=-= Configuration Complete =-=-=-=-=-=-=-=-=-=-=-
  242. Configuration summary :
  243. Version : ..................... ${VERSION}
  244. Host CPU : .................... ${host_cpu}
  245. Host Vendor : ................. ${host_vendor}
  246. Host OS : ..................... ${host_os}
  247. ])
  248. if test x$ac_cv_c_compiler_gnu = xyes ; then
  249. echo -e " Tools :\n"
  250. echo " Compiler is GCC : ............. ${ac_cv_c_compiler_gnu}"
  251. echo " GCC major version : ........... ${GCC_MAJOR_VERSION}"
  252. fi
  253. AC_MSG_RESULT([
  254. Extra tools required for testing and examples :
  255. Have FFTW : ................... ${ac_cv_fftw3}])
  256. AC_MSG_RESULT([ Have libsndfile : ............. ${ac_cv_sndfile}])
  257. AC_MSG_RESULT([ Have ALSA : ................... ${ac_cv_header_alsa_asoundlib_h}
  258. ])
  259. AC_MSG_RESULT([ Installation directories :
  260. Library directory : ........... ${prefix}/lib
  261. Program directory : ........... ${prefix}/bin
  262. Pkgconfig directory : ......... ${prefix}/lib/pkgconfig
  263. ])
  264. if test x$prefix != "x/usr" ; then
  265. echo "Compiling some other packages against ${PACKAGE} may require "
  266. echo -e "the addition of \"${prefix}/lib/pkgconfig\" to the "
  267. echo -e "PKG_CONFIG_PATH environment variable.\n"
  268. fi