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