Release 4.0.12 tarball
[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 librtaudio.pc Makefile tests/Makefile])
6
7 # Fill GXX with something before test.
8 AC_SUBST( GXX, ["no"] )
9
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])
13 AC_MSG_RESULT([no])])
14
15 PKG_PROG_PKG_CONFIG
16
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])
21 AC_MSG_RESULT([no])
22 $4])
23
24 # Checks for programs.
25 AC_PROG_CXX(g++ CC c++ cxx)
26 AC_PROG_RANLIB
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");
30 fi
31
32 # Checks for header files.
33 AC_HEADER_STDC
34 AC_CHECK_HEADERS(sys/ioctl.h unistd.h)
35
36 # Check for debug
37 AC_MSG_CHECKING(whether to compile debug version)
38 AC_ARG_ENABLE(debug,
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)])
42
43
44 # Checks for functions
45 AC_CHECK_FUNC(gettimeofday, [cppflag="$cppflag -DHAVE_GETTIMEOFDAY"], )
46
47 # For -I and -D flags
48 CPPFLAGS="$CPPFLAGS $cppflag"
49
50 # For debugging and optimization ... overwrite default because it has both -g and -O2
51 #CXXFLAGS="$CXXFLAGS $cxxflag"
52 CXXFLAGS="$cxxflag"
53
54 # Check compiler and use -Wall if gnu.
55 if [test $GXX = "yes" ;] then
56   AC_SUBST( cxxflag, [-Wall] )
57 fi
58
59 CXXFLAGS="$CXXFLAGS $cxxflag"
60
61 AC_CANONICAL_HOST
62
63 AC_SUBST( sharedlib, ["librtaudio.so"] )
64 AC_SUBST( sharedname, ["librtaudio.so.\$(RELEASE)"] )
65 AC_SUBST( libflags, ["-shared -Wl,-soname,\$(SHARED).\$(MAJOR) -o \$(SHARED).\$(RELEASE)"] )
66 case $host in
67   *-apple*)
68   AC_SUBST( sharedlib, ["librtaudio.dylib"] )
69   AC_SUBST( sharedname, ["librtaudio.\$(RELEASE).dylib"] )
70   AC_SUBST( libflags, ["-dynamiclib -o librtaudio.\$(RELEASE).dylib"] )
71 esac
72
73 # Checks for package options and external software
74 AC_SUBST( api, [""] )
75 AC_SUBST( req, [""] )
76 AC_MSG_CHECKING(for audio API)
77 case $host in
78   *-*-netbsd*)
79     AC_MSG_RESULT(using OSS)
80     api="$api -D__LINUX_OSS__"
81     LIBS="$LIBS -lossaudio"
82     AC_CHECK_LIB(pthread, pthread_create, , AC_MSG_ERROR(RtAudio requires the pthread library!))
83   ;;
84
85   *-*-linux*)
86   AC_ARG_WITH(jack, [  --with-jack = choose JACK server support (mac and linux only)], [
87     api="$api -D__UNIX_JACK__"
88     AC_MSG_RESULT(using JACK)
89     AC_CHECK_LIB(jack, jack_client_open, , AC_MSG_ERROR(JACK support requires the jack library!))
90     AC_CHECK_LIB(asound, snd_pcm_open, , AC_MSG_ERROR(Jack support also requires the asound library!))], )
91
92   # Look for ALSA flag
93   AC_ARG_WITH(alsa, [  --with-alsa = choose native ALSA API support (linux only)], [
94     api="$api -D__LINUX_ALSA__"
95     req="$req alsa"
96     AC_MSG_RESULT(using ALSA)
97     AC_CHECK_LIB(asound, snd_pcm_open, , AC_MSG_ERROR(ALSA support requires the asound library!))], )
98
99   # Look for PULSE flag
100   AC_ARG_WITH(pulse, [  --with-pulse = choose PulseAudio API support (linux only)], [
101     api="$api -D__LINUX_PULSE__"
102     req="$req libpulse-simple"
103     AC_MSG_RESULT(using PulseAudio)
104     PKG_CHECK_MODULES([PULSE], [libpulse-simple], , AC_MSG_ERROR(PulseAudio support requires the pulse-simple library!))
105         LIBS="$LIBS `pkg-config --libs libpulse-simple`" ], )
106
107   # Look for OSS flag
108   AC_ARG_WITH(oss, [  --with-oss = choose OSS API support (linux only)], [
109     api="$api -D__LINUX_OSS__"
110     AC_MSG_RESULT(using OSS)], )
111
112   # If no audio api flags specified, use ALSA
113   if [test "$api" == "";] then
114     AC_MSG_RESULT(using ALSA)
115     AC_SUBST( api, [-D__LINUX_ALSA__] )
116     req="$req alsa"
117     AC_CHECK_LIB(asound, snd_pcm_open, , AC_MSG_ERROR(ALSA support requires the asound library!))
118   fi
119
120   AC_CHECK_LIB(pthread, pthread_create, , AC_MSG_ERROR(RtAudio requires the pthread library!))
121   ;;
122
123   *-apple*)
124   AC_ARG_WITH(jack, [  --with-jack = choose JACK server support (unix only)], [
125     api="$api -D__UNIX_JACK__"
126     AC_MSG_RESULT(using JACK)
127     AC_CHECK_LIB(jack, jack_client_open, , AC_MSG_ERROR(JACK support requires the jack library!))], )
128
129 #    AC_CHECK_HEADER(jack/jack.h, [], [AC_MSG_ERROR(Jack header file not found!)] )
130 #    LIBS="$LIBS -framework jackmp" ], )
131
132
133   # Look for Core flag
134   AC_ARG_WITH(core, [  --with-core = choose CoreAudio API support (mac only)], [
135     api="$api -D__MACOSX_CORE__"
136     AC_MSG_RESULT(using CoreAudio)
137     AC_CHECK_HEADER(CoreAudio/CoreAudio.h, [], [AC_MSG_ERROR(CoreAudio header files not found!)] )
138     LIBS="$LIBS -framework CoreAudio -framework CoreFoundation" ], )
139
140   # If no audio api flags specified, use CoreAudio
141   if [test "$api" == ""; ] then
142     AC_SUBST( api, [-D__MACOSX_CORE__] )
143     AC_MSG_RESULT(using CoreAudio)
144     AC_CHECK_HEADER(CoreAudio/CoreAudio.h,
145       [],
146       [AC_MSG_ERROR(CoreAudio header files not found!)] )
147     AC_SUBST( LIBS, ["-framework CoreAudio -framework CoreFoundation"] )
148   fi
149
150   AC_CHECK_LIB(pthread, pthread_create, , AC_MSG_ERROR(RtAudio requires the pthread library!))
151   ;;
152
153   *-mingw32*)
154   AC_ARG_WITH(asio, [  --with-asio = choose ASIO API support (windoze only)], [
155     api="$api -D__WINDOWS_ASIO__"
156     AC_MSG_RESULT(using ASIO)
157     AC_SUBST( objects, ["asio.o asiodrivers.o asiolist.o iasiothiscallresolver.o"] ) ], )
158
159   # Look for DirectSound flag
160   AC_ARG_WITH(ds, [  --with-ds = choose DirectSound API support (windoze only)], [
161     api="$api -D__WINDOWS_DS__"
162     AC_MSG_RESULT(using DirectSound)
163     LIBS="-ldsound -lwinmm $LIBS" ], )
164
165   # If no audio api flags specified, use DirectSound
166   if [test "$api" == "";] then
167     AC_SUBST( api, [-D__WINDOWS_DS__] )
168     AC_MSG_RESULT(using DirectSound)
169     LIBS="-ldsound -lwinmm $LIBS"
170   fi
171
172   LIBS="-lole32 $LIBS"
173   ;;
174
175   *)
176   # Default case for unknown realtime systems.
177   AC_MSG_ERROR(Unknown system type for realtime support!)
178   ;;
179 esac
180
181 CPPFLAGS="$CPPFLAGS $api"
182
183 AC_OUTPUT
184
185 chmod oug+x rtaudio-config