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