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