42a5083492c24f4d122b6253f0fb5a000db27f00
[paraslash.git] / configure.ac
1 #                                               -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
3
4 AC_PREREQ([2.61])
5
6 AC_INIT([paraslash],[git],[maan@systemlinux.org])
7 AC_CONFIG_HEADER([config.h])
8
9 AC_CONFIG_FILES([Makefile])
10 AC_DEFUN([add_dot_o],[$(for i in $@; do printf "$i.o "; done)])
11 AC_DEFUN([add_cmdline],[$(for i in $@; do printf "${i}.cmdline "; done)])
12 AC_DEFUN([objlist_to_errlist],[$(for i in $@; do printf "DEFINE_ERRLIST($(echo $i| tr 'a-z' 'A-Z'));"; done) [const char **para_errlist[[]]] = {$(for i in $@; do printf "PARA_ERRLIST($(echo $i | tr 'a-z' 'A-Z')), "; done) }])
13 AC_PATH_PROG(UNAMEPATH, uname, no)
14 if test "$UNAMEPATH" = "no"; then
15         AC_MSG_ERROR(unable to determine system type)
16 fi
17 AC_MSG_CHECKING(os type)
18 OSTYPE="`$UNAMEPATH -s`"
19 AC_MSG_RESULT("$OSTYPE")
20
21 if test "$OSTYPE" = "SunOS"; then
22         # needed on SunOS for socket magic
23         arch_cppflags="-D_XOPEN_SOURCE=500 -D__EXTENSIONS__"
24         AC_SUBST(arch_cppflags)
25 fi
26
27 AC_C_BIGENDIAN()
28
29 AC_PATH_PROG([gengetopt], [gengetopt])
30 test -z "$gengetopt" && AC_MSG_ERROR(
31         [gengetopt is required to build this package])
32
33 AC_PATH_PROG([help2man], [help2man])
34 test -z "$help2man" && AC_MSG_ERROR(
35         [help2man is required to build this package])
36
37 AC_PATH_PROG([install], [install])
38 test -z "$install" && AC_MSG_ERROR(
39         [The install program is required to build this package])
40
41 AC_PROG_CC
42 AC_PROG_CPP
43
44 AC_HEADER_DIRENT
45 AC_HEADER_STDC
46 AC_HEADER_SYS_WAIT
47 AC_HEADER_STDBOOL
48 AC_CHECK_HEADERS([arpa/inet.h ctype.h fcntl.h limits.h netdb.h netinet/in.h \
49         stdlib.h string.h sys/socket.h sys/time.h sys/timeb.h sys/un.h \
50         sys/ipc.h unistd.h utime.h stddef.h],
51         [], [AC_MSG_ERROR([$ac_header not found])])
52
53 # Checks for typedefs, structures, and compiler characteristics.
54 AC_C_CONST
55 AC_C_INLINE
56 AC_TYPE_OFF_T
57 AC_TYPE_PID_T
58 AC_TYPE_SIZE_T
59 AC_HEADER_TIME
60 AC_STRUCT_TM
61 AC_TYPE_INT8_T
62 AC_TYPE_INT16_T
63 AC_TYPE_INT32_T
64 AC_TYPE_INT64_T
65 AC_TYPE_MODE_T
66 AC_TYPE_SSIZE_T
67 AC_TYPE_UID_T
68 AC_TYPE_UINT8_T
69 AC_TYPE_UINT16_T
70 AC_TYPE_UINT32_T
71 AC_TYPE_UINT64_T
72
73 # Checks for library functions.
74 AC_FUNC_FORK
75 AC_PROG_GCC_TRADITIONAL
76 AC_FUNC_MEMCMP
77 AC_FUNC_MKTIME
78 AC_FUNC_MMAP
79 AC_FUNC_SELECT_ARGTYPES
80 AC_FUNC_STAT
81 AC_FUNC_STRFTIME
82 AC_FUNC_VPRINTF
83 AC_FUNC_CLOSEDIR_VOID
84 AC_FUNC_LSTAT
85
86 AC_CHECK_FUNCS([atexit dup2 memchr memmove memset \
87         regcomp select strchr strdup strerror strstr strtol uname \
88         fchdir gettimeofday localtime_r munmap strcasecmp strcspn \
89         strncasecmp strrchr strspn alarm mkdir inet_ntoa socket], [],
90         [AC_MSG_ERROR([function not found, cannot live without it])])
91
92 executables="recv filter audioc write afh play"
93 audio_format_handlers="mp3 wma"
94
95 audioc_cmdline_objs="audioc"
96 audioc_errlist_objs="
97         audioc
98         string
99         net
100         fd
101         version
102         ggo
103 "
104 audioc_ldflags=""
105
106 afh_cmdline_objs="afh"
107 afh_errlist_objs="
108         afh
109         string
110         fd
111         mp3_afh
112         afh_common
113         time
114         wma_afh
115         wma_common
116         version
117         ggo
118 "
119 afh_ldflags=""
120
121 write_cmdline_objs="
122         write
123         file_write
124 "
125 write_errlist_objs="
126         write
127         write_common
128         file_write
129         time
130         fd
131         string
132         sched
133         stdin
134         buffer_tree
135         ggo
136         check_wav
137         version
138 "
139 write_ldflags=""
140 writers="file"
141 default_writer="FILE_WRITE"
142
143 play_errlist_objs="
144         play
145         fd
146         sched
147         ggo
148         buffer_tree
149         time
150         string
151         net
152         afh_recv
153         afh_common
154         wma_afh
155         wma_common
156         mp3_afh
157         recv_common
158         udp_recv
159         http_recv
160         dccp_recv
161         filter_common
162         fec
163         bitstream
164         imdct
165         wav_filter
166         compress_filter
167         amp_filter
168         prebuffer_filter
169         fecdec_filter
170         wmadec_filter
171         write_common
172         file_write
173         version
174 "
175 play_cmdline_objs="
176         http_recv
177         dccp_recv
178         udp_recv
179         afh_recv
180         compress_filter
181         amp_filter
182         prebuffer_filter
183         file_write
184         play
185 "
186 play_ldflags="-lm"
187 ################################################################## clock_gettime
188 clock_gettime_lib=
189 AC_CHECK_LIB([c], [clock_gettime], [clock_gettime_lib=c], [
190         AC_CHECK_LIB([rt], [clock_gettime], [clock_gettime_lib=rt], [], [])
191 ])
192 if test -n "$clock_gettime_lib"; then
193         AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [
194                 define to 1 if clock_gettime() is supported])
195 fi
196 if test "$clock_gettime_lib" = "rt"; then
197         AC_SUBST(clock_gettime_ldflags, -lrt)
198 fi
199 ########################################################################### osl
200 have_osl=yes
201 OLD_CPPFLAGS="$CPPFLAGS"
202 OLD_LDFLAGS="$LDFLAGS"
203 OLD_LIBS="$LIBS"
204 AC_ARG_WITH(osl_headers, [AS_HELP_STRING(--with-osl-headers=dir,
205         [look for osl.h also in dir])])
206 if test -n "$with_osl_headers"; then
207         osl_cppflags="-I$with_osl_headers"
208         CPPFLAGS="$CPPFLAGS $osl_cppflags"
209 fi
210 AC_ARG_WITH(osl_libs, [AS_HELP_STRING(--with-osl-libs=dir,
211         [look for libosl also in dir])])
212 if test -n "$with_osl_libs"; then
213         osl_libs="-L$with_osl_libs"
214         LDFLAGS="$LDFLAGS $osl_libs"
215 fi
216
217 AC_CHECK_HEADER(osl.h, [], have_osl=no)
218 AC_CHECK_LIB([osl], [osl_open_table], [], have_osl=no)
219 if test "$have_osl" = "yes"; then
220         AC_SUBST(osl_cppflags)
221         osl_ldflags="$osl_libs -losl"
222         AC_SUBST(osl_ldflags)
223 else
224         AC_MSG_WARN([libosl not found, can not build para_server.
225 Download libosl at
226         http://systemlinux.org/~maan/osl
227 or execute
228         git clone git://git.tuebingen.mpg.de/osl
229         ])
230 fi
231 CPPFLAGS="$OLD_CPPFLAGS"
232 LDFLAGS="$OLD_LDFLAGS"
233 LIBS="$OLD_LIBS"
234 ########################################################################### crypto
235 AC_ARG_ENABLE(cryptolib, [AS_HELP_STRING(--enable-cryptolib=lib, [
236         Force using crypto library "lib". This package requires either
237         openssl or libgcrypt being installed. Possible values for "lib"
238         are thus "openssl" and "gcrypt". If this option is not given,
239         openssl is tried first. If openssl was not found, gcrypt is
240         tried next.])])
241
242 case "$enable_cryptolib" in
243         "openssl") check_openssl="yes"; check_gcrypt="no";;
244         "gcrypt") check_openssl="no"; check_gcrypt="yes";;
245         "") check_openssl="yes"; check_gcrypt="yes";;
246         *) AC_MSG_ERROR([invalid value "$enable_cryptolib" for --enable-cryptolib]);;
247 esac
248 ###################################################################### openssl
249 if test "$check_openssl" = "yes"; then
250         OLD_CPPFLAGS="$CPPFLAGS"
251         OLD_LDFLAGS="$LDFLAGS"
252         OLD_LIBS="$LIBS"
253         have_openssl="yes"
254         AC_ARG_WITH(openssl_headers, [AS_HELP_STRING(--with-openssl-headers=dir,
255                 [look for openssl headers also in dir])])
256         if test -n "$with_openssl_headers"; then
257                 openssl_cppflags="-I$with_openssl_headers"
258                 CPPFLAGS="$CPPFLAGS $openssl_cppflags"
259         fi
260         AC_ARG_WITH(openssl_libs, [AS_HELP_STRING(--with-openssl-libs=dir,
261                 [look for openssl libraries also in dir])])
262         if test -n "$with_openssl_libs"; then
263                 openssl_libs="-L$with_openssl_libs"
264                 LDFLAGS="$LDFLAGS $openssl_libs"
265         fi
266         AC_CHECK_HEADER(openssl/ssl.h, [], [have_openssl="no"])
267         AC_CHECK_LIB([crypto], [RAND_bytes], [], [have_openssl="no"])
268         if test "$have_openssl" = "no" -a -z "$with_openssl_headers$with_openssl_libs"; then
269                 # try harder: openssl is sometimes installed in /usr/local/ssl
270                 openssl_cppflags="-I/usr/local/ssl/include"
271                 CPPFLAGS="$CPPFLAGS $openssl_cppflags"
272                 openssl_libs="-L/usr/local/ssl/lib"
273                 LDFLAGS="$LDFLAGS $openssl_libs"
274                 # clear cache
275                 unset ac_cv_header_openssl_ssl_h 2> /dev/null
276                 unset ac_cv_lib_crypto_RAND_bytes 2> /dev/null
277                 AC_CHECK_HEADER(openssl/ssl.h, [have_openssl="yes"], [])
278                 if test "$have_openssl" = "yes"; then
279                         AC_CHECK_LIB([crypto], [RAND_bytes], [], [have_openssl="no"])
280                 fi
281         fi
282         if test "$have_openssl" = "yes"; then
283                 AC_DEFINE(HAVE_OPENSSL, 1, [define to 1 to turn on openssl support])
284                 AC_SUBST(openssl_cppflags)
285                 openssl_ldflags="$openssl_libs -lssl -lcrypto"
286                 AC_SUBST(openssl_ldflags)
287
288                 server_errlist_objs="$server_errlist_objs crypt"
289                 client_errlist_objs="$client_errlist_objs crypt"
290                 audiod_errlist_objs="$audiod_errlist_objs crypt"
291
292                 check_gcrypt="no"
293         else
294                 AC_MSG_WARN([openssl libraries not found])
295         fi
296         CPPFLAGS="$OLD_CPPFLAGS"
297         LDFLAGS="$OLD_LDFLAGS"
298         LIBS="$OLD_LIBS"
299 else
300         have_openssl="no"
301 fi
302 ########################################################################### gcrypt
303 if test "$check_gcrypt" = "yes"; then
304         OLD_CPPFLAGS="$CPPFLAGS"
305         OLD_LDFLAGS="$LDFLAGS"
306         OLD_LIBS="$LIBS"
307         have_gcrypt="yes"
308         AC_ARG_WITH(gcrypt_headers, [AS_HELP_STRING(--with-gcrypt-headers=dir,
309                 [look for gcrypt headers also in dir])])
310         if test -n "$with_gcrypt_headers"; then
311                 gcrypt_cppflags="-I$with_gcrypt_headers"
312                 CPPFLAGS="$CPPFLAGS $gcrypt_cppflags"
313         fi
314         AC_ARG_WITH(gcrypt_libs, [AS_HELP_STRING(--with-gcrypt-libs=dir,
315                 [look for libgcrypt also in dir])])
316         if test -n "$with_gcrypt_libs"; then
317                 gcrypt_libs="-L$with_gcrypt_libs"
318                 LDFLAGS="$LDFLAGS $gcrypt_libs"
319         fi
320         AC_CHECK_HEADER(gcrypt.h, [], [have_gcrypt="no"])
321         AC_CHECK_LIB([gcrypt], [gcry_randomize], [], [have_gcrypt="no"])
322         if test "$have_gcrypt" = "yes"; then
323                 AC_DEFINE(HAVE_GCRYPT, 1, [define to 1 to turn on gcrypt support])
324                 AC_SUBST(gcrypt_cppflags)
325                 gcrypt_ldflags="$gcrypt_libs -lgcrypt"
326                 AC_SUBST(gcrypt_ldflags)
327
328                 server_errlist_objs="$server_errlist_objs gcrypt"
329                 client_errlist_objs="$client_errlist_objs gcrypt"
330                 audiod_errlist_objs="$audiod_errlist_objs gcrypt"
331         else
332                 AC_MSG_WARN([gcrypt library not found])
333         fi
334         CPPFLAGS="$OLD_CPPFLAGS"
335         LDFLAGS="$OLD_LDFLAGS"
336         LIBS="$OLD_LIBS"
337 else
338         have_gcrypt="no"
339 fi
340 ########################################################################### libsocket
341 AC_CHECK_LIB([c], [socket],
342         [socket_ldlflags=],
343         [socket_ldflags="-lsocket"]
344 )
345 AC_SUBST(socket_ldflags)
346 ########################################################################### libnsl
347 AC_CHECK_LIB([c], [gethostbyname],
348         [nsl_ldflags=],
349         [nsl_ldflags="-lnsl"]
350 )
351 AC_SUBST(nsl_ldflags)
352 ########################################################################### ucred
353 AC_MSG_CHECKING(for struct ucred)
354 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
355         #define _GNU_SOURCE
356         #include <sys/types.h>
357         #include <sys/socket.h>
358 ]], [[
359         struct ucred sucred; sucred.pid=0;
360 ]])],[have_ucred=yes],[have_ucred=no])
361 AC_MSG_RESULT($have_ucred)
362 if test ${have_ucred} = yes; then
363         AC_DEFINE(HAVE_UCRED, 1, define to 1 you have struct ucred)
364 fi
365 ########################################################################### gengetopt
366 echo 'option "z" z "" flag off' | $gengetopt --file-name conftest-ggo &&
367 AC_CHECK_DECL(
368         [gengetopt_args_info_description],
369         [ggo_descriptions_declared=yes],
370         [ggo_descriptions_declared=no],
371         [#include "conftest-ggo.h"]
372 )
373 AC_SUBST(ggo_descriptions_declared)
374 ########################################################################### curses
375 have_curses="yes"
376 OLD_CPPFLAGS="$CPPFLAGS"
377 OLD_LDFLAGS="$LDFLAGS"
378 OLD_LIBS="$LIBS"
379 AC_ARG_WITH(curses_headers, [AS_HELP_STRING(--with-curses-headers=dir,
380         [look for curses.h also in dir])])
381 if test -n "$with_curses_headers"; then
382         curses_cppflags="-I$with_curses_headers"
383         CPPFLAGS="$CPPFLAGS $curses_cppflags"
384 fi
385 AC_ARG_WITH(curses_libs, [AS_HELP_STRING(--with-curses-libs=dir,
386         [look for libcurses also in dir])])
387 if test -n "$with_curses_libs"; then
388         curses_libs="-L$with_curses_libs"
389         LDFLAGS="$LDFLAGS $curses_libs"
390 fi
391 AC_CHECK_HEADER(curses.h, [], [
392         have_curses="no"
393 ])
394 curses_ldflags="$curses_libs"
395 AC_CHECK_LIB([ncursesw], [initscr],
396         [curses_ldflags="$curses_libs -lncursesw"], [
397                 AC_CHECK_LIB([curses], [initscr],
398                         [curses_ldflags="$curses_libs -lcurses"],
399                         [have_curses="no"]
400                 )
401         ]
402 )
403 AC_SUBST(curses_cppflags)
404 AC_SUBST(curses_ldflags)
405 CPPFLAGS="$OLD_CPPFLAGS"
406 LDFLAGS="$OLD_LDFLAGS"
407 LIBS="$OLD_LIBS"
408 ########################################################################### ip_mreqn
409 AC_MSG_CHECKING(for struct ip_mreqn (UDPv4 multicast))
410 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
411         #include <netdb.h>
412         #include <net/if.h>
413 ]], [[
414         struct ip_mreqn mn;
415         mn.imr_ifindex = 0;
416 ]])],[have_ip_mreqn=yes],[have_ip_mreqn=no])
417 AC_MSG_RESULT($have_ip_mreqn)
418 if test ${have_ip_mreqn} = yes; then
419         AC_DEFINE(HAVE_IP_MREQN, 1, define to 1 you have struct ip_mreqn)
420 fi
421 ########################################################################### osx
422
423 AC_MSG_CHECKING(for CoreAudio (MacOs))
424 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
425         #include <CoreAudio/CoreAudio.h>
426 ]], [[
427         AudioDeviceID id;
428 ]])],[have_core_audio=yes],[have_core_audio=no])
429 AC_MSG_RESULT($have_core_audio)
430 if test ${have_core_audio} = yes; then
431         f1="-framework CoreAudio"
432         f2="-framework AudioToolbox"
433         f3="-framework AudioUnit"
434         f4="-framework CoreServices"
435         core_audio_ldflags="$f1 $f2 $f3 $f4"
436         AC_SUBST(core_audio_ldflags)
437
438         audiod_errlist_objs="$audiod_errlist_objs osx_write ipc"
439         audiod_cmdline_objs="$audiod_cmdline_objs osx_write.cmdline"
440
441         play_errlist_objs="$play_errlist_objs osx_write ipc"
442         play_cmdline_objs="$play_cmdline_objs osx_write.cmdline"
443
444         write_errlist_objs="$write_errlist_objs osx_write ipc"
445         write_cmdline_objs="$write_cmdline_objs osx_write.cmdline"
446         writers="$writers osx"
447         default_writer="OSX_WRITE"
448         AC_DEFINE(HAVE_CORE_AUDIO, 1, define to 1 on Mac Os X)
449 fi
450 ####################################################### ogg/vorbis/speex/opus
451 have_ogg="yes"
452 OLD_CPPFLAGS="$CPPFLAGS"
453 OLD_LDFLAGS="$LDFLAGS"
454 OLD_LIBS="$LIBS"
455 AC_ARG_WITH(ogg_headers, [AS_HELP_STRING(--with-ogg-headers=dir,
456         [look for ogg headers also in dir])])
457 AC_ARG_WITH(ogg_libs, [AS_HELP_STRING(--with-ogg-libs=dir,
458         [look for ogg libs also in dir])])
459 AC_ARG_WITH(vorbis_headers, [AS_HELP_STRING(--with-vorbis-headers=dir,
460         [look for vorbis headers also in dir])])
461 AC_ARG_WITH(vorbis_libs, [AS_HELP_STRING(--with-vorbis-libs=dir,
462         [look for vorbis libs also in dir])])
463 AC_ARG_WITH(speex_headers, [AS_HELP_STRING(--with-speex-headers=dir,
464         [look for speex headers also in dir])])
465 AC_ARG_WITH(speex_libs, [AS_HELP_STRING(--with-speex-libs=dir,
466         [look for speex libs also in dir])])
467 AC_ARG_WITH(opus_headers, [AS_HELP_STRING(--with-opus-headers=dir,
468         [look for opus headers also in dir])])
469 AC_ARG_WITH(opus_libs, [AS_HELP_STRING(--with-opus-libs=dir,
470         [look for opus libs also in dir])])
471
472 if test -n "$with_ogg_headers"; then
473         ogg_cppflags="-I$with_ogg_headers"
474         CPPFLAGS="$CPPFLAGS $ogg_cppflags"
475 fi
476 if test -n "$with_ogg_libs"; then
477         ogg_libs="-L$with_ogg_libs"
478         LDFLAGS="$LDFLAGS $ogg_libs"
479 fi
480 AC_CHECK_HEADERS([ogg/ogg.h], [], [ have_ogg="no"; ])
481 AC_CHECK_LIB([ogg], [ogg_stream_init], [], [ have_ogg="no" ])
482
483 have_vorbis="yes"
484 have_speex="yes"
485 have_opus="yes"
486 if test "$have_ogg" = "yes"; then
487         # vorbis
488         if test -n "$with_vorbis_headers"; then
489                 vorbis_cppflags="-I$with_vorbis_headers"
490                 CPPFLAGS="$CPPFLAGS $vorbis_cppflags"
491         fi
492         if test -n "$with_vorbis_libs"; then
493                 vorbis_libs="-L$with_vorbis_libs"
494                 LDFLAGS="$LDFLAGS $vorbis_libs"
495         fi
496         AC_CHECK_HEADERS([vorbis/codec.h], [], [ have_vorbis="no" ])
497         AC_CHECK_LIB([vorbis], [vorbis_info_init], [], [ have_vorbis="no" ])
498
499         # speex
500         if test -n "$with_speex_headers"; then
501                 speex_cppflags="-I$with_speex_headers"
502                 CPPFLAGS="$CPPFLAGS $speex_cppflags"
503         fi
504         if test -n "$with_speex_libs"; then
505                 speex_libs="-L$with_speex_libs"
506                 LDFLAGS="$LDFLAGS $speex_libs"
507         fi
508         AC_CHECK_LIB([speex], [speex_decoder_init], [], [ have_speex="no" ])
509         AC_CHECK_HEADERS([speex/speex.h], [], [ have_speex="no" ])
510
511         # opus
512         if test -n "$with_opus_headers"; then
513                 opus_cppflags="-I$with_opus_headers"
514                 CPPFLAGS="$CPPFLAGS $opus_cppflags"
515         fi
516         if test -n "$with_opus_libs"; then
517                 opus_libs="-L$with_opus_libs"
518                 LDFLAGS="$LDFLAGS $opus_libs"
519         fi
520         AC_CHECK_LIB([opus], [opus_multistream_decode], [], [ have_opus="no" ])
521         AC_CHECK_HEADERS([opus/opus.h], [], [ have_opus="no" ])
522 else
523         AC_MSG_WARN([vorbis/speex/opus depend on libogg, which was not detected])
524         have_vorbis="no"
525         have_speex="no"
526         have_opus="no"
527 fi
528
529 msg="support in para_server/para_filter/para_afh"
530 if test "$have_vorbis" = "yes" || \
531                 test "$have_speex" = "yes" || \
532                 test "$have_opus" = "yes"; then
533         AC_SUBST(ogg_cppflags)
534         ogg_ldflags="$ogg_libs -logg"
535         if test "$OSTYPE" = "Darwin"; then
536                 ogg_ldflags="-Wl,-bind_at_load $ogg_ldflags"
537         fi
538         AC_SUBST(ogg_ldflags)
539         afh_errlist_objs="$afh_errlist_objs ogg_afh_common"
540         server_errlist_objs="$server_errlist_objs ogg_afh_common"
541         play_errlist_objs="$play_errlist_objs ogg_afh_common"
542 fi
543 if test "$have_vorbis" = "yes"; then
544         AC_DEFINE(HAVE_OGGVORBIS, 1, define to 1 to turn on ogg/vorbis support)
545         vorbis_ldflags="$vorbis_libs -lvorbis -lvorbisfile"
546         AC_SUBST(vorbis_ldflags)
547
548         server_errlist_objs="$server_errlist_objs ogg_afh"
549         audiod_errlist_objs="$audiod_errlist_objs oggdec_filter"
550         play_errlist_objs="$play_errlist_objs oggdec_filter ogg_afh"
551         afh_errlist_objs="$afh_errlist_objs ogg_afh"
552
553         audiod_audio_formats="$audiod_audio_formats ogg"
554         audio_format_handlers="$audio_format_handlers ogg"
555 fi
556 if test "$have_speex" = "yes"; then
557         AC_DEFINE(HAVE_SPEEX, 1, define to 1 to turn on ogg/speex support)
558         AC_SUBST(speex_cppflags)
559         speex_ldflags="$speex_libs -lspeex"
560         AC_SUBST(speex_ldflags)
561
562
563         server_errlist_objs="$server_errlist_objs spx_afh spx_common"
564         audiod_errlist_objs="$audiod_errlist_objs spxdec_filter spx_common"
565         play_errlist_objs="$play_errlist_objs spxdec_filter spx_afh spx_common"
566         afh_errlist_objs="$afh_errlist_objs spx_afh spx_common"
567
568         audiod_audio_formats="$audiod_audio_formats spx"
569         audio_format_handlers="$audio_format_handlers spx"
570 else
571         AC_MSG_WARN([no ogg/speex $msg])
572 fi
573 if test "$have_opus" = "yes"; then
574         AC_DEFINE(HAVE_OPUS, 1, define to 1 to turn on ogg/opus support)
575         AC_SUBST(opus_cppflags)
576         opus_ldflags="$opus_libs -lopus"
577         AC_SUBST(opus_ldflags)
578
579
580         server_errlist_objs="$server_errlist_objs opus_afh opus_common"
581         audiod_errlist_objs="$audiod_errlist_objs opusdec_filter opus_common"
582         afh_errlist_objs="$afh_errlist_objs opus_afh opus_common"
583         play_errlist_objs="$play_errlist_objs opusdec_filter opus_afh opus_common"
584
585         audiod_audio_formats="$audiod_audio_formats opus"
586         audio_format_handlers="$audio_format_handlers opus"
587 else
588         AC_MSG_WARN([no ogg/opus $msg])
589 fi
590 CPPFLAGS="$OLD_CPPFLAGS"
591 LDFLAGS="$OLD_LDFLAGS"
592 LIBS="$OLD_LIBS"
593 ########################################################################### faad
594 have_faad=yes
595 OLD_CPPFLAGS="$CPPFLAGS"
596 OLD_LDFLAGS="$LDFLAGS"
597 OLD_LIBS="$LIBS"
598 AC_ARG_WITH(faad_headers, [AS_HELP_STRING(--with-faad-headers=dir,
599         [look for neaacdec.h also in dir])])
600 if test -n "$with_faad_headers"; then
601         faad_cppflags="-I$with_faad_headers"
602         CPPFLAGS="$CPPFLAGS $faad_cppflags"
603 fi
604 AC_ARG_WITH(faad_libs, [AS_HELP_STRING(--with-faad-libs=dir,
605         [look for libfaad also in dir])])
606 if test -n "$with_faad_libs"; then
607         faad_libs="-L$with_faad_libs"
608         LDFLAGS="$LDFLAGS $faad_libs"
609 fi
610 AC_CHECK_HEADER(neaacdec.h, [], have_faad=no)
611 AC_CHECK_LIB([faad], [NeAACDecOpen], [], have_faad=no)
612 if test "$have_faad" = "yes"; then
613         AC_DEFINE(HAVE_FAAD, 1, define to 1 if you want to build the aacdec filter)
614         AC_SUBST(faad_cppflags)
615         faad_ldflags="$faad_libs -lfaad"
616         AC_SUBST(faad_ldflags)
617
618         afh_errlist_objs="$afh_errlist_objs aac_common aac_afh"
619         audiod_errlist_objs="$audiod_errlist_objs aacdec_filter aac_common"
620         play_errlist_objs="$play_errlist_objs aacdec_filter aac_afh aac_common"
621         server_errlist_objs="$server_errlist_objs aac_afh aac_common"
622
623         audiod_audio_formats="$audiod_audio_formats aac"
624         audio_format_handlers="$audio_format_handlers aac"
625 fi
626 CPPFLAGS="$OLD_CPPFLAGS"
627 LDFLAGS="$OLD_LDFLAGS"
628 LIBS="$OLD_LIBS"
629 ########################################################################### mad
630 have_mad="yes"
631 OLD_CPPFLAGS="$CPPFLAGS"
632 OLD_LDFLAGS="$LDFLAGS"
633 OLD_LIBS="$LIBS"
634
635 AC_ARG_WITH(mad_headers, [AS_HELP_STRING(--with-mad-headers=dir,
636         [look for mad.h also in dir])])
637 if test -n "$with_mad_headers"; then
638         mad_cppflags="-I$with_mad_headers"
639         CPPFLAGS="$CPPFLAGS $mad_cppflags"
640 fi
641 AC_ARG_WITH(mad_libs, [AS_HELP_STRING(--with-mad-libs=dir,
642         [look for libmad also in dir])])
643 if test -n "$with_mad_libs"; then
644         mad_libs="-L$with_mad_libs"
645         LDFLAGS="$LDFLAGS $mad_libs"
646 fi
647 AC_CHECK_HEADERS([mad.h], [], [
648         have_mad="no"
649 ])
650 AC_CHECK_LIB([mad], [mad_stream_init], [], [
651         have_mad="no"
652 ])
653 if test "$have_mad" = "yes"; then
654         AC_DEFINE(HAVE_MAD, 1, define to 1 if you want to build the mp3dec filter)
655         AC_SUBST(mad_cppflags)
656         mad_ldflags="$mad_libs -lmad"
657         AC_SUBST(mad_ldflags)
658         audiod_cmdline_objs="$audiod_cmdline_objs mp3dec_filter"
659         play_cmdline_objs="$play_cmdline_objs mp3dec_filter"
660         audiod_errlist_objs="$audiod_errlist_objs mp3dec_filter"
661         play_errlist_objs="$play_errlist_objs mp3dec_filter"
662         audiod_audio_formats="$audiod_audio_formats mp3"
663 else
664         AC_MSG_WARN([no mp3dec support in para_audiod/para_filter])
665 fi
666 CPPFLAGS="$OLD_CPPFLAGS"
667 LDFLAGS="$OLD_LDFLAGS"
668 LIBS="$OLD_LIBS"
669 ###################################################################### libid3tag
670 OLD_CPPFLAGS="$CPPFLAGS"
671 OLD_LDFLAGS="$LDFLAGS"
672 OLD_LIBS="$LIBS"
673
674 have_libid3tag="yes"
675 AC_ARG_WITH(id3tag_headers, [AS_HELP_STRING(--with-id3tag-headers=dir,
676         [look for id3tag header files also in dir])])
677 if test -n "$with_id3tag_headers"; then
678         id3tag_cppflags="-I$with_id3tag_headers"
679         CPPFLAGS="$CPPFLAGS $id3tag_cppflags"
680 fi
681 AC_ARG_WITH(id3tag_libs, [AS_HELP_STRING(--with-id3tag-libs=dir,
682         [look for id3tag libs also in dir])])
683 if test -n "$with_id3tag_libs"; then
684         id3tag_libs="-L$with_id3tag_libs"
685         LDFLAGS="$LDFLAGS $id3tag_libs"
686 fi
687
688 AC_MSG_CHECKING(for libid3tag)
689 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
690         #include <id3tag.h>
691 ]], [[
692         struct id3_tag t = {.flags = 0};
693 ]])],[],[have_libid3tag=no])
694 AC_MSG_RESULT($have_libid3tag)
695
696 if test ${have_libid3tag} = yes; then
697         AC_DEFINE(HAVE_LIBID3TAG, 1, define to 1 you have libid3tag)
698         AC_SUBST(id3tag_cppflags)
699         AC_SUBST(id3tag_ldflags, "$id3tag_libs -lid3tag -lz")
700 fi
701 CPPFLAGS="$OLD_CPPFLAGS"
702 LDFLAGS="$OLD_LDFLAGS"
703 LIBS="$OLD_LIBS"
704 ########################################################################### flac
705 OLD_CPPFLAGS="$CPPFLAGS"
706 OLD_LDFLAGS="$LDFLAGS"
707 OLD_LIBS="$LIBS"
708
709 have_flac="yes"
710 AC_ARG_WITH(flac_headers, [AS_HELP_STRING(--with-flac-headers=dir,
711         [look for flac headers also in dir])])
712 if test -n "$with_flac_headers"; then
713         flac_cppflags="-I$with_flac_headers"
714         CPPFLAGS="$CPPFLAGS $flac_cppflags"
715 fi
716 AC_ARG_WITH(flac_libs, [AS_HELP_STRING(--with-flac-libs=dir,
717         [look for flac libs also in dir])])
718 if test -n "$with_flac_libs"; then
719         flac_libs="-L$with_flac_libs"
720         LDFLAGS="$LDFLAGS $flac_libs"
721 fi
722 AC_CHECK_HEADER(FLAC/stream_decoder.h, [], have_flac=no)
723 AC_CHECK_LIB([FLAC], [FLAC__stream_decoder_init_file], [], have_flac=no, -logg -lm)
724 if test "$have_flac" = "yes"; then
725         AC_DEFINE(HAVE_FLAC, 1, define to 1 if you want to build the flacdec filter)
726         AC_SUBST(flac_cppflags)
727         flac_ldflags="$flac_libs -lFLAC"
728         AC_SUBST(flac_ldflags)
729
730         audiod_errlist_objs="$audiod_errlist_objs flacdec_filter"
731         play_errlist_objs="$play_errlist_objs flacdec_filter flac_afh"
732         afh_errlist_objs="$afh_errlist_objs flac_afh"
733         server_errlist_objs="$server_errlist_objs flac_afh"
734         audio_format_handlers="$audio_format_handlers flac"
735         audiod_audio_formats="$audiod_audio_formats flac"
736 else
737         AC_MSG_WARN([no flac support in para_audiod/para_filter/para_afh/para_server])
738 fi
739 CPPFLAGS="$OLD_CPPFLAGS"
740 LDFLAGS="$OLD_LDFLAGS"
741 LIBS="$OLD_LIBS"
742 ########################################################################### oss
743 OLD_CPPFLAGS="$CPPFLAGS"
744 OLD_LDFLAGS="$LDFLAGS"
745 OLD_LIBS="$LIBS"
746
747 have_oss="yes"
748 msg="=> will not build oss writer"
749
750 AC_CHECK_HEADER(sys/soundcard.h, [
751         audiod_errlist_objs="$audiod_errlist_objs oss_write"
752         play_errlist_objs="$play_errlist_objs oss_write"
753         audiod_cmdline_objs="$audiod_cmdline_objs oss_write"
754         play_cmdline_objs="$play_cmdline_objs oss_write"
755
756         write_errlist_objs="$write_errlist_objs oss_write"
757         write_cmdline_objs="$write_cmdline_objs oss_write"
758         fade_errlist_objs="$fade_errlist_objs oss_mix"
759
760         writers="$writers oss"
761         default_writer="OSS_WRITE"
762         mixers="${mixers}oss "
763         default_mixer="OSS_MIX"
764
765         AC_CHECK_LIB(ossaudio, _oss_ioctl, [
766                         oss_ldflags="-lossaudio"
767                         AC_SUBST(oss_ldflags)
768                 ]
769         )
770         ],
771         [
772                 have_oss="no"
773                 AC_MSG_WARN([no sys/soundcard.h $msg])
774         ]
775 )
776 CPPFLAGS="$OLD_CPPFLAGS"
777 LDFLAGS="$OLD_LDFLAGS"
778 LIBS="$OLD_LIBS"
779
780 ########################################################################### alsa
781 OLD_CPPFLAGS="$CPPFLAGS"
782 OLD_LDFLAGS="$LDFLAGS"
783 OLD_LIBS="$LIBS"
784
785 msg="=> no alsa support for para_audiod/para_write"
786 if test "$OSTYPE" != "Linux"; then
787         have_alsa="no"
788 else
789         have_alsa="yes"
790 fi
791 if test "$have_alsa" = "yes"; then
792         AC_CHECK_HEADERS([alsa/asoundlib.h], [], [
793                 have_alsa="no"
794                 AC_MSG_WARN([no alsa/asoundlib $msg])
795         ])
796 fi
797
798 if test "$have_alsa" = "yes"; then
799         AC_CHECK_LIB([asound], [snd_pcm_open], [], [
800                 have_alsa="no"
801                 AC_MSG_WARN([no libasound $msg])
802         ])
803 fi
804
805 if test "$have_alsa" = "yes"; then
806         alsa_ldflags="-lasound"
807         AC_SUBST(alsa_ldflags)
808         audiod_errlist_objs="$audiod_errlist_objs alsa_write"
809         audiod_cmdline_objs="$audiod_cmdline_objs alsa_write"
810         play_errlist_objs="$play_errlist_objs alsa_write"
811         play_cmdline_objs="$play_cmdline_objs alsa_write"
812
813         write_errlist_objs="$write_errlist_objs alsa_write"
814         write_cmdline_objs="$write_cmdline_objs alsa_write"
815         fade_errlist_objs="$fade_errlist_objs alsa_mix"
816
817         writers="$writers alsa"
818         default_writer="ALSA_WRITE"
819         mixers="${mixers}alsa "
820         default_mixer="ALSA_MIX"
821 fi
822
823 CPPFLAGS="$OLD_CPPFLAGS"
824 LDFLAGS="$OLD_LDFLAGS"
825 LIBS="$OLD_LIBS"
826 ########################################################################### libao
827 OLD_CPPFLAGS="$CPPFLAGS"
828 OLD_LDFLAGS="$LDFLAGS"
829 OLD_LIBS="$LIBS"
830
831 have_ao="yes"
832 AC_ARG_WITH(ao_headers, [AS_HELP_STRING(--with-ao-headers=dir,
833         [look for ao/ao.h also in dir])])
834 if test -n "$with_ao_headers"; then
835         ao_cppflags="-I$with_ao_headers"
836         CPPFLAGS="$CPPFLAGS $ao_cppflags"
837 fi
838 AC_ARG_WITH(ao_libs, [AS_HELP_STRING(--with-ao-libs=dir,
839         [look for libao also in dir])])
840 if test -n "$with_ao_libs"; then
841         ao_libs="-L$with_ao_libs"
842         LDFLAGS="$LDFLAGS $ao_libs"
843 fi
844 msg="no libao support for para_audiod/para_write"
845 AC_CHECK_HEADERS([ao/ao.h], [
846         ], [
847         have_ao="no"
848         AC_MSG_WARN([ao.h not found, $msg])
849 ])
850 if test "$have_ao" = "yes"; then
851         AC_CHECK_LIB([ao], [ao_initialize], [], [
852                 have_ao="no"
853                 AC_MSG_WARN([ao lib not found or not working, $msg])
854         ])
855 fi
856 if test "$have_ao" = "yes"; then
857         AC_CHECK_HEADERS([pthread.h], [
858                 ], [
859                 have_ao="no"
860                 AC_MSG_WARN([pthread.h not found, $msg])
861         ])
862 fi
863 if test "$have_ao" = "yes"; then
864         AC_CHECK_LIB([pthread], [pthread_create], [], [
865                 have_ao="no"
866                 AC_MSG_WARN([pthread lib not found or not working, $msg])
867         ])
868 fi
869 if test "$have_ao" = "yes"; then
870         AC_SUBST(ao_cppflags)
871         ao_ldflags="$ao_libs -lao -lpthread"
872         AC_SUBST(ao_ldflags)
873
874         audiod_errlist_objs="$audiod_errlist_objs ao_write"
875         audiod_cmdline_objs="$audiod_cmdline_objs ao_write"
876
877         play_errlist_objs="$play_errlist_objs ao_write"
878         play_cmdline_objs="$play_cmdline_objs ao_write"
879
880         write_errlist_objs="$write_errlist_objs ao_write"
881         write_cmdline_objs="$write_cmdline_objs ao_write"
882         writers="$writers ao"
883 fi
884
885 CPPFLAGS="$OLD_CPPFLAGS"
886 LDFLAGS="$OLD_LDFLAGS"
887 LIBS="$OLD_LIBS"
888 ############################################################# readline
889 OLD_CPPFLAGS="$CPPFLAGS"
890 OLD_LDFLAGS="$LDFLAGS"
891 OLD_LIBS="$LIBS"
892
893 have_readline="yes"
894 AC_ARG_WITH(readline_headers, [AS_HELP_STRING(--with-readline-headers=dir,
895         [look for libreadline header files also in dir])])
896 if test -n "$with_readline_headers"; then
897         readline_cppflags="-I$with_readline_headers"
898         CPPFLAGS="$CPPFLAGS $readline_cppflags"
899 fi
900
901 AC_ARG_WITH(readline_libs, [AS_HELP_STRING(--with-readline-libs=dir,
902         [look for readline library also in dir])])
903 if test -n "$with_readline_libs"; then
904         readline_libs="-L$with_readline_libs"
905         LDFLAGS="$LDFLAGS $readline_libs"
906 fi
907 msg="no interactive cli support"
908 AC_CHECK_HEADERS([readline/readline.h], [
909         ], [
910         have_readline="no"
911         AC_MSG_WARN([readline/readline.h not found, $msg])
912 ])
913
914 if test "$have_curses" != "yes"; then
915         have_readline="no"
916         AC_MSG_WARN([interactive cli support depends on curses,])
917         AC_MSG_WARN([but no curses lib was detected, $msg])
918 fi
919
920 if test "$have_readline" = "yes"; then
921         readline_ldflags="$readline_libs -lreadline"
922         AC_SEARCH_LIBS([rl_free_keymap], [readline], [], [have_readline="no"])
923         if test "$have_readline" = "no"; then # try with -lcurses
924                 # clear cache
925                 AC_MSG_NOTICE([trying again with -lcurses])
926                 unset ac_cv_search_rl_free_keymap 2> /dev/null
927                 AC_SEARCH_LIBS([rl_free_keymap], [readline], [
928                         have_readline=yes
929                         readline_ldflags="$readline_ldflags -lcurses"
930                 ], [], [-lcurses])
931         fi
932         if test "$have_readline" = "no"; then # try with -ltermcap
933                 # clear cache
934                 AC_MSG_NOTICE([trying again with -ltermcap])
935                 unset ac_cv_search_rl_free_keymap 2> /dev/null
936                 AC_SEARCH_LIBS([rl_free_keymap], [readline], [
937                         have_readline=yes
938                         readline_ldflags="$readline_ldflags -ltermcap"
939                 ], [], [-ltermcap])
940         fi
941 fi
942
943 if test "$have_readline" = "yes"; then
944         AC_SUBST(readline_cppflags)
945         AC_SUBST(readline_ldflags)
946         client_errlist_objs="$client_errlist_objs interactive"
947         audioc_errlist_objs="$audioc_errlist_objs buffer_tree interactive sched time"
948         play_errlist_objs="$play_errlist_objs interactive"
949         AC_DEFINE(HAVE_READLINE, 1, define to 1 to turn on readline support)
950 else
951         AC_MSG_WARN([libreadline not found or unusable])
952 fi
953 CPPFLAGS="$OLD_CPPFLAGS"
954 LDFLAGS="$OLD_LDFLAGS"
955 LIBS="$OLD_LIBS"
956 ############################################################# libsamplerate
957 OLD_CPPFLAGS="$CPPFLAGS"
958 OLD_LDFLAGS="$LDFLAGS"
959 OLD_LIBS="$LIBS"
960
961 have_samplerate="yes"
962 AC_ARG_WITH(samplerate_headers, [AS_HELP_STRING(--with-samplerate-headers=dir,
963         [look for samplerate headers also in dir])])
964 if test -n "$with_samplerate_headers"; then
965         samplerate_cppflags="-I$with_samplerate_headers"
966         CPPFLAGS="$CPPFLAGS $samplerate_cppflags"
967 fi
968 AC_ARG_WITH(samplerate_libs, [AS_HELP_STRING(--with-samplerate-libs=dir,
969         [look for samplerate libs also in dir])])
970 if test -n "$with_samplerate_libs"; then
971         samplerate_libs="-L$with_samplerate_libs"
972         LDFLAGS="$LDFLAGS $samplerate_libs"
973 fi
974
975 AC_CHECK_HEADER(samplerate.h, [], have_samplerate=no)
976 AC_CHECK_LIB([samplerate], [src_process], [], have_samplerate=no, [])
977
978 if test "$have_samplerate" = "yes"; then
979         AC_SUBST(samplerate_cppflags)
980         samplerate_ldflags="$samplerate_libs -lsamplerate"
981         AC_SUBST(samplerate_ldflags)
982
983         audiod_errlist_objs="$audiod_errlist_objs resample_filter check_wav"
984         audiod_cmdline_objs="$audiod_cmdline_objs resample_filter"
985         play_errlist_objs="$play_errlist_objs resample_filter check_wav"
986         play_cmdline_objs="$play_cmdline_objs resample_filter"
987 else
988         AC_MSG_WARN([no resample support in para_audiod/para_filter])
989 fi
990 CPPFLAGS="$OLD_CPPFLAGS"
991 LDFLAGS="$OLD_LDFLAGS"
992 LIBS="$OLD_LIBS"
993 ######################################################################### server
994 if test \( "$have_openssl" = "yes" -o "$have_gcrypt" = "yes" \) \
995         -a "$have_osl" = "yes" ; then
996
997         build_server="yes"
998         executables="$executables server"
999         server_cmdline_objs="server"
1000         server_errlist_objs="$server_errlist_objs
1001                 server
1002                 afh_common
1003                 mp3_afh
1004                 vss
1005                 command
1006                 net
1007                 string
1008                 signal
1009                 time
1010                 daemon
1011                 http_send
1012                 close_on_fork
1013                 mm
1014                 crypt_common
1015                 ipc
1016                 dccp_send
1017                 fd
1018                 user_list
1019                 chunk_queue
1020                 afs
1021                 aft
1022                 mood
1023                 score
1024                 attribute
1025                 blob
1026                 playlist
1027                 sched
1028                 acl
1029                 send_common
1030                 udp_send
1031                 color
1032                 fec
1033                 wma_afh
1034                 wma_common
1035                 sideband
1036                 version
1037                 ggo
1038         "
1039 else
1040         build_server="no"
1041 fi
1042 ############################################################# client
1043 if test "$have_openssl" = "yes" -o "$have_gcrypt" = "yes"; then
1044         build_client="yes"
1045         executables="$executables client"
1046         client_cmdline_objs="client"
1047         client_errlist_objs="$client_errlist_objs
1048                 client
1049                 net
1050                 string
1051                 fd
1052                 sched
1053                 stdin
1054                 stdout
1055                 time
1056                 sideband
1057                 client_common
1058                 buffer_tree
1059                 crypt_common
1060                 version
1061                 ggo
1062         "
1063 else
1064         build_client="no"
1065 fi
1066 ############################################################# audiod
1067 if test "$have_openssl" = "yes" -o "$have_gcrypt" = "yes"; then
1068         build_audiod="yes"
1069         executables="$executables audiod"
1070         audiod_cmdline_objs="$audiod_cmdline_objs
1071                 audiod
1072                 compress_filter
1073                 http_recv
1074                 dccp_recv
1075                 file_write
1076                 client
1077                 amp_filter
1078                 udp_recv
1079                 prebuffer_filter
1080         "
1081         audiod_errlist_objs="$audiod_errlist_objs
1082                 audiod
1083                 signal
1084                 string
1085                 daemon
1086                 stat
1087                 net
1088                 crypt_common
1089                 sideband
1090                 time
1091                 grab_client
1092                 filter_common
1093                 wav_filter
1094                 compress_filter
1095                 amp_filter
1096                 http_recv
1097                 dccp_recv
1098                 recv_common
1099                 fd
1100                 sched
1101                 write_common
1102                 file_write
1103                 audiod_command
1104                 fecdec_filter
1105                 client_common
1106                 ggo
1107                 udp_recv
1108                 color
1109                 fec
1110                 prebuffer_filter
1111                 version
1112                 bitstream
1113                 imdct
1114                 wma_common
1115                 wmadec_filter
1116                 buffer_tree
1117         "
1118         audiod_ldflags="$audiod_ldflags -lm"
1119         audiod_audio_formats="$audiod_audio_formats wma"
1120 else
1121         build_audiod="no"
1122 fi
1123 ########################################################################### fade
1124 if test -n "$mixers"; then
1125         build_fade="yes"
1126         executables="$executables fade"
1127         fade_errlist_objs="$fade_errlist_objs fade exec string fd version ggo"
1128         fade_cmdline_objs="fade"
1129         fade_objs="add_cmdline($fade_cmdline_objs) $fade_errlist_objs"
1130         AC_SUBST(fade_objs, add_dot_o($fade_objs))
1131         AC_SUBST(fade_ldflags, $fade_ldflags)
1132         AC_DEFINE_UNQUOTED(INIT_FADE_ERRLISTS,
1133                 objlist_to_errlist($fade_errlist_objs),
1134                 errors used by para_fade)
1135         enum="$(
1136                 for i in $mixers; do
1137                         printf "${i}_MIX, " | tr '[a-z]' '[A-Z]'
1138                 done
1139         )"
1140         AC_DEFINE_UNQUOTED(MIXER_ENUM, $enum NUM_SUPPORTED_MIXERS,
1141                 enum of supported mixers)
1142         AC_DEFINE_UNQUOTED(DEFAULT_MIXER, $default_mixer,
1143                 use this mixer if none was specified)
1144         names="$(for i in $mixers; do printf \"$i\",' ' ; done)"
1145         AC_DEFINE_UNQUOTED(MIXER_NAMES, $names, supported mixer names)
1146         inits="$(
1147                 for i in $mixers; do
1148                         printf 'extern void '$i'_mix_init(struct mixer *); '
1149                 done
1150         )"
1151         AC_DEFINE_UNQUOTED(DECLARE_MIXER_INITS, $inits,
1152                 init functions of the supported mixers)
1153         array="$(for i in $mixers; do printf '{.init = '$i'_mix_init},'; done)"
1154         AC_DEFINE_UNQUOTED(MIXER_ARRAY, $array, array of supported mixers)
1155         mixer_summary="supported mixers:: $mixers, default: $default_mixer"
1156 else
1157         build_fade="no"
1158         AC_MSG_WARN([no mixer support])
1159         mixer_summary="para_fade: no"
1160 fi
1161 ########################################################################### gui
1162 if test "$have_curses" = "yes"; then
1163         build_gui="yes"
1164         executables="$executables gui"
1165         gui_cmdline_objs="gui"
1166         gui_errlist_objs="
1167                 exec
1168                 signal
1169                 string
1170                 stat
1171                 ringbuffer
1172                 fd
1173                 gui
1174                 gui_theme
1175                 time
1176                 version
1177                 ggo
1178         "
1179         gui_objs="add_cmdline($gui_cmdline_objs) $gui_errlist_objs"
1180 else
1181         build_gui="no"
1182         AC_MSG_WARN([no curses lib, cannot build para_gui])
1183 fi
1184 ######################################################################## filter
1185 filters="
1186         compress
1187         wav
1188         amp
1189         fecdec
1190         wmadec
1191         prebuffer
1192 "
1193 filter_errlist_objs="
1194         filter_common
1195         wav_filter
1196         compress_filter
1197         filter
1198         string
1199         stdin
1200         stdout
1201         sched
1202         fd
1203         amp_filter
1204         ggo
1205         fecdec_filter
1206         fec
1207         version
1208         prebuffer_filter
1209         time
1210         bitstream
1211         imdct
1212         wma_common
1213         wmadec_filter
1214         buffer_tree
1215         net
1216 "
1217 filter_cmdline_objs="
1218         filter
1219         compress_filter
1220         amp_filter
1221         prebuffer_filter
1222 "
1223
1224 if test "$have_vorbis" = "yes"; then
1225         filters="$filters oggdec"
1226         filter_errlist_objs="$filter_errlist_objs oggdec_filter"
1227 fi
1228 if test "$have_speex" = "yes"; then
1229         filters="$filters spxdec"
1230         filter_errlist_objs="$filter_errlist_objs spxdec_filter spx_common"
1231 fi
1232 if test "$have_opus" = "yes"; then
1233         filters="$filters opusdec"
1234         filter_errlist_objs="$filter_errlist_objs opusdec_filter opus_common"
1235 fi
1236 if test "$have_faad" = "yes"; then
1237         filter_errlist_objs="$filter_errlist_objs aacdec_filter aac_common"
1238         filters="$filters aacdec"
1239 fi
1240 if test "$have_mad" = "yes"; then
1241         filter_cmdline_objs="$filter_cmdline_objs mp3dec_filter"
1242         filter_errlist_objs="$filter_errlist_objs mp3dec_filter"
1243         filters="$filters mp3dec"
1244 fi
1245 if test "$have_flac" = "yes"; then
1246         filter_errlist_objs="$filter_errlist_objs flacdec_filter"
1247         filters="$filters flacdec"
1248 fi
1249 if test "$have_samplerate" = "yes"; then
1250         filter_errlist_objs="$filter_errlist_objs resample_filter check_wav"
1251         filter_cmdline_objs="$filter_cmdline_objs resample_filter"
1252         filters="$filters resample"
1253 fi
1254 ########################################################################## recv
1255 recv_cmdline_objs="
1256         recv
1257         http_recv
1258         dccp_recv
1259         udp_recv
1260         afh_recv
1261 "
1262
1263 recv_errlist_objs="
1264         http_recv
1265         recv_common
1266         recv
1267         time
1268         string
1269         net
1270         dccp_recv
1271         fd
1272         sched
1273         stdout
1274         ggo
1275         udp_recv
1276         buffer_tree
1277         afh_recv
1278         afh_common
1279         wma_afh
1280         wma_common
1281         mp3_afh
1282         version
1283 "
1284 if test "$have_vorbis" = "yes" || \
1285                 test "$have_speex" = "yes" || \
1286                 test "$have_opus" = "yes"; then
1287         recv_errlist_objs="$recv_errlist_objs ogg_afh_common"
1288 fi
1289 if test "$have_vorbis" = "yes"; then
1290         recv_errlist_objs="$recv_errlist_objs ogg_afh"
1291 fi
1292 if test "$have_speex" = "yes"; then
1293         recv_errlist_objs="$recv_errlist_objs spx_afh spx_common"
1294 fi
1295 if test "$have_opus" = "yes"; then
1296         recv_errlist_objs="$recv_errlist_objs opus_afh opus_common"
1297 fi
1298 if test "$have_faad" = "yes"; then
1299         recv_errlist_objs="$recv_errlist_objs aac_afh aac_common"
1300 fi
1301 if test "$have_flac" = "yes"; then
1302         recv_errlist_objs="$recv_errlist_objs flac_afh"
1303 fi
1304 recv_objs="add_cmdline($recv_cmdline_objs) $recv_errlist_objs"
1305 AC_SUBST(recv_objs, add_dot_o($recv_objs))
1306 AC_DEFINE_UNQUOTED(INIT_RECV_ERRLISTS, objlist_to_errlist($recv_errlist_objs),
1307         errors used by para_recv)
1308 ############################################################# error2.h
1309 # these are always built
1310 all_errlist_objs="
1311         $recv_errlist_objs
1312         $filter_errlist_objs
1313         $audioc_errlist_objs
1314         $write_errlist_objs
1315         $afh_errlist_objs
1316         $play_errlist_objs
1317 "
1318
1319 # optional executables
1320 if test "$build_server" = "yes"; then
1321         all_errlist_objs="$all_errlist_objs $server_errlist_objs"
1322 fi
1323 if test "$build_gui" = "yes"; then
1324         all_errlist_objs="$all_errlist_objs $gui_errlist_objs"
1325 fi
1326 if test "$build_fade" = "yes"; then
1327         all_errlist_objs="$all_errlist_objs $fade_errlist_objs"
1328 fi
1329 if test "$build_client" = "yes"; then
1330         all_errlist_objs="$all_errlist_objs $client_errlist_objs"
1331 fi
1332 if test "$build_audiod" = "yes"; then
1333         all_errlist_objs="$all_errlist_objs $audiod_errlist_objs"
1334 fi
1335
1336 all_errlist_objs="$(echo $all_errlist_objs | tr ' ' '\n' | sort | uniq)"
1337
1338 object_executable_matrix=
1339 for i in $executables; do
1340         eval objs=\$${i}_errlist_objs
1341         object_executable_matrix="$object_executable_matrix $i: $objs"
1342 done
1343 # use echo to replace newlines by space
1344 AC_SUBST(object_executable_matrix, $(echo $object_executable_matrix))
1345
1346 for obj in $all_errlist_objs; do
1347         SS="$SS SS_$(echo $obj | tr 'a-z' 'A-Z'),"
1348 done
1349 AC_DEFINE_UNQUOTED(DEFINE_ERRLIST_OBJECT_ENUM,
1350         [enum {$SS NUM_SS}],
1351         [list of all objects that use the paraslash error facility]
1352 )
1353 ################################################################## status items
1354
1355 status_items="basename status num_played mtime bitrate frequency file_size
1356 status_flags format score techinfo afs_mode
1357 attributes_txt decoder_flags audiod_status play_time attributes_bitmap
1358 offset seconds_total stream_start current_time audiod_uptime image_id
1359 lyrics_id duration directory lyrics_name image_name path hash channels
1360 last_played num_chunks chunk_time amplification artist title year album
1361 comment"
1362
1363 result=
1364 for i in $status_items; do
1365         result="$result SI_$(echo $i | tr 'a-z' 'A-Z'), "
1366 done
1367 AC_DEFINE_UNQUOTED(STATUS_ITEM_ENUM, [$result],
1368         [enum of all status items])
1369
1370 result=
1371 for i in $status_items; do
1372         result="$result \"$i\", "
1373 done
1374 AC_DEFINE_UNQUOTED(STATUS_ITEM_ARRAY, [$result],
1375         [char * array of all status items])
1376
1377 AC_DEFINE_UNQUOTED(AUDIO_FORMAT_HANDLERS, "$audio_format_handlers",
1378         [formats supported by para_server and para_afh])
1379
1380 AC_SUBST(executables)
1381
1382 filter_objs="add_cmdline($filter_cmdline_objs) $filter_errlist_objs"
1383 audiod_objs="add_cmdline($audiod_cmdline_objs) $audiod_errlist_objs"
1384 server_objs="add_cmdline($server_cmdline_objs) $server_errlist_objs"
1385 write_objs="add_cmdline($write_cmdline_objs) $write_errlist_objs"
1386 client_objs="add_cmdline($client_cmdline_objs) $client_errlist_objs"
1387 audioc_objs="add_cmdline($audioc_cmdline_objs) $audioc_errlist_objs"
1388 afh_objs="add_cmdline($afh_cmdline_objs) $afh_errlist_objs"
1389 play_objs="add_cmdline($play_cmdline_objs) $play_errlist_objs"
1390 gui_objs="add_cmdline($gui_cmdline_objs) $gui_errlist_objs"
1391
1392 AC_SUBST(filter_objs, add_dot_o($filter_objs))
1393 AC_DEFINE_UNQUOTED(INIT_FILTER_ERRLISTS,
1394         objlist_to_errlist($filter_errlist_objs), errors used by para_filter)
1395
1396 AC_SUBST(audiod_objs, add_dot_o($audiod_objs))
1397 AC_SUBST(audiod_ldflags, $audiod_ldflags)
1398 AC_DEFINE_UNQUOTED(INIT_AUDIOD_ERRLISTS, objlist_to_errlist($audiod_errlist_objs),
1399         errors used by para_audiod)
1400
1401 AC_SUBST(server_objs, add_dot_o($server_objs))
1402 AC_SUBST(server_ldflags, $server_ldflags)
1403 AC_DEFINE_UNQUOTED(INIT_SERVER_ERRLISTS,
1404         objlist_to_errlist($server_errlist_objs), errors used by para_server)
1405
1406 AC_SUBST(afh_objs, add_dot_o($afh_objs))
1407 AC_SUBST(afh_ldflags, $afh_ldflags)
1408 AC_DEFINE_UNQUOTED(INIT_AFH_ERRLISTS,
1409         objlist_to_errlist($afh_errlist_objs), errors used by para_afh)
1410
1411 AC_SUBST(write_objs, add_dot_o($write_objs))
1412 AC_SUBST(write_ldflags, $write_ldflags)
1413 AC_DEFINE_UNQUOTED(INIT_WRITE_ERRLISTS,
1414         objlist_to_errlist($write_errlist_objs), errors used by para_write)
1415
1416 AC_SUBST(client_objs, add_dot_o($client_objs))
1417 AC_SUBST(client_ldflags, $client_ldflags)
1418 AC_DEFINE_UNQUOTED(INIT_CLIENT_ERRLISTS,
1419         objlist_to_errlist($client_errlist_objs), errors used by para_client)
1420
1421 AC_SUBST(audioc_objs, add_dot_o($audioc_objs))
1422 AC_SUBST(audioc_ldflags, $audioc_ldflags)
1423 AC_DEFINE_UNQUOTED(INIT_AUDIOC_ERRLISTS,
1424         objlist_to_errlist($audioc_errlist_objs), errors used by para_audioc)
1425
1426 AC_SUBST(gui_objs, add_dot_o($gui_objs))
1427 AC_DEFINE_UNQUOTED(INIT_GUI_ERRLISTS,
1428         objlist_to_errlist($gui_errlist_objs), errors used by para_gui)
1429
1430 AC_SUBST(play_objs, add_dot_o($play_objs))
1431 AC_SUBST(play_ldflags, $play_ldflags)
1432 AC_DEFINE_UNQUOTED(INIT_PLAY_ERRLISTS,
1433         objlist_to_errlist($play_errlist_objs), errors used by para_play)
1434
1435 enum="$(for i in $filters; do printf "${i}_FILTER, " | tr '[a-z]' '[A-Z]'; done)"
1436 AC_DEFINE_UNQUOTED(FILTER_ENUM, $enum NUM_SUPPORTED_FILTERS,
1437         enum of supported filters)
1438 inits="$(for i in $filters; do printf 'extern void '$i'_filter_init(struct filter *f); '; done)"
1439 AC_DEFINE_UNQUOTED(DECLARE_FILTER_INITS, $inits, init functions of the supported filters)
1440 array="$(for i in $filters; do printf '{.name = "'$i'", .init = '$i'_filter_init},'; done)"
1441 AC_DEFINE_UNQUOTED(FILTER_ARRAY, $array, array of supported filters)
1442
1443 enum="$(for i in $writers; do printf "${i}_WRITE, " | tr '[a-z]' '[A-Z]'; done)"
1444 AC_DEFINE_UNQUOTED(WRITER_ENUM, $enum NUM_SUPPORTED_WRITERS,
1445         enum of supported writers)
1446 AC_DEFINE_UNQUOTED(DEFAULT_WRITER, $default_writer, use this writer if none was specified)
1447 names="$(for i in $writers; do printf \"$i\",' ' ; done)"
1448 AC_DEFINE_UNQUOTED(WRITER_NAMES, $names, supported writer names)
1449 inits="$(for i in $writers; do printf 'extern void '$i'_write_init(struct writer *); '; done)"
1450 AC_DEFINE_UNQUOTED(DECLARE_WRITER_INITS, $inits, init functions of the supported writers)
1451 array="$(for i in $writers; do printf '{.init = '$i'_write_init},'; done)"
1452 AC_DEFINE_UNQUOTED(WRITER_ARRAY, $array, array of supported writers)
1453
1454 enum="$(for i in $audiod_audio_formats; do printf "AUDIO_FORMAT_${i}, " | tr '[a-z]' '[A-Z]'; done)"
1455 AC_DEFINE_UNQUOTED(AUDIOD_AUDIO_FORMATS_ENUM, $enum NUM_AUDIO_FORMATS,
1456         enum of audio formats supported by audiod)
1457 names="$(for i in $audiod_audio_formats; do printf \"$i\",' ' ; done)"
1458 AC_DEFINE_UNQUOTED(AUDIOD_AUDIO_FORMAT_ARRAY, $names, array of audio formats supported by audiod)
1459
1460 AC_OUTPUT
1461 AC_MSG_NOTICE([
1462 paraslash configuration:
1463 ~~~~~~~~~~~~~~~~~~~~~~~~
1464 unix socket credentials: $have_ucred
1465 readline (interactive CLIs): $have_readline
1466 audio formats handlers: $audio_format_handlers
1467 id3 version2 support: $have_libid3tag
1468 filters: $(echo $filters)
1469 writers: $writers
1470
1471 $mixer_summary
1472 para_server: $build_server
1473 para_gui: $build_gui
1474 para_fade: $build_fade
1475 para_client: $build_client
1476 para_audiod: $build_audiod
1477 ])