Various updates in ALSA for probing while device is open and in Windows for thread...
[rtaudio-cdist.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_SRCDIR(RtAudio.cpp)
4 AC_CONFIG_FILES([rtaudio-config Makefile tests/Makefile])
5
6 # Fill GXX with something before test.
7 AC_SUBST( GXX, ["no"] )
8
9 # Checks for programs.
10 AC_PROG_CC
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 # Checks for typedefs, structures, and compiler characteristics.
23 AC_C_CONST
24
25 # Check for debug
26 AC_MSG_CHECKING(whether to compile debug version)
27 AC_ARG_ENABLE(debug,
28   [  --enable-debug = enable various debug output],
29   [AC_SUBST( debug, [-D__RTAUDIO_DEBUG__] ) AC_SUBST( cflags, [-g] ) AC_SUBST( object_path, [Debug] ) AC_MSG_RESULT(yes)],
30   [AC_SUBST( debug, [] ) AC_SUBST( cflags, [-O2] ) AC_SUBST( object_path, [Release] ) AC_MSG_RESULT(no)])
31
32 # Checks for functions
33 AC_CHECK_FUNC(gettimeofday, [CFLAGS=$CFLAGS" -DHAVE_GETTIMEOFDAY"], )
34
35 # Check compiler and use -Wall if gnu.
36 if [test $GXX = "yes" ;] then
37   AC_SUBST( warn, [-Wall] )
38 fi
39
40 CFLAGS="$CFLAGS $cflags"
41
42 # Checks for package options and external software
43 AC_CANONICAL_HOST
44 AC_MSG_CHECKING(for audio API)
45 case $host in
46   *-*-netbsd*)
47     AC_SUBST( sound_api, [-D__LINUX_OSS__] )
48     AC_MSG_RESULT(using OSS)
49     AC_SUBST( audio_apis, [-D__LINUX_OSS__] )
50     CFLAGS=$CFLAGS" -lossaudio"
51     AC_CHECK_LIB(pthread, pthread_create, , AC_MSG_ERROR(RtAudio requires the pthread library!))
52   ;;
53
54   *-*-linux*)
55   AC_SUBST( sound_api, [_NO_API_] )
56   AC_ARG_WITH(jack, [  --with-jack = choose JACK server support (mac and linux only)], [AC_SUBST( sound_api, [-D__UNIX_JACK__] ) AC_MSG_RESULT(using JACK)], )
57   if [test $sound_api = -D__UNIX_JACK__;] then
58     TEMP_LIBS=$LIBS
59     AC_CHECK_LIB(jack, jack_client_new, , AC_MSG_ERROR(JACK support requires the jack library!))
60     AC_CHECK_LIB(asound, snd_pcm_open, , AC_MSG_ERROR(Jack support also requires the asound library!))
61     LIBS="`pkg-config --CFLAGS --libs jack` $TEMP_LIBS -lasound"
62     audio_apis="-D__UNIX_JACK__"
63   fi
64
65   # Look for ALSA flag
66   AC_ARG_WITH(alsa, [  --with-alsa = choose native ALSA API support (linux only)], [AC_SUBST( sound_api, [-D__LINUX_ALSA__] ) AC_MSG_RESULT(using ALSA)], )
67   if [test $sound_api = -D__LINUX_ALSA__;] then
68     AC_CHECK_LIB(asound, snd_pcm_open, , AC_MSG_ERROR(ALSA support requires the asound library!))
69     audio_apis="-D__LINUX_ALSA__ $audio_apis"
70   fi
71
72   # Look for OSS flag
73   AC_ARG_WITH(oss, [  --with-oss = choose OSS API support (linux only)], [AC_SUBST( sound_api, [-D__LINUX_OSS__] ) AC_MSG_RESULT(using OSS)], )
74   if test $sound_api = -D__LINUX_OSS__; then
75     audio_apis="-D__LINUX_OSS__ $audio_apis"
76   fi
77
78   # If no audio api flags specified, use ALSA
79   if [test $sound_api = _NO_API_;] then
80     AC_MSG_RESULT(using ALSA)
81     AC_SUBST( audio_apis, [-D__LINUX_ALSA__] )
82     AC_CHECK_LIB(asound, snd_pcm_open, , AC_MSG_ERROR(ALSA support requires the asound library!))
83   fi
84
85   AC_CHECK_LIB(pthread, pthread_create, , AC_MSG_ERROR(RtAudio requires the pthread library!))
86   ;;
87
88   *-apple*)
89   AC_SUBST( sound_api, [_NO_API_] )
90   AC_ARG_WITH(jack, [  --with-jack = choose JACK server support (unix only)], [AC_SUBST( sound_api, [-D__UNIX_JACK__] ) AC_MSG_RESULT(using JACK)], )
91   if [test $sound_api = -D__UNIX_JACK__;] then
92     AC_CHECK_LIB(jack, jack_client_new, , AC_MSG_ERROR(JACK support requires the jack library!))
93     audio_apis="-D__UNIX_JACK__"
94   fi
95
96   # Look for Core flag
97   AC_ARG_WITH(core, [  --with-core = choose CoreAudio API support (mac only)], [AC_SUBST( sound_api, [-D__MACOSX_CORE__] ) AC_MSG_RESULT(using CoreAudio)], )
98   if test $sound_api = -D__MACOSX_CORE__; then
99     AC_CHECK_HEADER(CoreAudio/CoreAudio.h, [], [AC_MSG_ERROR(CoreAudio header files not found!)] )
100     AC_SUBST( frameworks, ["-framework CoreAudio -framework CoreFoundation"] )
101     audio_apis="-D__MACOSX_CORE__ $audio_apis"
102   fi
103
104   # If no audio api flags specified, use CoreAudio
105   if [test $sound_api = _NO_API_;] then
106     AC_SUBST( sound_api, [-D__MACOSX_CORE__] )
107     AC_MSG_RESULT(using CoreAudio)
108     AC_CHECK_HEADER(CoreAudio/CoreAudio.h,
109       [AC_SUBST( audio_apis, [-D__MACOSX_CORE__] )],
110       [AC_MSG_ERROR(CoreAudio header files not found!)] )
111     AC_SUBST( frameworks, ["-framework CoreAudio -framework CoreFoundation"] )
112   fi
113
114   AC_CHECK_LIB(pthread, pthread_create, , AC_MSG_ERROR(RtAudio requires the pthread library!))
115   ;;
116
117   *-mingw32*)
118   AC_SUBST( sound_api, [_NO_API_] )
119   AC_ARG_WITH(asio, [  --with-asio = choose ASIO API support (windoze only)], [AC_SUBST( sound_api, [-D__WINDOWS_ASIO__] ) AC_MSG_RESULT(using ASIO)], )
120   if [test $sound_api = -D__WINDOWS_ASIO__;] then
121     audio_apis="-D__WINDOWS_ASIO__"
122     AC_SUBST( objects, ["asio.o asiodrivers.o asiolist.o iasiothiscallresolver.o"] )
123   fi
124
125   # Look for DirectSound flag
126   AC_ARG_WITH(ds, [  --with-ds = choose DirectSound API support (windoze only)], [AC_SUBST( sound_api, [-D__WINDOWS_DS__] ) AC_MSG_RESULT(using DirectSound)], )
127   if test $sound_api = -D__WINDOWS_DS__; then
128     audio_apis="-D__WINDOWS_DS__ $audio_apis"
129     LIBS="-ldsound -lwinmm $LIBS"
130   fi
131
132   # If no audio api flags specified, use DirectSound
133   if [test $sound_api = _NO_API_;] then
134     AC_SUBST( sound_api, [-D__WINDOWS_DS__] )
135     AC_MSG_RESULT(using DirectSound)
136     audio_apis="-D__WINDOWS_DS__"
137     LIBS="-ldsound -lwinmm $LIBS"
138   fi
139
140   LIBS="-lole32 $LIBS"
141   ;;
142
143   *)
144   # Default case for unknown realtime systems.
145   AC_MSG_ERROR(Unknown system type for realtime support!)
146   ;;
147 esac
148
149 # Checks for library functions.
150 AC_PROG_GCC_TRADITIONAL
151
152 AC_OUTPUT
153
154 chmod oug+x rtaudio-config