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