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