Merge remote-tracking branch 'origin/master' into for-steve
[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 "$sox_too_old" = "yes"; then
538                 AS_MESSAGE([*** Detected SoX, but it is too old.])
539                 AS_MESSAGE([*** Consider upgrading, see http://sox.sourceforge.net])
540                 ACTION_IF_NOT_FOUND
541                 :
542         elif test "$sxe_cv_feat_sox" = "yes"; then
543                 ACTION_IF_FOUND
544                 :
545         else
546                 ACTION_IF_NOT_FOUND
547                 :
548         fi
549
550         popdef([ACTION_IF_FOUND])
551         popdef([ACTION_IF_NOT_FOUND])
552 ])dnl SXE_MM_CHECK_SOX
553
554 AC_DEFUN([_SXE_CHECK_SOX], [dnl
555         AC_REQUIRE([SXE_CHECK_SOX_LOCATOR])
556
557         if test "$have_libst_config" = "no" -o -z "$LIBST_CONFIG"; then
558                 AS_MESSAGE([*** libst-config not found.])
559                 AS_MESSAGE([*** Cannot check for SoX.])
560                 have_libst_config=no
561                 LIBST_CONFIG=
562         else
563                 AC_REQUIRE([SXE_CHECK_SOX_LOCATIONS])
564                 AC_REQUIRE([SXE_CHECK_SOX_HEADERS])
565                 AC_REQUIRE([SXE_CHECK_SOX_LIBS])
566                 AC_REQUIRE([SXE_CHECK_SOX_STRUCTS])
567                 :
568         fi
569
570         if test "$ac_cv_lib_sox_sox_open_read" = "yes" -a \
571                 "$ac_cv_lib_sox_sox_close" = "yes" -a \
572                 "$ac_cv_lib_sox_sox_seek" = "yes" -a \
573                 "$ac_cv_header_sox_h" = "yes" -a \
574                 "$ac_cv_type_sox_format_t" = "yes" -a \
575                 "$ac_cv_type_struct_sox_format" = "yes" -a \
576                 "$sxe_cv_mm_sox_open_read_fooked" != "yes"; then
577                 sox_libs="-lsox $sox_libs"
578                 sxe_cv_feat_sox="yes"
579         elif test "$ac_cv_lib_st_st_close" = "yes" -a \
580                 "$ac_cv_lib_st_st_read" = "yes" -a \
581                 "$ac_cv_lib_st_st_seek" = "yes" -a \
582                 "$ac_cv_header_st_h" = "yes" -a \
583                 "$ac_cv_type_ft_t" = "yes" -a \
584                 "$ac_cv_type_struct_st_soundstream" = "yes" -a \
585                 "$sxe_cv_mm_sox_open_read_fooked" != "yes"; then
586                 sox_libs="-lst $sox_libs"
587                 sxe_cv_feat_sox="yes"
588         else
589                 sxe_cv_feat_sox="no"
590         fi
591 ])dnl _SXE_CHECK_SOX
592
593 AC_DEFUN([SXE_CHECK_SOX_LOCATOR], [dnl
594         SXE_SEARCH_CONFIG_PROG([libst-config])
595 ])dnl SXE_CHECK_SOX_LOCATOR
596
597 AC_DEFUN([SXE_CHECK_SOX_LOCATIONS], [dnl
598         AC_REQUIRE([SXE_CHECK_SOX_LOCATOR])
599         if test "$have_libst_config" = "no" -o -z "$LIBST_CONFIG"; then
600                 sox_cppflags=
601                 sox_ldflags=
602                 sox_libs=
603         else
604                 sox_cppflags="$($LIBST_CONFIG --cflags)"
605                 sox_ldflags="-L$($LIBST_CONFIG --libdir)"
606                 sox_libs="$($LIBST_CONFIG --libs)"
607         fi
608 ])dnl SXE_CHECK_SOX_PLACES
609
610 AC_DEFUN([SXE_PUMP_SOX_LOCATIONS], [dnl
611         SXE_DUMP_LIBS
612         CPPFLAGS="$CPPFLAGS $sox_cppflags"
613         LDFLAGS="$LDFLAGS $sox_ldflags"
614         LIBS="$LIBS $sox_libs"
615 ])dnl SXE_PUMP_SOX_LOCATIONS
616
617 AC_DEFUN([SXE_DUMP_SOX_LOCATIONS], [dnl
618         SXE_RESTORE_LIBS
619 ])dnl SXE_DUMP_SOX_LOCATIONS
620
621 AC_DEFUN([SXE_CHECK_SOX_HEADERS], [dnl
622         AC_REQUIRE([SXE_CHECK_SOX_LOCATIONS])
623         SXE_PUMP_SOX_LOCATIONS
624         AC_CHECK_HEADERS([st.h])
625         AC_CHECK_HEADERS([sox.h])
626         SXE_DUMP_SOX_LOCATIONS
627 ])dnl SXE_CHECK_SOX_HEADERS
628
629 AC_DEFUN([SXE_CHECK_SOX_LIBS], [dnl
630         AC_REQUIRE([SXE_CHECK_SOX_LOCATIONS])
631
632         echo "void cleanup(void) {}" > cleanup.c
633         $CC -c -o cleanup.o cleanup.c
634
635         SXE_PUMP_SOX_LOCATIONS
636         ## we need 12.17.9 with st_open_read
637         AC_CHECK_LIB([st], [st_open_read], [:], [:],
638                 [cleanup.o $sox_ldflags $sox_libs])
639         AC_CHECK_LIB([st], [st_close], [:], [:], [cleanup.o $sox_ldflags $sox_libs])
640         AC_CHECK_LIB([st], [st_read], [:], [:], [cleanup.o $sox_ldflags $sox_libs])
641         AC_CHECK_LIB([st], [st_seek], [:], [:], [cleanup.o $sox_ldflags $sox_libs])
642
643         ## checks for the spankin' new sox
644         AC_CHECK_LIB([sox], [sox_open_read], [:], [:],
645                 [cleanup.o $sox_ldflags $sox_libs])
646         AC_CHECK_LIB([sox], [sox_close], [:], [:], [cleanup.o $sox_ldflags $sox_libs])
647         AC_CHECK_LIB([sox], [sox_read], [:], [:], [cleanup.o $sox_ldflags $sox_libs])
648         AC_CHECK_LIB([sox], [sox_seek], [:], [:], [cleanup.o $sox_ldflags $sox_libs])
649
650         SXE_DUMP_SOX_LOCATIONS
651
652         SXE_DUMP_LIBS
653         CPPFLAGS="$CPPFLAGS ${SOX_CPPFLAGS}"
654         SXE_LANG_WERROR([on])
655         SXE_MSG_CHECKING([whether sox_open_read() takes 4 arguments])
656         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
657 #if defined HAVE_ERRNO_H
658 # include <errno.h>
659 #endif
660 #if defined HAVE_SOX_H
661 # include <sox.h>
662 #endif
663                 ]], [
664                 sox_open_read("tmp", NULL, NULL, NULL);
665                 ])],
666                 [sxe_cv_mm_sox_open_read_4args="yes"],
667                 [sxe_cv_mm_sox_open_read_4args="no"])
668         SXE_MSG_RESULT([$sxe_cv_mm_sox_open_read_4args])
669
670         SXE_MSG_CHECKING([whether sox_open_read() takes 3 arguments])
671         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
672 #if defined HAVE_ERRNO_H
673 # include <errno.h>
674 #endif
675 #if defined HAVE_SOX_H
676 # include <sox.h>
677 #endif
678                 ]], [
679                 sox_open_read("tmp", NULL, NULL);
680                 ])],
681                 [sxe_cv_mm_sox_open_read_3args="yes"],
682                 [sxe_cv_mm_sox_open_read_3args="no"])
683         SXE_MSG_RESULT([$sxe_cv_mm_sox_open_read_3args])
684         SXE_RESTORE_LIBS
685
686         if test "$sxe_cv_mm_sox_open_read_3args" = "yes"; then
687                 AC_DEFINE([HAVE_SOX_OPEN_READ_3ARGS], [1],
688                         [Whether sox_open_read() takes 3 arguments.])
689                 AC_DEFINE([HAVE_SOX_OPEN_READ_NARGS], [3],
690                         [How many arguments sox_open_read() takes.])
691         elif test "$sxe_cv_mm_sox_open_read_4args" = "yes"; then
692                 AC_DEFINE([HAVE_SOX_OPEN_READ_4ARGS], [1],
693                         [Whether sox_open_read() takes 4 arguments.])
694                 AC_DEFINE([HAVE_SOX_OPEN_READ_NARGS], [4],
695                         [How many arguments sox_open_read() takes.])
696         else
697                 AC_MSG_NOTICE([
698 Very weird SoX you've got there.
699 I better disable SoX on your behalf.
700                         ])
701                 sxe_cv_mm_sox_open_read_fooked="yes"
702         fi
703
704         ## clean up our cleanup snack
705         rm -f cleanup.c cleanup.o
706 ])dnl SXE_CHECK_SOX_LIBS
707
708 AC_DEFUN([SXE_CHECK_SOX_STRUCTS], [dnl
709         ## the old structs
710         AC_CHECK_TYPES([ft_t], [:], [:], [
711 #if defined HAVE_ST_H
712 # include <st.h>
713 #endif
714                 ])
715         AC_CHECK_TYPES([st_signalinfo_t], [:], [:], [
716 #if defined HAVE_ST_H
717 # include <st.h>
718 #endif
719                 ])
720         AC_CHECK_TYPES([st_ssize_t], [:], [:], [
721 #ifdef HAVE_ST_H
722 # include <st.h>
723 #endif
724                 ])
725         AC_CHECK_TYPES([st_sample_t], [:], [:], [
726 #ifdef HAVE_ST_H
727 # include <st.h>
728 #endif
729                 ])
730         AC_CHECK_TYPES([struct st_soundstream], [:], [:], [
731 #if defined HAVE_ST_H
732 # include <st.h>
733 #endif
734                 ])
735         AC_CHECK_MEMBERS([struct st_soundstream.info], [:], [:], [
736 #if defined HAVE_ST_H
737 # include <st.h>
738 #endif
739                 ])
740         AC_CHECK_MEMBERS([struct st_soundstream.signal], [:], [:], [
741 #if defined HAVE_ST_H
742 # include <st.h>
743 #endif
744                 ])
745
746         ## evaluating the results
747         if test "$ac_cv_member_struct_st_soundstream_info" = "yes"; then
748                 AC_DEFINE([MEMBER_STRUCT_ST_SOUNDSTREAM_INFO], [1],
749                         [Whether we have the `info' slot])
750         fi
751         if test "$ac_cv_member_struct_st_soundstream_signal" = "yes"; then
752                 AC_DEFINE([MEMBER_STRUCT_ST_SOUNDSTREAM_SIGNAL], [1],
753                         [Whether we have the `signal' slot])
754         fi
755
756         ## the new structs
757         AC_CHECK_TYPES([sox_format_t], [:], [:], [
758 #ifdef HAVE_SOX_H
759 # include <sox.h>
760 #endif
761                 ])
762         AC_CHECK_TYPES([sox_ssize_t], [:], [:], [
763 #ifdef HAVE_SOX_H
764 # include <sox.h>
765 #endif
766                 ])
767         AC_CHECK_TYPES([sox_sample_t], [:], [:], [
768 #ifdef HAVE_SOX_H
769 # include <sox.h>
770 #endif
771                 ])
772         AC_CHECK_TYPES([sox_signalinfo_t], [:], [:], [
773 #if defined HAVE_SOX_H
774 # include <sox.h>
775 #endif
776                 ])
777         AC_CHECK_TYPES([struct sox_format], [:], [:], [
778 #ifdef HAVE_SOX_H
779 # include <sox.h>
780 #endif
781                 ])
782         AC_CHECK_MEMBERS([struct sox_format.signal], [:], [:], [
783 #ifdef HAVE_SOX_H
784 # include <sox.h>
785 #endif
786                 ])
787
788         AC_CHECK_MEMBERS([sox_signalinfo_t.precision], [:], [:], [
789 #ifdef HAVE_SOX_H
790 # include <sox.h>
791 #endif
792                 ])
793 ])dnl SXE_CHECK_SOX_STRUCTS
794
795 \f
796 AC_DEFUN([SXE_MM_CHECK_MAD], [
797         ## arg #1: action on success
798         ## arg #2: action on failure
799         pushdef([MM_SUCC], [$1])
800         pushdef([MM_FAIL], [$2])
801
802         AC_MSG_CHECKING([for mad support])
803         AC_MSG_RESULT([])
804
805         MM_SUCC
806         SXE_CHECK_HEADERS([mad.h], [:], [MM_FAIL])
807         AC_CHECK_LIB([mad], [mad_synth_init], [:], [MM_FAIL])
808         AC_CHECK_LIB([mad], [mad_stream_init], [:], [MM_FAIL])
809         AC_CHECK_LIB([mad], [mad_frame_init], [:], [MM_FAIL])
810         AC_CHECK_LIB([mad], [mad_synth_frame], [:], [MM_FAIL])
811         AC_CHECK_LIB([mad], [mad_stream_buffer], [:], [MM_FAIL])
812         AC_CHECK_LIB([mad], [mad_frame_decode], [:], [MM_FAIL])
813
814         popdef([MM_SUCC])
815         popdef([MM_FAIL])
816 ])dnl SXE_MM_CHECK_MAD
817
818 AC_DEFUN([SXE_MM_CHECK_MAGIC], [
819         ## assumes $PKG_CONFIG is defined
820         ## arg #1: action on success
821         ## arg #2: action on failure
822         pushdef([MM_SUCC], [$1])
823         pushdef([MM_FAIL], [$2])
824
825         AC_MSG_CHECKING([for libmagic/file support])
826         AC_MSG_RESULT([])
827
828         SXE_DUMP_LIBS
829         MM_SUCC
830         AC_CHECK_LIB([magic], [magic_open], [:], [MM_FAIL])
831         SXE_CHECK_HEADERS([magic.h], [:], [MM_FAIL])
832         SXE_CHECK_HEADERS([file.h])
833         SXE_RESTORE_LIBS
834
835         popdef([MM_SUCC])
836         popdef([MM_FAIL])
837 ])dnl SXE_MM_CHECK_MAGIC
838
839
840 AC_DEFUN([SXE_MM_CHECK_OSS], [
841         ## arg #1: action on success
842         ## arg #2: action on failure
843         pushdef([MM_SUCC], [$1])
844         pushdef([MM_FAIL], [$2])
845
846         AC_MSG_CHECKING([for OSS support])
847         AC_MSG_RESULT([])
848
849         SXE_DUMP_LIBS
850         MM_FAIL
851         SXE_CHECK_HEADERS([machine/soundcard.h sys/soundcard.h linux/soundcard.h soundcard.h])
852         if test "$ac_cv_header_linux_soundcard_h"="yes" -o      \
853                 "$ac_cv_header_machine_soundcard_h"="yes" -o    \
854                 "$ac_cv_header_soundcard_h"="yes" -o            \
855                 "$ac_cv_header_sys_soundcard_h"="yes"
856         then
857                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
858 #if defined HAVE_MACHINE_SOUNDCARD_H && HAVE_MACHINE_SOUNDCARD_H
859 #include <machine/soundcard.h>
860 #elif defined HAVE_SYS_SOUNDCARD_H && HAVE_SYS_SOUNDCARD_H
861 #include <sys/soundcard.h>
862 #elif defined HAVE_LINUX_SOUNDCARD_H && HAVE_LINUX_SOUNDCARD_H
863 #include <linux/soundcard.h>
864 #else
865 #include <soundcard.h>
866 #endif
867 ]],
868                 [[ ioctl(0, SNDCTL_DSP_RESET, 0); ]])],
869                         [oss_ioctl_linked=yes],
870                         [oss_ioctl_linked=no])
871                 if test "${oss_ioctl_linked}" = "no"
872                 then
873                         if test "${opsys}" = "netbsd"
874                         then
875                                 AC_CHECK_LIB([ossaudio],[_oss_ioctl],
876                                         [
877                                                 # netbsd needs this Linux OSS emulator library, just a ioctl
878                                                 # wrapper really
879                                                 MM_SUCC
880                                                 SXE_PREPEND([-lossaudio], [MM_LIBS])
881                                         ])
882                         fi
883                 else
884                         MM_SUCC
885                 fi
886         fi
887         SXE_RESTORE_LIBS
888
889         popdef([MM_SUCC])
890         popdef([MM_FAIL])
891 ])dnl SXE_MM_CHECK_OSS
892
893 AC_DEFUN([SXE_MM_CHECK_PULSE], [
894         ## assumes $PKG_CONFIG is defined
895         ## arg #1: action on success
896         ## arg #2: action on failure
897
898         PULSE_REQUIRED_VERSION=0.9.3
899         _SXE_MM_CHECK_pkgconfig_based(dnl
900                 [pulse], [libpulse], [$PULSE_REQUIRED_VERSION], [dnl
901                 pa_mainloop_new pa_threaded_mainloop_new pa_mainloop_iterate dnl
902                 pa_threaded_mainloop_lock pa_threaded_mainloop_unlock dnl
903                 pa_mainloop_get_api pa_threaded_mainloop_get_api dnl
904                 pa_mainloop_free pa_threaded_mainloop_free dnl
905                 pa_threaded_mainloop_stop dnl
906                 pa_context_new pa_context_get_state pa_context_is_pending dnl
907                 pa_context_disconnect dnl
908                 pa_operation_unref dnl
909                 pa_stream_new pa_stream_get_state pa_stream_write dnl
910                 pa_stream_set_state_callback pa_stream_set_write_callback dnl
911                 pa_stream_unref pa_stream_connect_playback pa_stream_disconnect dnl
912                 pa_stream_cork],
913                 [pulse/pulseaudio.h], [$1], [$2])
914 ])dnl SXE_MM_CHECK_PULSE
915
916 AC_DEFUN([SXE_MM_CHECK_JACK], [
917         ## assumes $PKG_CONFIG is defined
918         ## arg #1: action on success
919         ## arg #2: action on failure
920
921         _SXE_MM_CHECK_pkgconfig_based([jack], [jack], [0.98.0], [dnl
922                 jack_client_open jack_get_ports jack_port_register dnl
923                 jack_set_process_callback jack_set_error_function dnl
924                 jack_on_shutdown jack_activate jack_connect jack_disconnect dnl
925                 jack_client_close jack_port_get_buffer], [jack/jack.h], [$1], [$2])
926 ])dnl SXE_MM_CHECK_JACK
927
928 AC_DEFUN([SXE_MM_CHECK_AO], [
929         ## assumes $PKG_CONFIG is defined
930         ## arg #1: action on success
931         ## arg #2: action on failure
932
933         _SXE_MM_CHECK_pkgconfig_based([ao], [ao], [0.6], [dnl
934                 ao_initialize ao_driver_id ao_default_driver_id dnl
935                 ao_open_live ao_close ao_shutdown ao_play], [ao/ao.h], [$1], [$2])
936 ])dnl SXE_MM_CHECK_AO
937
938 AC_DEFUN([SXE_MM_CHECK_ESD], [
939         ## arg #1: action on success
940         ## arg #2: action on failure
941         SXE_SEARCH_CONFIG_PROG([esd-config])
942
943         pushdef([MM_SUCC], [$1])
944         pushdef([MM_FAIL], [$2])
945
946         AC_MSG_CHECKING([for ESD support])
947         AC_MSG_RESULT([])
948
949         if test "$have_esd_config" = "no" -o -z "$ESD_CONFIG"; then
950                 AS_MESSAGE([*** esd-config not found.])
951                 AS_MESSAGE([*** Cannot check for ESD.])
952                 have_esd_config=no
953                 ESD_CONFIG=
954                 MM_FAIL
955         fi
956
957         if test "$have_esd_config" = "yes"; then
958                 SXE_DUMP_LIBS
959                 ESD_CPPFLAGS="`$ESD_CONFIG --cflags`"
960                 ESD_LDFLAGS="-L`$ESD_CONFIG --libs`"
961                 dnl SXE_APPEND_UNDUP([$esd_c_switch], [c_switch_site])
962                 dnl SXE_PREPEND([$esd_libs], [LIBS])
963                 CPPFLAGS="$CPPFLAGS $ESD_CPPFLAGS"
964                 LDFLAGS="$LDFLAGS $ESD_LDFLAGS"
965
966                 MM_SUCC
967                 SXE_CHECK_HEADERS([esd.h], [:], [MM_FAIL])
968                 AC_CHECK_LIB([esd], [esd_play_stream], [:], [MM_FAIL], [$esd_libs])
969
970                 ## restore anything
971                 SXE_RESTORE_LIBS
972         fi
973
974         popdef([MM_SUCC])
975         popdef([MM_FAIL])
976 ])dnl SXE_MM_CHECK_ESD
977
978 AC_DEFUN([SXE_MM_CHECK_ALSA], [
979         ## call like this SXE_MM_CHECK_ALSA([<if-found>], [<if-not-found>])
980         ## defines HAVE_ALSA, HAVE_ALSA_SOUND
981         ## and sxe_cv_feat_alsa
982         pushdef([ACTION_IF_FOUND], [$1])
983         pushdef([ACTION_IF_NOT_FOUND], [$2])
984
985         AC_CACHE_CHECK([for ALSA support],
986                 [sxe_cv_feat_alsa], [_SXE_MM_CHECK_ALSA])
987
988         if test "$sxe_cv_feat_alsa" = "yes"; then
989                 AC_DEFINE([HAVE_ALSA], [1],
990                         [Whether ALSA can be used as sound device])
991                 AC_DEFINE([HAVE_ALSA_SOUND], [1],
992                         [Whether ALSA can be used as sound device])
993                 ACTION_IF_FOUND
994                 :
995         else
996                 ACTION_IF_NOT_FOUND
997                 :
998         fi
999         popdef([ACTION_IF_FOUND])
1000         popdef([ACTION_IF_NOT_FOUND])
1001 ])dnl SXE_MM_CHECK_ALSA
1002
1003 AC_DEFUN([_SXE_MM_CHECK_ALSA], [dnl
1004
1005         AC_REQUIRE([SXE_CHECK_ALSA_HEADERS])
1006         AC_REQUIRE([SXE_CHECK_ALSA_VERSION])
1007         AC_REQUIRE([SXE_CHECK_ALSA_LIBS])
1008
1009         if test "$ac_cv_header_alsa_input_h" = "yes" -a \
1010                 "$ac_cv_header_alsa_output_h" = "yes" -a \
1011                 "$ac_cv_header_alsa_global_h" = "yes" -a \
1012                 "$ac_cv_header_alsa_conf_h" = "yes" -a \
1013                 "$ac_cv_header_alsa_pcm_h" = "yes" -a \
1014                 "$ac_cv_header_alsa_error_h" = "yes" -a \
1015                 \
1016                 "$sxe_mm_alsa_version_supported_p" = "yes" -a \
1017                 \
1018                 "$ac_cv_lib_asound_snd_pcm_close" = "yes" -a \
1019                 "$ac_cv_lib_asound_snd_pcm_hw_free" = "yes" -a \
1020                 "$ac_cv_lib_asound_snd_pcm_hw_params_any" = "yes" -a \
1021                 "$ac_cv_lib_asound_snd_pcm_hw_params_free" = "yes" -a \
1022                 "$ac_cv_lib_asound_snd_pcm_hw_params_set_access" = "yes" -a \
1023                 "$ac_cv_lib_asound_snd_pcm_hw_params_set_channels" = "yes" -a \
1024                 "$ac_cv_lib_asound_snd_pcm_hw_params_set_format" = "yes" -a \
1025                 "$ac_cv_lib_asound_snd_pcm_hw_params_set_rate_near" = "yes" -a \
1026                 "$ac_cv_lib_asound_snd_pcm_hw_params_test_channels" = "yes" -a \
1027                 "$ac_cv_lib_asound_snd_pcm_hw_params_test_format" = "yes" -a \
1028                 "$ac_cv_lib_asound_snd_pcm_open" = "yes" -a \
1029                 "$ac_cv_lib_asound_snd_pcm_prepare" = "yes" -a \
1030                 "$ac_cv_lib_asound_snd_pcm_writei" = "yes"; then
1031                 sxe_cv_feat_alsa="yes"
1032         else
1033                 sxe_cv_feat_alsa="no"
1034         fi
1035 ])dnl _SXE_MM_CHECK_ALSA
1036
1037 AC_DEFUN([SXE_CHECK_ALSA_HEADERS], [dnl
1038         ## dump the current configuration
1039         SXE_DUMP_LIBS
1040         SXE_LANG_WERROR([off])
1041         SXE_CHECK_HEADERS([alsa/input.h alsa/output.h alsa/global.h])
1042         SXE_CHECK_HEADERS([alsa/conf.h], [:], [:], [[
1043 #include <stdlib.h>
1044 #include <stdio.h>
1045 #if defined HAVE_ALSA_INPUT_H
1046 # include <alsa/input.h>
1047 #endif
1048 #if defined HAVE_ALSA_OUTPUT_H
1049 # include <alsa/output.h>
1050 #endif
1051 #if defined HAVE_ALSA_GLOBAL_H
1052 # include <alsa/global.h>
1053 #endif
1054 ]])
1055         SXE_CHECK_HEADERS([alsa/pcm.h alsa/error.h alsa/version.h], [:], [:], [[
1056 #include <stdlib.h>
1057 #include <stdio.h>
1058 #if defined HAVE_ALSA_INPUT_H
1059 # include <alsa/input.h>
1060 #endif
1061 #if defined HAVE_ALSA_OUTPUT_H
1062 # include <alsa/output.h>
1063 #endif
1064 #if defined HAVE_ALSA_GLOBAL_H
1065 # include <alsa/global.h>
1066 #endif
1067 #if defined HAVE_ALSA_CONF_H
1068 # include <alsa/conf.h>
1069 #endif
1070 ]])
1071         ## restor everything
1072         SXE_RESTORE_LIBS
1073 ])dnl SXE_CHECK_ALSA_HEADERS
1074
1075 AC_DEFUN([SXE_CHECK_ALSA_VERSION], [dnl
1076         AC_REQUIRE([SXE_CHECK_ALSA_HEADERS])
1077
1078         ## dump the configuration
1079         SXE_DUMP_LIBS
1080         SXE_LANG_WERROR([off])
1081         AC_MSG_CHECKING([for alsa version])
1082
1083         AC_RUN_IFELSE([AC_LANG_SOURCE([[
1084 #include <stdlib.h>
1085 #include <stdio.h>
1086 #if defined HAVE_ALSA_INPUT_H
1087 # include <alsa/input.h>
1088 #endif
1089 #if defined HAVE_ALSA_OUTPUT_H
1090 # include <alsa/output.h>
1091 #endif
1092 #if defined HAVE_ALSA_GLOBAL_H
1093 # include <alsa/global.h>
1094 #endif
1095 #if defined HAVE_ALSA_CONF_H
1096 # include <alsa/conf.h>
1097 #endif
1098 #if defined HAVE_ALSA_PCM_H
1099 # include <alsa/pcm.h>
1100 #endif
1101 #if defined HAVE_ALSA_ERROR_H
1102 # include <alsa/error.h>
1103 #endif
1104 #if defined HAVE_ALSA_CONF_H
1105 # include <alsa/version.h>
1106 #endif
1107
1108 int main(int c, char *v[])
1109 {
1110         fprintf(stdout, SND_LIB_VERSION_STR);
1111         return 0;
1112 }]])], dnl [./conftest; alsa_subminor=$?],[alsa_subminor=$?],[alsa_subminor=0]
1113         [sxe_mm_alsa_version=$(./conftest)],
1114         [:], [sxe_mm_alsa_version="undeterminable"])
1115
1116         case "${sxe_mm_alsa_version}" in
1117         0.*.* | 1.0.3* | 1.0.9* )
1118                 AC_MSG_RESULT([${sxe_mm_alsa_version} (known to break)])
1119                 AC_MSG_WARN([Your ALSA version is _KNOWN_ to fail! Do not say we have not warned you!])
1120                 sxe_mm_alsa_version_supported_p="no"
1121                 ;;
1122         1.0.2 | 1.0.4* | 1.0.5* | 1.0.6* | 1.0.7* | 1.0.8* )
1123                 AC_MSG_RESULT([${sxe_mm_alsa_version} (suspicious to break)])
1124                 AC_MSG_WARN([Your ALSA version has not been tested. Do not be surprised if it fails!])
1125                 sxe_mm_alsa_version_supported_p="no"
1126                 ;;
1127         1.0.10* | 1.0.11* | 1.0.12* | 1.0.13* | 1.0.14* | 1.0.15* | 1.0.16* )
1128                 AC_MSG_RESULT([${sxe_mm_alsa_version} (sane)])
1129                 sxe_mm_alsa_version_supported_p="yes"
1130                 ;;
1131         1.* )
1132                 AC_MSG_RESULT([${sxe_mm_alsa_version} (unknown)])
1133                 AC_MSG_NOTICE([Your ALSA version is unknown, however we are confident that it works.])
1134                 AC_MSG_NOTICE([However, if we screwed up something, please report back!])
1135                 sxe_mm_alsa_version_supported_p="yes"
1136                 ;;
1137         * )
1138                 AC_MSG_RESULT([${sxe_mm_alsa_version} (unknown)])
1139                 AC_MSG_WARN([Your ALSA version is unknown hence not supported!])
1140                 sxe_mm_alsa_version_supported_p="no"
1141                 ;;
1142         esac
1143
1144         ## restore everything
1145         SXE_RESTORE_LIBS
1146 ])dnl SXE_CHECK_ALSA_VERSION
1147
1148 AC_DEFUN([SXE_CHECK_ALSA_LIBS], [dnl
1149         ## dump the current configuration
1150         SXE_DUMP_LIBS
1151
1152         AC_CHECK_LIB([asound], [snd_pcm_open], [:], [:])
1153         AC_CHECK_LIB([asound], [snd_pcm_close], [:], [:])
1154         AC_CHECK_LIB([asound], [snd_pcm_hw_free], [:], [:])
1155         AC_CHECK_LIB([asound], [snd_pcm_hw_params_any], [:], [:])
1156         AC_CHECK_LIB([asound], [snd_pcm_hw_params_set_access], [:], [:])
1157         AC_CHECK_LIB([asound], [snd_pcm_hw_params_free], [:], [:])
1158         AC_CHECK_LIB([asound], [snd_pcm_hw_params_test_channels], [:], [:])
1159         AC_CHECK_LIB([asound], [snd_pcm_hw_params_test_format], [:], [:])
1160         AC_CHECK_LIB([asound], [snd_pcm_hw_params_set_channels], [:], [:])
1161         AC_CHECK_LIB([asound], [snd_pcm_hw_params_set_format], [:], [:])
1162         AC_CHECK_LIB([asound], [snd_pcm_hw_params_set_rate_near], [:], [:])
1163         AC_CHECK_LIB([asound], [snd_pcm_prepare], [:], [:])
1164         AC_CHECK_LIB([asound], [snd_pcm_writei], [:], [:])
1165
1166         ## restore everything
1167         SXE_RESTORE_LIBS
1168 ])dnl SXE_CHECK_ALSA_LIBS
1169
1170
1171
1172 AC_DEFUN([SXE_MM_CHECK_NAS], [
1173         ## arg #1: action on success
1174         ## arg #2: action on failure
1175         pushdef([MM_SUCC], [$1])
1176         pushdef([MM_FAIL], [$2])
1177
1178         AC_MSG_CHECKING([for NAS support])
1179         AC_MSG_RESULT([])
1180
1181         SXE_DUMP_LIBS
1182
1183         MM_SUCC
1184         ## NAS is often stored inside the X hierarchy, so ...
1185         CPPFLAGS="$CPPFLAGS $X_CFLAGS"
1186         LDFLAGS="$LDFLAGS $X_LIBS"
1187         SXE_CHECK_HEADERS([audio/audiolib.h], [:], [MM_FAIL])
1188         AC_CHECK_LIB([audio], [AuOpenServer], [:], [MM_FAIL])
1189         AC_CHECK_LIB([audio], [AuCloseServer], [:], [MM_FAIL])
1190         AC_CHECK_LIB([audio], [AuCreateFlow], [:], [MM_FAIL])
1191         AC_CHECK_LIB([audio], [AuStartFlow], [:], [MM_FAIL])
1192         AC_CHECK_LIB([audio], [AuStopFlow], [:], [MM_FAIL])
1193         AC_CHECK_LIB([audio], [AuScanForTypedEvent], [:], [MM_FAIL])
1194         AC_CHECK_LIB([audio], [AuDispatchEvent], [:], [MM_FAIL])
1195         AC_CHECK_LIB([audio], [AuSetErrorHandler], [:], [MM_FAIL])
1196         AC_CHECK_LIB([audio], [AuSetIOErrorHandler], [:], [MM_FAIL])
1197         AC_CHECK_LIB([audio], [AuWriteElement], [:], [MM_FAIL])
1198         AC_CHECK_LIB([audio], [AuSetElements], [:], [MM_FAIL])
1199         AC_CHECK_LIB([audio], [AuRegisterEventHandler], [:], [MM_FAIL])
1200         AC_CHECK_LIB([audio], [AuSetElementParameters], [:], [MM_FAIL])
1201
1202         dnl If the nas library does not contain the error jump point,
1203         dnl then we force safer behavior.
1204         AC_EGREP_HEADER([AuXtErrorJump], [audio/Xtutil.h], [], [old_nas=yes])
1205         if test "$old_nas" = "yes"; then
1206                 AC_DEFINE([NAS_NO_ERROR_JUMP], [1], [Description here!])
1207         fi
1208
1209         ## restore anything
1210         SXE_RESTORE_LIBS
1211
1212         popdef([MM_SUCC])
1213         popdef([MM_FAIL])
1214 ])dnl SXE_MM_CHECK_NAS
1215
1216 dnl sxe-mm.m4 ends here