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])
8 # libtool version: current:revision:age
10 # If the library source code has changed at all since the last update, then
11 # increment revision (`c:r:a' becomes `c:r+1:a').
13 # If any interfaces have been added, removed, or changed since the last update,
14 # increment current, and set revision to 0.
16 # If any interfaces have been added since the last public release, then
19 # If any interfaces have been removed since the last public release, then set
21 m4_define([lt_current], 6)
22 m4_define([lt_revision], 0)
23 m4_define([lt_age], 0)
25 m4_define([lt_version_info], [lt_current:lt_revision:lt_age])
26 m4_define([lt_current_minus_age], [m4_eval(lt_current - lt_age)])
28 SO_VERSION=lt_version_info
40 AC_ARG_ENABLE(debug, [AS_HELP_STRING([--enable-debug],[enable various debug output])])
41 AC_ARG_WITH(jack, [AS_HELP_STRING([--with-jack], [choose JACK server support])])
42 AC_ARG_WITH(alsa, [AS_HELP_STRING([--with-alsa], [choose native ALSA API support (linux only)])])
43 AC_ARG_WITH(pulse, [AS_HELP_STRING([--with-pulse], [choose PulseAudio API support (unixes)])])
44 AC_ARG_WITH(oss, [AS_HELP_STRING([--with-oss], [choose OSS API support (unixes)])])
45 AC_ARG_WITH(core, [AS_HELP_STRING([--with-core], [choose CoreAudio API support (mac only)])])
46 AC_ARG_WITH(asio, [AS_HELP_STRING([--with-asio], [choose ASIO API support (win32 only)])])
47 AC_ARG_WITH(ds, [AS_HELP_STRING([--with-ds], [choose DirectSound API support (win32 only)])])
48 AC_ARG_WITH(wasapi, [AS_HELP_STRING([--with-wasapi], [choose Windows Audio Session API support (win32 only)])])
50 # Check version number coherency between RtAudio.h and configure.ac
51 AC_MSG_CHECKING([that version numbers are coherent])
52 RTAUDIO_VERSION=`sed -n 's/#define RTAUDIO_VERSION "\(.*\)"/\1/p' $srcdir/RtAudio.h`
53 AS_IF([test "x$RTAUDIO_VERSION" != "x$PACKAGE_VERSION"],[
55 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.])
59 # Enable some nice automake features if they are available
60 m4_ifdef([AM_MAINTAINER_MODE], [AM_MAINTAINER_MODE])
61 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
63 # Fill GXX with something before test.
65 # if the user did not provide any CXXFLAGS, we can override them
66 AS_IF([test "x$CXXFLAGS" = "x" ], [override_cxx=yes], [override_cxx=no])
67 AS_IF([test "x$CFLAGS" = "x" ], [override_c=yes], [override_c=no])
69 # Checks for programs.
70 AC_PROG_CXX(g++ CC c++ cxx)
72 AC_PATH_PROG(AR, ar, no)
73 AS_IF([test "x${AR}" = "xno" ], [
74 AC_MSG_ERROR([Could not find ar - needed to create a library])
79 AC_CONFIG_MACRO_DIR([m4])
81 # Checks for header files.
83 AC_CHECK_HEADERS(sys/ioctl.h unistd.h)
85 # Check compiler and use -Wall if gnu
86 AS_IF([test "x${GXX}" = "xyes" ], [
87 CXXFLAGS="-Wall -Wextra ${CXXFLAGS}"
88 AS_IF([ test "x${enable_debug}" = "xyes" ], [
89 # Add -Werror in debug mode (except unused-function)
90 CXXFLAGS="-Werror -Wno-error=unused-function ${CXXFLAGS}"
92 # hide private symbols in non-debug mode
93 visibility="-fvisibility=hidden"
98 AC_MSG_CHECKING([whether to compile debug version])
100 AS_CASE([${enable_debug}],
103 AC_DEFINE([__RTAUDIO_DEBUG__])
104 debugflags="${debugflags} -g -O0"
109 debugflags="${debugflags} -O3"
114 # For debugging and optimization ... overwrite default because it has both -g and -O2
115 AS_IF([test "x$debugflags" != x],
116 AS_IF([test "x$override_cxx" = "xyes" ], CXXFLAGS="$CXXFLAGS $debugflags", CXXFLAGS="$debugflags $CXXFLAGS")
117 AS_IF([test "x$override_c" = "xyes" ], CFLAGS="$CFLAGS $debugflags", CFLAGS="$debugflags $CFLAGS")
121 # Checks for functions
122 AC_CHECK_FUNCS(gettimeofday)
125 AC_CHECK_PROG( DOXYGEN, [doxygen], [doxygen] )
126 AM_CONDITIONAL( MAKE_DOC, [test "x${DOXYGEN}" != x ] )
128 # Copy doc files to build dir if necessary
129 AC_CONFIG_LINKS( [doc/release.txt:doc/release.txt] )
130 AC_CONFIG_LINKS( [doc/doxygen/footer.html:doc/doxygen/footer.html] )
131 AC_CONFIG_LINKS( [doc/doxygen/error.txt:doc/doxygen/error.txt] )
132 AC_CONFIG_LINKS( [doc/doxygen/tutorial.txt:doc/doxygen/tutorial.txt] )
133 AC_CONFIG_LINKS( [doc/doxygen/compiling.txt:doc/doxygen/compiling.txt] )
134 AC_CONFIG_LINKS( [doc/doxygen/acknowledge.txt:doc/doxygen/acknowledge.txt] )
135 AC_CONFIG_LINKS( [doc/doxygen/license.txt:doc/doxygen/license.txt] )
136 AC_CONFIG_LINKS( [doc/doxygen/header.html:doc/doxygen/header.html] )
137 AC_CONFIG_LINKS( [doc/doxygen/duplex.txt:doc/doxygen/duplex.txt] )
138 AC_CONFIG_LINKS( [doc/doxygen/settings.txt:doc/doxygen/settings.txt] )
139 AC_CONFIG_LINKS( [doc/doxygen/probe.txt:doc/doxygen/probe.txt] )
140 AC_CONFIG_LINKS( [doc/doxygen/playback.txt:doc/doxygen/playback.txt] )
141 AC_CONFIG_LINKS( [doc/doxygen/multi.txt:doc/doxygen/multi.txt] )
142 AC_CONFIG_LINKS( [doc/doxygen/recording.txt:doc/doxygen/recording.txt] )
143 AC_CONFIG_LINKS( [doc/doxygen/apinotes.txt:doc/doxygen/apinotes.txt] )
144 AC_CONFIG_LINKS( [doc/images/mcgill.gif:doc/images/mcgill.gif] )
145 AC_CONFIG_LINKS( [doc/images/ccrma.gif:doc/images/ccrma.gif] )
147 # Checks for package options and external software
150 # Aggregate options into a single string.
151 AS_IF([test "x$with_jack" = "xyes"], [systems="$systems jack"])
152 AS_IF([test "x$with_alsa" = "xyes"], [systems="$systems alsa"])
153 AS_IF([test "x$with_pulse" = "xyes"], [systems="$systems pulse"])
154 AS_IF([test "x$with_oss" = "xyes"], [systems="$systems oss"])
155 AS_IF([test "x$with_core" = "xyes"], [systems="$systems core"])
156 AS_IF([test "x$with_asio" = "xyes"], [systems="$systems asio"])
157 AS_IF([test "x$with_dsound" = "xyes"], [systems="$systems dsound"])
158 AS_IF([test "x$with_wasapi" = "xyes"], [systems="$systems wasapi"])
159 required=" $systems "
161 # If none, assign defaults if any are known for this OS.
162 # User must specified with-* options for any unknown OS.
163 AS_IF([test "x$systems" = "x"],
165 [*-*-netbsd*], [systems="oss"],
166 [*-*-freebsd*], [systems="oss"],
167 [*-*-linux*], [systems="alsa pulse jack oss"],
168 [*-apple*], [systems="core jack"],
169 [*-mingw32*], [systems="asio dsound wasapi jack"],
170 [*-mingw64*], [systems="asio dsound wasapi jack"],
171 [*-msys*], [systems="asio dsound wasapi jack"],
174 # If any were specifically requested disabled, do it.
175 AS_IF([test "x$with_jack" = "xno"], [systems=`echo $systems|tr ' ' \\\\n|grep -v jack`])
176 AS_IF([test "x$with_alsa" = "xno"], [systems=`echo $systems|tr ' ' \\\\n|grep -v alsa`])
177 AS_IF([test "x$with_pulse" = "xno"], [systems=`echo $systems|tr ' ' \\\\n|grep -v pulse`])
178 AS_IF([test "x$with_oss" = "xno"], [systems=`echo $systems|tr ' ' \\\\n|grep -v oss`])
179 AS_IF([test "x$with_core" = "xno"], [systems=`echo $systems|tr ' ' \\\\n|grep -v core`])
180 AS_IF([test "x$with_asio" = "xno"], [systems=`echo $systems|tr ' ' \\\\n|grep -v asio`])
181 AS_IF([test "x$with_dsound" = "xno"], [systems=`echo $systems|tr ' ' \\\\n|grep -v dsound`])
182 AS_IF([test "x$with_wasapi" = "xno"], [systems=`echo $systems|tr ' ' \\\\n|grep -v wasapi`])
183 systems=" `echo $systems|tr \\\\n ' '` "
185 # For each audio system, check if it is selected and found.
186 # Note: Order specified above is not necessarily respected. However,
187 # *actual* priority is set at run-time, see RtAudio::openRtApi.
188 # One AS_CASE per system, since they are not mutually-exclusive.
190 AS_CASE(["$systems"], [*" alsa "*], [
191 AC_CHECK_LIB(asound, snd_pcm_open,
192 [api="$api -D__LINUX_ALSA__"
196 LIBS="-lasound $LIBS"],
197 AS_CASE(["$required"], [*" alsa "*],
198 AC_MSG_ERROR([ALSA support requires the asound library!])))
201 AS_CASE(["$systems"], [*" pulse "*], [
202 AC_CHECK_LIB(pulse-simple, pa_simple_flush,
203 [api="$api -D__LINUX_PULSE__"
204 req="$req libpulse-simple"
206 found="$found PulseAudio"
207 LIBS="-lpulse-simple $LIBS"],
208 AS_CASE(["$required"], [*" pulse "*],
209 AC_MSG_ERROR([PulseAudio support requires the pulse-simple library!])))
212 AS_CASE(["$systems"], [*" oss "*], [
213 # libossaudio not required on some platforms (e.g. linux) so we
214 # don't break things if it's not found, but issue a warning when we
215 # are not sure (i.e. not on linux)
216 AS_CASE([$host], [*-*-linux*], [], [*], [need_ossaudio=yes])
217 AC_CHECK_LIB(ossaudio, main, [have_ossaudio=true],
218 AS_CASE(["$required"], [*" oss "*],
219 AS_IF([test "x$need_ossaudio" = xyes],
220 AC_MSG_WARN([RtAudio may require the ossaudio library]))))
222 # linux systems may have soundcard.h but *not* have OSS4 installed,
223 # we have to actually check if it exports OSS4 symbols
224 AC_CHECK_DECL(SNDCTL_SYSINFO,
225 [api="$api -D__LINUX_OSS__"
228 AS_CASE(["$required"], [*" oss "*],
229 AC_MSG_ERROR([sys/soundcard.h not found]))
231 [#include <sys/soundcard.h>])
234 AS_CASE(["$systems"], [*" jack "*], [
235 AC_CHECK_LIB(jack, jack_client_open,
236 [api="$api -D__UNIX_JACK__"
240 LIBS="-ljack $LIBS"],
241 AS_CASE(["$required"], [*" jack "*],
242 AC_MSG_ERROR([JACK support requires the jack library!])))
245 AS_CASE(["$systems"], [*" core "*], [
246 AC_CHECK_HEADER(CoreAudio/CoreAudio.h,
247 [api="$api -D__MACOSX_CORE__"
249 found="$found CoreAudio",
250 LIBS="$LIBS -framework CoreAudio -framework CoreFoundation"],
251 AS_CASE(["$required"], [*" core "*],
252 AC_MSG_ERROR([CoreAudio header files not found!])))
255 AS_CASE(["$systems"], [*" asio "*], [
256 api="$api -D__WINDOWS_ASIO__"
258 CPPFLAGS="-I$srcdir/include $CPPFLAGS"
263 AS_CASE(["$systems"], [*" dsound "*], [
264 AC_CHECK_HEADERS(windows.h)
265 AC_CHECK_HEADERS(mmsystem.h mmreg.h dsound.h, [], [],
266 [#ifdef HAVE_WINDOWS_H
267 # include <windows.h>
269 AS_IF([test "x$ac_cv_header_windows_h" = xyes \
270 && test "x$ac_cv_header_mmsystem_h" = xyes \
271 && test "x$ac_cv_header_mmreg_h" = xyes \
272 && test "x$ac_cv_header_dsound_h" = xyes],
273 [api="$api -D__WINDOWS_DS__"
275 found="$found DirectSound"
276 LIBS="-ldsound -lwinmm $LIBS"])
279 AS_CASE(["$systems"], [*" wasapi "*], [
280 AC_CHECK_HEADERS(windows.h)
281 AC_CHECK_HEADERS(audioclient.h avrt.h mmdeviceapi.h, [], [],
282 [#ifdef HAVE_WINDOWS_H
283 # include <windows.h>
285 AS_IF([test "x$ac_cv_header_windows_h" = xyes \
286 && test "x$ac_cv_header_audioclient_h" = xyes \
287 && test "x$ac_cv_header_avrt_h" = xyes \
288 && test "x$ac_cv_header_mmdeviceapi_h" = xyes],
289 [api="$api -D__WINDOWS_WASAPI__"
290 CPPFLAGS="-I$srcdir/include $CPPFLAGS"
292 found="$found WASAPI"
293 LIBS="-lwinmm -lksuser -lmfplat -lmfuuid -lwmcodecdspuuid $LIBS"])
296 AS_IF([test -n "$need_ole32"], [LIBS="-lole32 $LIBS"])
298 AS_IF([test -n "$need_pthread"],[
299 AC_MSG_CHECKING([for pthread])
300 AC_CHECK_LIB(pthread, pthread_create, ,
301 AC_MSG_ERROR([RtAudio requires the pthread library!]))])
303 AC_MSG_CHECKING([for audio API])
305 # Error case: no known realtime systems found.
306 AS_IF([test x"$api" = "x"], [
307 AC_MSG_RESULT([none])
308 AC_MSG_ERROR([No known system type found for realtime support!])
310 AC_MSG_RESULT([$found])
313 AM_CONDITIONAL( ASIO, [test "x${use_asio}" = "xyes" ])
315 CPPFLAGS="$CPPFLAGS $api"