1 # Process this file with autoconf to produce a configure script.
2 AC_INIT(RtAudio, 4.1, gary@music.mcgill.ca, rtaudio)
3 AC_CONFIG_AUX_DIR(config)
4 AC_CONFIG_SRCDIR(RtAudio.cpp)
5 AC_CONFIG_FILES([rtaudio-config librtaudio.pc Makefile tests/Makefile])
7 # Fill GXX with something before test.
8 AC_SUBST( GXX, ["no"] )
10 dnl Check for pkg-config program, used for configuring some libraries.
11 m4_define_default([PKG_PROG_PKG_CONFIG],
12 [AC_MSG_CHECKING([pkg-config])
17 dnl If the pkg-config autoconf support isn't installed, define its
18 dnl autoconf macro to disable any packages depending on it.
19 m4_define_default([PKG_CHECK_MODULES],
20 [AC_MSG_CHECKING([$1])
24 # Checks for programs.
25 AC_PROG_CXX(g++ CC c++ cxx)
27 AC_PATH_PROG(AR, ar, no)
28 if [[ $AR = "no" ]] ; then
29 AC_MSG_ERROR("Could not find ar - needed to create a library");
32 # Checks for header files.
34 AC_CHECK_HEADERS(sys/ioctl.h unistd.h)
37 AC_MSG_CHECKING(whether to compile debug version)
39 [ --enable-debug = enable various debug output],
40 [AC_SUBST( cppflag, [-D__RTAUDIO_DEBUG__] ) AC_SUBST( cxxflag, [-g] ) AC_SUBST( object_path, [Debug] ) AC_MSG_RESULT(yes)],
41 [AC_SUBST( cppflag, [] ) AC_SUBST( cxxflag, [-O2] ) AC_SUBST( object_path, [Release] ) AC_MSG_RESULT(no)])
44 # Checks for functions
45 AC_CHECK_FUNC(gettimeofday, [cppflag="$cppflag -DHAVE_GETTIMEOFDAY"], )
47 # Set paths if prefix is defined
48 if test "x$prefix" != "x" && test "x$prefix" != "xNONE"; then
49 LIBS="$LIBS -L$prefix/lib"
50 CPPFLAGS="$CPPFLAGS -I$prefix/include"
54 CPPFLAGS="$CPPFLAGS $cppflag"
56 # For debugging and optimization ... overwrite default because it has both -g and -O2
57 #CXXFLAGS="$CXXFLAGS $cxxflag"
60 # Check compiler and use -Wall if gnu.
61 if [test $GXX = "yes" ;] then
62 AC_SUBST( cxxflag, ["-Wall -Wextra"] )
65 CXXFLAGS="$CXXFLAGS $cxxflag"
69 AC_SUBST( sharedlib, ["librtaudio.so"] )
70 AC_SUBST( sharedname, ["librtaudio.so.\$(RELEASE)"] )
71 AC_SUBST( libflags, ["-shared -Wl,-soname,\$(SHARED).\$(MAJOR) -o \$(SHARED).\$(RELEASE)"] )
74 AC_SUBST( sharedlib, ["librtaudio.dylib"] )
75 AC_SUBST( sharedname, ["librtaudio.\$(RELEASE).dylib"] )
76 AC_SUBST( libflags, ["-dynamiclib -o librtaudio.\$(RELEASE).dylib"] )
79 # Checks for package options and external software
82 AC_MSG_CHECKING(for audio API)
85 AC_MSG_RESULT(using OSS)
86 api="$api -D__LINUX_OSS__"
87 LIBS="$LIBS -lossaudio"
88 AC_CHECK_LIB(pthread, pthread_create, , AC_MSG_ERROR(RtAudio requires the pthread library!))
92 AC_ARG_WITH(jack, [ --with-jack = choose JACK server support (mac and linux only)], [
93 api="$api -D__UNIX_JACK__"
94 AC_MSG_RESULT(using JACK)
95 AC_CHECK_LIB(jack, jack_client_open, , AC_MSG_ERROR(JACK support requires the jack library!))
96 AC_CHECK_LIB(asound, snd_pcm_open, , AC_MSG_ERROR(Jack support also requires the asound library!))], )
99 AC_ARG_WITH(alsa, [ --with-alsa = choose native ALSA API support (linux only)], [
100 api="$api -D__LINUX_ALSA__"
102 AC_MSG_RESULT(using ALSA)
103 AC_CHECK_LIB(asound, snd_pcm_open, , AC_MSG_ERROR(ALSA support requires the asound library!))], )
105 # Look for PULSE flag
106 AC_ARG_WITH(pulse, [ --with-pulse = choose PulseAudio API support (linux only)], [
107 api="$api -D__LINUX_PULSE__"
108 req="$req libpulse-simple"
109 AC_MSG_RESULT(using PulseAudio)
110 AC_CHECK_LIB(pulse-simple, pa_simple_flush, , AC_MSG_ERROR(PulseAudio support requires the pulse-simple library!))], )
113 AC_ARG_WITH(oss, [ --with-oss = choose OSS API support (linux only)], [
114 api="$api -D__LINUX_OSS__"
115 AC_MSG_RESULT(using OSS)], )
117 # If no audio api flags specified, use ALSA
118 if [test "$api" == "";] then
119 AC_MSG_RESULT(using ALSA)
120 AC_SUBST( api, [-D__LINUX_ALSA__] )
122 AC_CHECK_LIB(asound, snd_pcm_open, , AC_MSG_ERROR(ALSA support requires the asound library!))
125 AC_CHECK_LIB(pthread, pthread_create, , AC_MSG_ERROR(RtAudio requires the pthread library!))
129 AC_ARG_WITH(jack, [ --with-jack = choose JACK server support (unix only)], [
130 api="$api -D__UNIX_JACK__"
131 AC_MSG_RESULT(using JACK)
132 AC_CHECK_LIB(jack, jack_client_open, , AC_MSG_ERROR(JACK support requires the jack library!))], )
134 # AC_CHECK_HEADER(jack/jack.h, [], [AC_MSG_ERROR(Jack header file not found!)] )
135 # LIBS="$LIBS -framework jackmp" ], )
139 AC_ARG_WITH(core, [ --with-core = choose CoreAudio API support (mac only)], [
140 api="$api -D__MACOSX_CORE__"
141 AC_MSG_RESULT(using CoreAudio)
142 AC_CHECK_HEADER(CoreAudio/CoreAudio.h, [], [AC_MSG_ERROR(CoreAudio header files not found!)] )
143 LIBS="$LIBS -framework CoreAudio -framework CoreFoundation" ], )
145 # If no audio api flags specified, use CoreAudio
146 if [test "$api" == ""; ] then
147 AC_SUBST( api, [-D__MACOSX_CORE__] )
148 AC_MSG_RESULT(using CoreAudio)
149 AC_CHECK_HEADER(CoreAudio/CoreAudio.h,
151 [AC_MSG_ERROR(CoreAudio header files not found!)] )
152 AC_SUBST( LIBS, ["-framework CoreAudio -framework CoreFoundation"] )
155 AC_CHECK_LIB(pthread, pthread_create, , AC_MSG_ERROR(RtAudio requires the pthread library!))
159 AC_ARG_WITH(asio, [ --with-asio = choose ASIO API support (windoze only)], [
160 api="$api -D__WINDOWS_ASIO__"
161 AC_MSG_RESULT(using ASIO)
162 AC_SUBST( objects, ["asio.o asiodrivers.o asiolist.o iasiothiscallresolver.o"] ) ], )
164 # Look for DirectSound flag
165 AC_ARG_WITH(ds, [ --with-ds = choose DirectSound API support (windoze only)], [
166 api="$api -D__WINDOWS_DS__"
167 AC_MSG_RESULT(using DirectSound)
168 LIBS="-ldsound -lwinmm $LIBS" ], )
170 # Look for WASAPI flag
171 AC_ARG_WITH(wasapi, [ --with-wasapi = choose Windows Audio Session API support (windoze only)], [
172 api="$api -D__WINDOWS_WASAPI__"
173 AC_MSG_RESULT(using WASAPI)
174 LIBS="-lwinmm -luuid -lksuser $LIBS" ], )
176 # If no audio api flags specified, use DS
177 if [test "$api" == "";] then
178 AC_SUBST( api, [-D__WINDOWS_DS__] )
179 AC_MSG_RESULT(using DirectSound)
180 LIBS="-ldsound -lwinmm $LIBS"
187 # Default case for unknown realtime systems.
188 AC_MSG_ERROR(Unknown system type for realtime support!)
192 CPPFLAGS="$CPPFLAGS $api"
196 chmod oug+x rtaudio-config