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