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