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