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