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