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