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