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