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