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