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