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