Fix SoX
[sxemacs] / m4 / sxe-mm.m4
1 dnl sxe-mm.m4 -- Multimedia goodness
2
3 dnl MM tests
4 dnl ========
5
6 AC_DEFUN([SXE_MM_CHECK_XPM], [
7         ## arg #1: action on success
8         ## arg #2: action on failure
9         pushdef([MM_SUCC], [$1])
10         pushdef([MM_FAIL], [$2])
11
12         AC_MSG_CHECKING([for xpm support])
13         AC_MSG_RESULT([])
14
15         MM_SUCC
16         if test "$window_system" = "none"; then
17                 MM_FAIL
18         fi
19
20         SXE_DUMP_LIBS
21         SXE_LANG_WERROR([off])
22         CPPFLAGS="$CPPFLAGS $X_CFLAGS"
23         LDFLAGS="$LDFLAGS $X_PRE_LIBS $X_LIBS $libs_x"
24         LIBS="$LIBS -lXpm -lX11"
25
26         SXE_CHECK_HEADERS([X11/xpm.h], [:], [MM_FAIL])
27
28         AC_MSG_CHECKING([for Xpm (more recent than 3.4f)])
29         AC_RUN_IFELSE([AC_LANG_SOURCE([[
30 #define XPM_NUMBERS
31 #include <X11/xpm.h>
32 int main(int c, char **v)
33 {
34         return c == 1 ? 0 :
35                 XpmIncludeVersion != XpmLibraryVersion() ? 1 :
36                 XpmIncludeVersion < 30406 ? 2 : 0 ;
37 }]])], [./conftest dummy_arg; xpm_status=$?;
38                 if test "$xpm_status" = "0"; then
39                         AC_MSG_RESULT([yes])
40                 else
41                         AC_MSG_RESULT([no])
42                         MM_FAIL
43                         if test "$xpm_status" = "1"; then
44                                 AC_MSG_WARN([dnl
45 Xpm library version and header file version don't match!
46 I have disabled xpm on your behalf.])
47                         elif test "$xpm_status" = "2"; then
48                                 AC_MSG_WARN([dnl
49 Xpm library version is too old!
50 I have disabled xpm on your behalf.])
51                         else
52                                 AC_MSG_WARN([dnl
53 Internal xpm detection logic error!])
54                         fi
55                 fi], [dnl
56                 AC_MSG_RESULT([no])
57                 MM_FAIL], [dnl
58                 AC_MSG_RESULT([no])
59                 MM_FAIL])
60         xe_check_libs=
61         SXE_RESTORE_LIBS
62 ])dnl SXE_MM_CHECK_XPM
63
64 AC_DEFUN([SXE_MM_CHECK_XFACE], [
65         ## arg #1: action on success
66         ## arg #2: action on failure
67         pushdef([MM_SUCC], [$1])
68         pushdef([MM_FAIL], [$2])
69
70         AC_MSG_CHECKING([for xface support])
71         AC_MSG_RESULT([])
72
73         SXE_DUMP_LIBS
74         SXE_LANG_WERROR([off])
75         dnl SXE_PREPEND_UNDUP([-I$x_includes], [c_switch_site])
76         dnl SXE_PREPEND_UNDUP([-L$x_libraries], [ld_switch_site])
77         CPPFLAGS="$CPPFLAGS $X_CFLAGS"
78         LDFLAGS="$LDFLAGS $X_LIBS"
79
80         MM_SUCC
81         if test "$window_system" = "none"; then
82                 MM_FAIL
83         fi
84
85         SXE_CHECK_HEADERS([compface.h], [:], [MM_FAIL])
86         AC_CHECK_LIB([compface], [UnGenFace], [:], [MM_FAIL])
87
88         SXE_RESTORE_LIBS
89 ])dnl SXE_MM_CHECK_XFACE
90
91 AC_DEFUN([SXE_MM_CHECK_GIF], [
92         ## arg #1: action on success
93         ## arg #2: action on failure
94         pushdef([MM_SUCC], [$1])
95         pushdef([MM_FAIL], [$2])
96
97         AC_MSG_CHECKING([for gif support])
98         AC_MSG_RESULT([])
99
100         SXE_DUMP_LIBS
101
102         MM_SUCC
103         if test "$window_system" = "none"; then
104                 MM_FAIL
105         fi
106
107         SXE_RESTORE_LIBS
108 ])dnl SXE_MM_CHECK_GIF
109
110 AC_DEFUN([SXE_MM_CHECK_JPEG], [
111         ## arg #1: action on success
112         ## arg #2: action on failure
113         pushdef([MM_SUCC], [$1])
114         pushdef([MM_FAIL], [$2])
115
116         AC_MSG_CHECKING([for jpeg support])
117         AC_MSG_RESULT([])
118
119         SXE_DUMP_LIBS
120         SXE_LANG_WERROR([off])
121         dnl SXE_PREPEND_UNDUP([-I$x_includes], [c_switch_site])
122         dnl SXE_PREPEND_UNDUP([-L$x_libraries], [ld_switch_site])
123         CPPFLAGS="$CPPFLAGS $X_CFLAGS"
124         LDFLAGS="$LDFLAGS $X_LIBS"
125
126         MM_SUCC
127         if test "$window_system" = "none"; then
128                 MM_FAIL
129         fi
130
131         SXE_CHECK_HEADERS([jpeglib.h], [:], [MM_FAIL])
132         AC_CHECK_LIB([jpeg], [jpeg_destroy_decompress], [:], [MM_FAIL], [$INFLATE_LIB])
133
134         SXE_RESTORE_LIBS
135 ])dnl SXE_MM_CHECK_JPEG
136
137
138 AC_DEFUN([_SXE_MM_CHECK_PNG_HEADERS], [dnl
139         ## defines sxe_cv_feat_png_headers
140         ## also defines and substs PNG_CPPFLAGS
141
142         SXE_DUMP_LIBS
143         SXE_LANG_WERROR([off])
144         PNG_CPPFLAGS="$CPPFLAGS $X_CFLAGS"
145         CPPFLAGS="$PNG_CPPFLAGS"
146         SXE_CHECK_HEADERS([png.h])
147         SXE_RESTORE_LIBS
148
149         if test "${ac_cv_header_png_h}" = "yes"; then
150                 sxe_cv_feat_png_headers="yes"
151         else
152                 sxe_cv_feat_png_headers="no"
153         fi
154
155         AC_SUBST([PNG_CPPFLAGS])
156 ])dnl _SXE_MM_CHECK_PNG_HEADERS
157
158 AC_DEFUN([_SXE_MM_CHECK_PNG_LIBS], [dnl
159         ## defines sxe_cv_feat_png_libs
160         ## also defines and substs PNG_LIBS and PNG_LDFLAGS
161
162         SXE_DUMP_LIBS
163         SXE_LANG_WERROR([off])
164         PNG_LDFLAGS="$LDFLAGS $X_LIBS"
165         LDFLAGS="$PNG_LDFLAGS"
166         AC_CHECK_LIB([png], [png_read_image], [], [], [$INFLATE_LIB])
167         SXE_RESTORE_LIBS
168
169         if test "${ac_cv_lib_png_png_read_image}" = "yes"; then
170                 sxe_cv_feat_png_libs="yes"
171                 PNG_LIBS="$INFLATE_LIB -lpng"
172         else
173                 sxe_cv_feat_png_libs="no"
174                 PNG_LIBS=
175         fi
176
177         AC_SUBST([PNG_LIBS])
178         AC_SUBST([PNG_LDFLAGS])
179 ])dnl _SXE_MM_CHECK_PNG_LIBS
180
181 AC_DEFUN([_SXE_MM_CHECK_PNG_VERSION], [dnl
182         ## defines sxe_cv_tmp_png_status to yes if version info seems okay
183         AC_REQUIRE([_SXE_MM_CHECK_PNG_HEADERS])
184         AC_REQUIRE([_SXE_MM_CHECK_PNG_LIBS])
185
186         SXE_MSG_CHECKING([for workable png version information])
187
188         SXE_DUMP_LIBS
189         CPPFLAGS="$PNG_CPPFLAGS"
190         LDFLAGS="$PNG_LDFLAGS"
191         LIBS="$PNG_LIBS"
192         AC_RUN_IFELSE([AC_LANG_SOURCE([[
193 #if defined HAVE_PNG_H
194 # include <png.h>
195 #endif /* HAVE_PNG_H */
196
197 int main(int c, char **v)
198 {
199         if (c == 1) {
200                 return 0;
201         }
202         if (strcmp(png_libpng_ver, PNG_LIBPNG_VER_STRING) != 0) {
203                 return 1;
204         }
205         return (PNG_LIBPNG_VER < 10002) ? 2 : 0 ;
206 }]])], [./conftest dummy_arg; png_status=$?;
207                 if test "$png_status" = "0"; then
208                         sxe_cv_tmp_png_status="yes"
209
210                 elif test "$png_status" = "1"; then
211                         sxe_cv_tmp_png_status="yes"
212                         AC_MSG_WARN([dnl
213 PNG library version and header file don't match!
214 This is odd but I think I give it a whirl.
215 If things work out badly I suggest to turn off your computer forever.])
216
217                 elif test "$png_status" = "2"; then
218                         sxe_cv_tmp_png_status="no"
219                         AC_MSG_WARN([dnl
220 PNG library version too old (pre 1.0.2)!
221 I have disabled PNG support on your behalf.])
222
223                 else
224                         sxe_cv_tmp_png_status="no"
225                         AC_MSG_ERROR([dnl
226 Whatever happened just now, I'm completely fucked.])
227                 fi], [sxe_cv_tmp_png_status="no"], [sxe_cv_tmp_png_status="no"])
228         SXE_MSG_RESULT([${sxe_cv_tmp_png_status}])
229         SXE_RESTORE_LIBS
230 ])dnl _SXE_MM_CHECK_PNG_VERSION
231
232 AC_DEFUN([SXE_MM_CHECK_PNG], [
233         ## SXE_MM_CHECK_PNG(<action-if-found>, <action-if-not-found>)
234         ## defines HAVE_PNG in case png is usable
235         pushdef([MM_SUCC], [$1])
236         pushdef([MM_FAIL], [$2])
237
238         SXE_MSG_CHECKING([for PNG support])
239         SXE_MSG_RESULT([])
240
241         _SXE_MM_CHECK_PNG_HEADERS
242         _SXE_MM_CHECK_PNG_LIBS
243         _SXE_MM_CHECK_PNG_VERSION
244
245         ## final judgement
246         ## we want to see a header and png_read_image really
247         if test "${sxe_cv_feat_png_headers}" = "yes" -a \
248                 "${sxe_cv_feat_png_libs}" = "yes" -a \
249                 "${sxe_cv_tmp_png_status}" = "yes"; then
250                 sxe_cv_feat_png="yes"
251                 AC_DEFINE([HAVE_PNG], [1], [Define to 1 if png is usable.])
252                 MM_SUCC
253         else
254                 sxe_cv_feat_png="no"
255                 MM_FAIL
256         fi
257 ])dnl SXE_MM_CHECK_PNG
258
259 AC_DEFUN([SXE_MM_CHECK_TIFF], [
260         ## arg #1: action on success
261         ## arg #2: action on failure
262         pushdef([MM_SUCC], [$1])
263         pushdef([MM_FAIL], [$2])
264
265         AC_MSG_CHECKING([for TIFF support])
266         AC_MSG_RESULT([])
267
268         SXE_DUMP_LIBS
269         SXE_LANG_WERROR([off])
270         dnl SXE_PREPEND_UNDUP([-I$x_includes], [c_switch_site])
271         dnl SXE_PREPEND_UNDUP([-L$x_libraries], [ld_switch_site])
272         CPPFLAGS="$CPPFLAGS $X_CFLAGS"
273         LDFLAGS="$LDFLAGS $X_LIBS"
274
275         MM_SUCC
276         if test "$window_system" = "none"; then
277                 MM_FAIL
278         fi
279
280         SXE_CHECK_HEADERS([tiffio.h], [:], [MM_FAIL])
281         AC_CHECK_LIB([tiff], [TIFFClientOpen], [:], [MM_FAIL], [$INFLATE_LIB])
282
283         SXE_RESTORE_LIBS
284 ])dnl SXE_MM_CHECK_TIFF
285
286 AC_DEFUN([SXE_MM_SEARCH_INFLATE], [
287         dnl Too many stupid linkers can't detect cascaded lib dependencies
288         dnl  until runtime. So we always search for libz compression support.
289         AC_SEARCH_LIBS([inflate], [c z gz], [
290                 if test "$ac_cv_lib_c_inflate" = "yes"; then
291                         INFLATE_LIB="c"
292                 elif test "$ac_cv_lib_z_inflate" = "yes"; then
293                         INFLATE_LIB="z"
294                 elif test "$ac_cv_lib_gz_inflate" = "yes"; then
295                         INFLATE_LIB="gz"
296                 fi], [INFLATE_LIB=])
297         if test -n "$INFLATE_LIB"; then
298                 SXE_PREPEND([$INFLATE_LIB], [MM_LIBS])
299         fi
300 ])dnl SXE_MM_SEARCH_INFLATE
301
302 AC_DEFUN([SXE_MM_CHECK_SNDFILE], [
303         ## assumes $PKG_CONFIG is defined
304         ## arg #1: action on success
305         ## arg #2: action on failure
306
307         _SXE_MM_CHECK_pkgconfig_based([sndfile], [sndfile], [1.0.12], [dnl
308                 sf_open sf_close sf_readf_short sf_readf_int dnl
309                 sf_readf_float sf_seek sf_open_virtual],
310                 [sndfile.h], [$1], [$2])
311 ])dnl SXE_MM_CHECK_SNDFILE
312
313 AC_DEFUN([SXE_MM_CHECK_FFMPEG], [
314         ## assumes $PKG_CONFIG is defined
315         ## arg #1: action on success
316         ## arg #2: action on failure
317         pushdef([ACTION_IF_FOUND], [$1])
318         pushdef([ACTION_IF_NOT_FOUND], [$2])
319
320         sxe_cv_feat_ffmpeg=
321         ## we can't use that one since we have to check multiple headers
322 dnl     _SXE_MM_CHECK_pkgconfig_based([ffmpeg], [libavformat], [49.0.0], [dnl
323 dnl             av_open_input_file av_close_input_file av_find_stream_info dnl
324 dnl             url_fopen av_probe_input_format avcodec_find_decoder dnl
325 dnl             avcodec_open av_read_frame av_seek_frame av_register_all dnl
326 dnl             avcodec_decode_audio avcodec_decode_audio2], [avformat.h],
327 dnl             [sxe_cv_feat_ffmpeg=yes], [sxe_cv_feat_ffmpeg=no])
328
329 dnl     Dropped in favour of sxe-pkgconfig.m4 macros
330 dnl     _SXE_CHECK_pkgconfig_based([ffmpeg], [libavformat], [49.0.0])
331
332         SXE_PC_CHECK_VERSION_ATLEAST([libavformat], [51.0.0])
333
334         SXE_CHECK_FFMPEG_HEADERS
335         SXE_CHECK_FFMPEG_LIBS
336
337         ## make sure we have at least one of the headers
338         if test "$ac_cv_header_avformat_h" = "yes" -o \
339                 "$ac_cv_header_ffmpeg_avformat_h" = "yes" -o \
340                 "$ac_cv_header_libavformat_avformat_h" = "yes"; then
341                 sxe_cv_feat_ffmpeg_headers="yes"
342         fi
343         ## make sure either decode_audio or decode_audio2 is there
344         if test "$ac_cv_lib_avformat_avcodec_decode_audio2" = "yes" -o \
345                 "$ac_cv_lib_avformat_avcodec_decode_audio" = "yes"; then
346                 sxe_cv_feat_ffmpeg_decoders="yes"
347         fi
348         ## make sure we can either use av_register_protocol()
349         ## or register_protocol()
350         if test "$ac_cv_lib_avformat_av_register_protocol" = "yes" -o \
351                 "$ac_cv_lib_avformat_register_protocol" = "yes"; then
352                 sxe_cv_feat_ffmpeg_proto_reg="yes"
353         fi
354         ## make sure this bloody av context allocator is there
355         if test "$ac_cv_lib_avformat_avformat_alloc_context" = "yes" -o \
356                 "$ac_cv_lib_avformat_av_alloc_format_context" = "yes"; then
357                 sxe_cv_feat_ffmpeg_avformat_alloc="yes"
358         fi
359         if test "$sxe_cv_feat_ffmpeg_headers" = "yes" -a \
360                 "$sxe_cv_feat_ffmpeg_decoders" = "yes" -a \
361                 "$sxe_cv_feat_ffmpeg_proto_reg" = "yes" -a \
362                 "$sxe_cv_feat_ffmpeg_avformat_alloc" = "yes" -a \
363                 "$ac_cv_lib_avformat_av_close_input_file" = "yes" -a \
364                 "$ac_cv_lib_avformat_av_find_stream_info" = "yes" -a \
365                 "$ac_cv_lib_avformat_av_open_input_file" = "yes" -a \
366                 "$ac_cv_lib_avformat_av_probe_input_format" = "yes" -a \
367                 "$ac_cv_lib_avformat_av_read_frame" = "yes" -a \
368                 "$ac_cv_lib_avformat_av_register_all" = "yes" -a \
369                 "$ac_cv_lib_avformat_av_seek_frame" = "yes" -a \
370                 "$ac_cv_lib_avformat_avcodec_find_decoder" = "yes" -a \
371                 "$ac_cv_lib_avformat_avcodec_open" = "yes" -a \
372                 "$ac_cv_lib_avformat_url_fopen" = "yes"; then
373                 sxe_cv_feat_ffmpeg="yes"
374         else
375                 sxe_cv_feat_ffmpeg="no"
376         fi
377
378         ## newer ffmpegs want a bioctx** in url_fopen, check that
379         AC_MSG_CHECKING([what url_fopen() needs])
380         sxe_cv_tmp_ffmpeg_url_fopen="uncertain"
381
382         SXE_DUMP_LIBS
383         CPPFLAGS="$CPPFLAGS ${FFMPEG_CPPFLAGS}"
384         SXE_LANG_WERROR([off])
385         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
386 #if defined HAVE_ERRNO_H
387 # include <errno.h>
388 #endif
389 #if defined HAVE_LIBAVFORMAT_AVFORMAT_H
390 # include <libavformat/avformat.h>
391 #elif defined HAVE_FFMPEG_AVFORMAT_H
392 # include <ffmpeg/avformat.h>
393 #elif defined HAVE_AVFORMAT_H
394 # include <avformat.h>
395 #endif
396
397 extern int foobar(void);
398 int foobar(void)
399 {
400         ByteIOContext *bioctx = 0;
401
402         url_fopen(&bioctx, "/foobar", URL_RDONLY);
403         return 0;
404 }
405                 ]])], [sxe_cv_tmp_ffmpeg_url_fopen="ByteIOContext**"], [:])
406         SXE_RESTORE_LIBS
407
408         SXE_DUMP_LIBS
409         CPPFLAGS="$CPPFLAGS ${FFMPEG_CPPFLAGS}"
410         SXE_LANG_WERROR([on])
411         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
412 #if defined HAVE_ERRNO_H
413 # include <errno.h>
414 #endif
415 #if defined HAVE_LIBAVFORMAT_AVFORMAT_H
416 # include <libavformat/avformat.h>
417 #elif defined HAVE_FFMPEG_AVFORMAT_H
418 # include <ffmpeg/avformat.h>
419 #elif defined HAVE_AVFORMAT_H
420 # include <avformat.h>
421 #endif
422
423 extern int foobar(void);
424 int foobar(void)
425 {
426         ByteIOContext *bioctx = 0;
427
428         url_fopen(bioctx, "/foobar", URL_RDONLY);
429         return 0;
430 }
431                 ]])], [sxe_cv_tmp_ffmpeg_url_fopen="ByteIOContext*"], [:])
432         SXE_RESTORE_LIBS
433
434         ## post the result
435         AC_MSG_RESULT([$sxe_cv_tmp_ffmpeg_url_fopen])
436
437         if test "$sxe_cv_tmp_ffmpeg_url_fopen" = "ByteIOContext**"; then
438                 AC_DEFINE([FFMPEG_URL_FOPEN_BIOCTX_STAR_STAR], [1],
439                         [Whether url_fopen want a ByteIOContext**])
440         elif test "$sxe_cv_tmp_ffmpeg_url_fopen" = "ByteIOContext*"; then
441                 AC_DEFINE([FFMPEG_URL_FOPEN_BIOCTX_STAR], [1],
442                         [Whether url_fopen want a ByteIOContext*])
443         else
444                 sxe_cv_feat_ffmpeg="no"
445         fi
446
447         if test "$sxe_cv_feat_ffmpeg" = "yes"; then
448                 :
449                 ACTION_IF_FOUND
450         else
451                 :
452                 ACTION_IF_NOT_FOUND
453         fi
454
455         popdef([ACTION_IF_FOUND])
456         popdef([ACTION_IF_NOT_FOUND])
457 ])dnl SXE_MM_CHECK_FFMPEG
458
459 AC_DEFUN([SXE_CHECK_FFMPEG_HEADERS], [dnl
460         FFMPEG_CPPFLAGS="$(${PKG_CONFIG} --cflags libavformat)"
461
462         ## backup current configuration
463         SXE_DUMP_LIBS
464         CPPFLAGS="${CPPFLAGS} ${FFMPEG_CPPFLAGS}"
465         AC_CHECK_HEADERS([avformat.h ffmpeg/avformat.h libavformat/avformat.h])
466         ## restore configuration
467         SXE_RESTORE_LIBS
468 ])dnl SXE_CHECK_FFMPEG_HEADERS
469
470 AC_DEFUN([SXE_CHECK_FFMPEG_LIBS], [dnl
471         FFMPEG_LDFLAGS="$(${PKG_CONFIG} --libs-only-other libavformat) \
472                 $(${PKG_CONFIG} --libs-only-L libavformat)"
473         FFMPEG_LIBS="$(${PKG_CONFIG} --libs-only-l libavformat)"
474
475         ## backup current configuration
476         SXE_DUMP_LIBS
477         LDFLAGS="${LDFLAGS} ${FFMPEG_LDFLAGS}"
478
479         AC_CHECK_LIB([avformat], [av_open_input_file], [:], [:], [${FFMPEG_LIBS}])
480         AC_CHECK_LIB([avformat], [av_close_input_file], [:], [:], [${FFMPEG_LIBS}])
481         AC_CHECK_LIB([avformat], [av_find_stream_info], [:], [:], [${FFMPEG_LIBS}])
482         AC_CHECK_LIB([avformat], [url_fopen], [:], [:], [${FFMPEG_LIBS}])
483         AC_CHECK_LIB([avformat], [av_probe_input_format], [:], [:], [${FFMPEG_LIBS}])
484         AC_CHECK_LIB([avformat], [avcodec_find_decoder], [:], [:], [${FFMPEG_LIBS}])
485         AC_CHECK_LIB([avformat], [avcodec_open], [:], [:], [${FFMPEG_LIBS}])
486         AC_CHECK_LIB([avformat], [av_read_frame], [:], [:], [${FFMPEG_LIBS}])
487         AC_CHECK_LIB([avformat], [av_seek_frame], [:], [:], [${FFMPEG_LIBS}])
488         AC_CHECK_LIB([avformat], [av_register_all], [:], [:], [${FFMPEG_LIBS}])
489         AC_CHECK_LIB([avformat], [avcodec_decode_audio], [:], [:], [${FFMPEG_LIBS}])
490         AC_CHECK_LIB([avformat], [avcodec_decode_audio2], [:], [:], [${FFMPEG_LIBS}])
491
492         AC_CHECK_LIB([avformat], [av_alloc_format_context], [:], [:], [${FFMPEG_LIBS}])
493         AC_CHECK_LIB([avformat], [avformat_alloc_context], [:], [:], [${FFMPEG_LIBS}])
494         AC_CHECK_LIB([avformat], [register_protocol], [:], [:], [${FFMPEG_LIBS}])
495         AC_CHECK_LIB([avformat], [av_register_protocol], [:], [:], [${FFMPEG_LIBS}])
496
497         if test "$ac_cv_lib_avformat_av_alloc_format_context" = "yes"; then
498                 AC_DEFINE([HAVE_AV_ALLOC_FORMAT_CONTEXT], [1], [Description here!])
499         fi
500         if test "$ac_cv_lib_avformat_avformat_alloc_context" = "yes"; then
501                 AC_DEFINE([HAVE_AVFORMAT_ALLOC_CONTEXT], [1], [Description here!])
502         fi
503
504         if test "$ac_cv_lib_avformat___avcodec_decode_audio2" = "yes" -o \
505                 "$ac_cv_lib_avformat_avcodec_decode_audio2" = "yes"; then
506                 AC_DEFINE([HAVE_AVCODEC_DECODE_AUDIO2], [1], [Description here!])
507         fi
508         if test "$ac_cv_lib_avformat___avcodec_decode_audio" = "yes" -o \
509                 "$ac_cv_lib_avformat_avcodec_decode_audio" = "yes"; then
510                 AC_DEFINE([HAVE_AVCODEC_DECODE_AUDIO], [1], [Description here!])
511         fi
512
513         if test "$ac_cv_lib_avformat_av_register_protocol" = "yes"; then
514                 AC_DEFINE([HAVE_AV_REGISTER_PROTOCOL], [1], [Description here!])
515         fi
516         if test "$ac_cv_lib_avformat_register_protocol" = "yes"; then
517                 AC_DEFINE([HAVE_REGISTER_PROTOCOL], [1], [Description here!])
518         fi
519
520         ## restore configuration
521         SXE_RESTORE_LIBS
522 ])dnl SXE_CHECK_FFMPEG_LIBS
523
524
525 dnl
526 dnl SoX
527 dnl ===
528 AC_DEFUN([SXE_MM_CHECK_SOX], [dnl
529         ## call like this SXE_MM_CHECK_SOX([<if-found>], [<if-not-found>])
530         ## arg #1: action on success
531         ## arg #2: action on failure
532         pushdef([ACTION_IF_FOUND], [$1])
533         pushdef([ACTION_IF_NOT_FOUND], [$2])
534
535         AC_CACHE_CHECK([for SoX support], [sxe_cv_feat_sox], [_SXE_CHECK_SOX])
536
537         if test "$sxe_cv_feat_sox" = "yes"; then
538                 ACTION_IF_FOUND
539                 :
540         else
541                 ACTION_IF_NOT_FOUND
542                 :
543         fi
544
545         popdef([ACTION_IF_FOUND])
546         popdef([ACTION_IF_NOT_FOUND])
547 ])dnl SXE_MM_CHECK_SOX
548
549 AC_DEFUN([_SXE_CHECK_SOX], [dnl
550         AC_REQUIRE([SXE_CHECK_SOX_LOCATIONS])
551
552         if test "$have_smelly_sox" = "yes"; then
553                 sxe_cv_feat_sox="no"
554         else
555                 SXE_CHECK_SOX_HEADERS
556                 SXE_CHECK_SOX_LIBS
557                 SXE_CHECK_SOX_STRUCTS
558
559                 if test "$ac_cv_lib_sox_sox_open_read" = "yes" -a \
560                         "$ac_cv_lib_sox_sox_close" = "yes" -a \
561                         "$ac_cv_lib_sox_sox_seek" = "yes" -a \
562                         "$ac_cv_header_sox_h" = "yes" -a \
563                         "$ac_cv_type_sox_format_t" = "yes" -a \
564                         "$ac_cv_type_struct_sox_format_t" = "yes" -a \
565                         "$sxe_cv_mm_sox_open_read_fooked" != "yes"; then
566                         sxe_cv_feat_sox="yes"
567                 else
568                         sxe_cv_feat_sox="no"
569                 fi
570                 :
571         fi
572 ])dnl _SXE_CHECK_SOX
573
574 AC_DEFUN([SXE_CHECK_SOX_LOCATIONS], [dnl
575         PKG_CHECK_MODULES([SOX], [sox >= 14.1.0], [dnl
576                 have_smelly_sox="no"
577                 sox_cppflags="$SOX_CFLAGS"
578                 sox_ldflags=
579                 sox_libs="$SOX_LIBS"], [dnl
580                 have_smelly_sox="yes"
581                 AC_MSG_WARN([Your SoX is too old or non-existant. You need >= 14.1.0])])
582 ])dnl SXE_CHECK_SOX_PLACES
583
584 AC_DEFUN([SXE_PUMP_SOX_LOCATIONS], [dnl
585         SXE_DUMP_LIBS
586         CPPFLAGS="$CPPFLAGS $sox_cppflags"
587         LDFLAGS="$LDFLAGS $sox_ldflags"
588         LIBS="$LIBS $sox_libs"
589 ])dnl SXE_PUMP_SOX_LOCATIONS
590
591 AC_DEFUN([SXE_DUMP_SOX_LOCATIONS], [dnl
592         SXE_RESTORE_LIBS
593 ])dnl SXE_DUMP_SOX_LOCATIONS
594
595 AC_DEFUN([SXE_CHECK_SOX_HEADERS], [dnl
596         AC_REQUIRE([SXE_CHECK_SOX_LOCATIONS])
597         SXE_PUMP_SOX_LOCATIONS
598         AC_CHECK_HEADERS([sox.h])
599         SXE_DUMP_SOX_LOCATIONS
600 ])dnl SXE_CHECK_SOX_HEADERS
601
602 AC_DEFUN([SXE_CHECK_SOX_LIBS], [dnl
603         AC_REQUIRE([SXE_CHECK_SOX_LOCATIONS])
604
605         echo "void cleanup(void) {}" > cleanup.c
606         $CC -c -o cleanup.o cleanup.c
607
608         SXE_PUMP_SOX_LOCATIONS
609         ## checks for the spankin' new sox
610         AC_CHECK_LIB([sox], [sox_open_read], [:], [:],
611                 [cleanup.o $sox_ldflags $sox_libs])
612         AC_CHECK_LIB([sox], [sox_close], [:], [:], [cleanup.o $sox_ldflags $sox_libs])
613         AC_CHECK_LIB([sox], [sox_read], [:], [:], [cleanup.o $sox_ldflags $sox_libs])
614         AC_CHECK_LIB([sox], [sox_seek], [:], [:], [cleanup.o $sox_ldflags $sox_libs])
615
616         SXE_DUMP_SOX_LOCATIONS
617
618         SXE_DUMP_LIBS
619         CPPFLAGS="$CPPFLAGS ${SOX_CPPFLAGS}"
620         SXE_LANG_WERROR([on])
621         SXE_MSG_CHECKING([whether sox_open_read() takes 4 arguments])
622         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
623 #if defined HAVE_ERRNO_H
624 # include <errno.h>
625 #endif
626 #if defined HAVE_SOX_H
627 # include <sox.h>
628 #endif
629                 ]], [
630                 sox_open_read("tmp", NULL, NULL, NULL);
631                 ])],
632                 [sxe_cv_mm_sox_open_read_4args="yes"],
633                 [sxe_cv_mm_sox_open_read_4args="no"])
634         SXE_MSG_RESULT([$sxe_cv_mm_sox_open_read_4args])
635
636         SXE_MSG_CHECKING([whether sox_open_read() takes 3 arguments])
637         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
638 #if defined HAVE_ERRNO_H
639 # include <errno.h>
640 #endif
641 #if defined HAVE_SOX_H
642 # include <sox.h>
643 #endif
644                 ]], [
645                 sox_open_read("tmp", NULL, NULL);
646                 ])],
647                 [sxe_cv_mm_sox_open_read_3args="yes"],
648                 [sxe_cv_mm_sox_open_read_3args="no"])
649         SXE_MSG_RESULT([$sxe_cv_mm_sox_open_read_3args])
650         SXE_RESTORE_LIBS
651
652         if test "$sxe_cv_mm_sox_open_read_3args" = "yes"; then
653                 AC_DEFINE([HAVE_SOX_OPEN_READ_3ARGS], [1],
654                         [Whether sox_open_read() takes 3 arguments.])
655                 AC_DEFINE([HAVE_SOX_OPEN_READ_NARGS], [3],
656                         [How many arguments sox_open_read() takes.])
657         elif test "$sxe_cv_mm_sox_open_read_4args" = "yes"; then
658                 AC_DEFINE([HAVE_SOX_OPEN_READ_4ARGS], [1],
659                         [Whether sox_open_read() takes 4 arguments.])
660                 AC_DEFINE([HAVE_SOX_OPEN_READ_NARGS], [4],
661                         [How many arguments sox_open_read() takes.])
662         else
663                 AC_MSG_NOTICE([
664 Very weird SoX you've got there.
665 I better disable SoX on your behalf.
666                         ])
667                 sxe_cv_mm_sox_open_read_fooked="yes"
668         fi
669
670         ## clean up our cleanup snack
671         rm -f cleanup.c cleanup.o
672 ])dnl SXE_CHECK_SOX_LIBS
673
674 AC_DEFUN([SXE_CHECK_SOX_STRUCTS], [dnl
675         ## the new structs
676         AC_CHECK_TYPES([sox_format_t], [:], [:], [
677 #ifdef HAVE_SOX_H
678 # include <sox.h>
679 #endif
680                 ])
681         AC_CHECK_TYPES([sox_ssize_t], [:], [:], [
682 #ifdef HAVE_SOX_H
683 # include <sox.h>
684 #endif
685                 ])
686         AC_CHECK_TYPES([sox_sample_t], [:], [:], [
687 #ifdef HAVE_SOX_H
688 # include <sox.h>
689 #endif
690                 ])
691         AC_CHECK_TYPES([sox_signalinfo_t], [:], [:], [
692 #if defined HAVE_SOX_H
693 # include <sox.h>
694 #endif
695                 ])
696         AC_CHECK_TYPES([struct sox_format_t], [:], [:], [
697 #ifdef HAVE_SOX_H
698 # include <sox.h>
699 #endif
700                 ])
701         AC_CHECK_MEMBERS([struct sox_format_t.signal], [:], [:], [
702 #ifdef HAVE_SOX_H
703 # include <sox.h>
704 #endif
705                 ])
706
707         AC_CHECK_MEMBERS([sox_signalinfo_t.precision], [:], [:], [
708 #ifdef HAVE_SOX_H
709 # include <sox.h>
710 #endif
711                 ])
712 ])dnl SXE_CHECK_SOX_STRUCTS
713
714 \f
715 AC_DEFUN([SXE_MM_CHECK_MAD], [
716         ## arg #1: action on success
717         ## arg #2: action on failure
718         pushdef([MM_SUCC], [$1])
719         pushdef([MM_FAIL], [$2])
720
721         AC_MSG_CHECKING([for mad support])
722         AC_MSG_RESULT([])
723
724         MM_SUCC
725         SXE_CHECK_HEADERS([mad.h], [:], [MM_FAIL])
726         AC_CHECK_LIB([mad], [mad_synth_init], [:], [MM_FAIL])
727         AC_CHECK_LIB([mad], [mad_stream_init], [:], [MM_FAIL])
728         AC_CHECK_LIB([mad], [mad_frame_init], [:], [MM_FAIL])
729         AC_CHECK_LIB([mad], [mad_synth_frame], [:], [MM_FAIL])
730         AC_CHECK_LIB([mad], [mad_stream_buffer], [:], [MM_FAIL])
731         AC_CHECK_LIB([mad], [mad_frame_decode], [:], [MM_FAIL])
732
733         popdef([MM_SUCC])
734         popdef([MM_FAIL])
735 ])dnl SXE_MM_CHECK_MAD
736
737 AC_DEFUN([SXE_MM_CHECK_MAGIC], [
738         ## assumes $PKG_CONFIG is defined
739         ## arg #1: action on success
740         ## arg #2: action on failure
741         pushdef([MM_SUCC], [$1])
742         pushdef([MM_FAIL], [$2])
743
744         AC_MSG_CHECKING([for libmagic/file support])
745         AC_MSG_RESULT([])
746
747         SXE_DUMP_LIBS
748         MM_SUCC
749         AC_CHECK_LIB([magic], [magic_open], [:], [MM_FAIL])
750         SXE_CHECK_HEADERS([magic.h], [:], [MM_FAIL])
751         SXE_CHECK_HEADERS([file.h])
752         SXE_RESTORE_LIBS
753
754         popdef([MM_SUCC])
755         popdef([MM_FAIL])
756 ])dnl SXE_MM_CHECK_MAGIC
757
758
759 AC_DEFUN([SXE_MM_CHECK_OSS], [
760         ## arg #1: action on success
761         ## arg #2: action on failure
762         pushdef([MM_SUCC], [$1])
763         pushdef([MM_FAIL], [$2])
764
765         AC_MSG_CHECKING([for OSS support])
766         AC_MSG_RESULT([])
767
768         SXE_DUMP_LIBS
769         MM_FAIL
770         SXE_CHECK_HEADERS([machine/soundcard.h sys/soundcard.h linux/soundcard.h soundcard.h])
771         if test "$ac_cv_header_linux_soundcard_h"="yes" -o      \
772                 "$ac_cv_header_machine_soundcard_h"="yes" -o    \
773                 "$ac_cv_header_soundcard_h"="yes" -o            \
774                 "$ac_cv_header_sys_soundcard_h"="yes"
775         then
776                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
777 #if defined HAVE_MACHINE_SOUNDCARD_H && HAVE_MACHINE_SOUNDCARD_H
778 #include <machine/soundcard.h>
779 #elif defined HAVE_SYS_SOUNDCARD_H && HAVE_SYS_SOUNDCARD_H
780 #include <sys/soundcard.h>
781 #elif defined HAVE_LINUX_SOUNDCARD_H && HAVE_LINUX_SOUNDCARD_H
782 #include <linux/soundcard.h>
783 #else
784 #include <soundcard.h>
785 #endif
786 ]],
787                 [[ ioctl(0, SNDCTL_DSP_RESET, 0); ]])],
788                         [oss_ioctl_linked=yes],
789                         [oss_ioctl_linked=no])
790                 if test "${oss_ioctl_linked}" = "no"
791                 then
792                         if test "${opsys}" = "netbsd"
793                         then
794                                 AC_CHECK_LIB([ossaudio],[_oss_ioctl],
795                                         [
796                                                 # netbsd needs this Linux OSS emulator library, just a ioctl
797                                                 # wrapper really
798                                                 MM_SUCC
799                                                 SXE_PREPEND([-lossaudio], [MM_LIBS])
800                                         ])
801                         fi
802                 else
803                         MM_SUCC
804                 fi
805         fi
806         SXE_RESTORE_LIBS
807
808         popdef([MM_SUCC])
809         popdef([MM_FAIL])
810 ])dnl SXE_MM_CHECK_OSS
811
812 AC_DEFUN([SXE_MM_CHECK_PULSE], [
813         ## assumes $PKG_CONFIG is defined
814         ## arg #1: action on success
815         ## arg #2: action on failure
816
817         PULSE_REQUIRED_VERSION=0.9.3
818         _SXE_MM_CHECK_pkgconfig_based(dnl
819                 [pulse], [libpulse], [$PULSE_REQUIRED_VERSION], [dnl
820                 pa_mainloop_new pa_threaded_mainloop_new pa_mainloop_iterate dnl
821                 pa_threaded_mainloop_lock pa_threaded_mainloop_unlock dnl
822                 pa_mainloop_get_api pa_threaded_mainloop_get_api dnl
823                 pa_mainloop_free pa_threaded_mainloop_free dnl
824                 pa_threaded_mainloop_stop dnl
825                 pa_context_new pa_context_get_state pa_context_is_pending dnl
826                 pa_context_disconnect dnl
827                 pa_operation_unref dnl
828                 pa_stream_new pa_stream_get_state pa_stream_write dnl
829                 pa_stream_set_state_callback pa_stream_set_write_callback dnl
830                 pa_stream_unref pa_stream_connect_playback pa_stream_disconnect dnl
831                 pa_stream_cork],
832                 [pulse/pulseaudio.h], [$1], [$2])
833 ])dnl SXE_MM_CHECK_PULSE
834
835 AC_DEFUN([SXE_MM_CHECK_JACK], [
836         ## assumes $PKG_CONFIG is defined
837         ## arg #1: action on success
838         ## arg #2: action on failure
839
840         _SXE_MM_CHECK_pkgconfig_based([jack], [jack], [0.98.0], [dnl
841                 jack_client_open jack_get_ports jack_port_register dnl
842                 jack_set_process_callback jack_set_error_function dnl
843                 jack_on_shutdown jack_activate jack_connect jack_disconnect dnl
844                 jack_client_close jack_port_get_buffer], [jack/jack.h], [$1], [$2])
845 ])dnl SXE_MM_CHECK_JACK
846
847 AC_DEFUN([SXE_MM_CHECK_AO], [
848         ## assumes $PKG_CONFIG is defined
849         ## arg #1: action on success
850         ## arg #2: action on failure
851
852         _SXE_MM_CHECK_pkgconfig_based([ao], [ao], [0.6], [dnl
853                 ao_initialize ao_driver_id ao_default_driver_id dnl
854                 ao_open_live ao_close ao_shutdown ao_play], [ao/ao.h], [$1], [$2])
855 ])dnl SXE_MM_CHECK_AO
856
857 AC_DEFUN([SXE_MM_CHECK_ESD], [
858         ## arg #1: action on success
859         ## arg #2: action on failure
860         SXE_SEARCH_CONFIG_PROG([esd-config])
861
862         pushdef([MM_SUCC], [$1])
863         pushdef([MM_FAIL], [$2])
864
865         AC_MSG_CHECKING([for ESD support])
866         AC_MSG_RESULT([])
867
868         if test "$have_esd_config" = "no" -o -z "$ESD_CONFIG"; then
869                 AS_MESSAGE([*** esd-config not found.])
870                 AS_MESSAGE([*** Cannot check for ESD.])
871                 have_esd_config=no
872                 ESD_CONFIG=
873                 MM_FAIL
874         fi
875
876         if test "$have_esd_config" = "yes"; then
877                 SXE_DUMP_LIBS
878                 ESD_CPPFLAGS="`$ESD_CONFIG --cflags`"
879                 ESD_LDFLAGS="-L`$ESD_CONFIG --libs`"
880                 dnl SXE_APPEND_UNDUP([$esd_c_switch], [c_switch_site])
881                 dnl SXE_PREPEND([$esd_libs], [LIBS])
882                 CPPFLAGS="$CPPFLAGS $ESD_CPPFLAGS"
883                 LDFLAGS="$LDFLAGS $ESD_LDFLAGS"
884
885                 MM_SUCC
886                 SXE_CHECK_HEADERS([esd.h], [:], [MM_FAIL])
887                 AC_CHECK_LIB([esd], [esd_play_stream], [:], [MM_FAIL], [$esd_libs])
888
889                 ## restore anything
890                 SXE_RESTORE_LIBS
891         fi
892
893         popdef([MM_SUCC])
894         popdef([MM_FAIL])
895 ])dnl SXE_MM_CHECK_ESD
896
897 AC_DEFUN([SXE_MM_CHECK_ALSA], [
898         ## call like this SXE_MM_CHECK_ALSA([<if-found>], [<if-not-found>])
899         ## defines HAVE_ALSA, HAVE_ALSA_SOUND
900         ## and sxe_cv_feat_alsa
901         pushdef([ACTION_IF_FOUND], [$1])
902         pushdef([ACTION_IF_NOT_FOUND], [$2])
903
904         AC_CACHE_CHECK([for ALSA support],
905                 [sxe_cv_feat_alsa], [_SXE_MM_CHECK_ALSA])
906
907         if test "$sxe_cv_feat_alsa" = "yes"; then
908                 AC_DEFINE([HAVE_ALSA], [1],
909                         [Whether ALSA can be used as sound device])
910                 AC_DEFINE([HAVE_ALSA_SOUND], [1],
911                         [Whether ALSA can be used as sound device])
912                 ACTION_IF_FOUND
913                 :
914         else
915                 ACTION_IF_NOT_FOUND
916                 :
917         fi
918         popdef([ACTION_IF_FOUND])
919         popdef([ACTION_IF_NOT_FOUND])
920 ])dnl SXE_MM_CHECK_ALSA
921
922 AC_DEFUN([_SXE_MM_CHECK_ALSA], [dnl
923
924         AC_REQUIRE([SXE_CHECK_ALSA_HEADERS])
925         AC_REQUIRE([SXE_CHECK_ALSA_VERSION])
926         AC_REQUIRE([SXE_CHECK_ALSA_LIBS])
927
928         if test "$ac_cv_header_alsa_input_h" = "yes" -a \
929                 "$ac_cv_header_alsa_output_h" = "yes" -a \
930                 "$ac_cv_header_alsa_global_h" = "yes" -a \
931                 "$ac_cv_header_alsa_conf_h" = "yes" -a \
932                 "$ac_cv_header_alsa_pcm_h" = "yes" -a \
933                 "$ac_cv_header_alsa_error_h" = "yes" -a \
934                 \
935                 "$sxe_mm_alsa_version_supported_p" = "yes" -a \
936                 \
937                 "$ac_cv_lib_asound_snd_pcm_close" = "yes" -a \
938                 "$ac_cv_lib_asound_snd_pcm_hw_free" = "yes" -a \
939                 "$ac_cv_lib_asound_snd_pcm_hw_params_any" = "yes" -a \
940                 "$ac_cv_lib_asound_snd_pcm_hw_params_free" = "yes" -a \
941                 "$ac_cv_lib_asound_snd_pcm_hw_params_set_access" = "yes" -a \
942                 "$ac_cv_lib_asound_snd_pcm_hw_params_set_channels" = "yes" -a \
943                 "$ac_cv_lib_asound_snd_pcm_hw_params_set_format" = "yes" -a \
944                 "$ac_cv_lib_asound_snd_pcm_hw_params_set_rate_near" = "yes" -a \
945                 "$ac_cv_lib_asound_snd_pcm_hw_params_test_channels" = "yes" -a \
946                 "$ac_cv_lib_asound_snd_pcm_hw_params_test_format" = "yes" -a \
947                 "$ac_cv_lib_asound_snd_pcm_open" = "yes" -a \
948                 "$ac_cv_lib_asound_snd_pcm_prepare" = "yes" -a \
949                 "$ac_cv_lib_asound_snd_pcm_writei" = "yes"; then
950                 sxe_cv_feat_alsa="yes"
951         else
952                 sxe_cv_feat_alsa="no"
953         fi
954 ])dnl _SXE_MM_CHECK_ALSA
955
956 AC_DEFUN([SXE_CHECK_ALSA_HEADERS], [dnl
957         ## dump the current configuration
958         SXE_DUMP_LIBS
959         SXE_LANG_WERROR([off])
960         SXE_CHECK_HEADERS([alsa/input.h alsa/output.h alsa/global.h])
961         SXE_CHECK_HEADERS([alsa/conf.h], [:], [:], [[
962 #include <stdlib.h>
963 #include <stdio.h>
964 #if defined HAVE_ALSA_INPUT_H
965 # include <alsa/input.h>
966 #endif
967 #if defined HAVE_ALSA_OUTPUT_H
968 # include <alsa/output.h>
969 #endif
970 #if defined HAVE_ALSA_GLOBAL_H
971 # include <alsa/global.h>
972 #endif
973 ]])
974         SXE_CHECK_HEADERS([alsa/pcm.h alsa/error.h alsa/version.h], [:], [:], [[
975 #include <stdlib.h>
976 #include <stdio.h>
977 #if defined HAVE_ALSA_INPUT_H
978 # include <alsa/input.h>
979 #endif
980 #if defined HAVE_ALSA_OUTPUT_H
981 # include <alsa/output.h>
982 #endif
983 #if defined HAVE_ALSA_GLOBAL_H
984 # include <alsa/global.h>
985 #endif
986 #if defined HAVE_ALSA_CONF_H
987 # include <alsa/conf.h>
988 #endif
989 ]])
990         ## restor everything
991         SXE_RESTORE_LIBS
992 ])dnl SXE_CHECK_ALSA_HEADERS
993
994 AC_DEFUN([SXE_CHECK_ALSA_VERSION], [dnl
995         AC_REQUIRE([SXE_CHECK_ALSA_HEADERS])
996
997         ## dump the configuration
998         SXE_DUMP_LIBS
999         SXE_LANG_WERROR([off])
1000         AC_MSG_CHECKING([for alsa version])
1001
1002         AC_RUN_IFELSE([AC_LANG_SOURCE([[
1003 #include <stdlib.h>
1004 #include <stdio.h>
1005 #if defined HAVE_ALSA_INPUT_H
1006 # include <alsa/input.h>
1007 #endif
1008 #if defined HAVE_ALSA_OUTPUT_H
1009 # include <alsa/output.h>
1010 #endif
1011 #if defined HAVE_ALSA_GLOBAL_H
1012 # include <alsa/global.h>
1013 #endif
1014 #if defined HAVE_ALSA_CONF_H
1015 # include <alsa/conf.h>
1016 #endif
1017 #if defined HAVE_ALSA_PCM_H
1018 # include <alsa/pcm.h>
1019 #endif
1020 #if defined HAVE_ALSA_ERROR_H
1021 # include <alsa/error.h>
1022 #endif
1023 #if defined HAVE_ALSA_CONF_H
1024 # include <alsa/version.h>
1025 #endif
1026
1027 int main(int c, char *v[])
1028 {
1029         fprintf(stdout, SND_LIB_VERSION_STR);
1030         return 0;
1031 }]])], dnl [./conftest; alsa_subminor=$?],[alsa_subminor=$?],[alsa_subminor=0]
1032         [sxe_mm_alsa_version=$(./conftest)],
1033         [:], [sxe_mm_alsa_version="undeterminable"])
1034
1035         case "${sxe_mm_alsa_version}" in
1036         0.*.* | 1.0.3* | 1.0.9* )
1037                 AC_MSG_RESULT([${sxe_mm_alsa_version} (known to break)])
1038                 AC_MSG_WARN([Your ALSA version is _KNOWN_ to fail! Do not say we have not warned you!])
1039                 sxe_mm_alsa_version_supported_p="no"
1040                 ;;
1041         1.0.2 | 1.0.4* | 1.0.5* | 1.0.6* | 1.0.7* | 1.0.8* )
1042                 AC_MSG_RESULT([${sxe_mm_alsa_version} (suspicious to break)])
1043                 AC_MSG_WARN([Your ALSA version has not been tested. Do not be surprised if it fails!])
1044                 sxe_mm_alsa_version_supported_p="no"
1045                 ;;
1046         1.0.10* | 1.0.11* | 1.0.12* | 1.0.13* | 1.0.14* | 1.0.15* | 1.0.16* )
1047                 AC_MSG_RESULT([${sxe_mm_alsa_version} (sane)])
1048                 sxe_mm_alsa_version_supported_p="yes"
1049                 ;;
1050         1.* )
1051                 AC_MSG_RESULT([${sxe_mm_alsa_version} (unknown)])
1052                 AC_MSG_NOTICE([Your ALSA version is unknown, however we are confident that it works.])
1053                 AC_MSG_NOTICE([However, if we screwed up something, please report back!])
1054                 sxe_mm_alsa_version_supported_p="yes"
1055                 ;;
1056         * )
1057                 AC_MSG_RESULT([${sxe_mm_alsa_version} (unknown)])
1058                 AC_MSG_WARN([Your ALSA version is unknown hence not supported!])
1059                 sxe_mm_alsa_version_supported_p="no"
1060                 ;;
1061         esac
1062
1063         ## restore everything
1064         SXE_RESTORE_LIBS
1065 ])dnl SXE_CHECK_ALSA_VERSION
1066
1067 AC_DEFUN([SXE_CHECK_ALSA_LIBS], [dnl
1068         ## dump the current configuration
1069         SXE_DUMP_LIBS
1070
1071         AC_CHECK_LIB([asound], [snd_pcm_open], [:], [:])
1072         AC_CHECK_LIB([asound], [snd_pcm_close], [:], [:])
1073         AC_CHECK_LIB([asound], [snd_pcm_hw_free], [:], [:])
1074         AC_CHECK_LIB([asound], [snd_pcm_hw_params_any], [:], [:])
1075         AC_CHECK_LIB([asound], [snd_pcm_hw_params_set_access], [:], [:])
1076         AC_CHECK_LIB([asound], [snd_pcm_hw_params_free], [:], [:])
1077         AC_CHECK_LIB([asound], [snd_pcm_hw_params_test_channels], [:], [:])
1078         AC_CHECK_LIB([asound], [snd_pcm_hw_params_test_format], [:], [:])
1079         AC_CHECK_LIB([asound], [snd_pcm_hw_params_set_channels], [:], [:])
1080         AC_CHECK_LIB([asound], [snd_pcm_hw_params_set_format], [:], [:])
1081         AC_CHECK_LIB([asound], [snd_pcm_hw_params_set_rate_near], [:], [:])
1082         AC_CHECK_LIB([asound], [snd_pcm_prepare], [:], [:])
1083         AC_CHECK_LIB([asound], [snd_pcm_writei], [:], [:])
1084
1085         ## restore everything
1086         SXE_RESTORE_LIBS
1087 ])dnl SXE_CHECK_ALSA_LIBS
1088
1089
1090
1091 AC_DEFUN([SXE_MM_CHECK_NAS], [
1092         ## arg #1: action on success
1093         ## arg #2: action on failure
1094         pushdef([MM_SUCC], [$1])
1095         pushdef([MM_FAIL], [$2])
1096
1097         AC_MSG_CHECKING([for NAS support])
1098         AC_MSG_RESULT([])
1099
1100         SXE_DUMP_LIBS
1101
1102         MM_SUCC
1103         ## NAS is often stored inside the X hierarchy, so ...
1104         CPPFLAGS="$CPPFLAGS $X_CFLAGS"
1105         LDFLAGS="$LDFLAGS $X_LIBS"
1106         SXE_CHECK_HEADERS([audio/audiolib.h], [:], [MM_FAIL])
1107         AC_CHECK_LIB([audio], [AuOpenServer], [:], [MM_FAIL])
1108         AC_CHECK_LIB([audio], [AuCloseServer], [:], [MM_FAIL])
1109         AC_CHECK_LIB([audio], [AuCreateFlow], [:], [MM_FAIL])
1110         AC_CHECK_LIB([audio], [AuStartFlow], [:], [MM_FAIL])
1111         AC_CHECK_LIB([audio], [AuStopFlow], [:], [MM_FAIL])
1112         AC_CHECK_LIB([audio], [AuScanForTypedEvent], [:], [MM_FAIL])
1113         AC_CHECK_LIB([audio], [AuDispatchEvent], [:], [MM_FAIL])
1114         AC_CHECK_LIB([audio], [AuSetErrorHandler], [:], [MM_FAIL])
1115         AC_CHECK_LIB([audio], [AuSetIOErrorHandler], [:], [MM_FAIL])
1116         AC_CHECK_LIB([audio], [AuWriteElement], [:], [MM_FAIL])
1117         AC_CHECK_LIB([audio], [AuSetElements], [:], [MM_FAIL])
1118         AC_CHECK_LIB([audio], [AuRegisterEventHandler], [:], [MM_FAIL])
1119         AC_CHECK_LIB([audio], [AuSetElementParameters], [:], [MM_FAIL])
1120
1121         dnl If the nas library does not contain the error jump point,
1122         dnl then we force safer behavior.
1123         AC_EGREP_HEADER([AuXtErrorJump], [audio/Xtutil.h], [], [old_nas=yes])
1124         if test "$old_nas" = "yes"; then
1125                 AC_DEFINE([NAS_NO_ERROR_JUMP], [1], [Description here!])
1126         fi
1127
1128         ## restore anything
1129         SXE_RESTORE_LIBS
1130
1131         popdef([MM_SUCC])
1132         popdef([MM_FAIL])
1133 ])dnl SXE_MM_CHECK_NAS
1134
1135 dnl sxe-mm.m4 ends here