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