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