5949a5e0884a901d32f1f76863e737be0af59264
[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_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 # Checks for package options and external software
41 AC_CANONICAL_HOST
42 AC_MSG_CHECKING(for audio API)
43 case $host in
44   *-*-netbsd*)
45     AC_SUBST( sound_api, [-D__LINUX_OSS__] )
46     AC_MSG_RESULT(using OSS)
47     AC_SUBST( audio_apis, [-D__LINUX_OSS__] )
48     cflags=$cflags" -lossaudio"
49     AC_CHECK_LIB(pthread, pthread_create, , AC_MSG_ERROR(RtAudio requires the pthread library!))
50   ;;
51
52   *-*-linux*)
53   AC_SUBST( sound_api, [_NO_API_] )
54   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)], )
55   if [test $sound_api = -D__UNIX_JACK__;] then
56     TEMP_LIBS=$LIBS
57     AC_CHECK_LIB(jack, jack_client_new, , AC_MSG_ERROR(JACK support requires the jack library!))
58     AC_CHECK_LIB(asound, snd_pcm_open, , AC_MSG_ERROR(Jack support also requires the asound library!))
59     LIBS="`pkg-config --cflags --libs jack` $TEMP_LIBS -lasound"
60     audio_apis="-D__UNIX_JACK__"
61   fi
62
63   # Look for ALSA flag
64   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)], )
65   if [test $sound_api = -D__LINUX_ALSA__;] then
66     AC_CHECK_LIB(asound, snd_pcm_open, , AC_MSG_ERROR(ALSA support requires the asound library!))
67     audio_apis="-D__LINUX_ALSA__ $audio_apis"
68   fi
69
70   # Look for OSS flag
71   AC_ARG_WITH(oss, [  --with-oss = choose OSS API support (linux only)], [AC_SUBST( sound_api, [-D__LINUX_OSS__] ) AC_MSG_RESULT(using OSS)], )
72   if test $sound_api = -D__LINUX_OSS__; then
73     audio_apis="-D__LINUX_OSS__ $audio_apis"
74   fi
75
76   # If no audio api flags specified, use ALSA
77   if [test $sound_api = _NO_API_;] then
78     AC_MSG_RESULT(using ALSA)
79     AC_SUBST( audio_apis, [-D__LINUX_ALSA__] )
80     AC_CHECK_LIB(asound, snd_pcm_open, , AC_MSG_ERROR(ALSA support requires the asound library!))
81   fi
82
83   AC_CHECK_LIB(pthread, pthread_create, , AC_MSG_ERROR(RtAudio requires the pthread library!))
84   ;;
85
86   *-apple*)
87   AC_SUBST( sound_api, [_NO_API_] )
88   AC_ARG_WITH(jack, [  --with-jack = choose JACK server support (unix only)], [AC_SUBST( sound_api, [-D__UNIX_JACK__] ) AC_MSG_RESULT(using JACK)], )
89   if [test $sound_api = -D__UNIX_JACK__;] then
90     AC_CHECK_LIB(jack, jack_client_new, , AC_MSG_ERROR(JACK support requires the jack library!))
91     audio_apis="-D__UNIX_JACK__"
92   fi
93
94   # Look for Core flag
95   AC_ARG_WITH(core, [  --with-core = choose CoreAudio API support (mac only)], [AC_SUBST( sound_api, [-D__MACOSX_CORE__] ) AC_MSG_RESULT(using CoreAudio)], )
96   if test $sound_api = -D__MACOSX_CORE__; then
97     AC_CHECK_HEADER(CoreAudio/CoreAudio.h, [], [AC_MSG_ERROR(CoreAudio header files not found!)] )
98     AC_SUBST( frameworks, ["-framework CoreAudio -framework CoreFoundation"] )
99     audio_apis="-D__MACOSX_CORE__ $audio_apis"
100   fi
101
102   # If no audio api flags specified, use CoreAudio
103   if [test $sound_api = _NO_API_;] then
104     AC_SUBST( sound_api, [-D__MACOSX_CORE__] )
105     AC_MSG_RESULT(using CoreAudio)
106     AC_CHECK_HEADER(CoreAudio/CoreAudio.h,
107       [AC_SUBST( audio_apis, [-D__MACOSX_CORE__] )],
108       [AC_MSG_ERROR(CoreAudio header files not found!)] )
109     AC_SUBST( frameworks, ["-framework CoreAudio -framework CoreFoundation"] )
110   fi
111
112   AC_CHECK_LIB(pthread, pthread_create, , AC_MSG_ERROR(RtAudio requires the pthread library!))
113   ;;
114
115   *-mingw32*)
116   AC_SUBST( sound_api, [_NO_API_] )
117   AC_ARG_WITH(asio, [  --with-asio = choose ASIO API support (windoze only)], [AC_SUBST( sound_api, [-D__WINDOWS_ASIO__] ) AC_MSG_RESULT(using ASIO)], )
118   if [test $sound_api = -D__WINDOWS_ASIO__;] then
119     audio_apis="-D__WINDOWS_ASIO__"
120     AC_SUBST( objects, ["asio.o asiodrivers.o asiolist.o iasiothiscallresolver.o"] )
121   fi
122
123   # Look for DirectSound flag
124   AC_ARG_WITH(ds, [  --with-ds = choose DirectSound API support (windoze only)], [AC_SUBST( sound_api, [-D__WINDOWS_DS__] ) AC_MSG_RESULT(using DirectSound)], )
125   if test $sound_api = -D__WINDOWS_DS__; then
126     audio_apis="-D__WINDOWS_DS__ $audio_apis"
127     LIBS="-ldsound -lwinmm $LIBS"
128   fi
129
130   # If no audio api flags specified, use DirectSound
131   if [test $sound_api = _NO_API_;] then
132     AC_SUBST( sound_api, [-D__WINDOWS_DS__] )
133     AC_MSG_RESULT(using DirectSound)
134     audio_apis="-D__WINDOWS_DS__"
135     LIBS="-ldsound -lwinmm $LIBS"
136   fi
137
138   LIBS="-lole32 $LIBS"
139   ;;
140
141   *)
142   # Default case for unknown realtime systems.
143   AC_MSG_ERROR(Unknown system type for realtime support!)
144   ;;
145 esac
146
147 # Checks for library functions.
148 AC_PROG_GCC_TRADITIONAL
149
150 AC_OUTPUT
151
152 chmod oug+x rtaudio-config