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.

300 lines
11KB

  1. # Process this file with autoconf to produce a configure script.
  2. AC_INIT(RtAudio, 5.0.0, gary@music.mcgill.ca, rtaudio)
  3. AC_CONFIG_AUX_DIR(config)
  4. AC_CONFIG_SRCDIR(RtAudio.cpp)
  5. AC_CONFIG_FILES([rtaudio.pc Makefile tests/Makefile doc/Makefile doc/doxygen/Doxyfile])
  6. AM_INIT_AUTOMAKE([1.14 -Wall -Werror foreign subdir-objects])
  7. # libtool version: current:revision:age
  8. #
  9. # If the library source code has changed at all since the last update, then
  10. # increment revision (`c:r:a' becomes `c:r+1:a').
  11. #
  12. # If any interfaces have been added, removed, or changed since the last update,
  13. # increment current, and set revision to 0.
  14. #
  15. # If any interfaces have been added since the last public release, then
  16. # increment age.
  17. #
  18. # If any interfaces have been removed since the last public release, then set
  19. # age to 0.
  20. m4_define([lt_current], 6)
  21. m4_define([lt_revision], 0)
  22. m4_define([lt_age], 0)
  23. m4_define([lt_version_info], [lt_current:lt_revision:lt_age])
  24. m4_define([lt_current_minus_age], [m4_eval(lt_current - lt_age)])
  25. SO_VERSION=lt_version_info
  26. AC_SUBST(SO_VERSION)
  27. AC_SUBST(api)
  28. AC_SUBST(req)
  29. AC_SUBST(visibility)
  30. api=""
  31. req=""
  32. use_asio=""
  33. # configure flags
  34. AC_ARG_ENABLE(debug, [AS_HELP_STRING([--enable-debug],[enable various debug output])])
  35. AC_ARG_WITH(jack, [AS_HELP_STRING([--with-jack], [choose JACK server support])])
  36. AC_ARG_WITH(alsa, [AS_HELP_STRING([--with-alsa], [choose native ALSA API support (linux only)])])
  37. AC_ARG_WITH(pulse, [AS_HELP_STRING([--with-pulse], [choose PulseAudio API support (unixes)])])
  38. AC_ARG_WITH(oss, [AS_HELP_STRING([--with-oss], [choose OSS API support (unixes)])])
  39. AC_ARG_WITH(core, [AS_HELP_STRING([--with-core], [choose CoreAudio API support (mac only)])])
  40. AC_ARG_WITH(asio, [AS_HELP_STRING([--with-asio], [choose ASIO API support (win32 only)])])
  41. AC_ARG_WITH(ds, [AS_HELP_STRING([--with-ds], [choose DirectSound API support (win32 only)])])
  42. AC_ARG_WITH(wasapi, [AS_HELP_STRING([--with-wasapi], [choose Windows Audio Session API support (win32 only)])])
  43. # Check version number coherency between RtAudio.h and configure.ac
  44. AC_MSG_CHECKING([that version numbers are coherent])
  45. RTAUDIO_VERSION=`sed -n 's/#define RTAUDIO_VERSION "\(.*\)"/\1/p' $srcdir/RtAudio.h`
  46. AS_IF([test "x$RTAUDIO_VERSION" != "x$PACKAGE_VERSION"],[
  47. AC_MSG_RESULT([no])
  48. AC_MSG_FAILURE([testing RTAUDIO_VERSION==PACKAGE_VERSION failed, check that RtAudio.h defines RTAUDIO_VERSION as "$PACKAGE_VERSION" or that the first line of configure.ac has been updated.])
  49. ],[
  50. AC_MSG_RESULT([yes])
  51. ])
  52. # Enable some nice automake features if they are available
  53. m4_ifdef([AM_MAINTAINER_MODE], [AM_MAINTAINER_MODE])
  54. m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
  55. # Fill GXX with something before test.
  56. GXX="no"
  57. # if the user did not provide any CXXFLAGS, we can override them
  58. AS_IF([test "x$CXXFLAGS" = "x" ], [override_cxx=yes], [override_cxx=no])
  59. AS_IF([test "x$CFLAGS" = "x" ], [override_c=yes], [override_c=no])
  60. # Checks for programs.
  61. AC_PROG_CXX(g++ CC c++ cxx)
  62. AM_PROG_AR
  63. AC_PATH_PROG(AR, ar, no)
  64. AS_IF([test "x${AR}" = "xno" ], [
  65. AC_MSG_ERROR([Could not find ar - needed to create a library])
  66. ])
  67. # Initialize libtool
  68. LT_INIT([win32-dll])
  69. AC_CONFIG_MACRO_DIR([m4])
  70. # Checks for header files.
  71. AC_HEADER_STDC
  72. AC_CHECK_HEADERS(sys/ioctl.h unistd.h)
  73. # Check compiler and use -Wall if gnu
  74. AS_IF([test "x${GXX}" = "xyes" ], [
  75. CXXFLAGS="-Wall -Wextra ${CXXFLAGS}"
  76. AS_IF([ test "x${enable_debug}" = "xyes" ], [
  77. # Add -Werror in debug mode (except unused-function)
  78. CXXFLAGS="-Werror -Wno-error=unused-function ${CXXFLAGS}"
  79. ], [
  80. # hide private symbols in non-debug mode
  81. visibility="-fvisibility=hidden"
  82. ])
  83. ])
  84. # Check for debug
  85. AC_MSG_CHECKING([whether to compile debug version])
  86. debugflags=""
  87. AS_CASE([${enable_debug}],
  88. [ yes ], [
  89. AC_MSG_RESULT([yes])
  90. AC_DEFINE([__RTAUDIO_DEBUG__])
  91. debugflags="${debugflags} -g -O0"
  92. object_path=Debug
  93. ],
  94. [ no ], [
  95. AC_MSG_RESULT([no!])
  96. debugflags="${debugflags} -O3"
  97. ], [
  98. AC_MSG_RESULT([no])
  99. ])
  100. # For debugging and optimization ... overwrite default because it has both -g and -O2
  101. AS_IF([test "x$debugflags" != x],
  102. AS_IF([test "x$override_cxx" = "xyes" ], CXXFLAGS="$CXXFLAGS $debugflags", CXXFLAGS="$debugflags $CXXFLAGS")
  103. AS_IF([test "x$override_c" = "xyes" ], CFLAGS="$CFLAGS $debugflags", CFLAGS="$debugflags $CFLAGS")
  104. )
  105. # Checks for functions
  106. AC_CHECK_FUNC(gettimeofday, [cppflag="$cppflag -DHAVE_GETTIMEOFDAY"], )
  107. # Checks for doxygen
  108. AC_CHECK_PROG( DOXYGEN, [doxygen], [doxygen] )
  109. AM_CONDITIONAL( MAKE_DOC, [test "x${DOXYGEN}" != x ] )
  110. # Copy doc files to build dir if necessary
  111. AC_CONFIG_LINKS( [doc/release.txt:doc/release.txt] )
  112. AC_CONFIG_LINKS( [doc/doxygen/footer.html:doc/doxygen/footer.html] )
  113. AC_CONFIG_LINKS( [doc/doxygen/error.txt:doc/doxygen/error.txt] )
  114. AC_CONFIG_LINKS( [doc/doxygen/tutorial.txt:doc/doxygen/tutorial.txt] )
  115. AC_CONFIG_LINKS( [doc/doxygen/compiling.txt:doc/doxygen/compiling.txt] )
  116. AC_CONFIG_LINKS( [doc/doxygen/acknowledge.txt:doc/doxygen/acknowledge.txt] )
  117. AC_CONFIG_LINKS( [doc/doxygen/license.txt:doc/doxygen/license.txt] )
  118. AC_CONFIG_LINKS( [doc/doxygen/header.html:doc/doxygen/header.html] )
  119. AC_CONFIG_LINKS( [doc/doxygen/duplex.txt:doc/doxygen/duplex.txt] )
  120. AC_CONFIG_LINKS( [doc/doxygen/settings.txt:doc/doxygen/settings.txt] )
  121. AC_CONFIG_LINKS( [doc/doxygen/probe.txt:doc/doxygen/probe.txt] )
  122. AC_CONFIG_LINKS( [doc/doxygen/playback.txt:doc/doxygen/playback.txt] )
  123. AC_CONFIG_LINKS( [doc/doxygen/multi.txt:doc/doxygen/multi.txt] )
  124. AC_CONFIG_LINKS( [doc/doxygen/recording.txt:doc/doxygen/recording.txt] )
  125. AC_CONFIG_LINKS( [doc/doxygen/apinotes.txt:doc/doxygen/apinotes.txt] )
  126. AC_CONFIG_LINKS( [doc/images/mcgill.gif:doc/images/mcgill.gif] )
  127. AC_CONFIG_LINKS( [doc/images/ccrma.gif:doc/images/ccrma.gif] )
  128. # Checks for package options and external software
  129. AC_CANONICAL_HOST
  130. # Aggregate options into a single string.
  131. AS_IF([test "x$with_jack" = "xyes"], [systems="$systems jack"])
  132. AS_IF([test "x$with_alsa" = "xyes"], [systems="$systems alsa"])
  133. AS_IF([test "x$with_pulse" = "xyes"], [systems="$systems pulse"])
  134. AS_IF([test "x$with_oss" = "xyes"], [systems="$systems oss"])
  135. AS_IF([test "x$with_core" = "xyes"], [systems="$systems core"])
  136. AS_IF([test "x$with_asio" = "xyes"], [systems="$systems asio"])
  137. AS_IF([test "x$with_dsound" = "xyes"], [systems="$systems ds"])
  138. AS_IF([test "x$with_wasapi" = "xyes"], [systems="$systems wasapi"])
  139. required=" $systems "
  140. # If none, assign defaults if any are known for this OS.
  141. # User must specified with-* options for any unknown OS.
  142. AS_IF([test "x$systems" = "x"],
  143. AS_CASE([$host],
  144. [*-*-netbsd*], [systems="oss"],
  145. [*-*-freebsd*], [systems="oss"],
  146. [*-*-linux*], [systems="alsa pulse jack oss"],
  147. [*-apple*], [systems="core jack"],
  148. [*-mingw32*], [systems="asio ds wasapi jack"]
  149. ))
  150. # If any were specifically requested disabled, do it.
  151. AS_IF([test "x$with_jack" = "xno"], [systems=`echo $systems|tr ' ' \\\\n|grep -v jack`])
  152. AS_IF([test "x$with_alsa" = "xno"], [systems=`echo $systems|tr ' ' \\\\n|grep -v alsa`])
  153. AS_IF([test "x$with_pulse" = "xno"], [systems=`echo $systems|tr ' ' \\\\n|grep -v pulse`])
  154. AS_IF([test "x$with_oss" = "xno"], [systems=`echo $systems|tr ' ' \\\\n|grep -v oss`])
  155. AS_IF([test "x$with_core" = "xno"], [systems=`echo $systems|tr ' ' \\\\n|grep -v core`])
  156. AS_IF([test "x$with_asio" = "xno"], [systems=`echo $systems|tr ' ' \\\\n|grep -v asio`])
  157. AS_IF([test "x$with_dsound" = "xno"], [systems=`echo $systems|tr ' ' \\\\n|grep -v dsound`])
  158. AS_IF([test "x$with_wasapi" = "xno"], [systems=`echo $systems|tr ' ' \\\\n|grep -v wasapi`])
  159. systems=" `echo $systems|tr \\\\n ' '` "
  160. # For each audio system, check if it is selected and found.
  161. # Note: Order specified above is not necessarily respected. However,
  162. # *actual* priority is set at run-time, see RtAudio::openRtApi.
  163. # One AS_CASE per system, since they are not mutually-exclusive.
  164. AS_CASE(["$systems"], [*" alsa "*], [
  165. AC_CHECK_LIB(asound, snd_pcm_open,
  166. [api="$api -D__LINUX_ALSA__"
  167. req="$req alsa"
  168. need_pthread=yes
  169. found="$found ALSA"
  170. LIBS="-lasound $LIBS"],
  171. AS_CASE(["$required"], [*" alsa "*],
  172. AC_MSG_ERROR([ALSA support requires the asound library!])))
  173. ])
  174. AS_CASE(["$systems"], [*" pulse "*], [
  175. AC_CHECK_LIB(pulse-simple, pa_simple_flush,
  176. [api="$api -D__LINUX_PULSE__"
  177. req="$req libpulse-simple"
  178. need_pthread=yes
  179. found="$found PulseAudio"
  180. LIBS="-lpulse-simple $LIBS"],
  181. AS_CASE(["$required"], [*" pulse "*],
  182. AC_MSG_ERROR([PulseAudio support requires the pulse-simple library!])))
  183. ])
  184. AS_CASE(["$systems"], [*" oss "*], [
  185. # libossaudio not required on some platforms (e.g. linux) so we
  186. # don't break things if it's not found, but issue a warning when we
  187. # are not sure (i.e. not on linux)
  188. AS_CASE([$host], [*-*-linux*], [], [*], [need_ossaudio=yes])
  189. AC_CHECK_LIB(ossaudio, main, [have_ossaudio=true],
  190. AS_CASE(["$required"], [*" oss "*],
  191. AS_IF([test "x$need_ossaudio" = xyes],
  192. AC_MSG_WARN([RtAudio may require the ossaudio library]))))
  193. # linux systems may have soundcard.h but *not* have OSS4 installed,
  194. # we have to actually check if it exports OSS4 symbols
  195. AC_CHECK_DECL(SNDCTL_SYSINFO,
  196. [api="$api -D__LINUX_OSS__"
  197. need_pthread=yes
  198. found="$found OSS"],
  199. AS_CASE(["$required"], [*" oss "*],
  200. AC_MSG_ERROR([sys/soundcard.h not found]))
  201. [],
  202. [#include <sys/soundcard.h>])
  203. ])
  204. AS_CASE(["$systems"], [*" jack "*], [
  205. AC_CHECK_LIB(jack, jack_client_open,
  206. [api="$api -D__UNIX_JACK__"
  207. req="$req jack"
  208. need_pthread=yes
  209. found="$found JACK"
  210. LIBS="-ljack $LIBS"],
  211. AS_CASE(["$required"], [*" jack "*],
  212. AC_MSG_ERROR([JACK support requires the jack library!])))
  213. ])
  214. AS_CASE(["$systems"], [*" core "*], [
  215. AC_CHECK_HEADER(CoreAudio/CoreAudio.h,
  216. [api="$api -D__MACOSX_CORE__"
  217. need_pthread=yes
  218. found="$found CoreAudio",
  219. LIBS="$LIBS -framework CoreAudio -framework CoreFoundation"],
  220. AS_CASE(["$required"], [*" core "*],
  221. AC_MSG_ERROR([CoreAudio header files not found!])))
  222. ])
  223. AS_CASE(["$systems"], [*" asio "*], [
  224. api="$api -D__WINDOWS_ASIO__"
  225. use_asio=yes
  226. CPPFLAGS="-I$srcdir/include $CPPFLAGS"
  227. need_ole32=yes
  228. found="$found ASIO"
  229. ])
  230. AS_CASE(["$systems"], [*" ds "*], [
  231. AC_CHECK_HEADERS(mmsystem.h mmreg.h dsound.h,
  232. [api="$api -D__WINDOWS_DS__"
  233. need_ole32=yes
  234. found="$found DirectSound"
  235. LIBS="-ldsound -lwinmm $LIBS"])
  236. ])
  237. AS_CASE(["$systems"], [*" wasapi "*], [
  238. AC_CHECK_HEADERS(windows.h audioclient.h avrt.h mmdeviceapi.h,
  239. [api="$api -D__WINDOWS_WASAPI__"
  240. CPPFLAGS="-I$srcdir/include $CPPFLAGS"
  241. need_ole32=yes
  242. found="$found WASAPI"
  243. LIBS="-lwinmm -lksuser -lmfplat -lmfuuid -lwmcodecdspuuid $LIBS"])
  244. ])
  245. AS_IF([test -n "$need_ole32"], [LIBS="-lole32 $LIBS"])
  246. AS_IF([test -n "$need_pthread"],[
  247. AC_MSG_CHECKING([for pthread])
  248. AC_CHECK_LIB(pthread, pthread_create, ,
  249. AC_MSG_ERROR([RtAudio requires the pthread library!]))])
  250. AC_MSG_CHECKING([for audio API])
  251. # Error case: no known realtime systems found.
  252. AS_IF([test x"$api" = "x"], [
  253. AC_MSG_RESULT([none])
  254. AC_MSG_ERROR([No known system type found for realtime support!])
  255. ], [
  256. AC_MSG_RESULT([$found])
  257. ])
  258. AM_CONDITIONAL( ASIO, [test "x${use_asio}" = "xyes" ])
  259. CPPFLAGS="$CPPFLAGS $api"
  260. AC_OUTPUT