Fix for compile bug in Windows DS and library configure in linux (GS).
[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 OSS flag
84   AC_ARG_WITH(oss, [  --with-oss = choose OSS API support (linux only)], [
85     api="$api -D__LINUX_OSS__"
86     AC_MSG_RESULT(using OSS)], )
87
88   # If no audio api flags specified, use ALSA
89   if [test "$api" == "";] then
90     AC_MSG_RESULT(using ALSA)
91     AC_SUBST( api, [-D__LINUX_ALSA__] )
92     AC_CHECK_LIB(asound, snd_pcm_open, , AC_MSG_ERROR(ALSA support requires the asound library!))
93   fi
94
95   AC_CHECK_LIB(pthread, pthread_create, , AC_MSG_ERROR(RtAudio requires the pthread library!))
96   ;;
97
98   *-apple*)
99   AC_ARG_WITH(jack, [  --with-jack = choose JACK server support (unix only)], [
100     api="$api -D__UNIX_JACK__"
101     AC_MSG_RESULT(using JACK)
102     AC_CHECK_LIB(jack, jack_client_open, , AC_MSG_ERROR(JACK support requires the jack library!))], )
103
104 #    AC_CHECK_HEADER(jack/jack.h, [], [AC_MSG_ERROR(Jack header file not found!)] )
105 #    LIBS="$LIBS -framework jackmp" ], )
106
107
108   # Look for Core flag
109   AC_ARG_WITH(core, [  --with-core = choose CoreAudio API support (mac only)], [
110     api="$api -D__MACOSX_CORE__"
111     AC_MSG_RESULT(using CoreAudio)
112     AC_CHECK_HEADER(CoreAudio/CoreAudio.h, [], [AC_MSG_ERROR(CoreAudio header files not found!)] )
113     LIBS="$LIBS -framework CoreAudio -framework CoreFoundation" ], )
114
115   # If no audio api flags specified, use CoreAudio
116   if [test "$api" == ""; ] then
117     AC_SUBST( api, [-D__MACOSX_CORE__] )
118     AC_MSG_RESULT(using CoreAudio)
119     AC_CHECK_HEADER(CoreAudio/CoreAudio.h,
120       [],
121       [AC_MSG_ERROR(CoreAudio header files not found!)] )
122     AC_SUBST( LIBS, ["-framework CoreAudio -framework CoreFoundation"] )
123   fi
124
125   AC_CHECK_LIB(pthread, pthread_create, , AC_MSG_ERROR(RtAudio requires the pthread library!))
126   ;;
127
128   *-mingw32*)
129   AC_ARG_WITH(asio, [  --with-asio = choose ASIO API support (windoze only)], [
130     api="$api -D__WINDOWS_ASIO__"
131     AC_MSG_RESULT(using ASIO)
132     AC_SUBST( objects, ["asio.o asiodrivers.o asiolist.o iasiothiscallresolver.o"] ) ], )
133
134   # Look for DirectSound flag
135   AC_ARG_WITH(ds, [  --with-ds = choose DirectSound API support (windoze only)], [
136     api="$api -D__WINDOWS_DS__"
137     AC_MSG_RESULT(using DirectSound)
138     LIBS="-ldsound -lwinmm $LIBS" ], )
139
140   # If no audio api flags specified, use DirectSound
141   if [test "$api" == "";] then
142     AC_SUBST( api, [-D__WINDOWS_DS__] )
143     AC_MSG_RESULT(using DirectSound)
144     LIBS="-ldsound -lwinmm $LIBS"
145   fi
146
147   LIBS="-lole32 $LIBS"
148   ;;
149
150   *)
151   # Default case for unknown realtime systems.
152   AC_MSG_ERROR(Unknown system type for realtime support!)
153   ;;
154 esac
155
156 CPPFLAGS="$CPPFLAGS $api"
157
158 AC_OUTPUT
159
160 chmod oug+x rtaudio-config