13b25d7e8a0931914128db1ba985024aab0f1009
[rtaudio-cdist.git] / configure.ac
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
8 # libtool version: current:revision:age
9 #
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').
12 #
13 # If any interfaces have been added, removed, or changed since the last update,
14 # increment current, and set revision to 0.
15 #
16 # If any interfaces have been added since the last public release, then
17 # increment age.
18 #
19 # If any interfaces have been removed since the last public release, then set
20 # age to 0.
21 m4_define([lt_current], 6)
22 m4_define([lt_revision], 0)
23 m4_define([lt_age], 0)
24
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)])
27
28 SO_VERSION=lt_version_info
29 AC_SUBST(SO_VERSION)
30 AC_SUBST(api)
31 AC_SUBST(req)
32
33 api=""
34 req=""
35
36 # configure flags
37 AC_ARG_WITH(jack, [AS_HELP_STRING([--with-jack], [choose JACK server support (mac and linux only)])])
38 AC_ARG_WITH(alsa, [AS_HELP_STRING([--with-alsa], [choose native ALSA API support (linux only)])])
39 AC_ARG_WITH(pulse, [AS_HELP_STRING([--with-pulse], [choose PulseAudio API support (linux only)])])
40 AC_ARG_WITH(oss, [AS_HELP_STRING([--with-oss], [choose OSS API support (unixes)])])
41 AC_ARG_WITH(core, [AS_HELP_STRING([--with-core], [choose CoreAudio API support (mac only)])])
42 AC_ARG_WITH(asio, [AS_HELP_STRING([--with-asio], [choose ASIO API support (win32 only)])])
43 AC_ARG_WITH(ds, [AS_HELP_STRING([--with-ds], [choose DirectSound API support (win32 only)])])
44 AC_ARG_WITH(wasapi, [AS_HELP_STRING([--with-wasapi], [choose Windows Audio Session API support (win32 only)])])
45
46 # Check version number coherency between RtAudio.h and configure.ac
47 AC_MSG_CHECKING([that version numbers are coherent])
48 RTAUDIO_VERSION=`sed -n 's/#define RTAUDIO_VERSION "\(.*\)"/\1/p' $srcdir/RtAudio.h`
49 AS_IF(
50    [test "x$RTAUDIO_VERSION" != "x$PACKAGE_VERSION"],
51    [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.])]
52 )
53 # Enable some nice automake features if they are available
54 m4_ifdef([AM_MAINTAINER_MODE], [AM_MAINTAINER_MODE])
55 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
56
57 # Fill GXX with something before test.
58 GXX = "no"
59
60 dnl Check for pkg-config program, used for configuring some libraries.
61 m4_define_default([PKG_PROG_PKG_CONFIG],
62 [AC_MSG_CHECKING([pkg-config])
63 AC_MSG_RESULT([no])])
64
65 PKG_PROG_PKG_CONFIG
66
67 dnl If the pkg-config autoconf support isn't installed, define its
68 dnl autoconf macro to disable any packages depending on it.
69 m4_define_default([PKG_CHECK_MODULES],
70 [AC_MSG_CHECKING([$1])
71 AC_MSG_RESULT([no])
72 $4])
73
74 # Check for debug
75 AC_MSG_CHECKING(whether to compile debug version)
76 AC_ARG_ENABLE(debug,
77   [AS_HELP_STRING([--enable-debug],[enable various debug output])],
78   [: ${CXXFLAGS="-g -O0"};] [AC_DEFINE([__RTAUDIO_DEBUG__])],
79   [: ${CXXFLAGS="-O3"}])
80
81 # Checks for programs.
82 AC_PROG_CXX(g++ CC c++ cxx)
83 AM_PROG_AR
84 AC_PATH_PROG(AR, ar, no)
85 AS_IF([test "x${AR} = "xno" ], [
86     AC_MSG_ERROR("Could not find ar - needed to create a library");
87 ])
88
89 # Initialize libtool
90 LT_INIT([win32-dll])
91 AC_CONFIG_MACRO_DIR([m4])
92
93 # Checks for header files.
94 AC_HEADER_STDC
95 AC_CHECK_HEADERS(sys/ioctl.h unistd.h)
96
97 # Check compiler and use -Wall if gnu
98 AS_IF([test "x${GXX} = "xyes" ], [
99   CXXFLAGS="${CXXFLAGS} -Wall -Wextra"
100   # Add -Werror in debug mode
101   if test x"${enable_debug+set}" = xset; then
102     CXXFLAGS="${CXXFLAGS} -Werror"
103   fi
104 ])
105
106 # Checks for functions
107 AC_CHECK_FUNC(gettimeofday, [cppflag="$cppflag -DHAVE_GETTIMEOFDAY"], )
108
109 # Checks for doxygen
110 AC_CHECK_PROG( DOXYGEN, [doxygen], [doxygen] )
111 AM_CONDITIONAL( MAKE_DOC, [test "x${DOXYGEN}" != x] )
112
113 # Copy doc files to build dir if necessary
114 AC_CONFIG_LINKS( [doc/release.txt:doc/release.txt] )
115 AC_CONFIG_LINKS( [doc/doxygen/footer.html:doc/doxygen/footer.html] )
116 AC_CONFIG_LINKS( [doc/doxygen/error.txt:doc/doxygen/error.txt] )
117 AC_CONFIG_LINKS( [doc/doxygen/tutorial.txt:doc/doxygen/tutorial.txt] )
118 AC_CONFIG_LINKS( [doc/doxygen/compiling.txt:doc/doxygen/compiling.txt] )
119 AC_CONFIG_LINKS( [doc/doxygen/acknowledge.txt:doc/doxygen/acknowledge.txt] )
120 AC_CONFIG_LINKS( [doc/doxygen/license.txt:doc/doxygen/license.txt] )
121 AC_CONFIG_LINKS( [doc/doxygen/header.html:doc/doxygen/header.html] )
122 AC_CONFIG_LINKS( [doc/doxygen/duplex.txt:doc/doxygen/duplex.txt] )
123 AC_CONFIG_LINKS( [doc/doxygen/settings.txt:doc/doxygen/settings.txt] )
124 AC_CONFIG_LINKS( [doc/doxygen/probe.txt:doc/doxygen/probe.txt] )
125 AC_CONFIG_LINKS( [doc/doxygen/playback.txt:doc/doxygen/playback.txt] )
126 AC_CONFIG_LINKS( [doc/doxygen/multi.txt:doc/doxygen/multi.txt] )
127 AC_CONFIG_LINKS( [doc/doxygen/recording.txt:doc/doxygen/recording.txt] )
128 AC_CONFIG_LINKS( [doc/doxygen/apinotes.txt:doc/doxygen/apinotes.txt] )
129 AC_CONFIG_LINKS( [doc/images/mcgill.gif:doc/images/mcgill.gif] )
130 AC_CONFIG_LINKS( [doc/images/ccrma.gif:doc/images/ccrma.gif] )
131
132 # Checks for package options and external software
133 AC_CANONICAL_HOST
134
135 AC_MSG_CHECKING(for audio API)
136
137 AS_IF([test "x$with_jack" = "xyes"], [
138   AC_MSG_RESULT(using JACK)
139   AC_CHECK_LIB(jack, jack_client_open, , AC_MSG_ERROR(JACK support requires the jack library!))
140   api="$api -D__UNIX_JACK__"
141 ])
142
143 case $host in
144   *-*-netbsd*)
145   AS_IF([test "x$api" = "x"], [
146     AC_MSG_RESULT(using OSS)
147     api="$api -D__LINUX_OSS__"
148     AC_CHECK_LIB(ossaudio, main, , AC_MSG_ERROR([RtAudio requires the ossaudio library]))
149     AC_CHECK_LIB(pthread, pthread_create, , AC_MSG_ERROR(RtAudio requires the pthread library!))
150   ])
151   ;;
152
153   *-*-freebsd*)
154   AS_IF([test "x$api" = "x"], [
155     AC_MSG_RESULT(using OSS)
156     api="$api -D__LINUX_OSS__"
157     AC_CHECK_LIB(ossaudio, main, , AC_MSG_ERROR([RtAudio requires the ossaudio library]))
158     AC_CHECK_LIB(pthread, pthread_create, , AC_MSG_ERROR(RtAudio requires the pthread library!))
159   ])
160   ;;
161
162   *-*-linux*)
163   # Look for ALSA flag
164   AS_IF([test "x$with_alsa" = "xyes"], [
165     AC_MSG_RESULT(using ALSA)
166     api="$api -D__LINUX_ALSA__"
167     req="$req alsa"
168     AC_CHECK_LIB(asound, snd_pcm_open, , AC_MSG_ERROR(ALSA support requires the asound library!))
169   ])
170
171   # Look for PULSE flag
172   AS_IF([test "x$with_pulse" = "xyes"], [
173     AC_MSG_RESULT(using PulseAudio)
174     api="$api -D__LINUX_PULSE__"
175     req="$req libpulse-simple"
176     AC_CHECK_LIB(pulse-simple, pa_simple_flush, , AC_MSG_ERROR(PulseAudio support requires the pulse-simple library!))
177   ])
178
179   # Look for OSS flag
180   AS_IF([test "x$with_oss" = "xyes"], [
181     AC_MSG_RESULT(using OSS)
182     api="$api -D__LINUX_OSS__"
183   ])
184
185   # If no audio api flags specified, use ALSA
186   AS_IF([test "x$api" = "x" ], [
187     AC_MSG_RESULT(using ALSA)
188     api="${api} -D__LINUX_ALSA__"
189     req="${req} alsa"
190     AC_CHECK_LIB(asound, snd_pcm_open, , AC_MSG_ERROR(ALSA support requires the asound library!))
191   ])
192   AC_CHECK_LIB(pthread, pthread_create, , AC_MSG_ERROR(RtAudio requires the pthread library!))
193   ;;
194
195   *-apple*)
196   # Look for Core flag
197   AS_IF([test "x$with_core" = "xyes"], [
198     AC_MSG_RESULT(using CoreAudio)
199     api="$api -D__MACOSX_CORE__"
200     AC_CHECK_HEADER(CoreAudio/CoreAudio.h, [], [AC_MSG_ERROR(CoreAudio header files not found!)] )
201     LIBS="$LIBS -framework CoreAudio -framework CoreFoundation"
202   ])
203
204   # If no audio api flags specified, use CoreAudio
205   AS_IF([test "x$api" = "x" ], [
206     AC_MSG_RESULT(using CoreAudio)
207     api="${api} -D__MACOSX_CORE__"
208     AC_CHECK_HEADER(CoreAudio/CoreAudio.h,
209       [],
210       [AC_MSG_ERROR(CoreAudio header files not found!)] )
211     LIBS="LIBS -framework CoreAudio -framework CoreFoundation"
212   ])
213
214   AC_CHECK_LIB(pthread, pthread_create, , AC_MSG_ERROR(RtAudio requires the pthread library!))
215   ;;
216
217   *-mingw32*)
218   AS_IF([test "x$with_asio" = "xyes" ], [
219     AC_MSG_RESULT(using ASIO)
220     api="$api -D__WINDOWS_ASIO__"
221     AC_SUBST( objects, ["asio.o asiodrivers.o asiolist.o iasiothiscallresolver.o"] )
222   ])
223
224   # Look for DirectSound flag
225   AS_IF([test "x$with_ds" = "xyes" ], [
226     AC_MSG_RESULT(using DirectSound)
227     api="$api -D__WINDOWS_DS__"
228     LIBS="-ldsound -lwinmm $LIBS"
229   ])
230
231   # Look for WASAPI flag
232   AS_IF([test "x$with_wasapi" = "xyes"], [
233     AC_MSG_RESULT(using WASAPI)
234     api="$api -D__WINDOWS_WASAPI__"
235     LIBS="-lwinmm -luuid -lksuser $LIBS"
236   ])
237
238   # If no audio api flags specified, use DS
239   AS_IF([test "x$api" = "x" ], [
240     AC_MSG_RESULT(using DirectSound)
241     api="$api -D__WINDOWS_DS__"
242     LIBS="-ldsound -lwinmm $LIBS"
243   ])
244
245   LIBS="-lole32 $LIBS"
246   ;;
247
248   *)
249   # Default case for unknown realtime systems.
250   AC_MSG_ERROR(Unknown system type for realtime support!)
251   ;;
252 esac
253
254 CPPFLAGS="$CPPFLAGS $api"
255
256 AC_OUTPUT