doc: Change email address to maan@tuebingen.mpg.de
[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@tuebingen.mpg.de])
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://people.tuebingen.mpg.de/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 CPPFLAGS="$OLD_CPPFLAGS"
384 LDFLAGS="$OLD_LDFLAGS"
385 LIBS="$OLD_LIBS"
386
387 have_vorbis="yes"
388 have_speex="yes"
389 have_opus="yes"
390 if test "$have_ogg" = "yes"; then
391         OLD_CPPFLAGS="$CPPFLAGS"
392         OLD_LDFLAGS="$LDFLAGS"
393         OLD_LIBS="$LIBS"
394         # vorbis
395         if test -n "$with_vorbis_headers"; then
396                 vorbis_cppflags="-I$with_vorbis_headers"
397                 CPPFLAGS="$CPPFLAGS $vorbis_cppflags"
398         fi
399         if test -n "$with_vorbis_libs"; then
400                 vorbis_libs="-L$with_vorbis_libs"
401                 LDFLAGS="$LDFLAGS $vorbis_libs"
402         fi
403         AC_CHECK_HEADERS([vorbis/codec.h], [], [ have_vorbis="no" ])
404         AC_CHECK_LIB([vorbis], [vorbis_info_init], [], [ have_vorbis="no" ])
405         CPPFLAGS="$OLD_CPPFLAGS"
406         LDFLAGS="$OLD_LDFLAGS"
407         LIBS="$OLD_LIBS"
408
409         # speex
410         OLD_CPPFLAGS="$CPPFLAGS"
411         OLD_LDFLAGS="$LDFLAGS"
412         OLD_LIBS="$LIBS"
413         if test -n "$with_speex_headers"; then
414                 speex_cppflags="-I$with_speex_headers"
415                 CPPFLAGS="$CPPFLAGS $speex_cppflags"
416         fi
417         if test -n "$with_speex_libs"; then
418                 speex_libs="-L$with_speex_libs"
419                 LDFLAGS="$LDFLAGS $speex_libs"
420         fi
421         AC_CHECK_LIB([speex], [speex_decoder_init], [], [ have_speex="no" ])
422         AC_CHECK_HEADERS([speex/speex.h], [], [ have_speex="no" ])
423         CPPFLAGS="$OLD_CPPFLAGS"
424         LDFLAGS="$OLD_LDFLAGS"
425         LIBS="$OLD_LIBS"
426
427         # opus
428         OLD_CPPFLAGS="$CPPFLAGS"
429         OLD_LDFLAGS="$LDFLAGS"
430         OLD_LIBS="$LIBS"
431         if test -n "$with_opus_headers"; then
432                 opus_cppflags="-I$with_opus_headers"
433                 CPPFLAGS="$CPPFLAGS $opus_cppflags"
434         fi
435         if test -n "$with_opus_libs"; then
436                 opus_libs="-L$with_opus_libs"
437                 LDFLAGS="$LDFLAGS $opus_libs"
438         fi
439         AC_CHECK_LIB([opus], [opus_multistream_decode], [], [ have_opus="no" ])
440         AC_CHECK_HEADERS([opus/opus.h], [], [ have_opus="no" ])
441         CPPFLAGS="$OLD_CPPFLAGS"
442         LDFLAGS="$OLD_LDFLAGS"
443         LIBS="$OLD_LIBS"
444 else
445         AC_MSG_WARN([vorbis/speex/opus depend on libogg, which was not detected])
446         have_vorbis="no"
447         have_speex="no"
448         have_opus="no"
449 fi
450
451 msg="support in para_server/para_filter/para_afh"
452 if test "$have_vorbis" = "yes" || \
453                 test "$have_speex" = "yes" || \
454                 test "$have_opus" = "yes"; then
455         AC_SUBST(ogg_cppflags)
456         ogg_ldflags="$ogg_libs -logg"
457         if test "$OSTYPE" = "Darwin"; then
458                 ogg_ldflags="-Wl,-bind_at_load $ogg_ldflags"
459         fi
460         AC_SUBST(ogg_ldflags)
461 fi
462 if test "$have_vorbis" = "yes"; then
463         AC_DEFINE(HAVE_OGGVORBIS, 1, define to 1 to turn on ogg/vorbis support)
464         AC_SUBST(vorbis_cppflags)
465         vorbis_ldflags="$vorbis_libs -lvorbis -lvorbisfile"
466         AC_SUBST(vorbis_ldflags)
467 fi
468 if test "$have_speex" = "yes"; then
469         AC_DEFINE(HAVE_SPEEX, 1, define to 1 to turn on ogg/speex support)
470         AC_SUBST(speex_cppflags)
471         speex_ldflags="$speex_libs -lspeex"
472         AC_SUBST(speex_ldflags)
473 else
474         AC_MSG_WARN([no ogg/speex $msg])
475 fi
476 if test "$have_opus" = "yes"; then
477         AC_DEFINE(HAVE_OPUS, 1, define to 1 to turn on ogg/opus support)
478         AC_SUBST(opus_cppflags)
479         opus_ldflags="$opus_libs -lopus"
480         AC_SUBST(opus_ldflags)
481         audio_format_handlers="$audio_format_handlers opus"
482 else
483         AC_MSG_WARN([no ogg/opus $msg])
484 fi
485 ########################################################################### faad
486 have_faad=yes
487 OLD_CPPFLAGS="$CPPFLAGS"
488 OLD_LDFLAGS="$LDFLAGS"
489 OLD_LIBS="$LIBS"
490 AC_ARG_WITH(faad_headers, [AS_HELP_STRING(--with-faad-headers=dir,
491         [look for neaacdec.h also in dir])])
492 if test -n "$with_faad_headers"; then
493         faad_cppflags="-I$with_faad_headers"
494         CPPFLAGS="$CPPFLAGS $faad_cppflags"
495 fi
496 AC_ARG_WITH(faad_libs, [AS_HELP_STRING(--with-faad-libs=dir,
497         [look for libfaad also in dir])])
498 if test -n "$with_faad_libs"; then
499         faad_libs="-L$with_faad_libs"
500         LDFLAGS="$LDFLAGS $faad_libs"
501 fi
502 AC_CHECK_HEADER(neaacdec.h, [], have_faad=no)
503 AC_CHECK_LIB([faad], [NeAACDecOpen], [], have_faad=no)
504 if test "$have_faad" = "yes"; then
505         AC_DEFINE(HAVE_FAAD, 1, define to 1 if you want to build the aacdec filter)
506         AC_SUBST(faad_cppflags)
507         faad_ldflags="$faad_libs -lfaad"
508         AC_SUBST(faad_ldflags)
509 fi
510 CPPFLAGS="$OLD_CPPFLAGS"
511 LDFLAGS="$OLD_LDFLAGS"
512 LIBS="$OLD_LIBS"
513 ########################################################################### mad
514 have_mad="yes"
515 OLD_CPPFLAGS="$CPPFLAGS"
516 OLD_LDFLAGS="$LDFLAGS"
517 OLD_LIBS="$LIBS"
518
519 AC_ARG_WITH(mad_headers, [AS_HELP_STRING(--with-mad-headers=dir,
520         [look for mad.h also in dir])])
521 if test -n "$with_mad_headers"; then
522         mad_cppflags="-I$with_mad_headers"
523         CPPFLAGS="$CPPFLAGS $mad_cppflags"
524 fi
525 AC_ARG_WITH(mad_libs, [AS_HELP_STRING(--with-mad-libs=dir,
526         [look for libmad also in dir])])
527 if test -n "$with_mad_libs"; then
528         mad_libs="-L$with_mad_libs"
529         LDFLAGS="$LDFLAGS $mad_libs"
530 fi
531 AC_CHECK_HEADERS([mad.h], [], [
532         have_mad="no"
533 ])
534 AC_CHECK_LIB([mad], [mad_stream_init], [], [
535         have_mad="no"
536 ])
537 if test "$have_mad" = "yes"; then
538         AC_DEFINE(HAVE_MAD, 1, define to 1 if you want to build the mp3dec filter)
539         AC_SUBST(mad_cppflags)
540         mad_ldflags="$mad_libs -lmad"
541         AC_SUBST(mad_ldflags)
542 else
543         AC_MSG_WARN([no mp3dec support in para_audiod/para_filter])
544 fi
545 CPPFLAGS="$OLD_CPPFLAGS"
546 LDFLAGS="$OLD_LDFLAGS"
547 LIBS="$OLD_LIBS"
548 ###################################################################### libid3tag
549 OLD_CPPFLAGS="$CPPFLAGS"
550 OLD_LDFLAGS="$LDFLAGS"
551 OLD_LIBS="$LIBS"
552
553 have_libid3tag="yes"
554 AC_ARG_WITH(id3tag_headers, [AS_HELP_STRING(--with-id3tag-headers=dir,
555         [look for id3tag header files also in dir])])
556 if test -n "$with_id3tag_headers"; then
557         id3tag_cppflags="-I$with_id3tag_headers"
558         CPPFLAGS="$CPPFLAGS $id3tag_cppflags"
559 fi
560 AC_ARG_WITH(id3tag_libs, [AS_HELP_STRING(--with-id3tag-libs=dir,
561         [look for id3tag libs also in dir])])
562 if test -n "$with_id3tag_libs"; then
563         id3tag_libs="-L$with_id3tag_libs"
564         LDFLAGS="$LDFLAGS $id3tag_libs"
565 fi
566
567 AC_MSG_CHECKING(for libid3tag)
568 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
569         #include <id3tag.h>
570 ]], [[
571         struct id3_tag t = {.flags = 0};
572 ]])],[],[have_libid3tag=no])
573 AC_MSG_RESULT($have_libid3tag)
574
575 if test ${have_libid3tag} = yes; then
576         AC_DEFINE(HAVE_LIBID3TAG, 1, define to 1 you have libid3tag)
577         AC_SUBST(id3tag_cppflags)
578         AC_SUBST(id3tag_ldflags, "$id3tag_libs -lid3tag -lz")
579 fi
580 CPPFLAGS="$OLD_CPPFLAGS"
581 LDFLAGS="$OLD_LDFLAGS"
582 LIBS="$OLD_LIBS"
583 ########################################################################### flac
584 OLD_CPPFLAGS="$CPPFLAGS"
585 OLD_LDFLAGS="$LDFLAGS"
586 OLD_LIBS="$LIBS"
587
588 have_flac="yes"
589 AC_ARG_WITH(flac_headers, [AS_HELP_STRING(--with-flac-headers=dir,
590         [look for flac headers also in dir])])
591 if test -n "$with_flac_headers"; then
592         flac_cppflags="-I$with_flac_headers"
593         CPPFLAGS="$CPPFLAGS $flac_cppflags"
594 fi
595 AC_ARG_WITH(flac_libs, [AS_HELP_STRING(--with-flac-libs=dir,
596         [look for flac libs also in dir])])
597 if test -n "$with_flac_libs"; then
598         flac_libs="-L$with_flac_libs"
599         LDFLAGS="$LDFLAGS $flac_libs"
600 fi
601 AC_CHECK_HEADER(FLAC/stream_decoder.h, [], have_flac=no)
602 AC_CHECK_LIB([FLAC], [FLAC__stream_decoder_init_file], [], [
603         # nope, try again with -logg
604         AC_CHECK_LIB([FLAC], [FLAC__stream_decoder_init_file], [],
605                 have_flac=no, -lm -logg)
606         ], -lm)
607 if test "$have_flac" = "yes"; then
608         AC_DEFINE(HAVE_FLAC, 1, define to 1 if you want to build the flacdec filter)
609         AC_SUBST(flac_cppflags)
610         flac_ldflags="$flac_libs -lFLAC"
611         AC_SUBST(flac_ldflags)
612 else
613         AC_MSG_WARN([no flac support in para_audiod/para_filter/para_afh/para_server])
614 fi
615 CPPFLAGS="$OLD_CPPFLAGS"
616 LDFLAGS="$OLD_LDFLAGS"
617 LIBS="$OLD_LIBS"
618 ########################################################################### oss
619 OLD_CPPFLAGS="$CPPFLAGS"
620 OLD_LDFLAGS="$LDFLAGS"
621 OLD_LIBS="$LIBS"
622
623 have_oss="yes"
624 msg="=> will not build oss writer"
625
626 AC_CHECK_HEADER(sys/soundcard.h, [
627         AC_CHECK_LIB(ossaudio, _oss_ioctl, [
628                         oss_ldflags="-lossaudio"
629                         AC_SUBST(oss_ldflags)
630                 ]
631         )
632         ],
633         [
634                 have_oss="no"
635                 AC_MSG_WARN([no sys/soundcard.h $msg])
636         ]
637 )
638 CPPFLAGS="$OLD_CPPFLAGS"
639 LDFLAGS="$OLD_LDFLAGS"
640 LIBS="$OLD_LIBS"
641
642 ########################################################################### alsa
643 OLD_CPPFLAGS="$CPPFLAGS"
644 OLD_LDFLAGS="$LDFLAGS"
645 OLD_LIBS="$LIBS"
646
647 msg="=> no alsa support for para_audiod/para_write"
648 if test "$OSTYPE" != "Linux"; then
649         have_alsa="no"
650 else
651         have_alsa="yes"
652 fi
653 if test "$have_alsa" = "yes"; then
654         AC_CHECK_HEADERS([alsa/asoundlib.h], [], [
655                 have_alsa="no"
656                 AC_MSG_WARN([no alsa/asoundlib $msg])
657         ])
658 fi
659
660 if test "$have_alsa" = "yes"; then
661         AC_CHECK_LIB([asound], [snd_pcm_open], [], [
662                 have_alsa="no"
663                 AC_MSG_WARN([no libasound $msg])
664         ])
665 fi
666
667 if test "$have_alsa" = "yes"; then
668         alsa_ldflags="-lasound"
669         AC_SUBST(alsa_ldflags)
670 fi
671
672 CPPFLAGS="$OLD_CPPFLAGS"
673 LDFLAGS="$OLD_LDFLAGS"
674 LIBS="$OLD_LIBS"
675 ########################################################################### libao
676 OLD_CPPFLAGS="$CPPFLAGS"
677 OLD_LDFLAGS="$LDFLAGS"
678 OLD_LIBS="$LIBS"
679
680 have_ao="yes"
681 AC_ARG_WITH(ao_headers, [AS_HELP_STRING(--with-ao-headers=dir,
682         [look for ao/ao.h also in dir])])
683 if test -n "$with_ao_headers"; then
684         ao_cppflags="-I$with_ao_headers"
685         CPPFLAGS="$CPPFLAGS $ao_cppflags"
686 fi
687 AC_ARG_WITH(ao_libs, [AS_HELP_STRING(--with-ao-libs=dir,
688         [look for libao also in dir])])
689 if test -n "$with_ao_libs"; then
690         ao_libs="-L$with_ao_libs"
691         LDFLAGS="$LDFLAGS $ao_libs"
692 fi
693 msg="no libao support for para_audiod/para_write"
694 AC_CHECK_HEADERS([ao/ao.h], [
695         ], [
696         have_ao="no"
697         AC_MSG_WARN([ao.h not found, $msg])
698 ])
699 if test "$have_ao" = "yes"; then
700         AC_CHECK_LIB([ao], [ao_initialize], [], [
701                 have_ao="no"
702                 AC_MSG_WARN([ao lib not found or not working, $msg])
703         ])
704 fi
705 if test "$have_ao" = "yes"; then
706         AC_CHECK_HEADERS([pthread.h], [
707                 ], [
708                 have_ao="no"
709                 AC_MSG_WARN([pthread.h not found, $msg])
710         ])
711 fi
712 if test "$have_ao" = "yes"; then
713         AC_CHECK_LIB([pthread], [pthread_create], [], [
714                 have_ao="no"
715                 AC_MSG_WARN([pthread lib not found or not working, $msg])
716         ])
717 fi
718 if test "$have_ao" = "yes"; then
719         AC_SUBST(ao_cppflags)
720         ao_ldflags="$ao_libs -lao -lpthread"
721         AC_SUBST(ao_ldflags)
722 fi
723
724 CPPFLAGS="$OLD_CPPFLAGS"
725 LDFLAGS="$OLD_LDFLAGS"
726 LIBS="$OLD_LIBS"
727 ############################################################# readline
728 OLD_CPPFLAGS="$CPPFLAGS"
729 OLD_LDFLAGS="$LDFLAGS"
730 OLD_LIBS="$LIBS"
731
732 have_readline="yes"
733 AC_ARG_WITH(readline_headers, [AS_HELP_STRING(--with-readline-headers=dir,
734         [look for libreadline header files also in dir])])
735 if test -n "$with_readline_headers"; then
736         readline_cppflags="-I$with_readline_headers"
737         CPPFLAGS="$CPPFLAGS $readline_cppflags"
738 fi
739
740 AC_ARG_WITH(readline_libs, [AS_HELP_STRING(--with-readline-libs=dir,
741         [look for readline library also in dir])])
742 if test -n "$with_readline_libs"; then
743         readline_libs="-L$with_readline_libs"
744         LDFLAGS="$LDFLAGS $readline_libs"
745 fi
746 msg="no interactive cli support"
747 AC_CHECK_HEADERS([readline/readline.h], [
748         ], [
749         have_readline="no"
750         AC_MSG_WARN([readline/readline.h not found, $msg])
751 ])
752
753 if test "$have_readline" = "yes"; then
754         readline_ldflags="$readline_libs"
755         AC_SEARCH_LIBS([rl_free_keymap], [readline], [
756                 readline_ldflags="$readline_ldflags -lreadline"
757         ], [have_readline="no"])
758         if test "$have_readline" = "no"; then # try with -lcurses
759                 # clear cache
760                 AC_MSG_NOTICE([trying again with -lcurses])
761                 unset ac_cv_search_rl_free_keymap 2> /dev/null
762                 AC_SEARCH_LIBS([rl_free_keymap], [readline], [
763                         have_readline=yes
764                         readline_ldflags="$readline_ldflags -lreadline -lcurses"
765                 ], [], [-lcurses])
766         fi
767         if test "$have_readline" = "no"; then # try with -ltermcap
768                 # clear cache
769                 AC_MSG_NOTICE([trying again with -ltermcap])
770                 unset ac_cv_search_rl_free_keymap 2> /dev/null
771                 AC_SEARCH_LIBS([rl_free_keymap], [readline], [
772                         have_readline=yes
773                         readline_ldflags="$readline_ldflags -lreadline -ltermcap"
774                 ], [], [-ltermcap])
775         fi
776 fi
777
778 if test "$have_readline" = "yes"; then
779         AC_CHECK_DECL(
780                 [rl_free_keymap],
781                 [AC_DEFINE(RL_FREE_KEYMAP_DECLARED, 1, readline >= 6.3)],
782                 [],
783                 [
784                         #include <stdio.h>
785                         #include <readline/readline.h>
786                 ]
787         )
788         AC_SUBST(readline_cppflags)
789         AC_SUBST(readline_ldflags)
790         AC_DEFINE(HAVE_READLINE, 1, define to 1 to turn on readline support)
791 else
792         AC_MSG_WARN([libreadline not found or unusable])
793 fi
794 CPPFLAGS="$OLD_CPPFLAGS"
795 LDFLAGS="$OLD_LDFLAGS"
796 LIBS="$OLD_LIBS"
797 ############################################################# libsamplerate
798 OLD_CPPFLAGS="$CPPFLAGS"
799 OLD_LDFLAGS="$LDFLAGS"
800 OLD_LIBS="$LIBS"
801
802 have_samplerate="yes"
803 AC_ARG_WITH(samplerate_headers, [AS_HELP_STRING(--with-samplerate-headers=dir,
804         [look for samplerate headers also in dir])])
805 if test -n "$with_samplerate_headers"; then
806         samplerate_cppflags="-I$with_samplerate_headers"
807         CPPFLAGS="$CPPFLAGS $samplerate_cppflags"
808 fi
809 AC_ARG_WITH(samplerate_libs, [AS_HELP_STRING(--with-samplerate-libs=dir,
810         [look for samplerate libs also in dir])])
811 if test -n "$with_samplerate_libs"; then
812         samplerate_libs="-L$with_samplerate_libs"
813         LDFLAGS="$LDFLAGS $samplerate_libs"
814 fi
815
816 AC_CHECK_HEADER(samplerate.h, [], have_samplerate=no)
817 AC_CHECK_LIB([samplerate], [src_process], [], have_samplerate=no, [])
818
819 if test "$have_samplerate" = "yes"; then
820         AC_SUBST(samplerate_cppflags)
821         samplerate_ldflags="$samplerate_libs -lsamplerate"
822         AC_SUBST(samplerate_ldflags)
823 else
824         AC_MSG_WARN([no resample support in para_audiod/para_filter])
825 fi
826 CPPFLAGS="$OLD_CPPFLAGS"
827 LDFLAGS="$OLD_LDFLAGS"
828 LIBS="$OLD_LIBS"
829 ######################################################################### server
830 if test \( "$have_openssl" = "yes" -o "$have_gcrypt" = "yes" \) \
831         -a "$have_osl" = "yes" ; then
832
833         build_server="yes"
834         executables="$executables server"
835         server_cmdline_objs="server"
836         server_errlist_objs="
837                 server
838                 afh_common
839                 mp3_afh
840                 vss
841                 command
842                 net
843                 string
844                 signal
845                 time
846                 daemon
847                 http_send
848                 close_on_fork
849                 mm
850                 crypt_common
851                 ipc
852                 dccp_send
853                 fd
854                 user_list
855                 chunk_queue
856                 afs
857                 aft
858                 mood
859                 score
860                 attribute
861                 blob
862                 playlist
863                 sched
864                 acl
865                 send_common
866                 udp_send
867                 color
868                 fec
869                 wma_afh
870                 wma_common
871                 sideband
872                 version
873                 ggo
874         "
875         if test "$have_openssl" = "yes"; then
876                 server_errlist_objs="$server_errlist_objs crypt"
877         fi
878         if test "$have_gcrypt" = "yes"; then
879                 server_errlist_objs="$server_errlist_objs gcrypt"
880         fi
881         if test "$have_vorbis" = "yes" || \
882                         test "$have_speex" = "yes" || \
883                         test "$have_opus" = "yes"; then
884                 server_errlist_objs="$server_errlist_objs ogg_afh_common"
885         fi
886         if test "$have_vorbis" = "yes"; then
887                 server_errlist_objs="$server_errlist_objs ogg_afh"
888         fi
889         if test "$have_speex" = "yes"; then
890                 server_errlist_objs="$server_errlist_objs spx_afh spx_common"
891         fi
892         if test "$have_opus" = "yes"; then
893                 server_errlist_objs="$server_errlist_objs opus_afh opus_common"
894         fi
895         if test "$have_faad" = "yes"; then
896                 server_errlist_objs="$server_errlist_objs aac_afh aac_common"
897         fi
898         if test "$have_flac" = "yes"; then
899                 server_errlist_objs="$server_errlist_objs flac_afh"
900         fi
901         server_objs="add_cmdline($server_cmdline_objs) $server_errlist_objs"
902         AC_SUBST(server_objs, add_dot_o($server_objs))
903         AC_DEFINE_UNQUOTED(INIT_SERVER_ERRLISTS,
904                 objlist_to_errlist($server_errlist_objs), errors used by para_server)
905 else
906         build_server="no"
907 fi
908 ############################################################# client
909 if test "$have_openssl" = "yes" -o "$have_gcrypt" = "yes"; then
910         build_client="yes"
911         executables="$executables client"
912         client_cmdline_objs="client"
913         client_errlist_objs="
914                 client
915                 net
916                 string
917                 fd
918                 sched
919                 stdin
920                 stdout
921                 time
922                 sideband
923                 client_common
924                 buffer_tree
925                 crypt_common
926                 version
927                 ggo
928         "
929         if test "$have_openssl" = "yes"; then
930                 client_errlist_objs="$client_errlist_objs crypt"
931         fi
932         if test "$have_gcrypt" = "yes"; then
933                 client_errlist_objs="$client_errlist_objs gcrypt"
934         fi
935         if test "$have_readline" = "yes"; then
936                 client_errlist_objs="$client_errlist_objs interactive"
937         fi
938         client_objs="add_cmdline($client_cmdline_objs) $client_errlist_objs"
939         AC_SUBST(client_objs, add_dot_o($client_objs))
940         AC_DEFINE_UNQUOTED(INIT_CLIENT_ERRLISTS,
941                 objlist_to_errlist($client_errlist_objs), errors used by para_client)
942 else
943         build_client="no"
944 fi
945 ############################################################# audiod
946 if test "$have_openssl" = "yes" -o "$have_gcrypt" = "yes"; then
947         build_audiod="yes"
948         executables="$executables audiod"
949         audiod_audio_formats="wma"
950         audiod_cmdline_objs="$audiod_cmdline_objs
951                 audiod
952                 compress_filter
953                 http_recv
954                 dccp_recv
955                 file_write
956                 client
957                 amp_filter
958                 udp_recv
959                 prebuffer_filter
960                 sync_filter
961         "
962         audiod_errlist_objs="$audiod_errlist_objs
963                 audiod
964                 signal
965                 string
966                 daemon
967                 stat
968                 net
969                 crypt_common
970                 sideband
971                 time
972                 grab_client
973                 filter_common
974                 wav_filter
975                 compress_filter
976                 amp_filter
977                 http_recv
978                 dccp_recv
979                 recv_common
980                 fd
981                 sched
982                 write_common
983                 file_write
984                 audiod_command
985                 fecdec_filter
986                 client_common
987                 ggo
988                 udp_recv
989                 color
990                 fec
991                 prebuffer_filter
992                 version
993                 bitstream
994                 imdct
995                 wma_common
996                 wmadec_filter
997                 buffer_tree
998                 sync_filter
999         "
1000         if test "$have_openssl" = "yes"; then
1001                 audiod_errlist_objs="$audiod_errlist_objs crypt"
1002         fi
1003         if test "$have_gcrypt" = "yes"; then
1004                 audiod_errlist_objs="$audiod_errlist_objs gcrypt"
1005         fi
1006         if test "$have_core_audio" = "yes"; then
1007                 audiod_errlist_objs="$audiod_errlist_objs osx_write ipc"
1008                 audiod_cmdline_objs="$audiod_cmdline_objs osx_write"
1009         fi
1010         if test "$have_vorbis" = "yes"; then
1011                 audiod_errlist_objs="$audiod_errlist_objs oggdec_filter"
1012                 audiod_audio_formats="$audiod_audio_formats ogg"
1013         fi
1014         if test "$have_speex" = "yes"; then
1015                 audiod_errlist_objs="$audiod_errlist_objs spxdec_filter spx_common"
1016                 audiod_audio_formats="$audiod_audio_formats spx"
1017         fi
1018         if test "$have_opus" = "yes"; then
1019                 audiod_errlist_objs="$audiod_errlist_objs opusdec_filter opus_common"
1020                 audiod_audio_formats="$audiod_audio_formats opus"
1021         fi
1022         if test "$have_faad" = "yes"; then
1023                 audiod_errlist_objs="$audiod_errlist_objs aacdec_filter aac_common"
1024                 audiod_audio_formats="$audiod_audio_formats aac"
1025         fi
1026         if test "$have_mad" = "yes"; then
1027                 audiod_audio_formats="$audiod_audio_formats mp3"
1028                 audiod_cmdline_objs="$audiod_cmdline_objs mp3dec_filter"
1029                 audiod_errlist_objs="$audiod_errlist_objs mp3dec_filter"
1030         fi
1031         if test "$have_flac" = "yes"; then
1032                 audiod_errlist_objs="$audiod_errlist_objs flacdec_filter"
1033                 audiod_audio_formats="$audiod_audio_formats flac"
1034         fi
1035         if test "$have_oss" = "yes"; then
1036                 audiod_errlist_objs="$audiod_errlist_objs oss_write"
1037                 audiod_cmdline_objs="$audiod_cmdline_objs oss_write"
1038         fi
1039         if test "$have_alsa" = "yes"; then
1040                 audiod_errlist_objs="$audiod_errlist_objs alsa_write"
1041                 audiod_cmdline_objs="$audiod_cmdline_objs alsa_write"
1042         fi
1043         if test "$have_ao" = "yes"; then
1044                 audiod_errlist_objs="$audiod_errlist_objs ao_write"
1045                 audiod_cmdline_objs="$audiod_cmdline_objs ao_write"
1046         fi
1047         if test "$have_samplerate" = "yes"; then
1048                 audiod_errlist_objs="$audiod_errlist_objs resample_filter check_wav"
1049                 audiod_cmdline_objs="$audiod_cmdline_objs resample_filter"
1050         fi
1051         audiod_objs="add_cmdline($audiod_cmdline_objs) $audiod_errlist_objs"
1052         AC_SUBST(audiod_objs, add_dot_o($audiod_objs))
1053         AC_DEFINE_UNQUOTED(INIT_AUDIOD_ERRLISTS, objlist_to_errlist($audiod_errlist_objs),
1054                 errors used by para_audiod)
1055
1056         enum="$(for i in $audiod_audio_formats; do printf "AUDIO_FORMAT_${i}, " | tr '[a-z]' '[A-Z]'; done)"
1057         AC_DEFINE_UNQUOTED(AUDIOD_AUDIO_FORMATS_ENUM, $enum NUM_AUDIO_FORMATS,
1058                 enum of audio formats supported by audiod)
1059         names="$(for i in $audiod_audio_formats; do printf \"$i\",' ' ; done)"
1060         AC_DEFINE_UNQUOTED(AUDIOD_AUDIO_FORMAT_ARRAY, $names, array of audio formats supported by audiod)
1061 else
1062         build_audiod="no"
1063 fi
1064 ########################################################################### fade
1065 if test "$have_oss" = "yes" -o "$have_alsa" = "yes"; then
1066         build_fade="yes"
1067         executables="$executables fade"
1068         fade_cmdline_objs="fade"
1069         fade_errlist_objs="fade exec string fd version ggo"
1070         if test "$have_oss" = "yes"; then
1071                 fade_errlist_objs="$fade_errlist_objs oss_mix"
1072                 mixers="${mixers}oss "
1073                 default_mixer="OSS_MIX"
1074         fi
1075         if test "$have_alsa" = "yes"; then
1076                 fade_errlist_objs="$fade_errlist_objs alsa_mix"
1077                 mixers="${mixers}alsa "
1078                 default_mixer="ALSA_MIX"
1079         fi
1080         fade_objs="add_cmdline($fade_cmdline_objs) $fade_errlist_objs"
1081         AC_SUBST(fade_objs, add_dot_o($fade_objs))
1082         AC_DEFINE_UNQUOTED(INIT_FADE_ERRLISTS,
1083                 objlist_to_errlist($fade_errlist_objs),
1084                 errors used by para_fade)
1085         enum="$(
1086                 for i in $mixers; do
1087                         printf "${i}_MIX, " | tr '[a-z]' '[A-Z]'
1088                 done
1089         )"
1090         AC_DEFINE_UNQUOTED(MIXER_ENUM, $enum NUM_SUPPORTED_MIXERS,
1091                 enum of supported mixers)
1092         AC_DEFINE_UNQUOTED(DEFAULT_MIXER, $default_mixer,
1093                 use this mixer if none was specified)
1094         names="$(for i in $mixers; do printf \"$i\",' ' ; done)"
1095         AC_DEFINE_UNQUOTED(MIXER_NAMES, $names, supported mixer names)
1096         inits="$(
1097                 for i in $mixers; do
1098                         printf 'extern void '$i'_mix_init(struct mixer *); '
1099                 done
1100         )"
1101         AC_DEFINE_UNQUOTED(DECLARE_MIXER_INITS, $inits,
1102                 init functions of the supported mixers)
1103         array="$(for i in $mixers; do printf '{.init = '$i'_mix_init},'; done)"
1104         AC_DEFINE_UNQUOTED(MIXER_ARRAY, $array, array of supported mixers)
1105 else
1106         build_fade="no"
1107         AC_MSG_WARN([no mixer support])
1108 fi
1109 ########################################################################### gui
1110 if test "$have_curses" = "yes"; then
1111         build_gui="yes"
1112         executables="$executables gui"
1113         gui_cmdline_objs="gui"
1114         gui_errlist_objs="
1115                 exec
1116                 signal
1117                 string
1118                 stat
1119                 ringbuffer
1120                 fd
1121                 gui
1122                 gui_theme
1123                 time
1124                 sched
1125                 version
1126                 ggo
1127         "
1128         gui_objs="add_cmdline($gui_cmdline_objs) $gui_errlist_objs"
1129         AC_SUBST(gui_objs, add_dot_o($gui_objs))
1130         AC_DEFINE_UNQUOTED(INIT_GUI_ERRLISTS,
1131                 objlist_to_errlist($gui_errlist_objs), errors used by para_gui)
1132 else
1133         build_gui="no"
1134         AC_MSG_WARN([no curses lib, cannot build para_gui])
1135 fi
1136 ######################################################################## filter
1137 filters="
1138         compress
1139         wav
1140         amp
1141         fecdec
1142         wmadec
1143         prebuffer
1144         sync
1145 "
1146 filter_errlist_objs="
1147         filter_common
1148         wav_filter
1149         compress_filter
1150         filter
1151         string
1152         stdin
1153         stdout
1154         sched
1155         fd
1156         amp_filter
1157         ggo
1158         fecdec_filter
1159         fec
1160         version
1161         prebuffer_filter
1162         time
1163         bitstream
1164         imdct
1165         wma_common
1166         wmadec_filter
1167         buffer_tree
1168         net
1169         sync_filter
1170 "
1171 filter_cmdline_objs="
1172         filter
1173         compress_filter
1174         amp_filter
1175         prebuffer_filter
1176         sync_filter
1177 "
1178
1179 if test "$have_vorbis" = "yes"; then
1180         filters="$filters oggdec"
1181         filter_errlist_objs="$filter_errlist_objs oggdec_filter"
1182 fi
1183 if test "$have_speex" = "yes"; then
1184         filters="$filters spxdec"
1185         filter_errlist_objs="$filter_errlist_objs spxdec_filter spx_common"
1186 fi
1187 if test "$have_opus" = "yes"; then
1188         filters="$filters opusdec"
1189         filter_errlist_objs="$filter_errlist_objs opusdec_filter opus_common"
1190 fi
1191 if test "$have_faad" = "yes"; then
1192         filter_errlist_objs="$filter_errlist_objs aacdec_filter aac_common"
1193         filters="$filters aacdec"
1194 fi
1195 if test "$have_mad" = "yes"; then
1196         filter_cmdline_objs="$filter_cmdline_objs mp3dec_filter"
1197         filter_errlist_objs="$filter_errlist_objs mp3dec_filter"
1198         filters="$filters mp3dec"
1199 fi
1200 if test "$have_flac" = "yes"; then
1201         filter_errlist_objs="$filter_errlist_objs flacdec_filter"
1202         filters="$filters flacdec"
1203 fi
1204 if test "$have_samplerate" = "yes"; then
1205         filter_errlist_objs="$filter_errlist_objs resample_filter check_wav"
1206         filter_cmdline_objs="$filter_cmdline_objs resample_filter"
1207         filters="$filters resample"
1208 fi
1209 filters="$(echo $filters)"
1210 AC_SUBST(filters)
1211 filter_objs="add_cmdline($filter_cmdline_objs) $filter_errlist_objs"
1212
1213 AC_SUBST(filter_objs, add_dot_o($filter_objs))
1214 AC_DEFINE_UNQUOTED(INIT_FILTER_ERRLISTS,
1215         objlist_to_errlist($filter_errlist_objs), errors used by para_filter)
1216
1217 enum="$(for i in $filters; do printf "${i}_FILTER, " | tr '[a-z]' '[A-Z]'; done)"
1218 AC_DEFINE_UNQUOTED(FILTER_ENUM, $enum NUM_SUPPORTED_FILTERS,
1219         enum of supported filters)
1220 inits="$(for i in $filters; do printf 'extern void '$i'_filter_init(struct filter *f); '; done)"
1221 AC_DEFINE_UNQUOTED(DECLARE_FILTER_INITS, $inits, init functions of the supported filters)
1222 array="$(for i in $filters; do printf '{.name = "'$i'", .init = '$i'_filter_init},'; done)"
1223 AC_DEFINE_UNQUOTED(FILTER_ARRAY, $array, array of supported filters)
1224 ########################################################################## recv
1225 recv_cmdline_objs="
1226         recv
1227         http_recv
1228         dccp_recv
1229         udp_recv
1230         afh_recv
1231 "
1232
1233 recv_errlist_objs="
1234         http_recv
1235         recv_common
1236         recv
1237         time
1238         string
1239         net
1240         dccp_recv
1241         fd
1242         sched
1243         stdout
1244         ggo
1245         udp_recv
1246         buffer_tree
1247         afh_recv
1248         afh_common
1249         wma_afh
1250         wma_common
1251         mp3_afh
1252         version
1253 "
1254 if test "$have_vorbis" = "yes" || \
1255                 test "$have_speex" = "yes" || \
1256                 test "$have_opus" = "yes"; then
1257         recv_errlist_objs="$recv_errlist_objs ogg_afh_common"
1258 fi
1259 if test "$have_vorbis" = "yes"; then
1260         recv_errlist_objs="$recv_errlist_objs ogg_afh"
1261 fi
1262 if test "$have_speex" = "yes"; then
1263         recv_errlist_objs="$recv_errlist_objs spx_afh spx_common"
1264 fi
1265 if test "$have_opus" = "yes"; then
1266         recv_errlist_objs="$recv_errlist_objs opus_afh opus_common"
1267 fi
1268 if test "$have_faad" = "yes"; then
1269         recv_errlist_objs="$recv_errlist_objs aac_afh aac_common"
1270 fi
1271 if test "$have_flac" = "yes"; then
1272         recv_errlist_objs="$recv_errlist_objs flac_afh"
1273 fi
1274 recv_objs="add_cmdline($recv_cmdline_objs) $recv_errlist_objs"
1275 AC_SUBST(receivers, "http dccp udp afh")
1276 AC_SUBST(recv_objs, add_dot_o($recv_objs))
1277 AC_DEFINE_UNQUOTED(INIT_RECV_ERRLISTS, objlist_to_errlist($recv_errlist_objs),
1278         errors used by para_recv)
1279 ########################################################################### afh
1280 audio_format_handlers="mp3 wma"
1281 afh_cmdline_objs="afh"
1282 afh_errlist_objs="
1283         afh
1284         string
1285         fd
1286         mp3_afh
1287         afh_common
1288         time
1289         wma_afh
1290         wma_common
1291         version
1292         ggo
1293 "
1294 if test "$have_vorbis" = "yes" || \
1295                 test "$have_speex" = "yes" || \
1296                 test "$have_opus" = "yes"; then
1297         afh_errlist_objs="$afh_errlist_objs ogg_afh_common"
1298 fi
1299 if test "$have_vorbis" = "yes"; then
1300         afh_errlist_objs="$afh_errlist_objs ogg_afh"
1301         audio_format_handlers="$audio_format_handlers ogg"
1302 fi
1303 if test "$have_speex" = "yes"; then
1304         afh_errlist_objs="$afh_errlist_objs spx_afh spx_common"
1305         audio_format_handlers="$audio_format_handlers spx"
1306 fi
1307 if test "$have_opus" = "yes"; then
1308         afh_errlist_objs="$afh_errlist_objs opus_afh opus_common"
1309         audio_format_handlers="$audio_format_handlers opus"
1310 fi
1311 if test "$have_faad" = "yes"; then
1312         afh_errlist_objs="$afh_errlist_objs aac_common aac_afh"
1313         audio_format_handlers="$audio_format_handlers aac"
1314 fi
1315 if test "$have_flac" = "yes"; then
1316         afh_errlist_objs="$afh_errlist_objs flac_afh"
1317         audio_format_handlers="$audio_format_handlers flac"
1318 fi
1319
1320 afh_objs="add_cmdline($afh_cmdline_objs) $afh_errlist_objs"
1321
1322 AC_SUBST(afh_objs, add_dot_o($afh_objs))
1323 AC_DEFINE_UNQUOTED(INIT_AFH_ERRLISTS,
1324         objlist_to_errlist($afh_errlist_objs), errors used by para_afh)
1325 ########################################################################## play
1326 play_errlist_objs="
1327         play
1328         fd
1329         sched
1330         ggo
1331         buffer_tree
1332         time
1333         string
1334         net
1335         afh_recv
1336         afh_common
1337         wma_afh
1338         wma_common
1339         mp3_afh
1340         recv_common
1341         udp_recv
1342         http_recv
1343         dccp_recv
1344         filter_common
1345         fec
1346         bitstream
1347         imdct
1348         wav_filter
1349         compress_filter
1350         amp_filter
1351         prebuffer_filter
1352         fecdec_filter
1353         wmadec_filter
1354         write_common
1355         file_write
1356         version
1357         sync_filter
1358 "
1359 play_cmdline_objs="
1360         http_recv
1361         dccp_recv
1362         udp_recv
1363         afh_recv
1364         compress_filter
1365         amp_filter
1366         prebuffer_filter
1367         file_write
1368         play
1369         sync_filter
1370 "
1371 if test "$have_core_audio" = "yes"; then
1372         play_errlist_objs="$play_errlist_objs osx_write ipc"
1373         play_cmdline_objs="$play_cmdline_objs osx_write"
1374 fi
1375 if test "$have_vorbis" = "yes" || \
1376                 test "$have_speex" = "yes" || \
1377                 test "$have_opus" = "yes"; then
1378         play_errlist_objs="$play_errlist_objs ogg_afh_common"
1379 fi
1380 if test "$have_vorbis" = "yes"; then
1381         play_errlist_objs="$play_errlist_objs oggdec_filter ogg_afh"
1382 fi
1383 if test "$have_speex" = "yes"; then
1384         play_errlist_objs="$play_errlist_objs spxdec_filter spx_afh spx_common"
1385 fi
1386 if test "$have_opus" = "yes"; then
1387         play_errlist_objs="$play_errlist_objs opusdec_filter opus_afh opus_common"
1388 fi
1389 if test "$have_faad" = "yes"; then
1390         play_errlist_objs="$play_errlist_objs aacdec_filter aac_afh aac_common"
1391 fi
1392 if test "$have_mad" = "yes"; then
1393         play_cmdline_objs="$play_cmdline_objs mp3dec_filter"
1394         play_errlist_objs="$play_errlist_objs mp3dec_filter"
1395 fi
1396 if test "$have_flac" = "yes"; then
1397         play_errlist_objs="$play_errlist_objs flacdec_filter flac_afh"
1398 fi
1399 if test "$have_oss" = "yes"; then
1400         play_errlist_objs="$play_errlist_objs oss_write"
1401         play_cmdline_objs="$play_cmdline_objs oss_write"
1402 fi
1403 if test "$have_alsa" = "yes"; then
1404         play_errlist_objs="$play_errlist_objs alsa_write"
1405         play_cmdline_objs="$play_cmdline_objs alsa_write"
1406 fi
1407 if test "$have_ao" = "yes"; then
1408         play_errlist_objs="$play_errlist_objs ao_write"
1409         play_cmdline_objs="$play_cmdline_objs ao_write"
1410 fi
1411 if test "$have_readline" = "yes"; then
1412         play_errlist_objs="$play_errlist_objs interactive"
1413 fi
1414 if test "$have_samplerate" = "yes"; then
1415         play_errlist_objs="$play_errlist_objs resample_filter check_wav"
1416         play_cmdline_objs="$play_cmdline_objs resample_filter"
1417 fi
1418
1419 play_objs="add_cmdline($play_cmdline_objs) $play_errlist_objs"
1420 AC_SUBST(play_objs, add_dot_o($play_objs))
1421 AC_DEFINE_UNQUOTED(INIT_PLAY_ERRLISTS,
1422         objlist_to_errlist($play_errlist_objs), errors used by para_play)
1423 ######################################################################### write
1424 write_cmdline_objs="
1425         write
1426         file_write
1427 "
1428 write_errlist_objs="
1429         write
1430         write_common
1431         file_write
1432         time
1433         fd
1434         string
1435         sched
1436         stdin
1437         buffer_tree
1438         ggo
1439         check_wav
1440         version
1441 "
1442 writers="file"
1443 default_writer="FILE_WRITE"
1444
1445 if test "$have_core_audio" = "yes"; then
1446         write_errlist_objs="$write_errlist_objs osx_write ipc"
1447         write_cmdline_objs="$write_cmdline_objs osx_write"
1448         writers="$writers osx"
1449         default_writer="OSX_WRITE"
1450 fi
1451 if test "$have_ao" = "yes"; then
1452         write_errlist_objs="$write_errlist_objs ao_write"
1453         write_cmdline_objs="$write_cmdline_objs ao_write"
1454         writers="$writers ao"
1455         default_writer="AO_WRITE"
1456 fi
1457 if test "$have_oss" = "yes"; then
1458         write_errlist_objs="$write_errlist_objs oss_write"
1459         write_cmdline_objs="$write_cmdline_objs oss_write"
1460         writers="$writers oss"
1461         default_writer="OSS_WRITE"
1462 fi
1463 if test "$have_alsa" = "yes"; then
1464         write_errlist_objs="$write_errlist_objs alsa_write"
1465         write_cmdline_objs="$write_cmdline_objs alsa_write"
1466         writers="$writers alsa"
1467         default_writer="ALSA_WRITE"
1468 fi
1469 AC_SUBST(writers)
1470 write_objs="add_cmdline($write_cmdline_objs) $write_errlist_objs"
1471 AC_SUBST(write_objs, add_dot_o($write_objs))
1472 AC_DEFINE_UNQUOTED(INIT_WRITE_ERRLISTS,
1473         objlist_to_errlist($write_errlist_objs), errors used by para_write)
1474 enum="$(for i in $writers; do printf "${i}_WRITE, " | tr '[a-z]' '[A-Z]'; done)"
1475 AC_DEFINE_UNQUOTED(WRITER_ENUM, $enum NUM_SUPPORTED_WRITERS,
1476         enum of supported writers)
1477 AC_DEFINE_UNQUOTED(DEFAULT_WRITER, $default_writer, use this writer if none was specified)
1478 names="$(for i in $writers; do printf \"$i\",' ' ; done)"
1479 AC_DEFINE_UNQUOTED(WRITER_NAMES, $names, supported writer names)
1480 inits="$(for i in $writers; do printf 'extern void '$i'_write_init(struct writer *); '; done)"
1481 AC_DEFINE_UNQUOTED(DECLARE_WRITER_INITS, $inits, init functions of the supported writers)
1482 array="$(for i in $writers; do printf '{.init = '$i'_write_init},'; done)"
1483 AC_DEFINE_UNQUOTED(WRITER_ARRAY, $array, array of supported writers)
1484 ######################################################################## audioc
1485 audioc_cmdline_objs="audioc"
1486 audioc_errlist_objs="
1487         audioc
1488         string
1489         net
1490         fd
1491         version
1492         ggo
1493 "
1494 if test "$have_readline" = "yes"; then
1495         audioc_errlist_objs="$audioc_errlist_objs
1496                 buffer_tree
1497                 interactive
1498                 sched
1499                 time
1500         "
1501 fi
1502 audioc_objs="add_cmdline($audioc_cmdline_objs) $audioc_errlist_objs"
1503 AC_SUBST(audioc_objs, add_dot_o($audioc_objs))
1504 AC_DEFINE_UNQUOTED(INIT_AUDIOC_ERRLISTS,
1505         objlist_to_errlist($audioc_errlist_objs), errors used by para_audioc)
1506 ############################################################# error2.h
1507 # these are always built
1508 all_errlist_objs="
1509         $recv_errlist_objs
1510         $filter_errlist_objs
1511         $audioc_errlist_objs
1512         $write_errlist_objs
1513         $afh_errlist_objs
1514         $play_errlist_objs
1515 "
1516
1517 # optional executables
1518 if test "$build_server" = "yes"; then
1519         all_errlist_objs="$all_errlist_objs $server_errlist_objs"
1520 fi
1521 if test "$build_gui" = "yes"; then
1522         all_errlist_objs="$all_errlist_objs $gui_errlist_objs"
1523 fi
1524 if test "$build_fade" = "yes"; then
1525         all_errlist_objs="$all_errlist_objs $fade_errlist_objs"
1526 fi
1527 if test "$build_client" = "yes"; then
1528         all_errlist_objs="$all_errlist_objs $client_errlist_objs"
1529 fi
1530 if test "$build_audiod" = "yes"; then
1531         all_errlist_objs="$all_errlist_objs $audiod_errlist_objs"
1532 fi
1533
1534 all_errlist_objs="$(echo $all_errlist_objs | tr ' ' '\n' | sort | uniq)"
1535
1536 object_executable_matrix=
1537 for i in $executables; do
1538         eval objs=\$${i}_errlist_objs
1539         object_executable_matrix="$object_executable_matrix $i: $objs"
1540 done
1541 # use echo to replace newlines by space
1542 AC_SUBST(object_executable_matrix, $(echo $object_executable_matrix))
1543
1544 for obj in $all_errlist_objs; do
1545         SS="$SS SS_$(echo $obj | tr 'a-z' 'A-Z'),"
1546 done
1547 AC_DEFINE_UNQUOTED(DEFINE_ERRLIST_OBJECT_ENUM,
1548         [enum {$SS NUM_SS}],
1549         [list of all objects that use the paraslash error facility]
1550 )
1551 ################################################################## status items
1552
1553 status_items="basename status num_played mtime bitrate frequency file_size
1554 status_flags format score techinfo afs_mode
1555 attributes_txt decoder_flags audiod_status play_time attributes_bitmap
1556 offset seconds_total stream_start current_time audiod_uptime image_id
1557 lyrics_id duration directory lyrics_name image_name path hash channels
1558 last_played num_chunks chunk_time amplification artist title year album
1559 comment"
1560
1561 result=
1562 for i in $status_items; do
1563         result="$result SI_$(echo $i | tr 'a-z' 'A-Z'), "
1564 done
1565 AC_DEFINE_UNQUOTED(STATUS_ITEM_ENUM, [$result],
1566         [enum of all status items])
1567
1568 result=
1569 for i in $status_items; do
1570         result="$result \"$i\", "
1571 done
1572 AC_DEFINE_UNQUOTED(STATUS_ITEM_ARRAY, [$result],
1573         [char * array of all status items])
1574
1575 AC_DEFINE_UNQUOTED(AUDIO_FORMAT_HANDLERS, "$audio_format_handlers",
1576         [formats supported by para_server and para_afh])
1577
1578 AC_SUBST(executables)
1579
1580 AC_OUTPUT
1581 AC_MSG_NOTICE([
1582 paraslash configuration:
1583 ~~~~~~~~~~~~~~~~~~~~~~~~
1584 unix socket credentials: $have_ucred
1585 readline (interactive CLIs): $have_readline
1586 audio formats handlers: $audio_format_handlers
1587 id3 version2 support: $have_libid3tag
1588 filters: $filters
1589 writers: $writers
1590
1591 para_fade: $build_fade
1592 para_server: $build_server
1593 para_gui: $build_gui
1594 para_fade: $build_fade
1595 para_client: $build_client
1596 para_audiod: $build_audiod
1597 ])