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