Version 3.0
[rtaudio.git] / configure.ac
1 # Process this file with autoconf to produce a configure script.
2 AC_INIT(RtAudio, 3.0, gary@ccrma.stanford.edu, rtaudio)
3 AC_CONFIG_SRCDIR(RtAudio.cpp)
4 AC_CONFIG_FILES(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
13 # Checks for libraries.
14 AC_CHECK_LIB(pthread, pthread_create, , AC_MSG_ERROR(RtAudio requires the pthread library!))
15
16 # Checks for header files.
17 AC_HEADER_STDC
18 AC_CHECK_HEADERS(sys/ioctl.h unistd.h)
19
20 # Checks for typedefs, structures, and compiler characteristics.
21 AC_C_CONST
22
23 # Check for debug
24 AC_MSG_CHECKING(whether to compile debug version)
25 AC_ARG_ENABLE(debug,
26   [  --enable-debug = enable various debug output],
27   [AC_SUBST( debug, [-D__RTAUDIO_DEBUG__] ) AC_SUBST( cflags, [-g] ) AC_SUBST( object_path, [Debug] ) AC_MSG_RESULT(yes)],
28   [AC_SUBST( debug, [] ) AC_SUBST( cflags, [-O2] ) AC_SUBST( object_path, [Release] ) AC_MSG_RESULT(no)])
29
30 # Check compiler and use -Wall if gnu.
31 if [test $GXX = "yes" ;] then
32   AC_SUBST( warn, [-Wall] )
33 fi
34
35 # Checks for package options and external software
36 AC_CANONICAL_HOST
37 AC_MSG_CHECKING(for audio API)
38 case $host in
39   *-*-linux*)
40   AC_SUBST( sound_api, [_NO_API_] )
41   AC_ARG_WITH(jack, [  --with-jack = choose JACK server support (linux only)], [AC_SUBST( sound_api, [-D__LINUX_JACK__] ) AC_MSG_RESULT(using JACK)], )
42   if [test $sound_api = -D__LINUX_JACK__;] then
43     TEMP_LIBS=$LIBS
44     AC_CHECK_LIB(jack, jack_client_new, , AC_MSG_ERROR(JACK support requires the jack library!))
45     AC_CHECK_LIB(asound, snd_pcm_open, , AC_MSG_ERROR(Jack support also requires the asound library!))
46     LIBS="`pkg-config --cflags --libs jack` $TEMP_LIBS -lasound"
47     audio_apis="-D__LINUX_JACK__"
48   fi
49
50   # Look for Alsa flag
51   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)], )
52   if [test $sound_api = -D__LINUX_ALSA__;] then
53     AC_CHECK_LIB(asound, snd_pcm_open, , AC_MSG_ERROR(ALSA support requires the asound library!))
54     audio_apis="-D__LINUX_ALSA__ $audio_apis"
55   fi
56
57   # Look for OSS flag
58   AC_ARG_WITH(oss, [  --with-oss = choose OSS API support (linux only)], [AC_SUBST( sound_api, [-D__LINUX_OSS__] ) AC_MSG_RESULT(using OSS)], )
59   if test $sound_api = -D__LINUX_OSS__; then
60     audio_apis="-D__LINUX_OSS__ $audio_apis"
61   fi
62
63   # If no audio api flags specified, use OSS
64   if [test $sound_api = _NO_API_;] then
65     AC_SUBST( sound_api, [-D__LINUX_OSS__] )
66     AC_MSG_RESULT(using OSS)
67     AC_SUBST( audio_apis, [-D__LINUX_OSS__] )
68   fi
69   ;;
70
71   *-sgi*)
72   AC_SUBST( audio_apis, ["-D__IRIX_AL__ -LANG:std -w"] )
73   AC_MSG_RESULT(using IRIX AL)
74   AC_CHECK_LIB(audio, alOpenPort, , AC_MSG_ERROR(IRIX audio support requires the audio library!) )
75   ;;
76
77   *-apple*)
78   # Check for CoreAudio framework
79   AC_CHECK_HEADER(CoreAudio/CoreAudio.h,
80     [AC_SUBST( audio_apis, [-D__MACOSX_CORE__] )],
81     [AC_MSG_ERROR(CoreAudio header files not found!)] )
82   AC_SUBST( frameworks, ["-framework CoreAudio"] )
83   AC_CHECK_LIB(stdc++, printf, , AC_MSG_ERROR(RtAudio requires the C++ library!) )
84   ;;
85
86   *)
87   # Default case for unknown realtime systems.
88   AC_MSG_ERROR(Unknown system type for realtime support!)
89   ;;
90 esac
91
92 # Checks for library functions.
93 AC_PROG_GCC_TRADITIONAL
94
95 AC_OUTPUT