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