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