Move wav detection code to a separate file.
[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
7 AC_INIT([paraslash],[git],[maan@systemlinux.org])
8 AC_CONFIG_HEADER([config.h])
9
10 AC_SUBST(install_sh, [$INSTALL])
11 AC_CONFIG_FILES([Makefile])
12 AC_DEFUN([add_dot_o],[$(for i in $@; do printf "$i.o "; done)])
13 AC_DEFUN([add_para],[$(for i in $@; do printf "para_$i "; done)])
14 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) }])
15 AC_PATH_PROG(UNAMEPATH, uname, no)
16 if test "$UNAMEPATH" = "no"; then
17         AC_MSG_ERROR(unable to determine system type)
18 fi
19 AC_MSG_CHECKING(os type)
20 OSTYPE="`$UNAMEPATH -s`"
21 AC_MSG_RESULT("$OSTYPE")
22
23 if test "$OSTYPE" = "SunOS"; then
24         # needed on SunOS for socket magic
25         arch_cppflags="-D_XOPEN_SOURCE=500 -D__EXTENSIONS__"
26         AC_SUBST(arch_cppflags)
27 fi
28
29 AC_C_BIGENDIAN()
30
31 AC_PATH_PROG([gengetopt], [gengetopt])
32 test -z "$gengetopt" && AC_MSG_ERROR(
33         [gengetopt is required to build this package])
34
35 AC_PATH_PROG([help2man], [help2man])
36 test -z "$help2man" && AC_MSG_ERROR(
37         [help2man is required to build this package])
38
39 AC_PROG_CC
40 AC_PROG_CPP
41 AC_PROG_INSTALL
42 AC_REPLACE_FNMATCH
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_MALLOC
77 AC_FUNC_MEMCMP
78 AC_FUNC_MKTIME
79 AC_FUNC_MMAP
80 AC_FUNC_REALLOC
81 AC_FUNC_SELECT_ARGTYPES
82 AC_FUNC_STAT
83 AC_FUNC_STRFTIME
84 AC_FUNC_VPRINTF
85 AC_FUNC_CLOSEDIR_VOID
86 AC_FUNC_LSTAT
87
88 AC_CHECK_FUNCS([atexit dup2 memchr memmove memset \
89         regcomp select strchr strdup strerror strstr strtol uname \
90         fchdir gettimeofday localtime_r munmap strcasecmp strcspn \
91         strncasecmp strrchr strspn alarm mkdir inet_ntoa socket], [],
92         [AC_MSG_ERROR([function not found, cannot live without it])])
93
94 AC_DEFUN([add_cmdline],[$(for i in $@; do printf "${i}.cmdline "; done)])
95
96
97 all_errlist_objs="mp3_afh afh_common net string signal time daemon
98         stat afh amp_filter fd ringbuffer sched audiod
99         grab_client filter_common wav_filter compress_filter http_recv
100         dccp_recv recv_common write_common file_write audiod_command
101         client_common recv stdout filter stdin audioc write client
102         exec send_common ggo udp_recv color fec fecdec_filter
103         prebuffer_filter bitstream imdct check_wav
104         wma_afh wma_common wmadec_filter buffer_tree crypt_common
105         gui gui_theme sideband"
106
107 executables="recv filter audioc write client afh audiod"
108
109 recv_cmdline_objs="add_cmdline(recv http_recv dccp_recv udp_recv)"
110
111 recv_errlist_objs="http_recv recv_common recv time string net dccp_recv
112         fd sched stdout ggo udp_recv buffer_tree"
113 recv_ldflags=""
114
115 filter_cmdline_objs="add_cmdline(filter compress_filter amp_filter prebuffer_filter)"
116 filter_errlist_objs="filter_common wav_filter compress_filter filter string
117         stdin stdout sched fd amp_filter ggo fecdec_filter fec
118         prebuffer_filter time bitstream imdct wma_common wmadec_filter buffer_tree"
119 filter_ldflags="-lm"
120 filters=" compress wav amp fecdec wmadec prebuffer"
121
122 audioc_cmdline_objs="add_cmdline(audioc)"
123 audioc_errlist_objs="audioc string net fd"
124 audioc_ldflags=""
125
126 audiod_cmdline_objs="add_cmdline(audiod compress_filter http_recv dccp_recv file_write client amp_filter udp_recv prebuffer_filter)"
127 audiod_errlist_objs="audiod signal string daemon stat net crypt_common sideband
128         time grab_client filter_common wav_filter compress_filter amp_filter http_recv dccp_recv
129         recv_common fd sched write_common file_write audiod_command fecdec_filter
130         client_common ggo udp_recv color fec prebuffer_filter
131         bitstream imdct wma_common wmadec_filter buffer_tree"
132 audiod_ldflags="-lm"
133 audiod_audio_formats="wma"
134
135 afh_cmdline_objs="add_cmdline(afh)"
136 afh_errlist_objs="afh string fd mp3_afh afh_common time wma_afh wma_common"
137 afh_ldflags=""
138
139 write_cmdline_objs="add_cmdline(write file_write)"
140 write_errlist_objs="write write_common file_write time fd string sched stdin
141         buffer_tree ggo check_wav"
142 write_ldflags=""
143 writers=" file"
144 default_writer="FILE_WRITE"
145
146 client_cmdline_objs="add_cmdline(client)"
147 client_errlist_objs="client net string fd sched stdin stdout time sideband
148         client_common buffer_tree crypt_common"
149 client_ldflags=""
150
151 gui_cmdline_objs="add_cmdline(gui)"
152 gui_errlist_objs="exec signal string stat ringbuffer fd gui gui_theme"
153 gui_objs="$gui_cmdline_objs $gui_errlist_objs"
154 ########################################################################### snprintf
155 # ===========================================================================
156 #        http://www.nongnu.org/autoconf-archive/ax_func_snprintf.html
157 # ===========================================================================
158 #
159 # SYNOPSIS
160 #
161 #   AX_FUNC_SNPRINTF
162 #
163 # DESCRIPTION
164 #
165 #   Checks for a fully C99 compliant snprintf, in particular checks whether
166 #   it does bounds checking and returns the correct string length; does the
167 #   same check for vsnprintf. If no working snprintf or vsnprintf is found,
168 #   it prints an error message and aborts.
169 #
170 # LICENSE
171 #
172 #   Copyright (c) 2008 Ruediger Kuhlmann <info@ruediger-kuhlmann.de>
173 #
174 #   Copying and distribution of this file, with or without modification, are
175 #   permitted in any medium without royalty provided the copyright notice
176 #   and this notice are preserved.
177
178 AU_ALIAS([AC_FUNC_SNPRINTF], [AX_FUNC_SNPRINTF])
179 AC_DEFUN([AX_FUNC_SNPRINTF],
180 [AC_CHECK_FUNCS(snprintf vsnprintf)
181 AC_MSG_CHECKING(for working snprintf)
182 AC_CACHE_VAL(ac_cv_have_working_snprintf,
183 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
184 #include <stdio.h>
185
186 int main(void)
187 {
188     char bufs[5] = { 'x', 'x', 'x', '\0', '\0' };
189     char bufd[5] = { 'x', 'x', 'x', '\0', '\0' };
190     int i;
191     i = snprintf (bufs, 2, "%s", "111");
192     if (strcmp (bufs, "1")) exit (1);
193     if (i != 3) exit (1);
194     i = snprintf (bufd, 2, "%d", 111);
195     if (strcmp (bufd, "1")) exit (1);
196     if (i != 3) exit (1);
197     exit(0);
198 }]])],[ac_cv_have_working_snprintf=yes],
199 [ac_cv_have_working_snprintf=no],[ac_cv_have_working_snprintf=cross])])
200 AC_MSG_RESULT([$ac_cv_have_working_snprintf])
201 AC_MSG_CHECKING(for working vsnprintf)
202 AC_CACHE_VAL(ac_cv_have_working_vsnprintf,
203 [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
204 #include <stdarg.h>
205
206 int my_vsnprintf (char *buf, const char *tmpl, ...)
207 {
208     int i;
209     va_list args;
210     va_start (args, tmpl);
211     i = vsnprintf (buf, 2, tmpl, args);
212     va_end (args);
213     return i;
214 }
215
216 int main(void)
217 {
218     char bufs[5] = { 'x', 'x', 'x', '\0', '\0' };
219     char bufd[5] = { 'x', 'x', 'x', '\0', '\0' };
220     int i;
221     i = my_vsnprintf (bufs, "%s", "111");
222     if (strcmp (bufs, "1")) exit (1);
223     if (i != 3) exit (1);
224     i = my_vsnprintf (bufd, "%d", 111);
225     if (strcmp (bufd, "1")) exit (1);
226     if (i != 3) exit (1);
227     exit(0);
228 }]])],[ac_cv_have_working_vsnprintf=yes],
229 [ac_cv_have_working_vsnprintf=no],[ac_cv_have_working_vsnprintf=cross])])
230 AC_MSG_RESULT([$ac_cv_have_working_vsnprintf])
231 if test x$ac_cv_have_working_snprintf$ac_cv_have_working_vsnprintf != "xyesyes"; then
232 AC_MSG_ERROR([fatal: buggy snprintf() detected])
233 fi])
234 AX_FUNC_SNPRINTF()
235 ########################################################################### osl
236 have_osl=yes
237 OLD_CPPFLAGS="$CPPFLAGS"
238 OLD_LD_FLAGS="$LDFLAGS"
239 OLD_LIBS="$LIBS"
240 AC_ARG_WITH(osl_headers, [AS_HELP_STRING(--with-osl-headers=dir,
241         [look for osl.h also in dir])])
242 if test -n "$with_osl_headers"; then
243         osl_cppflags="-I$with_osl_headers"
244         CPPFLAGS="$CPPFLAGS $osl_cppflags"
245 fi
246 AC_ARG_WITH(osl_libs, [AS_HELP_STRING(--with-osl-libs=dir,
247         [look for libosl also in dir])])
248 if test -n "$with_osl_libs"; then
249         osl_libs="-L$with_osl_libs"
250         LDFLAGS="$LDFLAGS $osl_libs"
251 fi
252
253 AC_CHECK_HEADER(osl.h, [], have_osl=no)
254 AC_CHECK_LIB([osl], [osl_open_table], [], have_osl=no)
255 if test "$have_osl" = "no"; then
256         AC_MSG_WARN([libosl not found, can not build para_server.
257 Download libosl at
258         http://systemlinux.org/~maan/osl
259 or execute
260         git clone git://git.tuebingen.mpg.de/osl
261         ])
262 else
263         extras="$extras server"
264         executables="$executables server"
265         server_cmdline_objs="add_cmdline(server)"
266         server_errlist_objs="server afh_common mp3_afh vss command net
267                 string signal time daemon http_send close_on_fork mm
268                 crypt_common ipc dccp_send fd user_list chunk_queue
269                 afs aft mood score attribute blob playlist sched acl
270                 send_common udp_send color fec wma_afh wma_common sideband"
271         all_errlist_objs="$all_errlist_objs server vss command
272                 http_send close_on_fork mm ipc dccp_send user_list
273                 chunk_queue afs aft mood score attribute blob playlist
274                 acl udp_send"
275
276         server_ldflags=""
277         server_audio_formats="mp3 wma"
278         AC_SUBST(osl_cppflags)
279         server_ldflags="$server_ldflags $osl_libs -losl"
280 fi
281 CPPFLAGS="$OLD_CPPFLAGS"
282 LDFLAGS="$OLD_LDFLAGS"
283 LIBS="$OLD_LIBS"
284 ########################################################################### crypto
285 AC_ARG_ENABLE(cryptolib, [AS_HELP_STRING(--enable-cryptolib=lib, [
286         Force using crypto library "lib". This package requires either
287         openssl or libgcrypt being installed. Possible values for "lib"
288         are thus "openssl" and "gcrypt". If this option is not given,
289         openssl is tried first. If openssl was not found, gcrypt is
290         tried next.])])
291
292 case "$enable_cryptolib" in
293         "openssl") check_openssl="yes"; check_gcrypt="no";;
294         "gcrypt") check_openssl="no"; check_gcrypt="yes";;
295         "") check_openssl="yes"; check_gcrypt="yes";;
296         *) AC_MSG_ERROR([invalid value "$enable_cryptolib" for --enable-cryptolib]);;
297 esac
298 ###################################################################### openssl
299 if test "$check_openssl" = "yes"; then
300         OLD_CPPFLAGS="$CPPFLAGS"
301         OLD_LD_FLAGS="$LDFLAGS"
302         OLD_LIBS="$LIBS"
303         have_openssl="yes"
304         AC_ARG_WITH(openssl_headers, [AS_HELP_STRING(--with-openssl-headers=dir,
305                 [look for openssl headers also in dir])])
306         if test -n "$with_openssl_headers"; then
307                 openssl_cppflags="-I$with_openssl_headers"
308                 CPPFLAGS="$CPPFLAGS $openssl_cppflags"
309         fi
310         AC_ARG_WITH(openssl_libs, [AS_HELP_STRING(--with-openssl-libs=dir,
311                 [look for openssl libraries also in dir])])
312         if test -n "$with_openssl_libs"; then
313                 openssl_libs="-L$with_openssl_libs"
314                 LDFLAGS="$LDFLAGS $openssl_libs"
315         fi
316         AC_CHECK_HEADER(openssl/ssl.h, [], [have_openssl="no"])
317         AC_CHECK_LIB([crypto], [RAND_bytes], [], [have_openssl="no"])
318         if test "$have_openssl" = "no" -a -z "$with_openssl_headers$with_openssl_libs"; then
319                 # try harder: openssl is sometimes installed in /usr/local/ssl
320                 openssl_cppflags="-I/usr/local/ssl/include"
321                 CPPFLAGS="$CPPFLAGS $openssl_cppflags"
322                 openssl_libs="-L/usr/local/ssl/lib"
323                 LDFLAGS="$LDFLAGS $openssl_libs"
324                 # clear cache
325                 unset ac_cv_header_openssl_ssl_h 2> /dev/null
326                 unset ac_cv_lib_crypto_RAND_bytes 2> /dev/null
327                 AC_CHECK_HEADER(openssl/ssl.h, [have_openssl="yes"], [])
328                 if test "$have_openssl" = "yes"; then
329                         AC_CHECK_LIB([crypto], [RAND_bytes], [], [have_openssl="no"])
330                 fi
331         fi
332         if test "$have_openssl" = "yes"; then
333                 AC_DEFINE(HAVE_OPENSSL, 1, [define to 1 to turn on openssl support])
334                 AC_SUBST(openssl_cppflags)
335                 openssl_libs="$openssl_libs -lssl -lcrypto"
336                 server_ldflags="$server_ldflags $openssl_libs"
337                 client_ldflags="$client_ldflags $openssl_libs"
338                 audiod_ldflags="$audiod_ldflags $openssl_libs"
339
340                 all_errlist_objs="$all_errlist_objs crypt"
341                 server_errlist_objs="$server_errlist_objs crypt"
342                 client_errlist_objs="$client_errlist_objs crypt"
343                 audiod_errlist_objs="$audiod_errlist_objs crypt"
344
345                 check_gcrypt="no"
346         else
347                 AC_MSG_WARN([openssl libraries not found])
348         fi
349         CPPFLAGS="$OLD_CPPFLAGS"
350         LDFLAGS="$OLD_LDFLAGS"
351         LIBS="$OLD_LIBS"
352 else
353         have_openssl="no"
354 fi
355 ########################################################################### gcrypt
356 if test "$check_gcrypt" = "yes"; then
357         OLD_CPPFLAGS="$CPPFLAGS"
358         OLD_LD_FLAGS="$LDFLAGS"
359         OLD_LIBS="$LIBS"
360         have_gcrypt="yes"
361         AC_ARG_WITH(gcrypt_headers, [AS_HELP_STRING(--with-gcrypt-headers=dir,
362                 [look for gcrypt headers also in dir])])
363         if test -n "$with_gcrypt_headers"; then
364                 gcrypt_cppflags="-I$with_gcrypt_headers"
365                 CPPFLAGS="$CPPFLAGS $gcrypt_cppflags"
366         fi
367         AC_ARG_WITH(gcrypt_libs, [AS_HELP_STRING(--with-gcrypt-libs=dir,
368                 [look for libgcrypt also in dir])])
369         if test -n "$with_gcrypt_libs"; then
370                 gcrypt_libs="-L$with_gcrypt_libs"
371                 LDFLAGS="$LDFLAGS $gcrypt_libs"
372         fi
373         AC_CHECK_HEADER(gcrypt.h, [], [have_gcrypt="no"])
374         AC_CHECK_LIB([gcrypt], [gcry_randomize], [], [have_gcrypt="no"])
375         if test "$have_gcrypt" = "yes"; then
376                 AC_DEFINE(HAVE_GCRYPT, 1, [define to 1 to turn on gcrypt support])
377                 AC_SUBST(gcrypt_cppflags)
378                 gcrypt_libs="$gcrypt_libs -lgcrypt"
379                 server_ldflags="$server_ldflags $gcrypt_libs"
380                 client_ldflags="$client_ldflags $gcrypt_libs"
381                 audiod_ldflags="$audiod_ldflags $gcrypt_libs"
382
383                 all_errlist_objs="$all_errlist_objs gcrypt"
384                 server_errlist_objs="$server_errlist_objs gcrypt"
385                 client_errlist_objs="$client_errlist_objs gcrypt"
386                 audiod_errlist_objs="$audiod_errlist_objs gcrypt"
387         else
388                 AC_MSG_WARN([gcrypt library not found])
389         fi
390         CPPFLAGS="$OLD_CPPFLAGS"
391         LDFLAGS="$OLD_LDFLAGS"
392         LIBS="$OLD_LIBS"
393 else
394         have_gcrypt="no"
395 fi
396 ###########################################################################
397 if test "$have_openssl" = "no" -a "$have_gcrypt" = "no"; then
398         AC_MSG_ERROR([neither openssl nor gcrypt usable])
399 fi
400 ########################################################################### libsocket
401 AC_CHECK_LIB([c], [socket],
402         [socket_lib=],
403         [socket_lib="-lsocket"]
404 )
405 server_ldflags="$server_ldflags $socket_lib"
406 client_ldflags="$client_ldflags $socket_lib"
407 audioc_ldflags="$audioc_ldflags $socket_lib"
408 audiod_ldflags="$audiod_ldflags $socket_lib"
409 recv_ldflags="$recv_ldflags $socket_lib"
410 AC_SEARCH_LIBS([connect],[socket],[],[
411         AC_MSG_ERROR([Fatal: Did not find connect().])
412 ],[])
413 ########################################################################### libnsl
414 AC_CHECK_LIB([c], [gethostbyname],
415         [nsl_lib=],
416         [nsl_lib="-lnsl"]
417 )
418 server_ldflags="$server_ldflags $nsl_lib"
419 client_ldflags="$client_ldflags $nsl_lib"
420 audioc_ldflags="$audioc_ldflags $nsl_lib"
421 recv_ldflags="$recv_ldflags $nsl_lib"
422 AC_SEARCH_LIBS([inet_ntoa],[nsl],[],[
423         AC_MSG_ERROR([Fatal: Did not find inet_ntoa().])
424 ],[])
425 ########################################################################### ucred
426 AC_MSG_CHECKING(for struct ucred)
427 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
428         #define _GNU_SOURCE
429         #include <sys/types.h>
430         #include <sys/socket.h>
431 ]], [[
432         struct ucred sucred; sucred.pid=0;
433 ]])],[have_ucred=yes],[have_ucred=no])
434 AC_MSG_RESULT($have_ucred)
435 if test ${have_ucred} = yes; then
436         AC_DEFINE(HAVE_UCRED, 1, define to 1 you have struct ucred)
437 fi
438
439 ########################################################################### curses
440 have_curses="yes"
441 OLD_CPPFLAGS="$CPPFLAGS"
442 OLD_LD_FLAGS="$LDFLAGS"
443 OLD_LIBS="$LIBS"
444 AC_ARG_WITH(curses_headers, [AS_HELP_STRING(--with-curses-headers=dir,
445         [look for curses.h also in dir])])
446 if test -n "$with_curses_headers"; then
447         curses_cppflags="-I$with_curses_headers"
448         CPPFLAGS="$CPPFLAGS $curses_cppflags"
449 fi
450 AC_ARG_WITH(curses_libs, [AS_HELP_STRING(--with-curses-libs=dir,
451         [look for libcurses also in dir])])
452 if test -n "$with_curses_libs"; then
453         curses_libs="-L$with_curses_libs"
454         LDFLAGS="$LDFLAGS $curses_libs"
455 fi
456 AC_CHECK_HEADER(curses.h, [], [
457         have_curses="no"
458 ])
459 AC_CHECK_LIB([curses], [initscr], [], [
460         have_curses="no"
461 ])
462 if test "$have_curses" = "yes"; then
463         AC_SUBST(curses_cppflags)
464         AC_DEFINE(HAVE_NCURSES, 1, [define to 1 to turn on curses support])
465         extras="$extras gui"
466         executables="$executables gui"
467 else
468         AC_MSG_WARN([cannot build para_gui])
469 fi
470 CPPFLAGS="$OLD_CPPFLAGS"
471 LDFLAGS="$OLD_LDFLAGS"
472 LIBS="$OLD_LIBS"
473
474 ########################################################################### ip_mreqn
475 AC_MSG_CHECKING(for struct ip_mreqn (UDPv4 multicast))
476 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
477         #include <netdb.h>
478         #include <net/if.h>
479 ]], [[
480         struct ip_mreqn mn;
481         mn.imr_ifindex = 0;
482 ]])],[have_ip_mreqn=yes],[have_ip_mreqn=no])
483 AC_MSG_RESULT($have_ip_mreqn)
484 if test ${have_ip_mreqn} = yes; then
485         AC_DEFINE(HAVE_IP_MREQN, 1, define to 1 you have struct ip_mreqn)
486 fi
487 ########################################################################### osx
488
489 AC_MSG_CHECKING(for CoreAudio (MacOs))
490 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
491         #include <CoreAudio/CoreAudio.h>
492 ]], [[
493         AudioDeviceID id;
494 ]])],[have_core_audio=yes],[have_core_audio=no])
495 AC_MSG_RESULT($have_core_audio)
496 if test ${have_core_audio} = yes; then
497         f1="-framework CoreAudio"
498         f2="-framework AudioToolbox"
499         f3="-framework AudioUnit"
500         f4="-framework CoreServices"
501         f="$f1 $f2 $f3 $f4"
502
503         all_errlist_objs="$all_errlist_objs osx_write"
504         # ipc is linked into para_server server and into the osx writer. If osl
505         # was not found, para_server will not be built and ipc has not yet been
506         # added to the list of all objects, so we must add it here.
507         if test "$have_osl" = "no"; then
508                 all_errlist_objs="$all_errlist_objs ipc"
509         fi
510         audiod_errlist_objs="$audiod_errlist_objs osx_write ipc"
511         audiod_cmdline_objs="$audiod_cmdline_objs osx_write.cmdline"
512         audiod_ldflags="$audiod_ldflags $f"
513
514         write_errlist_objs="$write_errlist_objs osx_write ipc"
515         write_cmdline_objs="$write_cmdline_objs osx_write.cmdline"
516         write_ldflags="$write_ldflags $f"
517         writers="$writers osx"
518         default_writer="OSX_WRITE"
519         AC_DEFINE(HAVE_CORE_AUDIO, 1, define to 1 on Mac Os X)
520 fi
521 ########################################################### ogg/vorbis/speex
522 have_ogg="yes"
523 OLD_CPPFLAGS="$CPPFLAGS"
524 OLD_LD_FLAGS="$LDFLAGS"
525 OLD_LIBS="$LIBS"
526 AC_ARG_WITH(ogg_headers, [AS_HELP_STRING(--with-ogg-headers=dir,
527         [look for ogg headers also in dir])])
528 AC_ARG_WITH(ogg_libs, [AS_HELP_STRING(--with-ogg-libs=dir,
529         [look for ogg libs also in dir])])
530 AC_ARG_WITH(vorbis_headers, [AS_HELP_STRING(--with-vorbis-headers=dir,
531         [look for vorbis headers also in dir])])
532 AC_ARG_WITH(vorbis_libs, [AS_HELP_STRING(--with-vorbis-libs=dir,
533         [look for vorbis libs also in dir])])
534 AC_ARG_WITH(speex_headers, [AS_HELP_STRING(--with-speex-headers=dir,
535         [look for speex headers also in dir])])
536 AC_ARG_WITH(speex_libs, [AS_HELP_STRING(--with-speex-libs=dir,
537         [look for speex libs also in dir])])
538
539 if test -n "$with_ogg_headers"; then
540         ogg_cppflags="-I$with_ogg_headers"
541         CPPFLAGS="$CPPFLAGS $ogg_cppflags"
542 fi
543 if test -n "$with_ogg_libs"; then
544         ogg_libs="-L$with_ogg_libs"
545         LDFLAGS="$LDFLAGS $ogg_libs"
546 fi
547 AC_CHECK_HEADERS([ogg/ogg.h], [], [ have_ogg="no"; ])
548 AC_CHECK_LIB([ogg], [ogg_stream_init], [], [ have_ogg="no" ])
549
550 have_vorbis="yes"
551 have_speex="yes"
552 if test "$have_ogg" = "yes"; then
553         # vorbis
554         if test -n "$with_vorbis_headers"; then
555                 vorbis_cppflags="-I$with_vorbis_headers"
556                 CPPFLAGS="$CPPFLAGS $vorbis_cppflags"
557         fi
558         if test -n "$with_vorbis_libs"; then
559                 vorbis_libs="-L$with_vorbis_libs"
560                 LDFLAGS="$LDFLAGS $vorbis_libs"
561         fi
562         AC_CHECK_HEADERS([vorbis/codec.h], [], [ have_vorbis="no" ])
563         AC_CHECK_LIB([vorbis], [vorbis_info_init], [], [ have_vorbis="no" ])
564
565         # speex
566         if test -n "$with_speex_headers"; then
567                 speex_cppflags="-I$with_speex_headers"
568                 CPPFLAGS="$CPPFLAGS $speex_cppflags"
569         fi
570         if test -n "$with_speex_libs"; then
571                 speex_libs="-L$with_speex_libs"
572                 LDFLAGS="$LDFLAGS $speex_libs"
573         fi
574         AC_CHECK_LIB([speex], [speex_decoder_init], [], [ have_speex="no" ])
575         AC_CHECK_HEADERS([speex/speex.h], [], [ have_speex="no" ])
576 else
577         AC_MSG_WARN([vorbis/speex depend on libogg, which was not detected])
578         have_vorbis="no"
579         have_speex="no"
580 fi
581
582 msg="support in para_server/para_filter/para_afh"
583 if test "$have_vorbis" = "yes" || test "$have_speex" = "yes"; then
584         AC_SUBST(ogg_cppflags)
585         ogg_libs="$ogg_libs -logg"
586         if test "$OSTYPE" = "Darwin"; then
587                 ogg_libs="-Wl,-bind_at_load $ogg_libs"
588         fi
589         server_ldflags="$server_ldflags $ogg_libs"
590         filter_ldflags="$filter_ldflags $ogg_libs"
591         audiod_ldflags="$audiod_ldflags $ogg_libs"
592         afh_ldflags="$afh_ldflags $ogg_libs"
593         all_errlist_objs="$all_errlist_objs ogg_afh_common"
594         afh_errlist_objs="$afh_errlist_objs ogg_afh_common"
595         server_errlist_objs="$server_errlist_objs ogg_afh_common"
596 fi
597 if test "$have_vorbis" = "yes"; then
598         all_errlist_objs="$all_errlist_objs oggdec_filter ogg_afh"
599         AC_DEFINE(HAVE_OGGVORBIS, 1, define to 1 to turn on ogg/vorbis support)
600         filters="$filters oggdec"
601         vorbis_libs="-lvorbis -lvorbisfile"
602         server_ldflags="$server_ldflags $vorbis_libs"
603         filter_ldflags="$filter_ldflags $vorbis_libs"
604         audiod_ldflags="$audiod_ldflags $vorbis_libs"
605         afh_ldflags="$afh_ldflags $vorbis_libs"
606
607         server_errlist_objs="$server_errlist_objs ogg_afh"
608         filter_errlist_objs="$filter_errlist_objs oggdec_filter"
609         audiod_errlist_objs="$audiod_errlist_objs oggdec_filter"
610         afh_errlist_objs="$afh_errlist_objs ogg_afh"
611
612         audiod_audio_formats="$audiod_audio_formats ogg"
613         server_audio_formats="$server_audio_formats ogg"
614 else
615         AC_MSG_WARN([no ogg/vorbis $msg])
616 fi
617 if test "$have_speex" = "yes"; then
618         all_errlist_objs="$all_errlist_objs spxdec_filter spx_afh spx_common"
619         AC_DEFINE(HAVE_SPEEX, 1, define to 1 to turn on ogg/speex support)
620         filters="$filters spxdec"
621         speex_libs="-lspeex"
622         server_ldflags="$server_ldflags $speex_libs"
623         filter_ldflags="$filter_ldflags $speex_libs"
624         audiod_ldflags="$audiod_ldflags $speex_libs"
625         afh_ldflags="$afh_ldflags $speex_libs"
626
627         server_errlist_objs="$server_errlist_objs spx_afh spx_common"
628         filter_errlist_objs="$filter_errlist_objs spxdec_filter spx_common"
629         audiod_errlist_objs="$audiod_errlist_objs spxdec_filter spx_common"
630         afh_errlist_objs="$afh_errlist_objs spx_afh spx_common"
631
632         audiod_audio_formats="$audiod_audio_formats spx"
633         server_audio_formats="$server_audio_formats spx"
634 else
635         AC_MSG_WARN([no ogg/speex $msg])
636 fi
637 CPPFLAGS="$OLD_CPPFLAGS"
638 LDFLAGS="$OLD_LDFLAGS"
639 LIBS="$OLD_LIBS"
640 ########################################################################### faad
641 have_faad=yes
642 OLD_CPPFLAGS="$CPPFLAGS"
643 OLD_LD_FLAGS="$LDFLAGS"
644 OLD_LIBS="$LIBS"
645 AC_ARG_WITH(faad_headers, [AS_HELP_STRING(--with-faad-headers=dir,
646         [look for neaacdec.h also in dir])])
647 if test -n "$with_faad_headers"; then
648         faad_cppflags="-I$with_faad_headers"
649         CPPFLAGS="$CPPFLAGS $faad_cppflags"
650 fi
651 AC_ARG_WITH(faad_libs, [AS_HELP_STRING(--with-faad-libs=dir,
652         [look for libfaad also in dir])])
653 if test -n "$with_faad_libs"; then
654         faad_libs="-L$with_faad_libs"
655         LDFLAGS="$LDFLAGS $faad_libs"
656 fi
657 AC_CHECK_HEADER(neaacdec.h, [], have_faad=no)
658 AC_CHECK_LIB([faad], [NeAACDecOpen], [], have_faad=no)
659 if test "$have_faad" = "yes"; then
660         AC_DEFINE(HAVE_FAAD, 1, define to 1 if you want to build the aacdec filter)
661         all_errlist_objs="$all_errlist_objs aac_common aacdec_filter aac_afh"
662         filter_errlist_objs="$filter_errlist_objs aacdec_filter aac_common"
663         afh_errlist_objs="$afh_errlist_objs aac_common aac_afh"
664         audiod_errlist_objs="$audiod_errlist_objs aacdec_filter aac_common"
665         server_errlist_objs="$server_errlist_objs aac_afh aac_common"
666         server_ldflags="$server_ldflags $faad_libs -lfaad"
667         filter_ldflags="$filter_ldflags $faad_libs -lfaad"
668         audiod_ldflags="$audiod_ldflags $faad_libs -lfaad"
669         afh_ldflags="$afh_ldflags $faad_libs -lfaad"
670         audiod_audio_formats="$audiod_audio_formats aac"
671         server_audio_formats="$server_audio_formats aac"
672         filters="$filters aacdec"
673         AC_SUBST(faad_cppflags)
674 else
675         AC_MSG_WARN([no aac support in para_audiod/para_filter])
676 fi
677 CPPFLAGS="$OLD_CPPFLAGS"
678 LDFLAGS="$OLD_LDFLAGS"
679 LIBS="$OLD_LIBS"
680 ########################################################################### mad
681 have_mad="yes"
682 OLD_CPPFLAGS="$CPPFLAGS"
683 OLD_LD_FLAGS="$LDFLAGS"
684 OLD_LIBS="$LIBS"
685
686 AC_ARG_WITH(mad_headers, [AS_HELP_STRING(--with-mad-headers=dir,
687         [look for mad.h also in dir])])
688 if test -n "$with_mad_headers"; then
689         mad_cppflags="-I$with_mad_headers"
690         CPPFLAGS="$CPPFLAGS $mad_cppflags"
691 fi
692 AC_ARG_WITH(mad_libs, [AS_HELP_STRING(--with-mad-libs=dir,
693         [look for libmad also in dir])])
694 if test -n "$with_mad_libs"; then
695         mad_libs="-L$with_mad_libs"
696         LDFLAGS="$LDFLAGS $mad_libs"
697 fi
698 AC_CHECK_HEADERS([mad.h], [], [
699         have_mad="no"
700 ])
701 AC_CHECK_LIB([mad], [mad_stream_init], [], [
702         have_mad="no"
703 ])
704 if test "$have_mad" = "yes"; then
705         AC_DEFINE(HAVE_MAD, 1, define to 1 if you want to build the mp3dec filter)
706         filter_cmdline_objs="$filter_cmdline_objs add_cmdline(mp3dec_filter)"
707         audiod_cmdline_objs="$audiod_cmdline_objs add_cmdline(mp3dec_filter)"
708         all_errlist_objs="$all_errlist_objs mp3dec_filter"
709         filter_errlist_objs="$filter_errlist_objs mp3dec_filter"
710         audiod_errlist_objs="$audiod_errlist_objs mp3dec_filter"
711         filter_ldflags="$filter_ldflags $mad_libs -lmad"
712         audiod_ldflags="$audiod_ldflags $mad_libs -lmad"
713         audiod_audio_formats="$audiod_audio_formats mp3"
714         filters="$filters mp3dec"
715         AC_SUBST(mad_cppflags)
716 else
717         AC_MSG_WARN([no mp3dec support in para_audiod/para_filter])
718 fi
719 CPPFLAGS="$OLD_CPPFLAGS"
720 LDFLAGS="$OLD_LDFLAGS"
721 LIBS="$OLD_LIBS"
722 ###################################################################### libid3tag
723 OLD_CPPFLAGS="$CPPFLAGS"
724 OLD_LD_FLAGS="$LDFLAGS"
725 OLD_LIBS="$LIBS"
726
727 have_libid3tag="yes"
728 AC_ARG_WITH(id3tag_headers, [AS_HELP_STRING(--with-id3tag-headers=dir,
729         [look for id3tag header files also in dir])])
730 if test -n "$with_id3tag_headers"; then
731         id3tag_cppflags="-I$with_id3tag_headers"
732         CPPFLAGS="$CPPFLAGS $id3tag_cppflags"
733 fi
734 AC_ARG_WITH(id3tag_libs, [AS_HELP_STRING(--with-id3tag-libs=dir,
735         [look for id3tag libs also in dir])])
736 if test -n "$with_id3tag_libs"; then
737         id3tag_libs="-L$with_id3tag_libs"
738         LDFLAGS="$LDFLAGS $id3tag_libs"
739 fi
740
741 AC_MSG_CHECKING(for libid3tag)
742 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
743         #include <id3tag.h>
744 ]], [[
745         struct id3_tag t = {.flags = 0};
746 ]])],[],[have_libid3tag=no])
747 AC_MSG_RESULT($have_libid3tag)
748
749 if test ${have_libid3tag} = yes; then
750         AC_DEFINE(HAVE_LIBID3TAG, 1, define to 1 you have libid3tag)
751         server_ldflags="$server_ldflags $id3tag_libs -lid3tag -lz"
752         afh_ldflags="$afh_ldflags $id3tag_libs -lid3tag -lz"
753         AC_SUBST(id3tag_cppflags)
754 else
755         AC_MSG_WARN([no support for id3v2 tags])
756 fi
757 CPPFLAGS="$OLD_CPPFLAGS"
758 LDFLAGS="$OLD_LDFLAGS"
759 LIBS="$OLD_LIBS"
760 ########################################################################### flac
761 OLD_CPPFLAGS="$CPPFLAGS"
762 OLD_LD_FLAGS="$LDFLAGS"
763 OLD_LIBS="$LIBS"
764
765 have_flac="yes"
766 AC_ARG_WITH(flac_headers, [AS_HELP_STRING(--with-flac-headers=dir,
767         [look for flac headers also in dir])])
768 if test -n "$with_flac_headers"; then
769         flac_cppflags="-I$with_flac_headers"
770         CPPFLAGS="$CPPFLAGS $flac_cppflags"
771 fi
772 AC_ARG_WITH(flac_libs, [AS_HELP_STRING(--with-flac-libs=dir,
773         [look for flac libs also in dir])])
774 if test -n "$with_flac_libs"; then
775         flac_libs="-L$with_flac_libs"
776         LDFLAGS="$LDFLAGS $flac_libs"
777 fi
778 AC_CHECK_HEADER(FLAC/stream_decoder.h, [], have_flac=no)
779 AC_CHECK_LIB([FLAC], [FLAC__stream_decoder_init_file], [], have_flac=no, -logg -lm)
780 if test "$have_flac" = "yes"; then
781         AC_DEFINE(HAVE_FLAC, 1, define to 1 if you want to build the flacdec filter)
782         all_errlist_objs="$all_errlist_objs flacdec_filter flac_afh"
783         filter_errlist_objs="$filter_errlist_objs flacdec_filter"
784         audiod_errlist_objs="$audiod_errlist_objs flacdec_filter"
785         afh_errlist_objs="$afh_errlist_objs flac_afh"
786         server_errlist_objs="$server_errlist_objs flac_afh"
787         filter_ldflags="$filter_ldflags $flac_libs -lFLAC"
788         audiod_ldflags="$audiod_ldflags $flac_libs -lFLAC"
789         server_ldflags="$server_ldflags $flac_libs -lFLAC"
790         afh_ldflags="$afh_ldflags $flac_libs -lFLAC"
791         filters="$filters flacdec"
792         server_audio_formats="$server_audio_formats flac"
793         audiod_audio_formats="$audiod_audio_formats flac"
794         AC_SUBST(flac_cppflags)
795 else
796         AC_MSG_WARN([no flac support in para_audiod/para_filter/para_afh/para_server])
797 fi
798 CPPFLAGS="$OLD_CPPFLAGS"
799 LDFLAGS="$OLD_LDFLAGS"
800 LIBS="$OLD_LIBS"
801 ########################################################################### oss
802 OLD_CPPFLAGS="$CPPFLAGS"
803 OLD_LD_FLAGS="$LDFLAGS"
804 OLD_LIBS="$LIBS"
805
806 have_oss="yes"
807 msg="=> will not build oss writer"
808
809 AC_CHECK_HEADER(sys/soundcard.h, [
810         audiod_errlist_objs="$audiod_errlist_objs oss_write"
811         audiod_cmdline_objs="$audiod_cmdline_objs add_cmdline(oss_write)"
812         write_errlist_objs="$write_errlist_objs oss_write"
813         write_cmdline_objs="$write_cmdline_objs add_cmdline(oss_write)"
814         fade_errlist_objs="$fade_errlist_objs oss_mix"
815         all_errlist_objs="$all_errlist_objs oss_write oss_mix"
816
817         writers="$writers oss"
818         default_writer="OSS_WRITE"
819         mixers="${mixers}oss "
820         default_mixer="OSS_MIX"
821
822         AC_CHECK_LIB(ossaudio, _oss_ioctl, [
823                         audiod_ldflags="$audiod_ldflags -lossaudio"
824                         write_ldflags="$write_ldflags -lossaudio"
825                         fade_ldflags="$fade_ldflags -lossaudio"
826                 ]
827         )
828         ],
829         [
830                 have_oss="no"
831                 AC_MSG_WARN([no sys/soundcard.h $msg])
832         ]
833 )
834 CPPFLAGS="$OLD_CPPFLAGS"
835 LDFLAGS="$OLD_LDFLAGS"
836 LIBS="$OLD_LIBS"
837
838 ########################################################################### alsa
839 OLD_CPPFLAGS="$CPPFLAGS"
840 OLD_LD_FLAGS="$LDFLAGS"
841 OLD_LIBS="$LIBS"
842
843 msg="=> no alsa support for para_audiod/para_write"
844 if test "$OSTYPE" != "Linux"; then
845         have_alsa="no"
846 else
847         have_alsa="yes"
848 fi
849 if test "$have_alsa" = "yes"; then
850         AC_CHECK_HEADERS([alsa/asoundlib.h], [], [
851                 have_alsa="no"
852                 AC_MSG_WARN([no alsa/asoundlib $msg])
853         ])
854 fi
855
856 if test "$have_alsa" = "yes"; then
857         AC_CHECK_LIB([asound], [snd_pcm_open], [], [
858                 have_alsa="no"
859                 AC_MSG_WARN([no libasound $msg])
860         ])
861 fi
862
863 if test "$have_alsa" = "yes"; then
864         audiod_errlist_objs="$audiod_errlist_objs alsa_write"
865         audiod_cmdline_objs="$audiod_cmdline_objs add_cmdline(alsa_write)"
866         audiod_ldflags="$audiod_ldflags -lasound"
867         write_errlist_objs="$write_errlist_objs alsa_write"
868         write_cmdline_objs="$write_cmdline_objs add_cmdline(alsa_write)"
869         write_ldflags="$write_ldflags -lasound"
870         fade_errlist_objs="$fade_errlist_objs alsa_mix"
871         fade_ldflags="$fade_ldflags -lasound"
872         all_errlist_objs="$all_errlist_objs alsa_write alsa_mix"
873
874         writers="$writers alsa"
875         default_writer="ALSA_WRITE"
876         mixers="${mixers}alsa "
877         default_mixer="ALSA_MIX"
878 fi
879
880 CPPFLAGS="$OLD_CPPFLAGS"
881 LDFLAGS="$OLD_LDFLAGS"
882 LIBS="$OLD_LIBS"
883 ########################################################################### fade
884 if test -n "$mixers"; then
885         extras="$extras fade"
886         executables="$executables fade"
887         all_errlist_objs="$all_errlist_objs fade"
888         fade_errlist_objs="$fade_errlist_objs fade exec string fd"
889         fade_cmdline_objs="add_cmdline(fade)"
890         fade_objs="$fade_cmdline_objs $fade_errlist_objs"
891         AC_SUBST(fade_objs, add_dot_o($fade_objs))
892         AC_SUBST(fade_ldflags, $fade_ldflags)
893         AC_DEFINE_UNQUOTED(INIT_FADE_ERRLISTS,
894                 objlist_to_errlist($fade_errlist_objs),
895                 errors used by para_fade)
896         enum="$(
897                 for i in $mixers; do
898                         printf "${i}_MIX, " | tr '[a-z]' '[A-Z]'
899                 done
900         )"
901         AC_DEFINE_UNQUOTED(MIXER_ENUM, $enum NUM_SUPPORTED_MIXERS,
902                 enum of supported mixers)
903         AC_DEFINE_UNQUOTED(DEFAULT_MIXER, $default_mixer,
904                 use this mixer if none was specified)
905         names="$(for i in $mixers; do printf \"$i\",' ' ; done)"
906         AC_DEFINE_UNQUOTED(MIXER_NAMES, $names, supported mixer names)
907         inits="$(
908                 for i in $mixers; do
909                         printf 'extern void '$i'_mix_init(struct mixer *); '
910                 done
911         )"
912         AC_DEFINE_UNQUOTED(DECLARE_MIXER_INITS, $inits,
913                 init functions of the supported mixers)
914         array="$(for i in $mixers; do printf '{.init = '$i'_mix_init},'; done)"
915         AC_DEFINE_UNQUOTED(MIXER_ARRAY, $array, array of supported mixers)
916         mixer_summary="supported mixers:: $mixers, default: $default_mixer"
917 else
918         AC_MSG_WARN([no mixer support])
919         mixer_summary="para_fade: no"
920 fi
921 ########################################################################### libao
922 OLD_CPPFLAGS="$CPPFLAGS"
923 OLD_LD_FLAGS="$LDFLAGS"
924 OLD_LIBS="$LIBS"
925
926 have_ao="yes"
927 AC_ARG_WITH(ao_headers, [AS_HELP_STRING(--with-ao-headers=dir,
928         [look for ao/ao.h also in dir])])
929 if test -n "$with_ao_headers"; then
930         ao_cppflags="-I$with_ao_headers"
931         CPPFLAGS="$CPPFLAGS $ao_cppflags"
932 fi
933 AC_ARG_WITH(ao_libs, [AS_HELP_STRING(--with-ao-libs=dir,
934         [look for libao also in dir])])
935 if test -n "$with_ao_libs"; then
936         ao_libs="-L$with_ao_libs"
937         LDFLAGS="$LDFLAGS $ao_libs"
938 fi
939 msg="no libao support for para_audiod/para_write"
940 AC_CHECK_HEADERS([ao/ao.h], [
941         ], [
942         have_ao="no"
943         AC_MSG_WARN([ao.h not found, $msg])
944 ])
945 if test "$have_ao" = "yes"; then
946         AC_CHECK_LIB([ao], [ao_initialize], [], [
947                 have_ao="no"
948                 AC_MSG_WARN([ao lib not found or not working, $msg])
949         ])
950 fi
951 if test "$have_ao" = "yes"; then
952         AC_CHECK_HEADERS([pthread.h], [
953                 ], [
954                 have_ao="no"
955                 AC_MSG_WARN([pthread.h not found, $msg])
956         ])
957 fi
958 if test "$have_ao" = "yes"; then
959         AC_CHECK_LIB([pthread], [pthread_create], [], [
960                 have_ao="no"
961                 AC_MSG_WARN([pthread lib not found or not working, $msg])
962         ])
963 fi
964 if test "$have_ao" = "yes"; then
965         all_errlist_objs="$all_errlist_objs ao_write"
966         audiod_errlist_objs="$audiod_errlist_objs ao_write"
967         audiod_cmdline_objs="$audiod_cmdline_objs add_cmdline(ao_write)"
968         audiod_ldflags="$audiod_ldflags -lao -lpthread"
969
970         write_errlist_objs="$write_errlist_objs ao_write"
971         write_cmdline_objs="$write_cmdline_objs add_cmdline(ao_write)"
972         write_ldflags="$write_ldflags $ao_libs -lao -lpthread"
973         writers="$writers ao"
974         AC_SUBST(ao_cppflags)
975 fi
976
977 CPPFLAGS="$OLD_CPPFLAGS"
978 LDFLAGS="$OLD_LDFLAGS"
979 LIBS="$OLD_LIBS"
980 ############################################################# readline
981 OLD_CPPFLAGS="$CPPFLAGS"
982 OLD_LD_FLAGS="$LDFLAGS"
983 OLD_LIBS="$LIBS"
984
985 have_readline="yes"
986 AC_ARG_WITH(readline_headers, [AS_HELP_STRING(--with-readline-headers=dir,
987         [look for libreadline header files also in dir])])
988 if test -n "$with_readline_headers"; then
989         readline_cppflags="-I$with_readline_headers"
990         CPPFLAGS="$CPPFLAGS $readline_cppflags"
991 fi
992
993 AC_ARG_WITH(readline_libs, [AS_HELP_STRING(--with-readline-libs=dir,
994         [look for readline library also in dir])])
995 if test -n "$with_readline_libs"; then
996         readline_libs="-L$with_readline_libs"
997         LDFLAGS="$LDFLAGS $readline_libs"
998 fi
999 msg="no interactive cli support"
1000 AC_CHECK_HEADERS([readline/readline.h], [
1001         ], [
1002         have_readline="no"
1003         AC_MSG_WARN([readline/readline.h not found, $msg])
1004 ])
1005 if test "$have_readline" = "yes"; then
1006         readline_libs="$readline_libs -lreadline"
1007         AC_SEARCH_LIBS([rl_replace_line], [readline], [], [have_readline="no"])
1008         if test "$have_readline" = "no"; then # try with -lcurses
1009                 # clear cache
1010                 AC_MSG_NOTICE([trying again with -lcurses])
1011                 unset ac_cv_search_rl_replace_line 2> /dev/null
1012                 AC_SEARCH_LIBS([rl_replace_line], [readline], [
1013                         have_readline=yes
1014                         readline_libs="$readline_libs -lcurses"
1015                 ], [], [-lcurses])
1016         fi
1017         if test "$have_readline" = "no"; then # try with -ltermcap
1018                 # clear cache
1019                 AC_MSG_NOTICE([trying again with -ltermcap])
1020                 unset ac_cv_search_rl_replace_line 2> /dev/null
1021                 AC_SEARCH_LIBS([rl_replace_line], [readline], [
1022                         have_readline=yes
1023                         readline_libs="$readline_libs -ltermcap"
1024                 ], [], [-ltermcap])
1025         fi
1026 fi
1027
1028 if test "$have_readline" = "yes"; then
1029         all_errlist_objs="$all_errlist_objs interactive"
1030         client_errlist_objs="$client_errlist_objs interactive"
1031         client_ldflags="$client_ldflags $readline_libs"
1032         audioc_errlist_objs="$audioc_errlist_objs buffer_tree interactive sched time"
1033         audioc_ldflags="$audioc_ldflags $readline_libs"
1034         AC_SUBST(readline_cppflags)
1035         AC_DEFINE(HAVE_READLINE, 1, define to 1 to turn on readline support)
1036 else
1037         AC_MSG_WARN([libreadline not found or unusable])
1038 fi
1039 CPPFLAGS="$OLD_CPPFLAGS"
1040 LDFLAGS="$OLD_LDFLAGS"
1041 LIBS="$OLD_LIBS"
1042 ############################################################# error2.h
1043 AC_MSG_NOTICE(creating error2.h)
1044 for i in $executables; do
1045         echo "$i: "
1046         eval echo \$${i}_errlist_objs
1047 done | ./error2.pl > error2.h
1048 for obj in $all_errlist_objs; do
1049         SS="$SS SS_$(echo $obj | tr 'a-z' 'A-Z'),"
1050 done
1051 AC_DEFINE_UNQUOTED(DEFINE_ERRLIST_OBJECT_ENUM,
1052         [enum {$SS NUM_SS}],
1053         [list of all objects that use the paraslash error facility]
1054 )
1055
1056 ################################################################## status items
1057
1058 status_items="basename status num_played mtime bitrate frequency file_size
1059 status_flags format score techinfo afs_mode
1060 attributes_txt decoder_flags audiod_status play_time attributes_bitmap
1061 offset seconds_total stream_start current_time audiod_uptime image_id
1062 lyrics_id duration directory lyrics_name image_name path hash channels
1063 last_played num_chunks chunk_time amplification artist title year album
1064 comment"
1065
1066 result=
1067 for i in $status_items; do
1068         result="$result SI_$(echo $i | tr 'a-z' 'A-Z'), "
1069 done
1070 AC_DEFINE_UNQUOTED(STATUS_ITEM_ENUM, [$result],
1071         [enum of all status items])
1072
1073 result=
1074 for i in $status_items; do
1075         result="$result \"$i\", "
1076 done
1077 AC_DEFINE_UNQUOTED(STATUS_ITEM_ARRAY, [$result],
1078         [char * array of all status items])
1079
1080 AC_DEFINE_UNQUOTED(SERVER_AUDIO_FORMATS, "$server_audio_formats",
1081         [formats supported by para_server and para_afh])
1082
1083 AC_SUBST(executables, add_para($executables))
1084
1085 recv_objs="$recv_cmdline_objs $recv_errlist_objs"
1086 filter_objs="$filter_cmdline_objs $filter_errlist_objs"
1087 audiod_objs="$audiod_cmdline_objs $audiod_errlist_objs"
1088 server_objs="$server_cmdline_objs $server_errlist_objs"
1089 write_objs="$write_cmdline_objs $write_errlist_objs"
1090 client_objs="$client_cmdline_objs $client_errlist_objs"
1091 audioc_objs="$audioc_cmdline_objs $audioc_errlist_objs"
1092 afh_objs="$afh_cmdline_objs $afh_errlist_objs"
1093
1094 AC_SUBST(recv_objs, add_dot_o($recv_objs))
1095 AC_SUBST(recv_ldflags, $recv_ldflags)
1096 AC_DEFINE_UNQUOTED(INIT_RECV_ERRLISTS, objlist_to_errlist($recv_errlist_objs),
1097         errors used by para_recv)
1098
1099 AC_SUBST(filter_objs, add_dot_o($filter_objs))
1100 AC_SUBST(filter_ldflags, $filter_ldflags)
1101 AC_DEFINE_UNQUOTED(INIT_FILTER_ERRLISTS,
1102         objlist_to_errlist($filter_errlist_objs), errors used by para_filter)
1103
1104 AC_SUBST(audiod_objs, add_dot_o($audiod_objs))
1105 AC_SUBST(audiod_ldflags, $audiod_ldflags)
1106 AC_DEFINE_UNQUOTED(INIT_AUDIOD_ERRLISTS, objlist_to_errlist($audiod_errlist_objs),
1107         errors used by para_audiod)
1108
1109 AC_SUBST(server_objs, add_dot_o($server_objs))
1110 AC_SUBST(server_ldflags, $server_ldflags)
1111 AC_DEFINE_UNQUOTED(INIT_SERVER_ERRLISTS,
1112         objlist_to_errlist($server_errlist_objs), errors used by para_server)
1113
1114 AC_SUBST(afh_objs, add_dot_o($afh_objs))
1115 AC_SUBST(afh_ldflags, $afh_ldflags)
1116 AC_DEFINE_UNQUOTED(INIT_AFH_ERRLISTS,
1117         objlist_to_errlist($afh_errlist_objs), errors used by para_afh)
1118
1119 AC_SUBST(write_objs, add_dot_o($write_objs))
1120 AC_SUBST(write_ldflags, $write_ldflags)
1121 AC_DEFINE_UNQUOTED(INIT_WRITE_ERRLISTS,
1122         objlist_to_errlist($write_errlist_objs), errors used by para_write)
1123
1124 AC_SUBST(client_objs, add_dot_o($client_objs))
1125 AC_SUBST(client_ldflags, $client_ldflags)
1126 AC_DEFINE_UNQUOTED(INIT_CLIENT_ERRLISTS,
1127         objlist_to_errlist($client_errlist_objs), errors used by para_client)
1128
1129 AC_SUBST(audioc_objs, add_dot_o($audioc_objs))
1130 AC_SUBST(audioc_ldflags, $audioc_ldflags)
1131 AC_DEFINE_UNQUOTED(INIT_AUDIOC_ERRLISTS,
1132         objlist_to_errlist($audioc_errlist_objs), errors used by para_audioc)
1133
1134 AC_SUBST(gui_objs, add_dot_o($gui_objs))
1135 AC_DEFINE_UNQUOTED(INIT_GUI_ERRLISTS,
1136         objlist_to_errlist($gui_errlist_objs), errors used by para_gui)
1137
1138 enum="$(for i in $filters; do printf "${i}_FILTER, " | tr '[a-z]' '[A-Z]'; done)"
1139 AC_DEFINE_UNQUOTED(FILTER_ENUM, $enum NUM_SUPPORTED_FILTERS,
1140         enum of supported filters)
1141 inits="$(for i in $filters; do printf 'extern void '$i'_filter_init(struct filter *f); '; done)"
1142 AC_DEFINE_UNQUOTED(DECLARE_FILTER_INITS, $inits, init functions of the supported filters)
1143 array="$(for i in $filters; do printf '{.name = "'$i'", .init = '$i'_filter_init},'; done)"
1144 AC_DEFINE_UNQUOTED(FILTER_ARRAY, $array, array of supported filters)
1145
1146 enum="$(for i in $writers; do printf "${i}_WRITE, " | tr '[a-z]' '[A-Z]'; done)"
1147 AC_DEFINE_UNQUOTED(WRITER_ENUM, $enum NUM_SUPPORTED_WRITERS,
1148         enum of supported writers)
1149 AC_DEFINE_UNQUOTED(DEFAULT_WRITER, $default_writer, use this writer if none was specified)
1150 names="$(for i in $writers; do printf \"$i\",' ' ; done)"
1151 AC_DEFINE_UNQUOTED(WRITER_NAMES, $names, supported writer names)
1152 inits="$(for i in $writers; do printf 'extern void '$i'_write_init(struct writer *); '; done)"
1153 AC_DEFINE_UNQUOTED(DECLARE_WRITER_INITS, $inits, init functions of the supported writers)
1154 array="$(for i in $writers; do printf '{.init = '$i'_write_init},'; done)"
1155 AC_DEFINE_UNQUOTED(WRITER_ARRAY, $array, array of supported writers)
1156
1157 enum="$(for i in $audiod_audio_formats; do printf "AUDIO_FORMAT_${i}, " | tr '[a-z]' '[A-Z]'; done)"
1158 AC_DEFINE_UNQUOTED(AUDIOD_AUDIO_FORMATS_ENUM, $enum NUM_AUDIO_FORMATS,
1159         enum of audio formats supported by audiod)
1160 names="$(for i in $audiod_audio_formats; do printf \"$i\",' ' ; done)"
1161 AC_DEFINE_UNQUOTED(AUDIOD_AUDIO_FORMAT_ARRAY, $names, array of audio formats supported by audiod)
1162
1163 AC_OUTPUT
1164 AC_MSG_NOTICE([
1165 paraslash configuration:
1166 ~~~~~~~~~~~~~~~~~~~~~~~~
1167 unix socket credentials: $have_ucred
1168 readline (interactive CLIs): $have_readline
1169 audio formats supported by para_server/para_afh: $server_audio_formats
1170 id3 version2 support: $have_libid3tag
1171 filters supported by para_audiod/para_filter: $filters
1172 writers supported by para_audiod/para_write: $writers
1173 optional executables: $extras
1174 $mixer_summary
1175 ])