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