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