Check in of new version 4.0.0 distribution (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_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 libraries.
19 AC_CHECK_LIB(pthread, pthread_create, , AC_MSG_ERROR(RtAudio requires the pthread library!))
20
21
22
23 # Checks for header files.
24 AC_HEADER_STDC
25 AC_CHECK_HEADERS(sys/ioctl.h unistd.h)
26
27 # Checks for typedefs, structures, and compiler characteristics.
28 AC_C_CONST
29
30 # Check for debug
31 AC_MSG_CHECKING(whether to compile debug version)
32 AC_ARG_ENABLE(debug,
33   [  --enable-debug = enable various debug output],
34   [AC_SUBST( debug, [-D__RTAUDIO_DEBUG__] ) AC_SUBST( cflags, [-g] ) AC_SUBST( object_path, [Debug] ) AC_MSG_RESULT(yes)],
35   [AC_SUBST( debug, [] ) AC_SUBST( cflags, [-O2] ) AC_SUBST( object_path, [Release] ) AC_MSG_RESULT(no)])
36
37 # Checks for functions
38 AC_CHECK_FUNC(gettimeofday, [cflags=$cflags" -DHAVE_GETTIMEOFDAY"], )
39
40 # Check compiler and use -Wall if gnu.
41 if [test $GXX = "yes" ;] then
42   AC_SUBST( warn, [-Wall] )
43 fi
44
45 # Checks for package options and external software
46 AC_CANONICAL_HOST
47 AC_MSG_CHECKING(for audio API)
48 case $host in
49   *-*-netbsd*)
50     AC_SUBST( sound_api, [-D__LINUX_OSS__] )
51     AC_MSG_RESULT(using OSS)
52     AC_SUBST( audio_apis, [-D__LINUX_OSS__] )
53     cflags=$cflags" -lossaudio"
54   ;;
55
56   *-*-linux*)
57   AC_SUBST( sound_api, [_NO_API_] )
58   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)], )
59   if [test $sound_api = -D__UNIX_JACK__;] then
60     TEMP_LIBS=$LIBS
61     AC_CHECK_LIB(jack, jack_client_new, , AC_MSG_ERROR(JACK support requires the jack library!))
62     AC_CHECK_LIB(asound, snd_pcm_open, , AC_MSG_ERROR(Jack support also requires the asound library!))
63     LIBS="`pkg-config --cflags --libs jack` $TEMP_LIBS -lasound"
64     audio_apis="-D__UNIX_JACK__"
65   fi
66
67   # Look for Alsa flag
68   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)], )
69   if [test $sound_api = -D__LINUX_ALSA__;] then
70     AC_CHECK_LIB(asound, snd_pcm_open, , AC_MSG_ERROR(ALSA support requires the asound library!))
71     audio_apis="-D__LINUX_ALSA__ $audio_apis"
72   fi
73
74   # Look for OSS flag
75   AC_ARG_WITH(oss, [  --with-oss = choose OSS API support (linux only)], [AC_SUBST( sound_api, [-D__LINUX_OSS__] ) AC_MSG_RESULT(using OSS)], )
76   if test $sound_api = -D__LINUX_OSS__; then
77     audio_apis="-D__LINUX_OSS__ $audio_apis"
78   fi
79
80   # If no audio api flags specified, use OSS
81   if [test $sound_api = _NO_API_;] then
82     AC_SUBST( sound_api, [-D__LINUX_OSS__] )
83     AC_MSG_RESULT(using OSS)
84     AC_SUBST( audio_apis, [-D__LINUX_OSS__] )
85   fi
86   ;;
87
88   *-sgi*)
89   AC_SUBST( audio_apis, ["-D__IRIX_AL__ -LANG:std -w"] )
90   AC_MSG_RESULT(using IRIX AL)
91   AC_CHECK_LIB(audio, alOpenPort, , AC_MSG_ERROR(IRIX audio support requires the audio library!) )
92   ;;
93
94   *-apple*)
95   AC_SUBST( sound_api, [_NO_API_] )
96   AC_ARG_WITH(jack, [  --with-jack = choose JACK server support (unix only)], [AC_SUBST( sound_api, [-D__UNIX_JACK__] ) AC_MSG_RESULT(using JACK)], )
97   if [test $sound_api = -D__UNIX_JACK__;] then
98     AC_CHECK_LIB(jack, jack_client_new, , AC_MSG_ERROR(JACK support requires the jack library!))
99     audio_apis="-D__UNIX_JACK__"
100   fi
101
102   # Look for Core flag
103   AC_ARG_WITH(core, [  --with-core = choose CoreAudio API support (mac only)], [AC_SUBST( sound_api, [-D__MACOSX_CORE__] ) AC_MSG_RESULT(using CoreAudio)], )
104   if test $sound_api = -D__MACOSX_CORE__; then
105     AC_CHECK_HEADER(CoreAudio/CoreAudio.h, [], [AC_MSG_ERROR(CoreAudio header files not found!)] )
106     AC_SUBST( frameworks, ["-framework CoreAudio -framework CoreFoundation"] )
107     audio_apis="-D__MACOSX_CORE__ $audio_apis"
108   fi
109
110   # If no audio api flags specified, use CoreAudio
111   if [test $sound_api = _NO_API_;] then
112     AC_SUBST( sound_api, [-D__MACOSX_CORE__] )
113     AC_MSG_RESULT(using CoreAudio)
114     AC_CHECK_HEADER(CoreAudio/CoreAudio.h,
115       [AC_SUBST( audio_apis, [-D__MACOSX_CORE__] )],
116       [AC_MSG_ERROR(CoreAudio header files not found!)] )
117     AC_SUBST( frameworks, ["-framework CoreAudio -framework CoreFoundation"] )
118   fi
119   ;;
120
121   *)
122   # Default case for unknown realtime systems.
123   AC_MSG_ERROR(Unknown system type for realtime support!)
124   ;;
125 esac
126
127 # Checks for library functions.
128 AC_PROG_GCC_TRADITIONAL
129
130 AC_OUTPUT
131
132 chmod oug+x rtaudio-config