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