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