Merge branch 'refs/heads/t/daemonize-fix'
[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], [m4_esyscmd_s(./GIT-VERSION-GEN)],
7 [maan@tuebingen.mpg.de], [], [http://people.tuebingen.mpg.de/maan/paraslash/])
8 AC_CONFIG_HEADERS([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_cmdline],[$(for i in $@; do printf "${i}.cmdline "; done)])
13 AC_DEFUN([make_errlist_defines], \
14 $(for i in $@; do \
15 printf "DEFINE_ERRLIST($(echo $i | tr 'a-z' 'A-Z'));"; \
16 done) \
17 )
18 AC_DEFUN([make_para_errlists], \
19 $(for i in $@; do \
20 printf "PARA_ERRLIST($(echo $i | tr 'a-z' 'A-Z')), "; \
21 done) \
22 )
23 AC_DEFUN([objlist_to_errlist],[ \
24 make_errlist_defines($@) \
25 [const char **para_errlist[[]]] = {make_para_errlists($@)} \
26 ])
27 AC_DEFUN([LIB_ARG_WITH], [
28 AC_ARG_WITH($1-headers, [AS_HELP_STRING(--with-$1-headers=dir,
29 [look for $1 headers in dir])])
30 AC_ARG_WITH($1-libs, [AS_HELP_STRING(--with-$1-libs=dir,
31 [look for $1 libraries in dir])])
32 if test -n "$with_$1_headers"; then
33 $1_cppflags="-I$with_$1_headers"
34 CPPFLAGS="$CPPFLAGS $$1_cppflags"
35 fi
36 if test -n "$with_$1_libs"; then
37 $1_ldflags="-L$with_$1_libs $2"
38 else
39 $1_ldflags="$2"
40 fi
41 LDFLAGS="$LDFLAGS $$1_ldflags"
42 ])
43
44 AC_DEFUN([STASH_FLAGS], [
45 OLD_CPPFLAGS="$CPPFLAGS"
46 OLD_LDFLAGS="$LDFLAGS"
47 OLD_LIBS="$LIBS"
48 ])
49
50 AC_DEFUN([UNSTASH_FLAGS], [
51 CPPFLAGS="$OLD_CPPFLAGS"
52 LDFLAGS="$OLD_LDFLAGS"
53 LIBS="$OLD_LIBS"
54 ])
55 AC_DEFUN([LIB_SUBST_FLAGS], [
56 if test "$HAVE_[]m4_toupper([$1])" = 'yes'; then
57 AC_DEFINE(HAVE_[]m4_toupper([$1]), 1,
58 define to 1 to turn on $1 support)
59 else
60 $1_cppflags=
61 $1_ldflags=
62 fi
63 AC_SUBST(HAVE_[]m4_toupper([$1]))
64 AC_SUBST($1_cppflags)
65 AC_SUBST($1_ldflags)
66 ])
67
68 AC_USE_SYSTEM_EXTENSIONS
69 AC_C_BIGENDIAN()
70
71 AC_PATH_PROG([GENGETOPT], [gengetopt])
72 test -z "$GENGETOPT" && AC_MSG_ERROR(
73 [gengetopt is required to build this package])
74
75 AC_PATH_PROG([M4], [m4])
76 test -z "$M4" && AC_MSG_ERROR(
77 [The m4 macro processor is required to build this package])
78
79 AC_PATH_PROG([HELP2MAN], [help2man])
80 test -z "$HELP2MAN" && AC_MSG_ERROR(
81 [help2man is required to build this package])
82
83 AC_PATH_PROG([INSTALL], [install])
84 test -z "$INSTALL" && AC_MSG_ERROR(
85 [The install program is required to build this package])
86
87 AC_PROG_CC
88 AC_PROG_CPP
89
90 executables="recv filter audioc write afh play"
91 ################################################################## clock_gettime
92 clock_gettime_lib=
93 AC_CHECK_LIB([c], [clock_gettime], [clock_gettime_lib=c], [
94 AC_CHECK_LIB([rt], [clock_gettime], [clock_gettime_lib=rt], [], [])
95 ])
96 if test -n "$clock_gettime_lib"; then
97 AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [
98 define to 1 if clock_gettime() is supported])
99 fi
100 if test "$clock_gettime_lib" = "rt"; then
101 AC_SUBST(clock_gettime_ldflags, -lrt)
102 fi
103
104 ########################################################################### osl
105 STASH_FLAGS
106 LIB_ARG_WITH([osl], [-losl])
107 HAVE_OSL=yes
108 AC_CHECK_HEADER(osl.h, [], [HAVE_OSL=no])
109 AC_CHECK_LIB([osl], [osl_open_table], [], [HAVE_OSL=no])
110 LIB_SUBST_FLAGS(osl)
111 UNSTASH_FLAGS
112 ######################################################################## openssl
113 STASH_FLAGS
114 HAVE_OPENSSL=yes
115 LIB_ARG_WITH([openssl], [-lssl -lcrypto])
116 AC_CHECK_HEADER(openssl/ssl.h, [], [HAVE_OPENSSL=no])
117 AC_CHECK_LIB([crypto], [RAND_bytes], [], [HAVE_OPENSSL=no])
118 LIB_SUBST_FLAGS(openssl)
119 UNSTASH_FLAGS
120 ######################################################################### gcrypt
121 STASH_FLAGS
122 HAVE_GCRYPT=yes
123 LIB_ARG_WITH([gcrypt], [-lgcrypt])
124 AC_CHECK_HEADER(gcrypt.h, [], [HAVE_GCRYPT=no])
125 AC_CHECK_LIB([gcrypt], [gcry_randomize], [], [HAVE_GCRYPT=no])
126 LIB_SUBST_FLAGS(gcrypt)
127 UNSTASH_FLAGS
128 ######################################################################### crypto
129 AC_ARG_ENABLE(cryptolib, [AS_HELP_STRING(--enable-cryptolib=lib, [
130 Force using crypto library "lib". This package requires either
131 openssl or libgcrypt being installed. Possible values for "lib"
132 are thus "openssl" and "gcrypt". If this option is not given,
133 openssl is tried first. If openssl was not found, gcrypt is
134 tried next.])])
135
136 CRYPTOLIB="$enable_cryptolib"
137 case "$enable_cryptolib" in
138 "openssl")
139 test $HAVE_OPENSSL = no && AC_MSG_ERROR(openssl not found)
140 crypto_ldflags="$openssl_ldflags"
141 ;;
142 "gcrypt")
143 test $HAVE_GCRYPT = no && AC_MSG_ERROR(gcrypt not found)
144 crypto_ldflags="$gcrypt_ldflags"
145 ;;
146 "")
147 crypto_ldflags=
148 if test $HAVE_GCRYPT = yes; then
149 CRYPTOLIB=gcrypt
150 crypto_ldflags="$gcrypt_ldflags"
151 fi
152 if test $HAVE_OPENSSL = yes; then
153 CRYPTOLIB=openssl
154 crypto_ldflags="$openssl_ldflags"
155 fi
156 ;;
157 *)
158 AC_MSG_ERROR([invalid value "$enable_cryptolib" for --enable-cryptolib])
159 ;;
160 esac
161 AC_SUBST(crypto_ldflags)
162 ########################################################################## iconv
163 STASH_FLAGS
164 LIBS=
165 AC_SEARCH_LIBS([libiconv_open], [iconv],
166 [iconv_ldflags="$LIBS"],
167 []
168 )
169 AC_SUBST(iconv_ldflags)
170 AC_MSG_CHECKING([whether iconv needs const char ** cast])
171 AC_COMPILE_IFELSE([
172 AC_LANG_PROGRAM([
173 #include <iconv.h>
174 ],[
175 size_t iconv(iconv_t cd, const char **inbuf,
176 size_t *inbytesleft, char **outbuf,
177 size_t *outbytesleft);
178 ])
179 ],
180 [cast='(const char **)'; msg=yes],
181 [cast=; msg=no]
182 )
183 AC_DEFINE_UNQUOTED(ICONV_CAST, $cast, [cast for second arg to iconv()])
184 AC_MSG_RESULT($msg)
185 UNSTASH_FLAGS
186 ########################################################################### ucred
187 AC_MSG_CHECKING(for struct ucred)
188 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
189 #include <sys/types.h>
190 #include <sys/socket.h>
191 ]], [[
192 struct ucred sucred; sucred.pid=0;
193 ]])],[have_ucred=yes],[have_ucred=no])
194 AC_MSG_RESULT($have_ucred)
195 if test ${have_ucred} = yes; then
196 AC_DEFINE(HAVE_UCRED, 1, define to 1 you have struct ucred)
197 fi
198 ########################################################################### gengetopt
199 echo 'option "z" z "" flag off' | $GENGETOPT --file-name conftest-ggo &&
200 AC_CHECK_DECL(
201 [gengetopt_args_info_description],
202 [ggo_descriptions_declared=yes],
203 [ggo_descriptions_declared=no],
204 [#include "conftest-ggo.h"]
205 )
206 AC_SUBST(ggo_descriptions_declared)
207 ########################################################################### curses
208 STASH_FLAGS
209 LIB_ARG_WITH([curses], [])
210 HAVE_CURSES=yes
211 AC_CHECK_HEADER(curses.h, [], [HAVE_CURSES=no])
212 AC_SEARCH_LIBS([initscr], [ncursesw curses], [], [HAVE_CURSES=no])
213 curses_ldflags="$curses_ldflags $LIBS"
214 LIB_SUBST_FLAGS(curses)
215 UNSTASH_FLAGS
216 ########################################################################### ip_mreqn
217 AC_MSG_CHECKING(for struct ip_mreqn (UDPv4 multicast))
218 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
219 #include <netdb.h>
220 #include <net/if.h>
221 ]], [[
222 struct ip_mreqn mn;
223 mn.imr_ifindex = 0;
224 ]])],[have_ip_mreqn=yes],[have_ip_mreqn=no])
225 AC_MSG_RESULT($have_ip_mreqn)
226 if test ${have_ip_mreqn} = yes; then
227 AC_DEFINE(HAVE_IP_MREQN, 1, define to 1 you have struct ip_mreqn)
228 fi
229 ########################################################################### osx
230
231 AC_MSG_CHECKING(for CoreAudio (MacOs))
232 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
233 #include <CoreAudio/CoreAudio.h>
234 ]], [[
235 AudioDeviceID id;
236 ]])],[have_core_audio=yes],[have_core_audio=no])
237 AC_MSG_RESULT($have_core_audio)
238 if test ${have_core_audio} = yes; then
239 f1="-framework CoreAudio"
240 f2="-framework AudioToolbox"
241 f3="-framework AudioUnit"
242 f4="-framework CoreServices"
243 core_audio_ldflags="$f1 $f2 $f3 $f4"
244 AC_SUBST(core_audio_ldflags)
245 AC_DEFINE(HAVE_CORE_AUDIO, 1, define to 1 on Mac Os X)
246 fi
247 ########################################################################### ogg
248 STASH_FLAGS
249 LIB_ARG_WITH([ogg], [-logg])
250 HAVE_OGG=yes
251 AC_CHECK_HEADERS([ogg/ogg.h], [], [HAVE_OGG=no])
252 AC_CHECK_LIB([ogg], [ogg_stream_init], [], [HAVE_OGG=no])
253 AC_CHECK_LIB([ogg], [ogg_stream_flush_fill], [
254 AC_DEFINE(HAVE_OGG_STREAM_FLUSH_FILL, 1, [libogg >= 1.3.0])])
255 LIB_SUBST_FLAGS(ogg)
256 UNSTASH_FLAGS
257 ######################################################################### vorbis
258 STASH_FLAGS
259 LIB_ARG_WITH([vorbis], [-lvorbis -lvorbisfile])
260 HAVE_VORBIS=yes
261 AC_CHECK_HEADERS([vorbis/codec.h], [], [HAVE_VORBIS=no])
262 AC_CHECK_LIB([vorbis], [vorbis_info_init], [], [HAVE_VORBIS=no])
263 LIB_SUBST_FLAGS(vorbis)
264 UNSTASH_FLAGS
265 ######################################################################### speex
266 STASH_FLAGS
267 LIB_ARG_WITH([speex], [-lspeex])
268 HAVE_SPEEX=yes
269 AC_CHECK_HEADERS([speex/speex.h], [], [HAVE_SPEEX=no])
270 AC_CHECK_LIB([speex], [speex_decoder_init], [], [HAVE_SPEEX=no])
271 LIB_SUBST_FLAGS(speex)
272 UNSTASH_FLAGS
273 ######################################################################### opus
274 STASH_FLAGS
275 LIB_ARG_WITH([opus], [-lopus])
276 HAVE_OPUS=yes
277 AC_CHECK_HEADERS([opus/opus.h], [], [HAVE_OPUS=no])
278 AC_CHECK_LIB([opus], [opus_multistream_decode], [], [HAVE_OPUS=no])
279 LIB_SUBST_FLAGS(opus)
280 UNSTASH_FLAGS
281 ########################################################################### flac
282 STASH_FLAGS
283 LIB_ARG_WITH([flac], [-lFLAC -lm])
284 HAVE_FLAC=yes
285 AC_CHECK_HEADER(FLAC/stream_decoder.h, [], HAVE_FLAC=no)
286 AC_CHECK_LIB([FLAC], [FLAC__stream_decoder_init_file], [], HAVE_FLAC=no)
287 LIB_SUBST_FLAGS(flac)
288 UNSTASH_FLAGS
289
290 # some helper functions for codecs which use the ogg container format
291 AC_DEFUN([NEED_OGG_OBJECTS], [{
292 test "$HAVE_OGG" = 'yes' -a \( \
293 "$HAVE_VORBIS" = 'yes' \
294 -o "$HAVE_SPEEX" = 'yes' \
295 -o "$HAVE_OPUS" = 'yes' \
296 -o "$HAVE_FLAC" = 'yes' \
297 \)
298 }])
299 AC_DEFUN([NEED_VORBIS_OBJECTS], [{
300 test "$HAVE_OGG" = 'yes' -a "$HAVE_VORBIS" = 'yes'
301 }])
302 AC_DEFUN([NEED_SPEEX_OBJECTS], [{
303 test "$HAVE_OGG" = 'yes' -a "$HAVE_SPEEX" = 'yes'
304 }])
305 AC_DEFUN([NEED_OPUS_OBJECTS], [{
306 test "$HAVE_OGG" = 'yes' -a "$HAVE_OPUS" = 'yes'
307 }])
308 AC_DEFUN([NEED_FLAC_OBJECTS], [{
309 test "$HAVE_OGG" = 'yes' -a "$HAVE_FLAC" = 'yes'
310 }])
311 ########################################################################### faad
312 STASH_FLAGS
313 LIB_ARG_WITH([faad], [-lfaad])
314 HAVE_FAAD=yes
315 AC_CHECK_HEADER(neaacdec.h, [], HAVE_FAAD=no)
316 AC_CHECK_LIB([faad], [NeAACDecOpen], [], HAVE_FAAD=no)
317 LIB_SUBST_FLAGS(faad)
318 UNSTASH_FLAGS
319 ########################################################################### mad
320 STASH_FLAGS
321 LIB_ARG_WITH([mad], [-lmad])
322 HAVE_MAD=yes
323 AC_CHECK_HEADER(mad.h, [], HAVE_MAD=no)
324 AC_CHECK_LIB([mad], [mad_stream_init], [], HAVE_MAD=no)
325 LIB_SUBST_FLAGS(mad)
326 UNSTASH_FLAGS
327 ###################################################################### libid3tag
328 STASH_FLAGS
329 LIB_ARG_WITH([id3tag], [-lid3tag -lz])
330 HAVE_ID3TAG=yes
331 AC_CHECK_HEADER(id3tag.h, [], HAVE_ID3TAG=no)
332 AC_CHECK_LIB([id3tag], [id3_file_fdopen], [], HAVE_ID3TAG=no)
333 LIB_SUBST_FLAGS(id3tag)
334 UNSTASH_FLAGS
335 ########################################################################### oss
336 STASH_FLAGS
337 LIB_ARG_WITH([oss], [])
338 AC_CHECK_HEADER(sys/soundcard.h, [HAVE_OSS=yes], [HAVE_OSS=no])
339 AC_CHECK_LIB(ossaudio, _oss_ioctl, [oss_ldflags="$oss_ldflags -lossaudio"], [])
340 LIB_SUBST_FLAGS(oss)
341 UNSTASH_FLAGS
342 ########################################################################### alsa
343 STASH_FLAGS
344 LIB_ARG_WITH([alsa], [-lasound])
345 HAVE_ALSA=yes
346 AC_CHECK_HEADER(alsa/asoundlib.h, [], HAVE_ALSA=no)
347 AC_CHECK_LIB([asound], [snd_pcm_open], [], HAVE_ALSA=no)
348 LIB_SUBST_FLAGS(alsa)
349 UNSTASH_FLAGS
350 ######################################################################### pthread
351 STASH_FLAGS
352 LIB_ARG_WITH([pthread], [-lpthread])
353 HAVE_PTHREAD=yes
354 AC_CHECK_HEADER(pthread.h, [], HAVE_PTHREAD=no)
355 AC_CHECK_LIB([pthread], [pthread_create], [], HAVE_PTHREAD=no)
356 LIB_SUBST_FLAGS(pthread)
357 UNSTASH_FLAGS
358 ########################################################################### libao
359 STASH_FLAGS
360 LIB_ARG_WITH([ao], [-lao])
361 HAVE_AO=yes
362 AC_CHECK_HEADER(ao/ao.h, [], HAVE_AO=no)
363 AC_CHECK_LIB([ao], [ao_initialize], [], HAVE_AO=no)
364 LIB_SUBST_FLAGS(ao)
365 UNSTASH_FLAGS
366 AC_DEFUN([NEED_AO_OBJECTS], [{ test $HAVE_AO = yes -a $HAVE_PTHREAD = yes; }])
367 ######################################################################## readline
368 STASH_FLAGS
369 AC_SEARCH_LIBS([tgetent], [tinfo curses terminfo termcap])
370 LIB_ARG_WITH([readline], [-lreadline $LIBS])
371 HAVE_READLINE=yes
372 AC_CHECK_HEADER([readline/readline.h], [], [HAVE_READLINE=no])
373 AC_CHECK_LIB([readline], [rl_free_keymap], [], HAVE_READLINE=no)
374 AC_CHECK_DECL(
375 [rl_free_keymap],
376 [AC_DEFINE(RL_FREE_KEYMAP_DECLARED, 1, readline >= 6.3)],
377 [],
378 [
379 #include <stdio.h>
380 #include <readline/readline.h>
381 ]
382 )
383 LIB_SUBST_FLAGS(readline)
384 UNSTASH_FLAGS
385 ############################################################# libsamplerate
386 STASH_FLAGS
387 LIB_ARG_WITH([samplerate], [-lsamplerate])
388 HAVE_SAMPLERATE=yes
389 AC_CHECK_HEADER(samplerate.h, [], HAVE_SAMPLERATE=no)
390 AC_CHECK_LIB([samplerate], [src_process], [], HAVE_SAMPLERATE=no)
391 LIB_SUBST_FLAGS(samplerate)
392 UNSTASH_FLAGS
393 ########################################################################## mp4v2
394 STASH_FLAGS
395 LIB_ARG_WITH([mp4v2], [-lmp4v2])
396 HAVE_MP4V2=yes
397 AC_CHECK_HEADER([mp4v2/mp4v2.h], [], [HAVE_MP4V2=no])
398 AC_CHECK_LIB([mp4v2], [MP4Read], [], [HAVE_MP4V2=no])
399 LIB_SUBST_FLAGS(mp4v2)
400 UNSTASH_FLAGS
401 ######################################################################### server
402 if test -n "$CRYPTOLIB" && test $HAVE_OSL = yes; then
403 build_server="yes"
404 executables="$executables server"
405 server_cmdline_objs="server"
406 server_errlist_objs="
407 server
408 afh_common
409 mp3_afh
410 vss
411 command
412 net
413 string
414 signal
415 time
416 daemon
417 http_send
418 close_on_fork
419 mm
420 crypt_common
421 base64
422 ipc
423 dccp_send
424 fd
425 user_list
426 chunk_queue
427 afs
428 aft
429 mood
430 score
431 attribute
432 blob
433 playlist
434 sched
435 acl
436 send_common
437 udp_send
438 color
439 fec
440 wma_afh
441 wma_common
442 sideband
443 version
444 ggo
445 "
446 if test "$CRYPTOLIB" = openssl; then
447 server_errlist_objs="$server_errlist_objs crypt"
448 else
449 server_errlist_objs="$server_errlist_objs gcrypt"
450 fi
451 NEED_OGG_OBJECTS() && server_errlist_objs="$server_errlist_objs ogg_afh_common"
452 NEED_VORBIS_OBJECTS() && server_errlist_objs="$server_errlist_objs ogg_afh"
453 NEED_SPEEX_OBJECTS() && server_errlist_objs="$server_errlist_objs spx_afh spx_common"
454 NEED_OPUS_OBJECTS() && server_errlist_objs="$server_errlist_objs opus_afh opus_common"
455 NEED_FLAC_OBJECTS && server_errlist_objs="$server_errlist_objs flac_afh"
456 if test $HAVE_FAAD = yes && test $HAVE_MP4V2 = yes; then
457 server_errlist_objs="$server_errlist_objs aac_afh aac_common"
458 fi
459 server_objs="add_cmdline($server_cmdline_objs) $server_errlist_objs"
460 AC_SUBST(server_objs, add_dot_o($server_objs))
461 AC_DEFINE_UNQUOTED(INIT_SERVER_ERRLISTS,
462 objlist_to_errlist($server_errlist_objs), errors used by para_server)
463 else
464 build_server="no"
465 fi
466 ############################################################# client
467 if test -n "$CRYPTOLIB"; then
468 build_client="yes"
469 executables="$executables client"
470 client_cmdline_objs="client"
471 client_errlist_objs="
472 client
473 net
474 string
475 fd
476 sched
477 stdin
478 stdout
479 time
480 sideband
481 client_common
482 buffer_tree
483 crypt_common
484 base64
485 version
486 ggo
487 "
488 if test "$CRYPTOLIB" = openssl; then
489 client_errlist_objs="$client_errlist_objs crypt"
490 else
491 client_errlist_objs="$client_errlist_objs gcrypt"
492 fi
493 if test $HAVE_READLINE = yes; then
494 client_errlist_objs="$client_errlist_objs interactive"
495 fi
496 client_objs="add_cmdline($client_cmdline_objs) $client_errlist_objs"
497 AC_SUBST(client_objs, add_dot_o($client_objs))
498 AC_DEFINE_UNQUOTED(INIT_CLIENT_ERRLISTS,
499 objlist_to_errlist($client_errlist_objs), errors used by para_client)
500 else
501 build_client="no"
502 fi
503 ############################################################# audiod
504 if test -n "$CRYPTOLIB"; then
505 build_audiod="yes"
506 executables="$executables audiod"
507 audiod_audio_formats="wma"
508 audiod_cmdline_objs="$audiod_cmdline_objs
509 audiod
510 compress_filter
511 http_recv
512 dccp_recv
513 file_write
514 client
515 amp_filter
516 udp_recv
517 prebuffer_filter
518 sync_filter
519 "
520 audiod_errlist_objs="$audiod_errlist_objs
521 audiod
522 signal
523 string
524 daemon
525 stat
526 net
527 crypt_common
528 base64
529 sideband
530 time
531 grab_client
532 filter_common
533 wav_filter
534 compress_filter
535 amp_filter
536 http_recv
537 dccp_recv
538 recv_common
539 fd
540 sched
541 write_common
542 file_write
543 audiod_command
544 fecdec_filter
545 client_common
546 ggo
547 udp_recv
548 color
549 fec
550 prebuffer_filter
551 version
552 bitstream
553 imdct
554 wma_common
555 wmadec_filter
556 buffer_tree
557 sync_filter
558 "
559 if test "$CRYPTOLIB" = openssl; then
560 audiod_errlist_objs="$audiod_errlist_objs crypt"
561 else
562 audiod_errlist_objs="$audiod_errlist_objs gcrypt"
563 fi
564 if test "$have_core_audio" = "yes"; then
565 audiod_errlist_objs="$audiod_errlist_objs osx_write ipc"
566 audiod_cmdline_objs="$audiod_cmdline_objs osx_write"
567 fi
568 NEED_VORBIS_OBJECTS && {
569 audiod_errlist_objs="$audiod_errlist_objs oggdec_filter"
570 audiod_audio_formats="$audiod_audio_formats ogg"
571 }
572 NEED_SPEEX_OBJECTS && {
573 audiod_errlist_objs="$audiod_errlist_objs spxdec_filter spx_common"
574 audiod_audio_formats="$audiod_audio_formats spx"
575 }
576 NEED_OPUS_OBJECTS && {
577 audiod_errlist_objs="$audiod_errlist_objs opusdec_filter opus_common"
578 audiod_audio_formats="$audiod_audio_formats opus"
579 }
580 NEED_FLAC_OBJECTS && {
581 audiod_errlist_objs="$audiod_errlist_objs flacdec_filter"
582 audiod_audio_formats="$audiod_audio_formats flac"
583 }
584 if test $HAVE_FAAD = yes; then
585 audiod_errlist_objs="$audiod_errlist_objs aacdec_filter aac_common"
586 audiod_audio_formats="$audiod_audio_formats aac"
587 fi
588 if test $HAVE_MAD = yes; then
589 audiod_audio_formats="$audiod_audio_formats mp3"
590 audiod_cmdline_objs="$audiod_cmdline_objs mp3dec_filter"
591 audiod_errlist_objs="$audiod_errlist_objs mp3dec_filter"
592 fi
593 if test $HAVE_OSS = yes; then
594 audiod_errlist_objs="$audiod_errlist_objs oss_write"
595 audiod_cmdline_objs="$audiod_cmdline_objs oss_write"
596 fi
597 if test $HAVE_ALSA = yes; then
598 audiod_errlist_objs="$audiod_errlist_objs alsa_write"
599 audiod_cmdline_objs="$audiod_cmdline_objs alsa_write"
600 fi
601 NEED_AO_OBJECTS && {
602 audiod_errlist_objs="$audiod_errlist_objs ao_write"
603 audiod_cmdline_objs="$audiod_cmdline_objs ao_write"
604 }
605 if test $HAVE_SAMPLERATE = yes; then
606 audiod_errlist_objs="$audiod_errlist_objs resample_filter check_wav"
607 audiod_cmdline_objs="$audiod_cmdline_objs resample_filter"
608 fi
609 audiod_objs="add_cmdline($audiod_cmdline_objs) $audiod_errlist_objs"
610 AC_SUBST(audiod_objs, add_dot_o($audiod_objs))
611 AC_DEFINE_UNQUOTED(INIT_AUDIOD_ERRLISTS, objlist_to_errlist($audiod_errlist_objs),
612 errors used by para_audiod)
613
614 enum="$(for i in $audiod_audio_formats; do printf "AUDIO_FORMAT_${i}, " | tr '[a-z]' '[A-Z]'; done)"
615 AC_DEFINE_UNQUOTED(AUDIOD_AUDIO_FORMATS_ENUM, $enum NUM_AUDIO_FORMATS,
616 enum of audio formats supported by audiod)
617 names="$(for i in $audiod_audio_formats; do printf \"$i\",' ' ; done)"
618 AC_DEFINE_UNQUOTED(AUDIOD_AUDIO_FORMAT_ARRAY, $names, array of audio formats supported by audiod)
619 else
620 build_audiod="no"
621 fi
622 ########################################################################### fade
623 if test $HAVE_OSS = yes -o $HAVE_ALSA = yes; then
624 build_fade="yes"
625 executables="$executables fade"
626 fade_cmdline_objs="fade"
627 fade_errlist_objs="fade exec string fd version ggo"
628 if test $HAVE_OSS = yes; then
629 fade_errlist_objs="$fade_errlist_objs oss_mix"
630 mixers="${mixers}oss "
631 default_mixer="OSS_MIX"
632 fi
633 if test $HAVE_ALSA = yes; then
634 fade_errlist_objs="$fade_errlist_objs alsa_mix"
635 mixers="${mixers}alsa "
636 default_mixer="ALSA_MIX"
637 fi
638 fade_objs="add_cmdline($fade_cmdline_objs) $fade_errlist_objs"
639 AC_SUBST(fade_objs, add_dot_o($fade_objs))
640 AC_DEFINE_UNQUOTED(INIT_FADE_ERRLISTS,
641 objlist_to_errlist($fade_errlist_objs),
642 errors used by para_fade)
643 enum="$(
644 for i in $mixers; do
645 printf "${i}_MIX, " | tr '[a-z]' '[A-Z]'
646 done
647 )"
648 AC_DEFINE_UNQUOTED(MIXER_ENUM, $enum NUM_SUPPORTED_MIXERS,
649 enum of supported mixers)
650 AC_DEFINE_UNQUOTED(DEFAULT_MIXER, $default_mixer,
651 use this mixer if none was specified)
652 names="$(for i in $mixers; do printf \"$i\",' ' ; done)"
653 AC_DEFINE_UNQUOTED(MIXER_NAMES, $names, supported mixer names)
654 inits="$(
655 for i in $mixers; do
656 printf 'extern void '$i'_mix_init(struct mixer *); '
657 done
658 )"
659 AC_DEFINE_UNQUOTED(DECLARE_MIXER_INITS, $inits,
660 init functions of the supported mixers)
661 array="$(for i in $mixers; do printf '{.init = '$i'_mix_init},'; done)"
662 AC_DEFINE_UNQUOTED(MIXER_ARRAY, $array, array of supported mixers)
663 else
664 build_fade="no"
665 AC_MSG_WARN([no mixer support])
666 fi
667 ########################################################################### gui
668 if test $HAVE_CURSES = yes; then
669 build_gui="yes"
670 executables="$executables gui"
671 gui_cmdline_objs="gui"
672 gui_errlist_objs="
673 exec
674 signal
675 string
676 stat
677 ringbuffer
678 fd
679 gui
680 gui_theme
681 time
682 sched
683 version
684 ggo
685 "
686 gui_objs="add_cmdline($gui_cmdline_objs) $gui_errlist_objs"
687 AC_SUBST(gui_objs, add_dot_o($gui_objs))
688 AC_DEFINE_UNQUOTED(INIT_GUI_ERRLISTS,
689 objlist_to_errlist($gui_errlist_objs), errors used by para_gui)
690 else
691 build_gui="no"
692 AC_MSG_WARN([no curses lib, cannot build para_gui])
693 fi
694 ######################################################################## filter
695 filters="
696 compress
697 wav
698 amp
699 fecdec
700 wmadec
701 prebuffer
702 sync
703 "
704 filter_errlist_objs="
705 filter_common
706 wav_filter
707 compress_filter
708 filter
709 string
710 stdin
711 stdout
712 sched
713 fd
714 amp_filter
715 ggo
716 fecdec_filter
717 fec
718 version
719 prebuffer_filter
720 time
721 bitstream
722 imdct
723 wma_common
724 wmadec_filter
725 buffer_tree
726 net
727 sync_filter
728 "
729 filter_cmdline_objs="
730 filter
731 compress_filter
732 amp_filter
733 prebuffer_filter
734 sync_filter
735 "
736 NEED_VORBIS_OBJECTS && {
737 filters="$filters oggdec"
738 filter_errlist_objs="$filter_errlist_objs oggdec_filter"
739 }
740 NEED_SPEEX_OBJECTS && {
741 filters="$filters spxdec"
742 filter_errlist_objs="$filter_errlist_objs spxdec_filter spx_common"
743 }
744 NEED_OPUS_OBJECTS && {
745 filters="$filters opusdec"
746 filter_errlist_objs="$filter_errlist_objs opusdec_filter opus_common"
747 }
748 NEED_FLAC_OBJECTS && {
749 filter_errlist_objs="$filter_errlist_objs flacdec_filter"
750 filters="$filters flacdec"
751 }
752 if test $HAVE_FAAD = yes; then
753 filter_errlist_objs="$filter_errlist_objs aacdec_filter aac_common"
754 filters="$filters aacdec"
755 fi
756 if test $HAVE_MAD = yes; then
757 filter_cmdline_objs="$filter_cmdline_objs mp3dec_filter"
758 filter_errlist_objs="$filter_errlist_objs mp3dec_filter"
759 filters="$filters mp3dec"
760 fi
761 if test $HAVE_SAMPLERATE = yes; then
762 filter_errlist_objs="$filter_errlist_objs resample_filter check_wav"
763 filter_cmdline_objs="$filter_cmdline_objs resample_filter"
764 filters="$filters resample"
765 fi
766 filters="$(echo $filters)"
767 AC_SUBST(filters)
768 filter_objs="add_cmdline($filter_cmdline_objs) $filter_errlist_objs"
769
770 AC_SUBST(filter_objs, add_dot_o($filter_objs))
771 AC_DEFINE_UNQUOTED(INIT_FILTER_ERRLISTS,
772 objlist_to_errlist($filter_errlist_objs), errors used by para_filter)
773
774 enum="$(for i in $filters; do printf "${i}_FILTER, " | tr '[a-z]' '[A-Z]'; done)"
775 AC_DEFINE_UNQUOTED(FILTER_ENUM, $enum NUM_SUPPORTED_FILTERS,
776 enum of supported filters)
777 inits="$(for i in $filters; do printf 'extern void '$i'_filter_init(struct filter *f); '; done)"
778 AC_DEFINE_UNQUOTED(DECLARE_FILTER_INITS, $inits, init functions of the supported filters)
779 array="$(for i in $filters; do printf '{.name = "'$i'", .init = '$i'_filter_init},'; done)"
780 AC_DEFINE_UNQUOTED(FILTER_ARRAY, $array, array of supported filters)
781 ########################################################################## recv
782 recv_cmdline_objs="
783 recv
784 http_recv
785 dccp_recv
786 udp_recv
787 afh_recv
788 "
789
790 recv_errlist_objs="
791 http_recv
792 recv_common
793 recv
794 time
795 string
796 net
797 dccp_recv
798 fd
799 sched
800 stdout
801 ggo
802 udp_recv
803 buffer_tree
804 afh_recv
805 afh_common
806 wma_afh
807 wma_common
808 mp3_afh
809 version
810 "
811 NEED_OGG_OBJECTS && recv_errlist_objs="$recv_errlist_objs ogg_afh_common"
812 NEED_VORBIS_OBJECTS && recv_errlist_objs="$recv_errlist_objs ogg_afh"
813 NEED_SPEEX_OBJECTS && recv_errlist_objs="$recv_errlist_objs spx_afh spx_common"
814 NEED_OPUS_OBJECTS && recv_errlist_objs="$recv_errlist_objs opus_afh opus_common"
815 NEED_FLAC_OBJECTS && recv_errlist_objs="$recv_errlist_objs flac_afh"
816
817 if test $HAVE_FAAD = yes -a $HAVE_MP4V2 = yes; then
818 recv_errlist_objs="$recv_errlist_objs aac_afh aac_common"
819 fi
820 recv_objs="add_cmdline($recv_cmdline_objs) $recv_errlist_objs"
821 AC_SUBST(receivers, "http dccp udp afh")
822 AC_SUBST(recv_objs, add_dot_o($recv_objs))
823 AC_DEFINE_UNQUOTED(INIT_RECV_ERRLISTS, objlist_to_errlist($recv_errlist_objs),
824 errors used by para_recv)
825 ########################################################################### afh
826 audio_format_handlers="mp3 wma"
827 afh_cmdline_objs="afh"
828 afh_errlist_objs="
829 afh
830 string
831 fd
832 mp3_afh
833 afh_common
834 time
835 wma_afh
836 wma_common
837 version
838 ggo
839 "
840 NEED_OGG_OBJECTS && afh_errlist_objs="$afh_errlist_objs ogg_afh_common"
841 NEED_VORBIS_OBJECTS && {
842 afh_errlist_objs="$afh_errlist_objs ogg_afh"
843 audio_format_handlers="$audio_format_handlers ogg"
844 }
845 NEED_SPEEX_OBJECTS && {
846 afh_errlist_objs="$afh_errlist_objs spx_afh spx_common"
847 audio_format_handlers="$audio_format_handlers spx"
848 }
849 NEED_OPUS_OBJECTS && {
850 afh_errlist_objs="$afh_errlist_objs opus_afh opus_common"
851 audio_format_handlers="$audio_format_handlers opus"
852 }
853 NEED_FLAC_OBJECTS && {
854 afh_errlist_objs="$afh_errlist_objs flac_afh"
855 audio_format_handlers="$audio_format_handlers flac"
856 }
857 if test $HAVE_FAAD = yes -a $HAVE_MP4V2 = yes; then
858 afh_errlist_objs="$afh_errlist_objs aac_afh aac_common"
859 audio_format_handlers="$audio_format_handlers aac"
860 fi
861
862 afh_objs="add_cmdline($afh_cmdline_objs) $afh_errlist_objs"
863
864 AC_SUBST(afh_objs, add_dot_o($afh_objs))
865 AC_DEFINE_UNQUOTED(INIT_AFH_ERRLISTS,
866 objlist_to_errlist($afh_errlist_objs), errors used by para_afh)
867 ########################################################################## play
868 play_errlist_objs="
869 play
870 fd
871 sched
872 ggo
873 buffer_tree
874 time
875 string
876 net
877 afh_recv
878 afh_common
879 wma_afh
880 wma_common
881 mp3_afh
882 recv_common
883 udp_recv
884 http_recv
885 dccp_recv
886 filter_common
887 fec
888 bitstream
889 imdct
890 wav_filter
891 compress_filter
892 amp_filter
893 prebuffer_filter
894 fecdec_filter
895 wmadec_filter
896 write_common
897 file_write
898 version
899 sync_filter
900 "
901 play_cmdline_objs="
902 http_recv
903 dccp_recv
904 udp_recv
905 afh_recv
906 compress_filter
907 amp_filter
908 prebuffer_filter
909 file_write
910 play
911 sync_filter
912 "
913 if test "$have_core_audio" = "yes"; then
914 play_errlist_objs="$play_errlist_objs osx_write ipc"
915 play_cmdline_objs="$play_cmdline_objs osx_write"
916 fi
917 NEED_OGG_OBJECTS && play_errlist_objs="$play_errlist_objs ogg_afh_common"
918 NEED_VORBIS_OBJECTS && {
919 play_errlist_objs="$play_errlist_objs oggdec_filter ogg_afh"
920 }
921 NEED_SPEEX_OBJECTS && {
922 play_errlist_objs="$play_errlist_objs spxdec_filter spx_afh spx_common"
923 }
924 NEED_OPUS_OBJECTS &&
925 play_errlist_objs="$play_errlist_objs
926 opusdec_filter
927 opus_afh
928 opus_common
929 "
930 NEED_FLAC_OBJECTS && {
931 play_errlist_objs="$play_errlist_objs flacdec_filter flac_afh"
932 }
933 if test $HAVE_FAAD = yes; then
934 play_errlist_objs="$play_errlist_objs aacdec_filter"
935 fi
936 if test $HAVE_MP4V2 = yes; then
937 play_errlist_objs="$play_errlist_objs aac_afh"
938 fi
939 if test $HAVE_MP4V2 = yes || test $HAVE_FAAD = yes; then
940 play_errlist_objs="$play_errlist_objs aac_common"
941 fi
942 if test $HAVE_MAD = yes; then
943 play_cmdline_objs="$play_cmdline_objs mp3dec_filter"
944 play_errlist_objs="$play_errlist_objs mp3dec_filter"
945 fi
946 if test $HAVE_OSS = yes; then
947 play_errlist_objs="$play_errlist_objs oss_write"
948 play_cmdline_objs="$play_cmdline_objs oss_write"
949 fi
950 if test $HAVE_ALSA = yes; then
951 play_errlist_objs="$play_errlist_objs alsa_write"
952 play_cmdline_objs="$play_cmdline_objs alsa_write"
953 fi
954 NEED_AO_OBJECTS && {
955 play_errlist_objs="$play_errlist_objs ao_write"
956 play_cmdline_objs="$play_cmdline_objs ao_write"
957 }
958 if test $HAVE_READLINE = yes; then
959 play_errlist_objs="$play_errlist_objs interactive"
960 fi
961 if test $HAVE_SAMPLERATE = yes; then
962 play_errlist_objs="$play_errlist_objs resample_filter check_wav"
963 play_cmdline_objs="$play_cmdline_objs resample_filter"
964 fi
965
966 play_objs="add_cmdline($play_cmdline_objs) $play_errlist_objs"
967 AC_SUBST(play_objs, add_dot_o($play_objs))
968 AC_DEFINE_UNQUOTED(INIT_PLAY_ERRLISTS,
969 objlist_to_errlist($play_errlist_objs), errors used by para_play)
970 ######################################################################### write
971 write_cmdline_objs="
972 write
973 file_write
974 "
975 write_errlist_objs="
976 write
977 write_common
978 file_write
979 time
980 fd
981 string
982 sched
983 stdin
984 buffer_tree
985 ggo
986 check_wav
987 version
988 "
989 writers="file"
990 default_writer="FILE_WRITE"
991
992 if test "$have_core_audio" = "yes"; then
993 write_errlist_objs="$write_errlist_objs osx_write ipc"
994 write_cmdline_objs="$write_cmdline_objs osx_write"
995 writers="$writers osx"
996 default_writer="OSX_WRITE"
997 fi
998 NEED_AO_OBJECTS && {
999 write_errlist_objs="$write_errlist_objs ao_write"
1000 write_cmdline_objs="$write_cmdline_objs ao_write"
1001 writers="$writers ao"
1002 default_writer="AO_WRITE"
1003 }
1004 if test $HAVE_OSS = yes; then
1005 write_errlist_objs="$write_errlist_objs oss_write"
1006 write_cmdline_objs="$write_cmdline_objs oss_write"
1007 writers="$writers oss"
1008 default_writer="OSS_WRITE"
1009 fi
1010 if test $HAVE_ALSA = yes; then
1011 write_errlist_objs="$write_errlist_objs alsa_write"
1012 write_cmdline_objs="$write_cmdline_objs alsa_write"
1013 writers="$writers alsa"
1014 default_writer="ALSA_WRITE"
1015 fi
1016 AC_SUBST(writers)
1017 write_objs="add_cmdline($write_cmdline_objs) $write_errlist_objs"
1018 AC_SUBST(write_objs, add_dot_o($write_objs))
1019 AC_DEFINE_UNQUOTED(INIT_WRITE_ERRLISTS,
1020 objlist_to_errlist($write_errlist_objs), errors used by para_write)
1021 enum="$(for i in $writers; do printf "${i}_WRITE, " | tr '[a-z]' '[A-Z]'; done)"
1022 AC_DEFINE_UNQUOTED(WRITER_ENUM, $enum NUM_SUPPORTED_WRITERS,
1023 enum of supported writers)
1024 AC_DEFINE_UNQUOTED(DEFAULT_WRITER, $default_writer, use this writer if none was specified)
1025 names="$(for i in $writers; do printf \"$i\",' ' ; done)"
1026 AC_DEFINE_UNQUOTED(WRITER_NAMES, $names, supported writer names)
1027 inits="$(for i in $writers; do printf 'extern void '$i'_write_init(struct writer *); '; done)"
1028 AC_DEFINE_UNQUOTED(DECLARE_WRITER_INITS, $inits, init functions of the supported writers)
1029 array="$(for i in $writers; do printf '{.init = '$i'_write_init},'; done)"
1030 AC_DEFINE_UNQUOTED(WRITER_ARRAY, $array, array of supported writers)
1031 ######################################################################## audioc
1032 audioc_cmdline_objs="audioc"
1033 audioc_errlist_objs="
1034 audioc
1035 string
1036 net
1037 fd
1038 version
1039 ggo
1040 "
1041 if test $HAVE_READLINE = yes; then
1042 audioc_errlist_objs="$audioc_errlist_objs
1043 buffer_tree
1044 interactive
1045 sched
1046 time
1047 "
1048 fi
1049 audioc_objs="add_cmdline($audioc_cmdline_objs) $audioc_errlist_objs"
1050 AC_SUBST(audioc_objs, add_dot_o($audioc_objs))
1051 AC_DEFINE_UNQUOTED(INIT_AUDIOC_ERRLISTS,
1052 objlist_to_errlist($audioc_errlist_objs), errors used by para_audioc)
1053 ############################################################# error2.h
1054 # these are always built
1055 all_errlist_objs="
1056 $recv_errlist_objs
1057 $filter_errlist_objs
1058 $audioc_errlist_objs
1059 $write_errlist_objs
1060 $afh_errlist_objs
1061 $play_errlist_objs
1062 "
1063
1064 # optional executables
1065 if test "$build_server" = "yes"; then
1066 all_errlist_objs="$all_errlist_objs $server_errlist_objs"
1067 fi
1068 if test "$build_gui" = "yes"; then
1069 all_errlist_objs="$all_errlist_objs $gui_errlist_objs"
1070 fi
1071 if test "$build_fade" = "yes"; then
1072 all_errlist_objs="$all_errlist_objs $fade_errlist_objs"
1073 fi
1074 if test "$build_client" = "yes"; then
1075 all_errlist_objs="$all_errlist_objs $client_errlist_objs"
1076 fi
1077 if test "$build_audiod" = "yes"; then
1078 all_errlist_objs="$all_errlist_objs $audiod_errlist_objs"
1079 fi
1080
1081 all_errlist_objs="$(echo $all_errlist_objs | tr ' ' '\n' | sort | uniq)"
1082
1083 object_executable_matrix=
1084 for i in $executables; do
1085 eval objs=\$${i}_errlist_objs
1086 object_executable_matrix="$object_executable_matrix $i: $objs"
1087 done
1088 # use echo to replace newlines by space
1089 AC_SUBST(object_executable_matrix, $(echo $object_executable_matrix))
1090
1091 SS=$(for obj in $all_errlist_objs; do
1092 printf '%s' " SS_$obj,"; done | tr 'a-z' 'A-Z')
1093 AC_DEFINE_UNQUOTED(DEFINE_ERRLIST_OBJECT_ENUM,
1094 [enum {$SS NUM_SS}],
1095 [list of all objects that use the paraslash error facility]
1096 )
1097 ################################################################## status items
1098
1099 status_items="basename status num_played mtime bitrate frequency file_size
1100 status_flags format score techinfo afs_mode
1101 attributes_txt decoder_flags audiod_status play_time attributes_bitmap
1102 offset seconds_total stream_start current_time audiod_uptime image_id
1103 lyrics_id duration directory lyrics_name image_name path hash channels
1104 last_played num_chunks chunk_time amplification artist title year album
1105 comment"
1106
1107 result=
1108 for i in $status_items; do
1109 result="$result SI_$(echo $i | tr 'a-z' 'A-Z'), "
1110 done
1111 AC_DEFINE_UNQUOTED(STATUS_ITEM_ENUM, [$result],
1112 [enum of all status items])
1113
1114 result=
1115 for i in $status_items; do
1116 result="$result \"$i\", "
1117 done
1118 AC_DEFINE_UNQUOTED(STATUS_ITEM_ARRAY, [$result],
1119 [char * array of all status items])
1120
1121 AC_DEFINE_UNQUOTED(AUDIO_FORMAT_HANDLERS, "$audio_format_handlers",
1122 [formats supported by para_server and para_afh])
1123
1124 AC_SUBST(executables)
1125
1126 AC_OUTPUT
1127 AC_MSG_NOTICE([
1128 paraslash configuration:
1129 ~~~~~~~~~~~~~~~~~~~~~~~~
1130 crypto lib: ${CRYPTOLIB:-[none]}
1131 unix socket credentials: $have_ucred
1132 readline (interactive CLIs): $HAVE_READLINE
1133 id3 version 2 support: $HAVE_ID3TAG
1134 faad: $HAVE_FAAD
1135 mp4v2: $HAVE_MP4V2
1136
1137 audio format handlers: $audio_format_handlers
1138 filters: $(echo $filters)
1139 writers: $writers
1140
1141 para_server: $build_server
1142 para_gui: $build_gui
1143 para_fade: $build_fade
1144 para_client: $build_client
1145 para_audiod: $build_audiod
1146 ])