Recognizes if input is ogg or not.
[xiph.git] / ao / configure.ac
blob2c6fd59a54cfa7c9410efcfc24a241151977728d
1 dnl Process this file with autoconf to produce a configure script.
3 AC_INIT([libao],[0.8.8],[benjihan@users.sourceforge.net])
4 AM_INIT_AUTOMAKE([gnu 1.6])
6 AM_MAINTAINER_MODE
8 dnl $$$ben: Is that neccessary ? And why ?
9 AM_DISABLE_STATIC
11 dnl Library versioning
12 LIB_CURRENT=3
13 LIB_REVISION=3
14 LIB_AGE=1
15 AC_SUBST(LIB_CURRENT)
16 AC_SUBST(LIB_REVISION)
17 AC_SUBST(LIB_AGE)
19 dnl Plugin versioning.  We use an integer version number much like LIB_CURRENT.
20 PLUGIN_VERSION=2
22 AC_CANONICAL_BUILD
23 AC_CANONICAL_HOST
25 plugindir=$libdir/ao/plugins-$PLUGIN_VERSION
26 AC_SUBST(plugindir)
28 dnl ====================================
29 dnl Check for programs
30 dnl ====================================
32 AC_PROG_CC
33 AC_LIBTOOL_WIN32_DLL
34 AC_LIBTOOL_DLOPEN
35 AM_PROG_LIBTOOL
37 dnl ====================================
38 dnl Check dlopen 
39 dnl ====================================
41 dnl Currently use this to disable plugin support dlfcn.h
42 AC_CHECK_HEADERS([dlfcn.h],
43         [AC_SEARCH_LIBS([dlopen],[dl],
44                 [AC_DEFINE([HAVE_DLOPEN],[1],
45                         [support dynamic linking loader])])])
47 dnl ====================================
48 dnl Set some general compile options
49 dnl ====================================
51 cflags_save="$CFLAGS"
52 if test -z "$GCC"; then
53         case $host in
54         *-*-irix*)
55                 if test -z "$CC"; then
56                         CC=cc
57                 fi
58                 PLUGIN_LDFLAGS="-export-dynamic -avoid-version"
59                 DEBUG="-g -signed"
60                 CFLAGS="-O2 -w -signed"
61                 PROFILE="-p -g3 -O2 -signed" ;;
62         sparc-sun-solaris*)
63                 PLUGIN_LDFLAGS="-export-dynamic -avoid-version"
64                 DEBUG="-v -g"
65                 CFLAGS="-xO4 -fast -w -fsimple -native -xcg92"
66                 PROFILE="-v -xpg -g -xO4 -fast -native -fsimple -xcg92 -Dsuncc" ;;
67         *)
68                 PLUGIN_LDFLAGS="-export-dynamic -avoid-version"
69                 DEBUG="-g"
70                 CFLAGS="-O"
71                 PROFILE="-g -p" ;;
72         esac
73 else
75         case $host in
76         *-*-linux*)
77                 PLUGIN_LDFLAGS="-export-dynamic -avoid-version"
78                 DEBUG="-g -Wall -D_REENTRANT -D__NO_MATH_INLINES -fsigned-char"
79                 CFLAGS="-O20 -ffast-math -D_REENTRANT -fsigned-char"
80                 PROFILE="-pg -g -O20 -ffast-math -D_REENTRANT -fsigned-char";;
81         sparc-sun-*)
82                 PLUGIN_LDFLAGS="-export-dynamic -avoid-version"
83                 DEBUG="-g -Wall -D__NO_MATH_INLINES -fsigned-char"
84                 CFLAGS="-O20 -ffast-math -D__NO_MATH_INLINES -fsigned-char"
85                 PROFILE="-pg -g -O20 -D__NO_MATH_INLINES -fsigned-char" ;;
86         *-darwin*)
87                 PLUGIN_LDFLAGS="-module -avoid-version"
88                 DEBUG="-g -Wall -D__NO_MATH_INLINES -fsigned-char -Ddlsym=dlsym_auto_underscore"
89                 CFLAGS="-D__NO_MATH_INLINES -fsigned-char -Ddlsym=dlsym_auto_underscore"
90                 PROFILE="-g -pg -D__NO_MATH_INLINES -fsigned-char -Ddlsym=dlsym_auto_underscore" ;;
91         *)
92                 PLUGIN_LDFLAGS="-export-dynamic -avoid-version"
93                 DEBUG="-g -Wall -D__NO_MATH_INLINES -fsigned-char"
94                 CFLAGS="-O20 -D__NO_MATH_INLINES -fsigned-char"
95                 PROFILE="-O20 -g -pg -D__NO_MATH_INLINES -fsigned-char" ;;
96         esac
98 CFLAGS="$CFLAGS $cflags_save"
99 DEBUG="$DEBUG $cflags_save"
100 PROFILE="$PROFILE $cflags_save"
103 AC_SUBST(DEBUG)
104 AC_SUBST(PROFILE)
106 dnl =========================================
107 dnl Need -no-undefined for building win32 dll
108 dnl =========================================
109 dnl Should we do that for cygwin too ???
110 dnl I guess so but it needs to be tested.
111 case $host in
112     *-mingw*|*-cygwin*)
113         LIBAO_LA_LDFLAGS="-no-undefined"
114         ;;
115     *)  
116         LIBAO_LA_LDFLAGS=""
117         ;;
118 esac
119 AC_SUBST(LIBAO_LA_LDFLAGS)
121 dnl ==============================
122 dnl Check for libraries
123 dnl ==============================
125 # we link to libpthread just in case one of our plugins does
126 # in which case this is required to avoid problems on dlclose()
127 AC_CHECK_LIB(pthread, pthread_kill)
129 dnl ==============================
130 dnl Checks for header files
131 dnl ==============================
133 dnl ==============================
134 dnl Select proper plugin options
135 dnl ==============================
136 case $host in
137     *hpux*)
138         DLOPEN_FLAG='(RTLD_LAZY)'
139         SHARED_LIB_EXT='.sl'
140         ;;    
141     *openbsd* | *netbsd* | *solaris2.7)
142         DLOPEN_FLAG='(RTLD_LAZY)'
143         SHARED_LIB_EXT='.so'
144         ;;
145     *)
146         DLOPEN_FLAG='(RTLD_NOW | RTLD_GLOBAL)'
147         SHARED_LIB_EXT='.so'
148         ;;
149 esac
150 AC_DEFINE_UNQUOTED(DLOPEN_FLAG, $DLOPEN_FLAG)
151 AC_DEFINE_UNQUOTED(SHARED_LIB_EXT, "$SHARED_LIB_EXT")
153 dnl ==============================
154 dnl Checks for types
155 dnl ==============================
157 AC_CHECK_SIZEOF(short)
158 AC_CHECK_SIZEOF(int)
159 AC_CHECK_SIZEOF(long)
161 case 2 in
162         $ac_cv_sizeof_short) SIZE16="short";;
163         $ac_cv_sizeof_int) SIZE16="int";;
164 esac
166 case 4 in
167         $ac_cv_sizeof_short) SIZE32="short";;
168         $ac_cv_sizeof_int) SIZE32="int";;
169         $ac_cv_sizeof_long) SIZE32="long";;
170 esac
172 if test -z "$SIZE16"; then
173         AC_MSG_ERROR(No 16 bit type found on this platform!)
175 if test -z "$SIZE32"; then
176         AC_MSG_ERROR(No 32 bit type found on this platform!)
179 AC_SUBST(SIZE16)
180 AC_SUBST(SIZE32)
182 dnl ======================================
183 dnl Detect possible output devices 
184 dnl ======================================
186 dnl Check for WMM
188 [has_wmm="no"]
189 AC_ARG_ENABLE([wmm],
190     [AS_HELP_STRING(
191         [--enable-wmm],
192         [include WMM output plugin @<:@default=check@:>@])],
193         [],[enable_wmm="check"]
195 AS_IF([test "x$enable_wmm" != "xno"],
196 [AC_CHECK_HEADERS([mmsystem.h],
197    [
198    AC_MSG_CHECKING([waveOut family functions])
199    waveout_old_LIBS="$LIBS"; LIBS="$LIBS -lwinmm"
200 dnl Can't use AC_SEARCH_LIBS because symbols are decorated
201    AC_LINK_IFELSE([
202 #include <windows.h>
203 #include <mmsystem.h>
204 int main(int na, char ** a) {
205     return waveOutOpen(0,0,0,0,0,0);
208 has_wmm="yes";
209 AC_MSG_RESULT([yes])
210 AC_DEFINE([HAVE_WMM],[1],[Support Windows MultiMedia])
212 AC_MSG_RESULT([no])
213 LIBS="$waveout_old_LIBS"
215 ],[],[#include <windows.h>])])
216 AM_CONDITIONAL([HAVE_WMM],[test "x$has_wmm" = "xyes"])
217 AS_IF([test "x${has_wmm}" = "xyes"],[WMM_LIBS="-lwinmm"],[WMM_LIBS=""])
218 AC_SUBST([WMM_LIBS])
220 dnl Check for ESD
222 AC_ARG_ENABLE(esd, [  --enable-esd            include ESD output plugin ],
223 [ BUILD_ESD="$enableval" ],[ BUILD_ESD="yes" ])
225 if test "$BUILD_ESD" = "yes"; then
226   AM_PATH_ESD(0.2.8, have_esd=yes, have_esd=no)
228 AM_CONDITIONAL(HAVE_ESD,test "x$have_esd" = xyes)
231 dnl Check for OSS
233 AC_CHECK_HEADERS(sys/soundcard.h)
234 AC_CHECK_HEADERS(machine/soundcard.h)
235 AM_CONDITIONAL(HAVE_OSS,test "${ac_cv_header_sys_soundcard_h}" = "yes" || test "${ac_cv_header_machine_soundcard_h}" = "yes")
238 dnl Check for ALSA 0.5.x
240 AC_ARG_ENABLE(alsa, [  --enable-alsa           include alsa 0.5 output plugin ],
241 [ BUILD_ALSA="$enableval" ],[ BUILD_ALSA="yes" ])
243 if test "$BUILD_ALSA" = "yes"; then
244    AC_CHECK_LIB(asound, snd_pcm_channel_params, have_alsa=yes, have_alsa=no)
245    AC_CHECK_HEADER(sys/asoundlib.h, , have_alsa=no)
248 if test "x$have_alsa" = xyes; then
249         ALSA_LIBS="-lasound"
250 else
251         ALSA_LIBS=""
253 AM_CONDITIONAL(HAVE_ALSA,test "x$have_alsa" = xyes)
254 AC_SUBST(ALSA_LIBS)
257 dnl Check for ALSA 0.9.x
259 AC_ARG_ENABLE(alsa09, [  --enable-alsa09         include alsa 0.9 output plugin ],
260 [ BUILD_ALSA09="$enableval" ],[ BUILD_ALSA09="yes" ])
261 AC_ARG_ENABLE(alsa09-mmap,
262    [  --enable-alsa09-mmap          use mmio with alsa 0.9 (experimental!) ],
263    [ BUILD_ALSA09MMIO="$enableval" ],[ BUILD_ALSA09MMIO="no" ])
265 if test "$BUILD_ALSA09" = "yes"; then
266    AC_CHECK_LIB(asound, snd_pcm_open, have_alsa09=yes, have_alsa09=no)
267    AC_CHECK_HEADER(alsa/asoundlib.h, , have_alsa09=no)
268    if test "$BUILD_ALSA09MMIO" = "yes" ; then
269       AC_CHECK_HEADER(sys/mman.h, have_alsa09mmio=yes, have_alsa09mmio=no)
270    fi
274 if test "x$have_alsa09" = xyes; then
275         ALSA09_LIBS="-lasound"
276         if test "x$have_alsa09mmio" = xyes; then
277                 AC_DEFINE(USE_ALSA_MMIO)
278         fi
279 else
280         ALSA09_LIBS=""
282 AM_CONDITIONAL(HAVE_ALSA09,test "x$have_alsa09" = xyes)
283 AC_SUBST(ALSA09_LIBS)
285 dnl Decide whether we need to enable the workaround for broken OSS APIs
286 dnl such as the OSS emulation in ALSA.
288 AC_ARG_ENABLE(broken-oss, [  --enable-broken-oss           workaround for some OSS drivers (see README for details)],,
289 if test "x$have_alsa" = "xyes" -o "x$have_alsa09" = "xyes"; then
290    enable_broken_oss="yes"
293 if test "x$enable_broken_oss" = "xyes"; then
294    AC_DEFINE(BROKEN_OSS)
295    AC_MSG_WARN(Broken OSS API workaround enabled.  See README for details.)
297    
298 dnl Check for Sun audio
300 AC_CHECK_HEADERS(sys/audioio.h)
301 AM_CONDITIONAL(HAVE_SUN_AUDIO,test "${ac_cv_header_sys_audioio_h}" = yes)
303 dnl Check for AIX audio
305 case $host in
306     *-aix*)
307         AC_CHECK_HEADERS(sys/audio.h)
308         ;;
309 esac
310 AM_CONDITIONAL(HAVE_AIX_AUDIO,test "x${ac_cv_header_sys_audio_h}" = xyes)
312 dnl Check for aRts
314 AC_ARG_ENABLE(arts, [  --enable-arts           include aRts output plugin ],
315 [ BUILD_ARTS="$enableval" ],[ BUILD_ARTS="maybe" ])
317 dnl aRts support is whacked on OS X, so don't build it by default
318 if test "$BUILD_ARTS" = "maybe"; then
319   case $host in
320          *-darwin*)
321                  BUILD_ARTS=no;;
322          *)
323                  BUILD_ARTS=yes;;
324   esac
328 if test "$BUILD_ARTS" = "yes"; then
329   AC_PATH_PROG(ARTSC_CONFIG, artsc-config)
331   if test "x$ac_cv_path_ARTSC_CONFIG" != x
332   then
333         ARTS_CFLAGS=`$ac_cv_path_ARTSC_CONFIG --cflags`
334         ARTS_LIBS=`$ac_cv_path_ARTSC_CONFIG --libs`
335         SAVELIBS=$LIBS
336         LIBS="$LIBS $ARTS_LIBS"
337         AC_CHECK_FUNCS(arts_suspended)
338         LIBS=$SAVELIBS
339   fi
341 AM_CONDITIONAL(HAVE_ARTS,test "x$ac_cv_path_ARTSC_CONFIG" != x)
343 AC_SUBST(ARTS_CFLAGS)
344 AC_SUBST(ARTS_LIBS)
347 dnl Check for IRIX
349 case $host in
350         *-*-irix*)
351                 AC_CHECK_LIB(audio, ALwritesamps, have_irix=yes, have_irix=no)
352         ;;
353 esac
354 AM_CONDITIONAL(HAVE_IRIX,test "x$have_irix" = xyes)
357 dnl Check for MacOS X
358 case $host in
359        *-darwin*)
360                have_macosx=yes;;
361        *)
362                have_macosx=no;;
363 esac
364 AM_CONDITIONAL(HAVE_MACOSX,test "x$have_macosx" = xyes)
367 dnl Check for NAS
369 AC_ARG_ENABLE(nas, [  --enable-nas            include NAS output plugin ],
370 [ BUILD_NAS="$enableval" ],[ BUILD_NAS="yes" ])
372 have_nas="no"
373 if test "$BUILD_NAS" = "yes"; then
374    AC_PATH_XTRA
375    AC_CHECK_LIB(Xau, XauFileName, have_nas=yes, have_nas=no, $X_LIBS)
376    AC_CHECK_LIB(audio, AuOpenServer, dummy="no-op", have_nas=no, -lXau $X_LIBS)
377    
378    ac_save_CPPFLAGS="$CPPFLAGS"
379    CPPFLAGS="$CPPFLAGS $X_CFLAGS"
380    AC_CHECK_HEADER(audio/audiolib.h, dummy="no-op", have_nas=no)
381    CPPFLAGS="$ac_save_CPPFLAGS"
384 AM_CONDITIONAL(HAVE_NAS,test "x$have_nas" = xyes)
386 if test "x$have_nas" = xyes; then
387         NAS_CFLAGS="$X_CFLAGS"
388         NAS_LIBS="-laudio -lXau $X_LIBS"
389 else
390         NAS_CFLAGS=""
391         NAS_LIBS=""
393 AC_SUBST(NAS_CFLAGS)
394 AC_SUBST(NAS_LIBS)
396 dnl Check for pulse
398 AC_ARG_ENABLE(pulse, [  --enable-pulse       include PulseAudio output plugin ],
399 [ BUILD_PULSE="$enableval" ],[ BUILD_PULSE="yes" ])
401 have_pulse=no
402 if test "x$BUILD_PULSE" = "xyes" ; then
403     PKG_CHECK_MODULES(PULSE, [ libpulse-simple >= 0.9 ],
404         [have_pulse=yes],[have_pulse=no])
405     AC_SUBST(PULSE_LIBS)
406     AC_SUBST(PULSE_CFLAGS)
409 AM_CONDITIONAL(HAVE_PULSE,test "x$have_pulse" = xyes)
411 dnl Orphaned driver.  We'll probably dump it soon.
412 AM_CONDITIONAL(HAVE_SOLARIS,test "x$have_solaris" = xyes)
414 dnl Plugins get special LDFLAGS
415 AC_SUBST(PLUGIN_LDFLAGS)
418 AC_OUTPUT(Makefile src/Makefile doc/Makefile include/Makefile include/ao/Makefile include/ao/os_types.h src/plugins/Makefile src/plugins/esd/Makefile src/plugins/oss/Makefile src/plugins/alsa/Makefile src/plugins/alsa09/Makefile src/plugins/sun/Makefile src/plugins/irix/Makefile src/plugins/arts/Makefile src/plugins/macosx/Makefile src/plugins/nas/Makefile src/plugins/pulse/Makefile ao.pc)