Mutex removal from several APIs, addition of PulseAudio support, documentation update...
[rtaudio.git] / configure.ac
1 # Process this file with autoconf to produce a configure script.
2 AC_INIT(RtAudio, 4.0, gary@music.mcgill.ca, rtaudio)
3 AC_CONFIG_AUX_DIR(config)
4 AC_CONFIG_SRCDIR(RtAudio.cpp)
5 AC_CONFIG_FILES([rtaudio-config Makefile tests/Makefile])
6
7 # Fill GXX with something before test.
8 AC_SUBST( GXX, ["no"] )
9
10 # Checks for programs.
11 AC_PROG_CXX(g++ CC c++ cxx)
12 AC_PROG_RANLIB
13 AC_PATH_PROG(AR, ar, no)
14 if [[ $AR = "no" ]] ; then
15     AC_MSG_ERROR("Could not find ar - needed to create a library");
16 fi
17
18 # Checks for header files.
19 AC_HEADER_STDC
20 AC_CHECK_HEADERS(sys/ioctl.h unistd.h)
21
22 # Check for debug
23 AC_MSG_CHECKING(whether to compile debug version)
24 AC_ARG_ENABLE(debug,
25   [  --enable-debug = enable various debug output],
26   [AC_SUBST( cppflag, [-D__RTAUDIO_DEBUG__] ) AC_SUBST( cxxflag, [-g] ) AC_SUBST( object_path, [Debug] ) AC_MSG_RESULT(yes)],
27   [AC_SUBST( cppflag, [] ) AC_SUBST( cxxflag, [-O2] ) AC_SUBST( object_path, [Release] ) AC_MSG_RESULT(no)])
28
29
30 # Checks for functions
31 AC_CHECK_FUNC(gettimeofday, [cppflag="$cppflag -DHAVE_GETTIMEOFDAY"], )
32
33 # For -I and -D flags
34 CPPFLAGS="$CPPFLAGS $cppflag"
35
36 # For debugging and optimization ... overwrite default because it has both -g and -O2
37 #CXXFLAGS="$CXXFLAGS $cxxflag"
38 CXXFLAGS="$cxxflag"
39
40 # Check compiler and use -Wall if gnu.
41 if [test $GXX = "yes" ;] then
42   AC_SUBST( cxxflag, [-Wall] )
43 fi
44
45 CXXFLAGS="$CXXFLAGS $cxxflag"
46
47 AC_CANONICAL_HOST
48
49 AC_SUBST( sharedlib, ["librtaudio.so"] )
50 AC_SUBST( sharedname, ["librtaudio.so.\$(RELEASE)"] )
51 AC_SUBST( libflags, ["-shared -Wl,-soname,\$(SHARED).\$(MAJOR) -o \$(SHARED).\$(RELEASE)"] )
52 case $host in
53   *-apple*)
54   AC_SUBST( sharedlib, ["librtaudio.dylib"] )
55   AC_SUBST( sharedname, ["librtaudio.\$(RELEASE).dylib"] )
56   AC_SUBST( libflags, ["-dynamiclib -o librtaudio.\$(RELEASE).dylib"] )
57 esac
58
59 # Checks for package options and external software
60 AC_SUBST( api, [""] )
61 AC_MSG_CHECKING(for audio API)
62 case $host in
63   *-*-netbsd*)
64     AC_MSG_RESULT(using OSS)
65     api="$api -D__LINUX_OSS__"
66     LIBS="$LIBS -lossaudio"
67     AC_CHECK_LIB(pthread, pthread_create, , AC_MSG_ERROR(RtAudio requires the pthread library!))
68   ;;
69
70   *-*-linux*)
71   AC_ARG_WITH(jack, [  --with-jack = choose JACK server support (mac and linux only)], [
72     api="$api -D__UNIX_JACK__"
73     AC_MSG_RESULT(using JACK)
74     AC_CHECK_LIB(jack, jack_client_open, , AC_MSG_ERROR(JACK support requires the jack library!))
75     AC_CHECK_LIB(asound, snd_pcm_open, , AC_MSG_ERROR(Jack support also requires the asound library!))], )
76
77   # Look for ALSA flag
78   AC_ARG_WITH(alsa, [  --with-alsa = choose native ALSA API support (linux only)], [
79     api="$api -D__LINUX_ALSA__"
80     AC_MSG_RESULT(using ALSA)
81     AC_CHECK_LIB(asound, snd_pcm_open, , AC_MSG_ERROR(ALSA support requires the asound library!))], )
82
83   # Look for PULSE flag
84   AC_ARG_WITH(pulse, [  --with-pulse = choose PulseAudio API support (linux only)], [
85     api="$api -D__LINUX_PULSE__"
86     AC_MSG_RESULT(using PulseAudio)
87     AC_CHECK_LIB(pulse-simple, pa_simple_new, , AC_MSG_ERROR(PulseAudio support requires the pulse-simple library!))], )
88
89   # Look for OSS flag
90   AC_ARG_WITH(oss, [  --with-oss = choose OSS API support (linux only)], [
91     api="$api -D__LINUX_OSS__"
92     AC_MSG_RESULT(using OSS)], )
93
94   # If no audio api flags specified, use ALSA
95   if [test "$api" == "";] then
96     AC_MSG_RESULT(using ALSA)
97     AC_SUBST( api, [-D__LINUX_ALSA__] )
98     AC_CHECK_LIB(asound, snd_pcm_open, , AC_MSG_ERROR(ALSA support requires the asound library!))
99   fi
100
101   AC_CHECK_LIB(pthread, pthread_create, , AC_MSG_ERROR(RtAudio requires the pthread library!))
102   ;;
103
104   *-apple*)
105   AC_ARG_WITH(jack, [  --with-jack = choose JACK server support (unix only)], [
106     api="$api -D__UNIX_JACK__"
107     AC_MSG_RESULT(using JACK)
108     AC_CHECK_LIB(jack, jack_client_open, , AC_MSG_ERROR(JACK support requires the jack library!))], )
109
110 #    AC_CHECK_HEADER(jack/jack.h, [], [AC_MSG_ERROR(Jack header file not found!)] )
111 #    LIBS="$LIBS -framework jackmp" ], )
112
113
114   # Look for Core flag
115   AC_ARG_WITH(core, [  --with-core = choose CoreAudio API support (mac only)], [
116     api="$api -D__MACOSX_CORE__"
117     AC_MSG_RESULT(using CoreAudio)
118     AC_CHECK_HEADER(CoreAudio/CoreAudio.h, [], [AC_MSG_ERROR(CoreAudio header files not found!)] )
119     LIBS="$LIBS -framework CoreAudio -framework CoreFoundation" ], )
120
121   # If no audio api flags specified, use CoreAudio
122   if [test "$api" == ""; ] then
123     AC_SUBST( api, [-D__MACOSX_CORE__] )
124     AC_MSG_RESULT(using CoreAudio)
125     AC_CHECK_HEADER(CoreAudio/CoreAudio.h,
126       [],
127       [AC_MSG_ERROR(CoreAudio header files not found!)] )
128     AC_SUBST( LIBS, ["-framework CoreAudio -framework CoreFoundation"] )
129   fi
130
131   AC_CHECK_LIB(pthread, pthread_create, , AC_MSG_ERROR(RtAudio requires the pthread library!))
132   ;;
133
134   *-mingw32*)
135   AC_ARG_WITH(asio, [  --with-asio = choose ASIO API support (windoze only)], [
136     api="$api -D__WINDOWS_ASIO__"
137     AC_MSG_RESULT(using ASIO)
138     AC_SUBST( objects, ["asio.o asiodrivers.o asiolist.o iasiothiscallresolver.o"] ) ], )
139
140   # Look for DirectSound flag
141   AC_ARG_WITH(ds, [  --with-ds = choose DirectSound API support (windoze only)], [
142     api="$api -D__WINDOWS_DS__"
143     AC_MSG_RESULT(using DirectSound)
144     LIBS="-ldsound -lwinmm $LIBS" ], )
145
146   # If no audio api flags specified, use DirectSound
147   if [test "$api" == "";] then
148     AC_SUBST( api, [-D__WINDOWS_DS__] )
149     AC_MSG_RESULT(using DirectSound)
150     LIBS="-ldsound -lwinmm $LIBS"
151   fi
152
153   LIBS="-lole32 $LIBS"
154   ;;
155
156   *)
157   # Default case for unknown realtime systems.
158   AC_MSG_ERROR(Unknown system type for realtime support!)
159   ;;
160 esac
161
162 CPPFLAGS="$CPPFLAGS $api"
163
164 AC_OUTPUT
165
166 chmod oug+x rtaudio-config