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