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