Merge branch 't/utf8'
[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
7 AC_INIT([paraslash],[git],[maan@systemlinux.org])
8 AC_CONFIG_HEADER([config.h])
9
10 AC_CONFIG_FILES([Makefile])
11 AC_DEFUN([add_dot_o],[$(for i in $@; do printf "$i.o "; done)])
12 AC_DEFUN([add_para],[$(for i in $@; do printf "para_$i "; done)])
13 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) }])
14 AC_PATH_PROG(UNAMEPATH, uname, no)
15 if test "$UNAMEPATH" = "no"; then
16 AC_MSG_ERROR(unable to determine system type)
17 fi
18 AC_MSG_CHECKING(os type)
19 OSTYPE="`$UNAMEPATH -s`"
20 AC_MSG_RESULT("$OSTYPE")
21
22 if test "$OSTYPE" = "SunOS"; then
23 # needed on SunOS for socket magic
24 arch_cppflags="-D_XOPEN_SOURCE=500 -D__EXTENSIONS__"
25 AC_SUBST(arch_cppflags)
26 fi
27
28 AC_C_BIGENDIAN()
29
30 AC_PATH_PROG([gengetopt], [gengetopt])
31 test -z "$gengetopt" && AC_MSG_ERROR(
32 [gengetopt is required to build this package])
33
34 AC_PATH_PROG([help2man], [help2man])
35 test -z "$help2man" && AC_MSG_ERROR(
36 [help2man is required to build this package])
37
38 AC_PROG_CC
39 AC_PROG_CPP
40 AC_PROG_INSTALL
41 AC_SUBST(install_sh, [$INSTALL])
42 AC_REPLACE_FNMATCH
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_MALLOC
77 AC_FUNC_MEMCMP
78 AC_FUNC_MKTIME
79 AC_FUNC_MMAP
80 AC_FUNC_REALLOC
81 AC_FUNC_SELECT_ARGTYPES
82 AC_FUNC_STAT
83 AC_FUNC_STRFTIME
84 AC_FUNC_VPRINTF
85 AC_FUNC_CLOSEDIR_VOID
86 AC_FUNC_LSTAT
87
88 AC_CHECK_FUNCS([atexit dup2 memchr memmove memset \
89 regcomp select strchr strdup strerror strstr strtol uname \
90 fchdir gettimeofday localtime_r munmap strcasecmp strcspn \
91 strncasecmp strrchr strspn alarm mkdir inet_ntoa socket], [],
92 [AC_MSG_ERROR([function not found, cannot live without it])])
93
94 AC_DEFUN([add_cmdline],[$(for i in $@; do printf "${i}.cmdline "; done)])
95
96
97 all_errlist_objs="mp3_afh afh_common net string signal time daemon
98 stat afh amp_filter fd ringbuffer sched audiod
99 grab_client filter_common wav_filter compress_filter http_recv
100 dccp_recv recv_common write_common file_write audiod_command
101 client_common recv stdout filter stdin audioc write client
102 exec send_common ggo udp_recv color fec fecdec_filter
103 prebuffer_filter bitstream imdct check_wav
104 wma_afh wma_common wmadec_filter buffer_tree crypt_common
105 gui gui_theme sideband afh_recv play"
106
107 executables="recv filter audioc write client afh audiod play"
108
109 recv_cmdline_objs="add_cmdline(recv http_recv dccp_recv udp_recv afh_recv)"
110
111 recv_errlist_objs="
112 http_recv recv_common recv time string net dccp_recv fd
113 sched stdout ggo udp_recv buffer_tree afh_recv afh_common
114 wma_afh wma_common mp3_afh
115 "
116
117 recv_ldflags=""
118
119 filter_cmdline_objs="add_cmdline(filter compress_filter amp_filter prebuffer_filter)"
120 filter_errlist_objs="filter_common wav_filter compress_filter filter string
121 stdin stdout sched fd amp_filter ggo fecdec_filter fec
122 prebuffer_filter time bitstream imdct wma_common wmadec_filter buffer_tree"
123 filter_ldflags="-lm"
124 filters=" compress wav amp fecdec wmadec prebuffer"
125
126 audioc_cmdline_objs="add_cmdline(audioc)"
127 audioc_errlist_objs="audioc string net fd"
128 audioc_ldflags=""
129
130 audiod_cmdline_objs="add_cmdline(audiod compress_filter http_recv dccp_recv file_write client amp_filter udp_recv prebuffer_filter)"
131 audiod_errlist_objs="audiod signal string daemon stat net crypt_common sideband
132 time grab_client filter_common wav_filter compress_filter amp_filter http_recv dccp_recv
133 recv_common fd sched write_common file_write audiod_command fecdec_filter
134 client_common ggo udp_recv color fec prebuffer_filter
135 bitstream imdct wma_common wmadec_filter buffer_tree"
136 audiod_ldflags="-lm"
137 audiod_audio_formats="wma"
138
139 afh_cmdline_objs="add_cmdline(afh)"
140 afh_errlist_objs="afh string fd mp3_afh afh_common time wma_afh wma_common"
141 afh_ldflags=""
142
143 write_cmdline_objs="add_cmdline(write file_write)"
144 write_errlist_objs="write write_common file_write time fd string sched stdin
145 buffer_tree ggo check_wav"
146 write_ldflags=""
147 writers=" file"
148 default_writer="FILE_WRITE"
149
150 client_cmdline_objs="add_cmdline(client)"
151 client_errlist_objs="client net string fd sched stdin stdout time sideband
152 client_common buffer_tree crypt_common"
153 client_ldflags=""
154
155 gui_cmdline_objs="add_cmdline(gui)"
156 gui_errlist_objs="exec signal string stat ringbuffer fd gui gui_theme"
157 gui_objs="$gui_cmdline_objs $gui_errlist_objs"
158 play_errlist_objs="play fd sched ggo buffer_tree time string net
159 afh_recv afh_common
160 wma_afh wma_common mp3_afh
161 recv_common udp_recv http_recv dccp_recv
162 filter_common fec bitstream imdct
163 wav_filter compress_filter amp_filter prebuffer_filter fecdec_filter
164 wmadec_filter
165 write_common file_write
166 "
167 play_cmdline_objs="add_cmdline(http_recv dccp_recv udp_recv afh_recv compress_filter amp_filter prebuffer_filter file_write play)"
168 play_ldflags="-lm"
169 ########################################################################### snprintf
170 # ===========================================================================
171 # http://www.nongnu.org/autoconf-archive/ax_func_snprintf.html
172 # ===========================================================================
173 #
174 # SYNOPSIS
175 #
176 # AX_FUNC_SNPRINTF
177 #
178 # DESCRIPTION
179 #
180 # Checks for a fully C99 compliant snprintf, in particular checks whether
181 # it does bounds checking and returns the correct string length; does the
182 # same check for vsnprintf. If no working snprintf or vsnprintf is found,
183 # it prints an error message and aborts.
184 #
185 # LICENSE
186 #
187 # Copyright (c) 2008 Ruediger Kuhlmann <info@ruediger-kuhlmann.de>
188 #
189 # Copying and distribution of this file, with or without modification, are
190 # permitted in any medium without royalty provided the copyright notice
191 # and this notice are preserved.
192
193 AU_ALIAS([AC_FUNC_SNPRINTF], [AX_FUNC_SNPRINTF])
194 AC_DEFUN([AX_FUNC_SNPRINTF],
195 [AC_CHECK_FUNCS(snprintf vsnprintf)
196 AC_MSG_CHECKING(for working snprintf)
197 AC_CACHE_VAL(ac_cv_have_working_snprintf,
198 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
199 #include <stdio.h>
200
201 int main(void)
202 {
203 char bufs[5] = { 'x', 'x', 'x', '\0', '\0' };
204 char bufd[5] = { 'x', 'x', 'x', '\0', '\0' };
205 int i;
206 i = snprintf (bufs, 2, "%s", "111");
207 if (strcmp (bufs, "1")) exit (1);
208 if (i != 3) exit (1);
209 i = snprintf (bufd, 2, "%d", 111);
210 if (strcmp (bufd, "1")) exit (1);
211 if (i != 3) exit (1);
212 exit(0);
213 }]])],[ac_cv_have_working_snprintf=yes],
214 [ac_cv_have_working_snprintf=no],[ac_cv_have_working_snprintf=cross])])
215 AC_MSG_RESULT([$ac_cv_have_working_snprintf])
216 AC_MSG_CHECKING(for working vsnprintf)
217 AC_CACHE_VAL(ac_cv_have_working_vsnprintf,
218 [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdio.h>
219 #include <stdarg.h>
220
221 int my_vsnprintf (char *buf, const char *tmpl, ...)
222 {
223 int i;
224 va_list args;
225 va_start (args, tmpl);
226 i = vsnprintf (buf, 2, tmpl, args);
227 va_end (args);
228 return i;
229 }
230
231 int main(void)
232 {
233 char bufs[5] = { 'x', 'x', 'x', '\0', '\0' };
234 char bufd[5] = { 'x', 'x', 'x', '\0', '\0' };
235 int i;
236 i = my_vsnprintf (bufs, "%s", "111");
237 if (strcmp (bufs, "1")) exit (1);
238 if (i != 3) exit (1);
239 i = my_vsnprintf (bufd, "%d", 111);
240 if (strcmp (bufd, "1")) exit (1);
241 if (i != 3) exit (1);
242 exit(0);
243 }]])],[ac_cv_have_working_vsnprintf=yes],
244 [ac_cv_have_working_vsnprintf=no],[ac_cv_have_working_vsnprintf=cross])])
245 AC_MSG_RESULT([$ac_cv_have_working_vsnprintf])
246 if test x$ac_cv_have_working_snprintf$ac_cv_have_working_vsnprintf != "xyesyes"; then
247 AC_MSG_ERROR([fatal: buggy snprintf() detected])
248 fi])
249 AX_FUNC_SNPRINTF()
250 ########################################################################### osl
251 have_osl=yes
252 OLD_CPPFLAGS="$CPPFLAGS"
253 OLD_LD_FLAGS="$LDFLAGS"
254 OLD_LIBS="$LIBS"
255 AC_ARG_WITH(osl_headers, [AS_HELP_STRING(--with-osl-headers=dir,
256 [look for osl.h also in dir])])
257 if test -n "$with_osl_headers"; then
258 osl_cppflags="-I$with_osl_headers"
259 CPPFLAGS="$CPPFLAGS $osl_cppflags"
260 fi
261 AC_ARG_WITH(osl_libs, [AS_HELP_STRING(--with-osl-libs=dir,
262 [look for libosl also in dir])])
263 if test -n "$with_osl_libs"; then
264 osl_libs="-L$with_osl_libs"
265 LDFLAGS="$LDFLAGS $osl_libs"
266 fi
267
268 AC_CHECK_HEADER(osl.h, [], have_osl=no)
269 AC_CHECK_LIB([osl], [osl_open_table], [], have_osl=no)
270 if test "$have_osl" = "no"; then
271 AC_MSG_WARN([libosl not found, can not build para_server.
272 Download libosl at
273 http://systemlinux.org/~maan/osl
274 or execute
275 git clone git://git.tuebingen.mpg.de/osl
276 ])
277 else
278 extras="$extras server"
279 executables="$executables server"
280 server_cmdline_objs="add_cmdline(server)"
281 server_errlist_objs="server afh_common mp3_afh vss command net
282 string signal time daemon http_send close_on_fork mm
283 crypt_common ipc dccp_send fd user_list chunk_queue
284 afs aft mood score attribute blob playlist sched acl
285 send_common udp_send color fec wma_afh wma_common sideband"
286 all_errlist_objs="$all_errlist_objs server vss command
287 http_send close_on_fork mm ipc dccp_send user_list
288 chunk_queue afs aft mood score attribute blob playlist
289 acl udp_send"
290
291 server_ldflags=""
292 audio_format_handlers="mp3 wma"
293 AC_SUBST(osl_cppflags)
294 server_ldflags="$server_ldflags $osl_libs -losl"
295 fi
296 CPPFLAGS="$OLD_CPPFLAGS"
297 LDFLAGS="$OLD_LDFLAGS"
298 LIBS="$OLD_LIBS"
299 ########################################################################### crypto
300 AC_ARG_ENABLE(cryptolib, [AS_HELP_STRING(--enable-cryptolib=lib, [
301 Force using crypto library "lib". This package requires either
302 openssl or libgcrypt being installed. Possible values for "lib"
303 are thus "openssl" and "gcrypt". If this option is not given,
304 openssl is tried first. If openssl was not found, gcrypt is
305 tried next.])])
306
307 case "$enable_cryptolib" in
308 "openssl") check_openssl="yes"; check_gcrypt="no";;
309 "gcrypt") check_openssl="no"; check_gcrypt="yes";;
310 "") check_openssl="yes"; check_gcrypt="yes";;
311 *) AC_MSG_ERROR([invalid value "$enable_cryptolib" for --enable-cryptolib]);;
312 esac
313 ###################################################################### openssl
314 if test "$check_openssl" = "yes"; then
315 OLD_CPPFLAGS="$CPPFLAGS"
316 OLD_LD_FLAGS="$LDFLAGS"
317 OLD_LIBS="$LIBS"
318 have_openssl="yes"
319 AC_ARG_WITH(openssl_headers, [AS_HELP_STRING(--with-openssl-headers=dir,
320 [look for openssl headers also in dir])])
321 if test -n "$with_openssl_headers"; then
322 openssl_cppflags="-I$with_openssl_headers"
323 CPPFLAGS="$CPPFLAGS $openssl_cppflags"
324 fi
325 AC_ARG_WITH(openssl_libs, [AS_HELP_STRING(--with-openssl-libs=dir,
326 [look for openssl libraries also in dir])])
327 if test -n "$with_openssl_libs"; then
328 openssl_libs="-L$with_openssl_libs"
329 LDFLAGS="$LDFLAGS $openssl_libs"
330 fi
331 AC_CHECK_HEADER(openssl/ssl.h, [], [have_openssl="no"])
332 AC_CHECK_LIB([crypto], [RAND_bytes], [], [have_openssl="no"])
333 if test "$have_openssl" = "no" -a -z "$with_openssl_headers$with_openssl_libs"; then
334 # try harder: openssl is sometimes installed in /usr/local/ssl
335 openssl_cppflags="-I/usr/local/ssl/include"
336 CPPFLAGS="$CPPFLAGS $openssl_cppflags"
337 openssl_libs="-L/usr/local/ssl/lib"
338 LDFLAGS="$LDFLAGS $openssl_libs"
339 # clear cache
340 unset ac_cv_header_openssl_ssl_h 2> /dev/null
341 unset ac_cv_lib_crypto_RAND_bytes 2> /dev/null
342 AC_CHECK_HEADER(openssl/ssl.h, [have_openssl="yes"], [])
343 if test "$have_openssl" = "yes"; then
344 AC_CHECK_LIB([crypto], [RAND_bytes], [], [have_openssl="no"])
345 fi
346 fi
347 if test "$have_openssl" = "yes"; then
348 AC_DEFINE(HAVE_OPENSSL, 1, [define to 1 to turn on openssl support])
349 AC_SUBST(openssl_cppflags)
350 openssl_libs="$openssl_libs -lssl -lcrypto"
351 server_ldflags="$server_ldflags $openssl_libs"
352 client_ldflags="$client_ldflags $openssl_libs"
353 audiod_ldflags="$audiod_ldflags $openssl_libs"
354
355 all_errlist_objs="$all_errlist_objs crypt"
356 server_errlist_objs="$server_errlist_objs crypt"
357 client_errlist_objs="$client_errlist_objs crypt"
358 audiod_errlist_objs="$audiod_errlist_objs crypt"
359
360 check_gcrypt="no"
361 else
362 AC_MSG_WARN([openssl libraries not found])
363 fi
364 CPPFLAGS="$OLD_CPPFLAGS"
365 LDFLAGS="$OLD_LDFLAGS"
366 LIBS="$OLD_LIBS"
367 else
368 have_openssl="no"
369 fi
370 ########################################################################### gcrypt
371 if test "$check_gcrypt" = "yes"; then
372 OLD_CPPFLAGS="$CPPFLAGS"
373 OLD_LD_FLAGS="$LDFLAGS"
374 OLD_LIBS="$LIBS"
375 have_gcrypt="yes"
376 AC_ARG_WITH(gcrypt_headers, [AS_HELP_STRING(--with-gcrypt-headers=dir,
377 [look for gcrypt headers also in dir])])
378 if test -n "$with_gcrypt_headers"; then
379 gcrypt_cppflags="-I$with_gcrypt_headers"
380 CPPFLAGS="$CPPFLAGS $gcrypt_cppflags"
381 fi
382 AC_ARG_WITH(gcrypt_libs, [AS_HELP_STRING(--with-gcrypt-libs=dir,
383 [look for libgcrypt also in dir])])
384 if test -n "$with_gcrypt_libs"; then
385 gcrypt_libs="-L$with_gcrypt_libs"
386 LDFLAGS="$LDFLAGS $gcrypt_libs"
387 fi
388 AC_CHECK_HEADER(gcrypt.h, [], [have_gcrypt="no"])
389 AC_CHECK_LIB([gcrypt], [gcry_randomize], [], [have_gcrypt="no"])
390 if test "$have_gcrypt" = "yes"; then
391 AC_DEFINE(HAVE_GCRYPT, 1, [define to 1 to turn on gcrypt support])
392 AC_SUBST(gcrypt_cppflags)
393 gcrypt_libs="$gcrypt_libs -lgcrypt"
394 server_ldflags="$server_ldflags $gcrypt_libs"
395 client_ldflags="$client_ldflags $gcrypt_libs"
396 audiod_ldflags="$audiod_ldflags $gcrypt_libs"
397
398 all_errlist_objs="$all_errlist_objs gcrypt"
399 server_errlist_objs="$server_errlist_objs gcrypt"
400 client_errlist_objs="$client_errlist_objs gcrypt"
401 audiod_errlist_objs="$audiod_errlist_objs gcrypt"
402 else
403 AC_MSG_WARN([gcrypt library not found])
404 fi
405 CPPFLAGS="$OLD_CPPFLAGS"
406 LDFLAGS="$OLD_LDFLAGS"
407 LIBS="$OLD_LIBS"
408 else
409 have_gcrypt="no"
410 fi
411 ###########################################################################
412 if test "$have_openssl" = "no" -a "$have_gcrypt" = "no"; then
413 AC_MSG_ERROR([neither openssl nor gcrypt usable])
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
454 ########################################################################### curses
455 have_curses="yes"
456 OLD_CPPFLAGS="$CPPFLAGS"
457 OLD_LD_FLAGS="$LDFLAGS"
458 OLD_LIBS="$LIBS"
459 AC_ARG_WITH(curses_headers, [AS_HELP_STRING(--with-curses-headers=dir,
460 [look for curses.h also in dir])])
461 if test -n "$with_curses_headers"; then
462 curses_cppflags="-I$with_curses_headers"
463 CPPFLAGS="$CPPFLAGS $curses_cppflags"
464 fi
465 AC_ARG_WITH(curses_libs, [AS_HELP_STRING(--with-curses-libs=dir,
466 [look for libcurses also in dir])])
467 if test -n "$with_curses_libs"; then
468 curses_libs="-L$with_curses_libs"
469 LDFLAGS="$LDFLAGS $curses_libs"
470 fi
471 AC_CHECK_HEADER(curses.h, [], [
472 have_curses="no"
473 ])
474 gui_ldflags="$curses_libs"
475 AC_CHECK_LIB([ncursesw], [initscr],
476 [gui_ldflags="$curses_libs -lncursesw"], [
477 AC_CHECK_LIB([curses], [initscr],
478 [gui_ldflags="$curses_libs -lcurses"],
479 [have_curses="no"]
480 )
481 ]
482 )
483 if test "$have_curses" = "yes"; then
484 AC_SUBST(curses_cppflags)
485 extras="$extras gui"
486 executables="$executables gui"
487 else
488 AC_MSG_WARN([no curses lib, cannot build para_gui])
489 fi
490 CPPFLAGS="$OLD_CPPFLAGS"
491 LDFLAGS="$OLD_LDFLAGS"
492 LIBS="$OLD_LIBS"
493
494 ########################################################################### ip_mreqn
495 AC_MSG_CHECKING(for struct ip_mreqn (UDPv4 multicast))
496 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
497 #include <netdb.h>
498 #include <net/if.h>
499 ]], [[
500 struct ip_mreqn mn;
501 mn.imr_ifindex = 0;
502 ]])],[have_ip_mreqn=yes],[have_ip_mreqn=no])
503 AC_MSG_RESULT($have_ip_mreqn)
504 if test ${have_ip_mreqn} = yes; then
505 AC_DEFINE(HAVE_IP_MREQN, 1, define to 1 you have struct ip_mreqn)
506 fi
507 ########################################################################### osx
508
509 AC_MSG_CHECKING(for CoreAudio (MacOs))
510 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
511 #include <CoreAudio/CoreAudio.h>
512 ]], [[
513 AudioDeviceID id;
514 ]])],[have_core_audio=yes],[have_core_audio=no])
515 AC_MSG_RESULT($have_core_audio)
516 if test ${have_core_audio} = yes; then
517 f1="-framework CoreAudio"
518 f2="-framework AudioToolbox"
519 f3="-framework AudioUnit"
520 f4="-framework CoreServices"
521 f="$f1 $f2 $f3 $f4"
522
523 all_errlist_objs="$all_errlist_objs osx_write"
524 # ipc is linked into para_server server and into the osx writer. If osl
525 # was not found, para_server will not be built and ipc has not yet been
526 # added to the list of all objects, so we must add it here.
527 if test "$have_osl" = "no"; then
528 all_errlist_objs="$all_errlist_objs ipc"
529 fi
530 audiod_errlist_objs="$audiod_errlist_objs osx_write ipc"
531 audiod_cmdline_objs="$audiod_cmdline_objs osx_write.cmdline"
532 audiod_ldflags="$audiod_ldflags $f"
533
534 play_errlist_objs="$play_errlist_objs osx_write ipc"
535 play_cmdline_objs="$play_cmdline_objs osx_write.cmdline"
536 play_ldflags="$play_ldflags $f"
537
538 write_errlist_objs="$write_errlist_objs osx_write ipc"
539 write_cmdline_objs="$write_cmdline_objs osx_write.cmdline"
540 write_ldflags="$write_ldflags $f"
541 writers="$writers osx"
542 default_writer="OSX_WRITE"
543 AC_DEFINE(HAVE_CORE_AUDIO, 1, define to 1 on Mac Os X)
544 fi
545 ########################################################### ogg/vorbis/speex
546 have_ogg="yes"
547 OLD_CPPFLAGS="$CPPFLAGS"
548 OLD_LD_FLAGS="$LDFLAGS"
549 OLD_LIBS="$LIBS"
550 AC_ARG_WITH(ogg_headers, [AS_HELP_STRING(--with-ogg-headers=dir,
551 [look for ogg headers also in dir])])
552 AC_ARG_WITH(ogg_libs, [AS_HELP_STRING(--with-ogg-libs=dir,
553 [look for ogg libs also in dir])])
554 AC_ARG_WITH(vorbis_headers, [AS_HELP_STRING(--with-vorbis-headers=dir,
555 [look for vorbis headers also in dir])])
556 AC_ARG_WITH(vorbis_libs, [AS_HELP_STRING(--with-vorbis-libs=dir,
557 [look for vorbis libs also in dir])])
558 AC_ARG_WITH(speex_headers, [AS_HELP_STRING(--with-speex-headers=dir,
559 [look for speex headers also in dir])])
560 AC_ARG_WITH(speex_libs, [AS_HELP_STRING(--with-speex-libs=dir,
561 [look for speex libs also in dir])])
562
563 if test -n "$with_ogg_headers"; then
564 ogg_cppflags="-I$with_ogg_headers"
565 CPPFLAGS="$CPPFLAGS $ogg_cppflags"
566 fi
567 if test -n "$with_ogg_libs"; then
568 ogg_libs="-L$with_ogg_libs"
569 LDFLAGS="$LDFLAGS $ogg_libs"
570 fi
571 AC_CHECK_HEADERS([ogg/ogg.h], [], [ have_ogg="no"; ])
572 AC_CHECK_LIB([ogg], [ogg_stream_init], [], [ have_ogg="no" ])
573
574 have_vorbis="yes"
575 have_speex="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 else
601 AC_MSG_WARN([vorbis/speex depend on libogg, which was not detected])
602 have_vorbis="no"
603 have_speex="no"
604 fi
605
606 msg="support in para_server/para_filter/para_afh"
607 if test "$have_vorbis" = "yes" || test "$have_speex" = "yes"; then
608 AC_SUBST(ogg_cppflags)
609 ogg_libs="$ogg_libs -logg"
610 if test "$OSTYPE" = "Darwin"; then
611 ogg_libs="-Wl,-bind_at_load $ogg_libs"
612 fi
613 server_ldflags="$server_ldflags $ogg_libs"
614 filter_ldflags="$filter_ldflags $ogg_libs"
615 audiod_ldflags="$audiod_ldflags $ogg_libs"
616 play_ldflags="$play_ldflags $ogg_libs"
617 afh_ldflags="$afh_ldflags $ogg_libs"
618 recv_ldflags="$recv_ldflags $ogg_libs"
619 all_errlist_objs="$all_errlist_objs ogg_afh_common"
620 afh_errlist_objs="$afh_errlist_objs ogg_afh_common"
621 recv_errlist_objs="$recv_errlist_objs ogg_afh_common"
622 server_errlist_objs="$server_errlist_objs ogg_afh_common"
623 play_errlist_objs="$play_errlist_objs ogg_afh_common"
624 fi
625 if test "$have_vorbis" = "yes"; then
626 all_errlist_objs="$all_errlist_objs oggdec_filter ogg_afh"
627 AC_DEFINE(HAVE_OGGVORBIS, 1, define to 1 to turn on ogg/vorbis support)
628 filters="$filters oggdec"
629 vorbis_libs="-lvorbis -lvorbisfile"
630 server_ldflags="$server_ldflags $vorbis_libs"
631 filter_ldflags="$filter_ldflags $vorbis_libs"
632 audiod_ldflags="$audiod_ldflags $vorbis_libs"
633 play_ldflags="$play_ldflags $vorbis_libs"
634 afh_ldflags="$afh_ldflags $vorbis_libs"
635 recv_ldflags="$recv_ldflags $vorbis_libs"
636
637 server_errlist_objs="$server_errlist_objs ogg_afh"
638 filter_errlist_objs="$filter_errlist_objs oggdec_filter"
639 audiod_errlist_objs="$audiod_errlist_objs oggdec_filter"
640 play_errlist_objs="$play_errlist_objs oggdec_filter ogg_afh"
641 afh_errlist_objs="$afh_errlist_objs ogg_afh"
642 recv_errlist_objs="$recv_errlist_objs ogg_afh"
643
644 audiod_audio_formats="$audiod_audio_formats ogg"
645 audio_format_handlers="$audio_format_handlers ogg"
646 else
647 AC_MSG_WARN([no ogg/vorbis $msg])
648 fi
649 if test "$have_speex" = "yes"; then
650 all_errlist_objs="$all_errlist_objs spxdec_filter spx_afh spx_common"
651 AC_DEFINE(HAVE_SPEEX, 1, define to 1 to turn on ogg/speex support)
652 filters="$filters spxdec"
653 speex_libs="-lspeex"
654 server_ldflags="$server_ldflags $speex_libs"
655 filter_ldflags="$filter_ldflags $speex_libs"
656 audiod_ldflags="$audiod_ldflags $speex_libs"
657 play_ldflags="$play_ldflags $speex_libs"
658 afh_ldflags="$afh_ldflags $speex_libs"
659 recv_ldflags="$recv_ldflags $speex_libs"
660
661 server_errlist_objs="$server_errlist_objs spx_afh spx_common"
662 filter_errlist_objs="$filter_errlist_objs spxdec_filter spx_common"
663 audiod_errlist_objs="$audiod_errlist_objs spxdec_filter spx_common"
664 play_errlist_objs="$play_errlist_objs spxdec_filter spx_afh spx_common"
665 afh_errlist_objs="$afh_errlist_objs spx_afh spx_common"
666 recv_errlist_objs="$recv_errlist_objs spx_afh spx_common"
667
668 audiod_audio_formats="$audiod_audio_formats spx"
669 audio_format_handlers="$audio_format_handlers spx"
670 else
671 AC_MSG_WARN([no ogg/speex $msg])
672 fi
673 CPPFLAGS="$OLD_CPPFLAGS"
674 LDFLAGS="$OLD_LDFLAGS"
675 LIBS="$OLD_LIBS"
676 ########################################################################### faad
677 have_faad=yes
678 OLD_CPPFLAGS="$CPPFLAGS"
679 OLD_LD_FLAGS="$LDFLAGS"
680 OLD_LIBS="$LIBS"
681 AC_ARG_WITH(faad_headers, [AS_HELP_STRING(--with-faad-headers=dir,
682 [look for neaacdec.h also in dir])])
683 if test -n "$with_faad_headers"; then
684 faad_cppflags="-I$with_faad_headers"
685 CPPFLAGS="$CPPFLAGS $faad_cppflags"
686 fi
687 AC_ARG_WITH(faad_libs, [AS_HELP_STRING(--with-faad-libs=dir,
688 [look for libfaad also in dir])])
689 if test -n "$with_faad_libs"; then
690 faad_libs="-L$with_faad_libs"
691 LDFLAGS="$LDFLAGS $faad_libs"
692 fi
693 AC_CHECK_HEADER(neaacdec.h, [], have_faad=no)
694 AC_CHECK_LIB([faad], [NeAACDecOpen], [], have_faad=no)
695 if test "$have_faad" = "yes"; then
696 AC_DEFINE(HAVE_FAAD, 1, define to 1 if you want to build the aacdec filter)
697 all_errlist_objs="$all_errlist_objs aac_common aacdec_filter aac_afh"
698 filter_errlist_objs="$filter_errlist_objs aacdec_filter aac_common"
699 afh_errlist_objs="$afh_errlist_objs aac_common aac_afh"
700 audiod_errlist_objs="$audiod_errlist_objs aacdec_filter aac_common"
701 play_errlist_objs="$play_errlist_objs aacdec_filter aac_afh aac_common"
702 server_errlist_objs="$server_errlist_objs aac_afh aac_common"
703 recv_errlist_objs="$recv_errlist_objs aac_afh aac_common"
704
705 server_ldflags="$server_ldflags $faad_libs -lfaad"
706 filter_ldflags="$filter_ldflags $faad_libs -lfaad"
707 audiod_ldflags="$audiod_ldflags $faad_libs -lfaad"
708 play_ldflags="$play_ldflags $faad_libs -lfaad"
709 afh_ldflags="$afh_ldflags $faad_libs -lfaad"
710 recv_ldflags="$afh_ldflags $faad_libs -lfaad"
711
712 audiod_audio_formats="$audiod_audio_formats aac"
713 audio_format_handlers="$audio_format_handlers aac"
714 filters="$filters aacdec"
715 AC_SUBST(faad_cppflags)
716 else
717 AC_MSG_WARN([no aac support in para_audiod/para_filter])
718 fi
719 CPPFLAGS="$OLD_CPPFLAGS"
720 LDFLAGS="$OLD_LDFLAGS"
721 LIBS="$OLD_LIBS"
722 ########################################################################### mad
723 have_mad="yes"
724 OLD_CPPFLAGS="$CPPFLAGS"
725 OLD_LD_FLAGS="$LDFLAGS"
726 OLD_LIBS="$LIBS"
727
728 AC_ARG_WITH(mad_headers, [AS_HELP_STRING(--with-mad-headers=dir,
729 [look for mad.h also in dir])])
730 if test -n "$with_mad_headers"; then
731 mad_cppflags="-I$with_mad_headers"
732 CPPFLAGS="$CPPFLAGS $mad_cppflags"
733 fi
734 AC_ARG_WITH(mad_libs, [AS_HELP_STRING(--with-mad-libs=dir,
735 [look for libmad also in dir])])
736 if test -n "$with_mad_libs"; then
737 mad_libs="-L$with_mad_libs"
738 LDFLAGS="$LDFLAGS $mad_libs"
739 fi
740 AC_CHECK_HEADERS([mad.h], [], [
741 have_mad="no"
742 ])
743 AC_CHECK_LIB([mad], [mad_stream_init], [], [
744 have_mad="no"
745 ])
746 if test "$have_mad" = "yes"; then
747 AC_DEFINE(HAVE_MAD, 1, define to 1 if you want to build the mp3dec filter)
748 filter_cmdline_objs="$filter_cmdline_objs add_cmdline(mp3dec_filter)"
749 audiod_cmdline_objs="$audiod_cmdline_objs add_cmdline(mp3dec_filter)"
750 play_cmdline_objs="$play_cmdline_objs add_cmdline(mp3dec_filter)"
751 all_errlist_objs="$all_errlist_objs mp3dec_filter"
752 filter_errlist_objs="$filter_errlist_objs mp3dec_filter"
753 audiod_errlist_objs="$audiod_errlist_objs mp3dec_filter"
754 play_errlist_objs="$play_errlist_objs mp3dec_filter"
755 filter_ldflags="$filter_ldflags $mad_libs -lmad"
756 audiod_ldflags="$audiod_ldflags $mad_libs -lmad"
757 play_ldflags="$play_ldflags $mad_libs -lmad"
758 audiod_audio_formats="$audiod_audio_formats mp3"
759 filters="$filters mp3dec"
760 AC_SUBST(mad_cppflags)
761 else
762 AC_MSG_WARN([no mp3dec support in para_audiod/para_filter])
763 fi
764 CPPFLAGS="$OLD_CPPFLAGS"
765 LDFLAGS="$OLD_LDFLAGS"
766 LIBS="$OLD_LIBS"
767 ###################################################################### libid3tag
768 OLD_CPPFLAGS="$CPPFLAGS"
769 OLD_LD_FLAGS="$LDFLAGS"
770 OLD_LIBS="$LIBS"
771
772 have_libid3tag="yes"
773 AC_ARG_WITH(id3tag_headers, [AS_HELP_STRING(--with-id3tag-headers=dir,
774 [look for id3tag header files also in dir])])
775 if test -n "$with_id3tag_headers"; then
776 id3tag_cppflags="-I$with_id3tag_headers"
777 CPPFLAGS="$CPPFLAGS $id3tag_cppflags"
778 fi
779 AC_ARG_WITH(id3tag_libs, [AS_HELP_STRING(--with-id3tag-libs=dir,
780 [look for id3tag libs also in dir])])
781 if test -n "$with_id3tag_libs"; then
782 id3tag_libs="-L$with_id3tag_libs"
783 LDFLAGS="$LDFLAGS $id3tag_libs"
784 fi
785
786 AC_MSG_CHECKING(for libid3tag)
787 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
788 #include <id3tag.h>
789 ]], [[
790 struct id3_tag t = {.flags = 0};
791 ]])],[],[have_libid3tag=no])
792 AC_MSG_RESULT($have_libid3tag)
793
794 if test ${have_libid3tag} = yes; then
795 AC_DEFINE(HAVE_LIBID3TAG, 1, define to 1 you have libid3tag)
796 server_ldflags="$server_ldflags $id3tag_libs -lid3tag -lz"
797 afh_ldflags="$afh_ldflags $id3tag_libs -lid3tag -lz"
798 play_ldflags="$play_ldflags -lz"
799 recv_ldflags="$recv_ldflags $id3tag_libs -lid3tag"
800 play_ldflags="$play_ldflags $id3tag_libs -lid3tag"
801 AC_SUBST(id3tag_cppflags)
802 else
803 AC_MSG_WARN([no support for id3v2 tags])
804 fi
805 CPPFLAGS="$OLD_CPPFLAGS"
806 LDFLAGS="$OLD_LDFLAGS"
807 LIBS="$OLD_LIBS"
808 ########################################################################### flac
809 OLD_CPPFLAGS="$CPPFLAGS"
810 OLD_LD_FLAGS="$LDFLAGS"
811 OLD_LIBS="$LIBS"
812
813 have_flac="yes"
814 AC_ARG_WITH(flac_headers, [AS_HELP_STRING(--with-flac-headers=dir,
815 [look for flac headers also in dir])])
816 if test -n "$with_flac_headers"; then
817 flac_cppflags="-I$with_flac_headers"
818 CPPFLAGS="$CPPFLAGS $flac_cppflags"
819 fi
820 AC_ARG_WITH(flac_libs, [AS_HELP_STRING(--with-flac-libs=dir,
821 [look for flac libs also in dir])])
822 if test -n "$with_flac_libs"; then
823 flac_libs="-L$with_flac_libs"
824 LDFLAGS="$LDFLAGS $flac_libs"
825 fi
826 AC_CHECK_HEADER(FLAC/stream_decoder.h, [], have_flac=no)
827 AC_CHECK_LIB([FLAC], [FLAC__stream_decoder_init_file], [], have_flac=no, -logg -lm)
828 if test "$have_flac" = "yes"; then
829 AC_DEFINE(HAVE_FLAC, 1, define to 1 if you want to build the flacdec filter)
830 all_errlist_objs="$all_errlist_objs flacdec_filter flac_afh"
831 filter_errlist_objs="$filter_errlist_objs flacdec_filter"
832 audiod_errlist_objs="$audiod_errlist_objs flacdec_filter"
833 play_errlist_objs="$play_errlist_objs flacdec_filter flac_afh"
834 afh_errlist_objs="$afh_errlist_objs flac_afh"
835 server_errlist_objs="$server_errlist_objs flac_afh"
836 recv_errlist_objs="$recv_errlist_objs flac_afh"
837 filter_ldflags="$filter_ldflags $flac_libs -lFLAC"
838 audiod_ldflags="$audiod_ldflags $flac_libs -lFLAC"
839 play_ldflags="$play_ldflags $flac_libs -lFLAC"
840 server_ldflags="$server_ldflags $flac_libs -lFLAC"
841 afh_ldflags="$afh_ldflags $flac_libs -lFLAC"
842 recv_ldflags="$afh_ldflags $flac_libs -lFLAC"
843 filters="$filters flacdec"
844 audio_format_handlers="$audio_format_handlers flac"
845 audiod_audio_formats="$audiod_audio_formats flac"
846 AC_SUBST(flac_cppflags)
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_LD_FLAGS="$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 add_cmdline(oss_write)"
865 play_cmdline_objs="$play_cmdline_objs add_cmdline(oss_write)"
866
867 write_errlist_objs="$write_errlist_objs oss_write"
868 write_cmdline_objs="$write_cmdline_objs add_cmdline(oss_write)"
869 fade_errlist_objs="$fade_errlist_objs oss_mix"
870 all_errlist_objs="$all_errlist_objs oss_write oss_mix"
871
872 writers="$writers oss"
873 default_writer="OSS_WRITE"
874 mixers="${mixers}oss "
875 default_mixer="OSS_MIX"
876
877 AC_CHECK_LIB(ossaudio, _oss_ioctl, [
878 audiod_ldflags="$audiod_ldflags -lossaudio"
879 play_ldflags="$play_ldflags -lossaudio"
880 write_ldflags="$write_ldflags -lossaudio"
881 fade_ldflags="$fade_ldflags -lossaudio"
882 ]
883 )
884 ],
885 [
886 have_oss="no"
887 AC_MSG_WARN([no sys/soundcard.h $msg])
888 ]
889 )
890 CPPFLAGS="$OLD_CPPFLAGS"
891 LDFLAGS="$OLD_LDFLAGS"
892 LIBS="$OLD_LIBS"
893
894 ########################################################################### alsa
895 OLD_CPPFLAGS="$CPPFLAGS"
896 OLD_LD_FLAGS="$LDFLAGS"
897 OLD_LIBS="$LIBS"
898
899 msg="=> no alsa support for para_audiod/para_write"
900 if test "$OSTYPE" != "Linux"; then
901 have_alsa="no"
902 else
903 have_alsa="yes"
904 fi
905 if test "$have_alsa" = "yes"; then
906 AC_CHECK_HEADERS([alsa/asoundlib.h], [], [
907 have_alsa="no"
908 AC_MSG_WARN([no alsa/asoundlib $msg])
909 ])
910 fi
911
912 if test "$have_alsa" = "yes"; then
913 AC_CHECK_LIB([asound], [snd_pcm_open], [], [
914 have_alsa="no"
915 AC_MSG_WARN([no libasound $msg])
916 ])
917 fi
918
919 if test "$have_alsa" = "yes"; then
920 audiod_errlist_objs="$audiod_errlist_objs alsa_write"
921 audiod_cmdline_objs="$audiod_cmdline_objs add_cmdline(alsa_write)"
922 audiod_ldflags="$audiod_ldflags -lasound"
923 play_errlist_objs="$play_errlist_objs alsa_write"
924 play_cmdline_objs="$play_cmdline_objs add_cmdline(alsa_write)"
925 play_ldflags="$play_ldflags -lasound"
926
927 write_errlist_objs="$write_errlist_objs alsa_write"
928 write_cmdline_objs="$write_cmdline_objs add_cmdline(alsa_write)"
929 write_ldflags="$write_ldflags -lasound"
930 fade_errlist_objs="$fade_errlist_objs alsa_mix"
931 fade_ldflags="$fade_ldflags -lasound"
932 all_errlist_objs="$all_errlist_objs alsa_write alsa_mix"
933
934 writers="$writers alsa"
935 default_writer="ALSA_WRITE"
936 mixers="${mixers}alsa "
937 default_mixer="ALSA_MIX"
938 fi
939
940 CPPFLAGS="$OLD_CPPFLAGS"
941 LDFLAGS="$OLD_LDFLAGS"
942 LIBS="$OLD_LIBS"
943 ########################################################################### fade
944 if test -n "$mixers"; then
945 extras="$extras fade"
946 executables="$executables fade"
947 all_errlist_objs="$all_errlist_objs fade"
948 fade_errlist_objs="$fade_errlist_objs fade exec string fd"
949 fade_cmdline_objs="add_cmdline(fade)"
950 fade_objs="$fade_cmdline_objs $fade_errlist_objs"
951 AC_SUBST(fade_objs, add_dot_o($fade_objs))
952 AC_SUBST(fade_ldflags, $fade_ldflags)
953 AC_DEFINE_UNQUOTED(INIT_FADE_ERRLISTS,
954 objlist_to_errlist($fade_errlist_objs),
955 errors used by para_fade)
956 enum="$(
957 for i in $mixers; do
958 printf "${i}_MIX, " | tr '[a-z]' '[A-Z]'
959 done
960 )"
961 AC_DEFINE_UNQUOTED(MIXER_ENUM, $enum NUM_SUPPORTED_MIXERS,
962 enum of supported mixers)
963 AC_DEFINE_UNQUOTED(DEFAULT_MIXER, $default_mixer,
964 use this mixer if none was specified)
965 names="$(for i in $mixers; do printf \"$i\",' ' ; done)"
966 AC_DEFINE_UNQUOTED(MIXER_NAMES, $names, supported mixer names)
967 inits="$(
968 for i in $mixers; do
969 printf 'extern void '$i'_mix_init(struct mixer *); '
970 done
971 )"
972 AC_DEFINE_UNQUOTED(DECLARE_MIXER_INITS, $inits,
973 init functions of the supported mixers)
974 array="$(for i in $mixers; do printf '{.init = '$i'_mix_init},'; done)"
975 AC_DEFINE_UNQUOTED(MIXER_ARRAY, $array, array of supported mixers)
976 mixer_summary="supported mixers:: $mixers, default: $default_mixer"
977 else
978 AC_MSG_WARN([no mixer support])
979 mixer_summary="para_fade: no"
980 fi
981 ########################################################################### libao
982 OLD_CPPFLAGS="$CPPFLAGS"
983 OLD_LD_FLAGS="$LDFLAGS"
984 OLD_LIBS="$LIBS"
985
986 have_ao="yes"
987 AC_ARG_WITH(ao_headers, [AS_HELP_STRING(--with-ao-headers=dir,
988 [look for ao/ao.h also in dir])])
989 if test -n "$with_ao_headers"; then
990 ao_cppflags="-I$with_ao_headers"
991 CPPFLAGS="$CPPFLAGS $ao_cppflags"
992 fi
993 AC_ARG_WITH(ao_libs, [AS_HELP_STRING(--with-ao-libs=dir,
994 [look for libao also in dir])])
995 if test -n "$with_ao_libs"; then
996 ao_libs="-L$with_ao_libs"
997 LDFLAGS="$LDFLAGS $ao_libs"
998 fi
999 msg="no libao support for para_audiod/para_write"
1000 AC_CHECK_HEADERS([ao/ao.h], [
1001 ], [
1002 have_ao="no"
1003 AC_MSG_WARN([ao.h not found, $msg])
1004 ])
1005 if test "$have_ao" = "yes"; then
1006 AC_CHECK_LIB([ao], [ao_initialize], [], [
1007 have_ao="no"
1008 AC_MSG_WARN([ao lib not found or not working, $msg])
1009 ])
1010 fi
1011 if test "$have_ao" = "yes"; then
1012 AC_CHECK_HEADERS([pthread.h], [
1013 ], [
1014 have_ao="no"
1015 AC_MSG_WARN([pthread.h not found, $msg])
1016 ])
1017 fi
1018 if test "$have_ao" = "yes"; then
1019 AC_CHECK_LIB([pthread], [pthread_create], [], [
1020 have_ao="no"
1021 AC_MSG_WARN([pthread lib not found or not working, $msg])
1022 ])
1023 fi
1024 if test "$have_ao" = "yes"; then
1025 all_errlist_objs="$all_errlist_objs ao_write"
1026 audiod_errlist_objs="$audiod_errlist_objs ao_write"
1027 audiod_cmdline_objs="$audiod_cmdline_objs add_cmdline(ao_write)"
1028 audiod_ldflags="$audiod_ldflags -lao -lpthread"
1029
1030 play_errlist_objs="$play_errlist_objs ao_write"
1031 play_cmdline_objs="$play_cmdline_objs add_cmdline(ao_write)"
1032 play_ldflags="$play_ldflags -lao -lpthread"
1033
1034 write_errlist_objs="$write_errlist_objs ao_write"
1035 write_cmdline_objs="$write_cmdline_objs add_cmdline(ao_write)"
1036 write_ldflags="$write_ldflags $ao_libs -lao -lpthread"
1037 writers="$writers ao"
1038 AC_SUBST(ao_cppflags)
1039 fi
1040
1041 CPPFLAGS="$OLD_CPPFLAGS"
1042 LDFLAGS="$OLD_LDFLAGS"
1043 LIBS="$OLD_LIBS"
1044 ############################################################# readline
1045 OLD_CPPFLAGS="$CPPFLAGS"
1046 OLD_LD_FLAGS="$LDFLAGS"
1047 OLD_LIBS="$LIBS"
1048
1049 have_readline="yes"
1050 AC_ARG_WITH(readline_headers, [AS_HELP_STRING(--with-readline-headers=dir,
1051 [look for libreadline header files also in dir])])
1052 if test -n "$with_readline_headers"; then
1053 readline_cppflags="-I$with_readline_headers"
1054 CPPFLAGS="$CPPFLAGS $readline_cppflags"
1055 fi
1056
1057 AC_ARG_WITH(readline_libs, [AS_HELP_STRING(--with-readline-libs=dir,
1058 [look for readline library also in dir])])
1059 if test -n "$with_readline_libs"; then
1060 readline_libs="-L$with_readline_libs"
1061 LDFLAGS="$LDFLAGS $readline_libs"
1062 fi
1063 msg="no interactive cli support"
1064 AC_CHECK_HEADERS([readline/readline.h], [
1065 ], [
1066 have_readline="no"
1067 AC_MSG_WARN([readline/readline.h not found, $msg])
1068 ])
1069
1070 if test "$have_curses" != "yes"; then
1071 have_readline="no"
1072 AC_MSG_WARN([interactive cli support depends on curses,])
1073 AC_MSG_WARN([but no curses lib was detected, $msg])
1074 fi
1075
1076 if test "$have_readline" = "yes"; then
1077 readline_libs="$readline_libs -lreadline"
1078 AC_SEARCH_LIBS([rl_free_keymap], [readline], [], [have_readline="no"])
1079 if test "$have_readline" = "no"; then # try with -lcurses
1080 # clear cache
1081 AC_MSG_NOTICE([trying again with -lcurses])
1082 unset ac_cv_search_rl_free_keymap 2> /dev/null
1083 AC_SEARCH_LIBS([rl_free_keymap], [readline], [
1084 have_readline=yes
1085 readline_libs="$readline_libs -lcurses"
1086 ], [], [-lcurses])
1087 fi
1088 if test "$have_readline" = "no"; then # try with -ltermcap
1089 # clear cache
1090 AC_MSG_NOTICE([trying again with -ltermcap])
1091 unset ac_cv_search_rl_free_keymap 2> /dev/null
1092 AC_SEARCH_LIBS([rl_free_keymap], [readline], [
1093 have_readline=yes
1094 readline_libs="$readline_libs -ltermcap"
1095 ], [], [-ltermcap])
1096 fi
1097 fi
1098
1099 if test "$have_readline" = "yes"; then
1100 all_errlist_objs="$all_errlist_objs interactive"
1101 client_errlist_objs="$client_errlist_objs interactive"
1102 client_ldflags="$client_ldflags $readline_libs"
1103 audioc_errlist_objs="$audioc_errlist_objs buffer_tree interactive sched time"
1104 audioc_ldflags="$audioc_ldflags $readline_libs"
1105 play_errlist_objs="$play_errlist_objs interactive"
1106 play_ldflags="$play_ldflags $readline_libs"
1107 AC_SUBST(readline_cppflags)
1108 AC_DEFINE(HAVE_READLINE, 1, define to 1 to turn on readline support)
1109 else
1110 AC_MSG_WARN([libreadline not found or unusable])
1111 fi
1112 CPPFLAGS="$OLD_CPPFLAGS"
1113 LDFLAGS="$OLD_LDFLAGS"
1114 LIBS="$OLD_LIBS"
1115 ############################################################# libsamplerate
1116 OLD_CPPFLAGS="$CPPFLAGS"
1117 OLD_LD_FLAGS="$LDFLAGS"
1118 OLD_LIBS="$LIBS"
1119
1120 have_samplerate="yes"
1121 AC_ARG_WITH(samplerate_headers, [AS_HELP_STRING(--with-samplerate-headers=dir,
1122 [look for samplerate headers also in dir])])
1123 if test -n "$with_samplerate_headers"; then
1124 samplerate_cppflags="-I$with_samplerate_headers"
1125 CPPFLAGS="$CPPFLAGS $samplerate_cppflags"
1126 fi
1127 AC_ARG_WITH(samplerate_libs, [AS_HELP_STRING(--with-samplerate-libs=dir,
1128 [look for samplerate libs also in dir])])
1129 if test -n "$with_samplerate_libs"; then
1130 samplerate_libs="-L$with_samplerate_libs"
1131 LDFLAGS="$LDFLAGS $samplerate_libs"
1132 fi
1133
1134 AC_CHECK_HEADER(samplerate.h, [], have_samplerate=no)
1135 AC_CHECK_LIB([samplerate], [src_process], [], have_samplerate=no, [])
1136
1137 if test "$have_samplerate" = "yes"; then
1138 all_errlist_objs="$all_errlist_objs resample_filter"
1139 filter_errlist_objs="$filter_errlist_objs resample_filter check_wav"
1140 filter_cmdline_objs="$filter_cmdline_objs add_cmdline(resample_filter)"
1141 audiod_errlist_objs="$audiod_errlist_objs resample_filter check_wav"
1142 audiod_cmdline_objs="$audiod_cmdline_objs add_cmdline(resample_filter)"
1143 play_errlist_objs="$play_errlist_objs resample_filter check_wav"
1144 play_cmdline_objs="$play_cmdline_objs add_cmdline(resample_filter)"
1145 filter_ldflags="$filter_ldflags $samplerate_libs -lsamplerate"
1146 audiod_ldflags="$audiod_ldflags $samplerate_libs -lsamplerate"
1147 play_ldflags="$play_ldflags $samplerate_libs -lsamplerate"
1148 filters="$filters resample"
1149 AC_SUBST(samplerate_cppflags)
1150 else
1151 AC_MSG_WARN([no resample support in para_audiod/para_filter])
1152 fi
1153 CPPFLAGS="$OLD_CPPFLAGS"
1154 LDFLAGS="$OLD_LDFLAGS"
1155 LIBS="$OLD_LIBS"
1156 ############################################################# error2.h
1157 AC_MSG_NOTICE(creating error2.h)
1158 for i in $executables; do
1159 echo "$i: "
1160 eval echo \$${i}_errlist_objs
1161 done | ./error2.pl > error2.h
1162 for obj in $all_errlist_objs; do
1163 SS="$SS SS_$(echo $obj | tr 'a-z' 'A-Z'),"
1164 done
1165 AC_DEFINE_UNQUOTED(DEFINE_ERRLIST_OBJECT_ENUM,
1166 [enum {$SS NUM_SS}],
1167 [list of all objects that use the paraslash error facility]
1168 )
1169
1170 ################################################################## status items
1171
1172 status_items="basename status num_played mtime bitrate frequency file_size
1173 status_flags format score techinfo afs_mode
1174 attributes_txt decoder_flags audiod_status play_time attributes_bitmap
1175 offset seconds_total stream_start current_time audiod_uptime image_id
1176 lyrics_id duration directory lyrics_name image_name path hash channels
1177 last_played num_chunks chunk_time amplification artist title year album
1178 comment"
1179
1180 result=
1181 for i in $status_items; do
1182 result="$result SI_$(echo $i | tr 'a-z' 'A-Z'), "
1183 done
1184 AC_DEFINE_UNQUOTED(STATUS_ITEM_ENUM, [$result],
1185 [enum of all status items])
1186
1187 result=
1188 for i in $status_items; do
1189 result="$result \"$i\", "
1190 done
1191 AC_DEFINE_UNQUOTED(STATUS_ITEM_ARRAY, [$result],
1192 [char * array of all status items])
1193
1194 AC_DEFINE_UNQUOTED(AUDIO_FORMAT_HANDLERS, "$audio_format_handlers",
1195 [formats supported by para_server and para_afh])
1196
1197 AC_SUBST(executables, add_para($executables))
1198
1199 recv_objs="$recv_cmdline_objs $recv_errlist_objs"
1200 filter_objs="$filter_cmdline_objs $filter_errlist_objs"
1201 audiod_objs="$audiod_cmdline_objs $audiod_errlist_objs"
1202 server_objs="$server_cmdline_objs $server_errlist_objs"
1203 write_objs="$write_cmdline_objs $write_errlist_objs"
1204 client_objs="$client_cmdline_objs $client_errlist_objs"
1205 audioc_objs="$audioc_cmdline_objs $audioc_errlist_objs"
1206 afh_objs="$afh_cmdline_objs $afh_errlist_objs"
1207 play_objs="$play_cmdline_objs $play_errlist_objs"
1208
1209
1210 AC_SUBST(recv_objs, add_dot_o($recv_objs))
1211 AC_SUBST(recv_ldflags, $recv_ldflags)
1212 AC_DEFINE_UNQUOTED(INIT_RECV_ERRLISTS, objlist_to_errlist($recv_errlist_objs),
1213 errors used by para_recv)
1214
1215 AC_SUBST(filter_objs, add_dot_o($filter_objs))
1216 AC_SUBST(filter_ldflags, $filter_ldflags)
1217 AC_DEFINE_UNQUOTED(INIT_FILTER_ERRLISTS,
1218 objlist_to_errlist($filter_errlist_objs), errors used by para_filter)
1219
1220 AC_SUBST(audiod_objs, add_dot_o($audiod_objs))
1221 AC_SUBST(audiod_ldflags, $audiod_ldflags)
1222 AC_DEFINE_UNQUOTED(INIT_AUDIOD_ERRLISTS, objlist_to_errlist($audiod_errlist_objs),
1223 errors used by para_audiod)
1224
1225 AC_SUBST(server_objs, add_dot_o($server_objs))
1226 AC_SUBST(server_ldflags, $server_ldflags)
1227 AC_DEFINE_UNQUOTED(INIT_SERVER_ERRLISTS,
1228 objlist_to_errlist($server_errlist_objs), errors used by para_server)
1229
1230 AC_SUBST(afh_objs, add_dot_o($afh_objs))
1231 AC_SUBST(afh_ldflags, $afh_ldflags)
1232 AC_DEFINE_UNQUOTED(INIT_AFH_ERRLISTS,
1233 objlist_to_errlist($afh_errlist_objs), errors used by para_afh)
1234
1235 AC_SUBST(write_objs, add_dot_o($write_objs))
1236 AC_SUBST(write_ldflags, $write_ldflags)
1237 AC_DEFINE_UNQUOTED(INIT_WRITE_ERRLISTS,
1238 objlist_to_errlist($write_errlist_objs), errors used by para_write)
1239
1240 AC_SUBST(client_objs, add_dot_o($client_objs))
1241 AC_SUBST(client_ldflags, $client_ldflags)
1242 AC_DEFINE_UNQUOTED(INIT_CLIENT_ERRLISTS,
1243 objlist_to_errlist($client_errlist_objs), errors used by para_client)
1244
1245 AC_SUBST(audioc_objs, add_dot_o($audioc_objs))
1246 AC_SUBST(audioc_ldflags, $audioc_ldflags)
1247 AC_DEFINE_UNQUOTED(INIT_AUDIOC_ERRLISTS,
1248 objlist_to_errlist($audioc_errlist_objs), errors used by para_audioc)
1249
1250 AC_SUBST(gui_objs, add_dot_o($gui_objs))
1251 AC_SUBST(gui_ldflags, $gui_ldflags)
1252 AC_DEFINE_UNQUOTED(INIT_GUI_ERRLISTS,
1253 objlist_to_errlist($gui_errlist_objs), errors used by para_gui)
1254
1255 AC_SUBST(play_objs, add_dot_o($play_objs))
1256 AC_SUBST(play_ldflags, $play_ldflags)
1257 AC_DEFINE_UNQUOTED(INIT_PLAY_ERRLISTS,
1258 objlist_to_errlist($play_errlist_objs), errors used by para_play)
1259
1260 AC_MSG_NOTICE(play objs: $play_objs)
1261
1262 enum="$(for i in $filters; do printf "${i}_FILTER, " | tr '[a-z]' '[A-Z]'; done)"
1263 AC_DEFINE_UNQUOTED(FILTER_ENUM, $enum NUM_SUPPORTED_FILTERS,
1264 enum of supported filters)
1265 inits="$(for i in $filters; do printf 'extern void '$i'_filter_init(struct filter *f); '; done)"
1266 AC_DEFINE_UNQUOTED(DECLARE_FILTER_INITS, $inits, init functions of the supported filters)
1267 array="$(for i in $filters; do printf '{.name = "'$i'", .init = '$i'_filter_init},'; done)"
1268 AC_DEFINE_UNQUOTED(FILTER_ARRAY, $array, array of supported filters)
1269
1270 enum="$(for i in $writers; do printf "${i}_WRITE, " | tr '[a-z]' '[A-Z]'; done)"
1271 AC_DEFINE_UNQUOTED(WRITER_ENUM, $enum NUM_SUPPORTED_WRITERS,
1272 enum of supported writers)
1273 AC_DEFINE_UNQUOTED(DEFAULT_WRITER, $default_writer, use this writer if none was specified)
1274 names="$(for i in $writers; do printf \"$i\",' ' ; done)"
1275 AC_DEFINE_UNQUOTED(WRITER_NAMES, $names, supported writer names)
1276 inits="$(for i in $writers; do printf 'extern void '$i'_write_init(struct writer *); '; done)"
1277 AC_DEFINE_UNQUOTED(DECLARE_WRITER_INITS, $inits, init functions of the supported writers)
1278 array="$(for i in $writers; do printf '{.init = '$i'_write_init},'; done)"
1279 AC_DEFINE_UNQUOTED(WRITER_ARRAY, $array, array of supported writers)
1280
1281 enum="$(for i in $audiod_audio_formats; do printf "AUDIO_FORMAT_${i}, " | tr '[a-z]' '[A-Z]'; done)"
1282 AC_DEFINE_UNQUOTED(AUDIOD_AUDIO_FORMATS_ENUM, $enum NUM_AUDIO_FORMATS,
1283 enum of audio formats supported by audiod)
1284 names="$(for i in $audiod_audio_formats; do printf \"$i\",' ' ; done)"
1285 AC_DEFINE_UNQUOTED(AUDIOD_AUDIO_FORMAT_ARRAY, $names, array of audio formats supported by audiod)
1286
1287 AC_OUTPUT
1288 AC_MSG_NOTICE([
1289 paraslash configuration:
1290 ~~~~~~~~~~~~~~~~~~~~~~~~
1291 unix socket credentials: $have_ucred
1292 readline (interactive CLIs): $have_readline
1293 audio formats handlers: $audio_format_handlers
1294 id3 version2 support: $have_libid3tag
1295 filters: $filters
1296 writers: $writers
1297 optional executables: $extras
1298 $mixer_summary
1299 ])