Port the build system to automake.
[rtaudio-cdist.git] / configure.ac
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 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], 5)
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
31 # Enable some nice automake features if they are available
32 m4_ifdef([AM_MAINTAINER_MODE], [AM_MAINTAINER_MODE])
33 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
34
35 # Fill GXX with something before test.
36 AC_SUBST( GXX, ["no"] )
37
38 dnl Check for pkg-config program, used for configuring some libraries.
39 m4_define_default([PKG_PROG_PKG_CONFIG],
40 [AC_MSG_CHECKING([pkg-config])
41 AC_MSG_RESULT([no])])
42
43 PKG_PROG_PKG_CONFIG
44
45 dnl If the pkg-config autoconf support isn't installed, define its
46 dnl autoconf macro to disable any packages depending on it.
47 m4_define_default([PKG_CHECK_MODULES],
48 [AC_MSG_CHECKING([$1])
49 AC_MSG_RESULT([no])
50 $4])
51
52 # Checks for programs.
53 AC_PROG_CXX(g++ CC c++ cxx)
54 AM_PROG_AR
55 AC_PATH_PROG(AR, ar, no)
56 if [[ $AR = "no" ]] ; then
57     AC_MSG_ERROR("Could not find ar - needed to create a library");
58 fi
59
60 # Initialize libtool
61 LT_INIT([win32-dll])
62 AC_CONFIG_MACRO_DIR([m4])
63
64 # Checks for header files.
65 AC_HEADER_STDC
66 AC_CHECK_HEADERS(sys/ioctl.h unistd.h)
67
68 # Check for debug
69 AC_MSG_CHECKING(whether to compile debug version)
70 AC_ARG_ENABLE(debug,
71   [  --enable-debug = enable various debug output],
72   [AC_SUBST( cppflag, [-D__RTAUDIO_DEBUG__] ) AC_SUBST( cxxflag, [-g] ) AC_SUBST( object_path, [Debug] ) AC_MSG_RESULT(yes)],
73   [AC_SUBST( cppflag, [] ) AC_SUBST( cxxflag, [-O2] ) AC_SUBST( object_path, [Release] ) AC_MSG_RESULT(no)])
74
75
76 # Checks for functions
77 AC_CHECK_FUNC(gettimeofday, [cppflag="$cppflag -DHAVE_GETTIMEOFDAY"], )
78
79 # Set paths if prefix is defined
80 if test "x$prefix" != "x" && test "x$prefix" != "xNONE"; then
81   LIBS="$LIBS -L$prefix/lib"
82   CPPFLAGS="$CPPFLAGS -I$prefix/include"
83 fi
84
85 # For -I and -D flags
86 CPPFLAGS="$CPPFLAGS $cppflag"
87
88 # For debugging and optimization ... overwrite default because it has both -g and -O2
89 #CXXFLAGS="$CXXFLAGS $cxxflag"
90 CXXFLAGS="$cxxflag"
91
92 # Check compiler and use -Wall if gnu.
93 if [test $GXX = "yes" ;] then
94   AC_SUBST( cxxflag, ["-Wall -Wextra"] )
95 fi
96
97 CXXFLAGS="$CXXFLAGS $cxxflag"
98
99 # Checks for doxygen
100 AC_CHECK_PROG( DOXYGEN, [doxygen], [doxygen] )
101 AM_CONDITIONAL( MAKE_DOC, [test "x${DOXYGEN}" != x] )
102
103 # Copy doc files to build dir if necessary
104 AC_CONFIG_LINKS( [doc/release.txt:doc/release.txt] )
105 AC_CONFIG_LINKS( [doc/doxygen/footer.html:doc/doxygen/footer.html] )
106 AC_CONFIG_LINKS( [doc/doxygen/error.txt:doc/doxygen/error.txt] )
107 AC_CONFIG_LINKS( [doc/doxygen/tutorial.txt:doc/doxygen/tutorial.txt] )
108 AC_CONFIG_LINKS( [doc/doxygen/compiling.txt:doc/doxygen/compiling.txt] )
109 AC_CONFIG_LINKS( [doc/doxygen/acknowledge.txt:doc/doxygen/acknowledge.txt] )
110 AC_CONFIG_LINKS( [doc/doxygen/license.txt:doc/doxygen/license.txt] )
111 AC_CONFIG_LINKS( [doc/doxygen/header.html:doc/doxygen/header.html] )
112 AC_CONFIG_LINKS( [doc/doxygen/duplex.txt:doc/doxygen/duplex.txt] )
113 AC_CONFIG_LINKS( [doc/doxygen/settings.txt:doc/doxygen/settings.txt] )
114 AC_CONFIG_LINKS( [doc/doxygen/probe.txt:doc/doxygen/probe.txt] )
115 AC_CONFIG_LINKS( [doc/doxygen/playback.txt:doc/doxygen/playback.txt] )
116 AC_CONFIG_LINKS( [doc/doxygen/multi.txt:doc/doxygen/multi.txt] )
117 AC_CONFIG_LINKS( [doc/doxygen/recording.txt:doc/doxygen/recording.txt] )
118 AC_CONFIG_LINKS( [doc/doxygen/apinotes.txt:doc/doxygen/apinotes.txt] )
119 AC_CONFIG_LINKS( [doc/images/mcgill.gif:doc/images/mcgill.gif] )
120 AC_CONFIG_LINKS( [doc/images/ccrma.gif:doc/images/ccrma.gif] )
121
122 # Checks for package options and external software
123 AC_CANONICAL_HOST
124
125 AC_SUBST( api, [""] )
126 AC_SUBST( req, [""] )
127 AC_MSG_CHECKING(for audio API)
128 case $host in
129   *-*-netbsd*)
130     AC_MSG_RESULT(using OSS)
131     api="$api -D__LINUX_OSS__"
132     LIBS="$LIBS -lossaudio"
133     AC_CHECK_LIB(pthread, pthread_create, , AC_MSG_ERROR(RtAudio requires the pthread library!))
134   ;;
135
136   *-*-linux*)
137   AC_ARG_WITH(jack, [  --with-jack = choose JACK server support (mac and linux only)], [
138     api="$api -D__UNIX_JACK__"
139     AC_MSG_RESULT(using JACK)
140     AC_CHECK_LIB(jack, jack_client_open, , AC_MSG_ERROR(JACK support requires the jack library!))
141     AC_CHECK_LIB(asound, snd_pcm_open, , AC_MSG_ERROR(Jack support also requires the asound library!))], )
142
143   # Look for ALSA flag
144   AC_ARG_WITH(alsa, [  --with-alsa = choose native ALSA API support (linux only)], [
145     api="$api -D__LINUX_ALSA__"
146     req="$req alsa"
147     AC_MSG_RESULT(using ALSA)
148     AC_CHECK_LIB(asound, snd_pcm_open, , AC_MSG_ERROR(ALSA support requires the asound library!))], )
149
150   # Look for PULSE flag
151   AC_ARG_WITH(pulse, [  --with-pulse = choose PulseAudio API support (linux only)], [
152     api="$api -D__LINUX_PULSE__"
153     req="$req libpulse-simple"
154     AC_MSG_RESULT(using PulseAudio)
155     AC_CHECK_LIB(pulse-simple, pa_simple_flush, , AC_MSG_ERROR(PulseAudio support requires the pulse-simple library!))], )
156
157   # Look for OSS flag
158   AC_ARG_WITH(oss, [  --with-oss = choose OSS API support (linux only)], [
159     api="$api -D__LINUX_OSS__"
160     AC_MSG_RESULT(using OSS)], )
161
162   # If no audio api flags specified, use ALSA
163   if [test "$api" == "";] then
164     AC_MSG_RESULT(using ALSA)
165     AC_SUBST( api, [-D__LINUX_ALSA__] )
166     req="$req alsa"
167     AC_CHECK_LIB(asound, snd_pcm_open, , AC_MSG_ERROR(ALSA support requires the asound library!))
168   fi
169
170   AC_CHECK_LIB(pthread, pthread_create, , AC_MSG_ERROR(RtAudio requires the pthread library!))
171   ;;
172
173   *-apple*)
174   AC_ARG_WITH(jack, [  --with-jack = choose JACK server support (unix only)], [
175     api="$api -D__UNIX_JACK__"
176     AC_MSG_RESULT(using JACK)
177     AC_CHECK_LIB(jack, jack_client_open, , AC_MSG_ERROR(JACK support requires the jack library!))], )
178
179 #    AC_CHECK_HEADER(jack/jack.h, [], [AC_MSG_ERROR(Jack header file not found!)] )
180 #    LIBS="$LIBS -framework jackmp" ], )
181
182
183   # Look for Core flag
184   AC_ARG_WITH(core, [  --with-core = choose CoreAudio API support (mac only)], [
185     api="$api -D__MACOSX_CORE__"
186     AC_MSG_RESULT(using CoreAudio)
187     AC_CHECK_HEADER(CoreAudio/CoreAudio.h, [], [AC_MSG_ERROR(CoreAudio header files not found!)] )
188     LIBS="$LIBS -framework CoreAudio -framework CoreFoundation" ], )
189
190   # If no audio api flags specified, use CoreAudio
191   if [test "$api" == ""; ] then
192     AC_SUBST( api, [-D__MACOSX_CORE__] )
193     AC_MSG_RESULT(using CoreAudio)
194     AC_CHECK_HEADER(CoreAudio/CoreAudio.h,
195       [],
196       [AC_MSG_ERROR(CoreAudio header files not found!)] )
197     AC_SUBST( LIBS, ["-framework CoreAudio -framework CoreFoundation"] )
198   fi
199
200   AC_CHECK_LIB(pthread, pthread_create, , AC_MSG_ERROR(RtAudio requires the pthread library!))
201   ;;
202
203   *-mingw32*)
204   AC_ARG_WITH(asio, [  --with-asio = choose ASIO API support (windoze only)], [
205     api="$api -D__WINDOWS_ASIO__"
206     AC_MSG_RESULT(using ASIO)
207     AC_SUBST( objects, ["asio.o asiodrivers.o asiolist.o iasiothiscallresolver.o"] ) ], )
208
209   # Look for DirectSound flag
210   AC_ARG_WITH(ds, [  --with-ds = choose DirectSound API support (windoze only)], [
211     api="$api -D__WINDOWS_DS__"
212     AC_MSG_RESULT(using DirectSound)
213     LIBS="-ldsound -lwinmm $LIBS" ], )
214
215   # Look for WASAPI flag
216   AC_ARG_WITH(wasapi, [  --with-wasapi = choose Windows Audio Session API support (windoze only)], [
217     api="$api -D__WINDOWS_WASAPI__"
218     AC_MSG_RESULT(using WASAPI)
219     LIBS="-lwinmm -luuid -lksuser $LIBS" ], )
220
221   # If no audio api flags specified, use DS
222   if [test "$api" == "";] then
223     AC_SUBST( api, [-D__WINDOWS_DS__] )
224     AC_MSG_RESULT(using DirectSound)
225     LIBS="-ldsound -lwinmm $LIBS"
226   fi
227
228   LIBS="-lole32 $LIBS"
229   ;;
230
231   *)
232   # Default case for unknown realtime systems.
233   AC_MSG_ERROR(Unknown system type for realtime support!)
234   ;;
235 esac
236
237 CPPFLAGS="$CPPFLAGS $api"
238
239 AC_OUTPUT
240
241 chmod oug+x rtaudio-config