]> git.tuebingen.mpg.de Git - paraslash.git/blob - configure.ac
The ogg/speex 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 AC_CHECK_LIB([ogg], [ogg_stream_flush_fill], [
276         AC_DEFINE(HAVE_OGG_STREAM_FLUSH_FILL, 1, [libogg >= 1.3.0])])
277 LIB_SUBST_FLAGS(ogg)
278 UNSTASH_FLAGS
279 ######################################################################### vorbis
280 STASH_FLAGS
281 LIB_ARG_WITH([vorbis], [-lvorbis -lvorbisfile])
282 HAVE_VORBIS=yes
283 AC_CHECK_HEADERS([vorbis/codec.h], [], [HAVE_VORBIS=no])
284 AC_CHECK_LIB([vorbis], [vorbis_info_init], [], [HAVE_VORBIS=no])
285 LIB_SUBST_FLAGS(vorbis)
286 UNSTASH_FLAGS
287 ######################################################################### speex
288 STASH_FLAGS
289 LIB_ARG_WITH([speex], [-lspeex])
290 HAVE_SPEEX=yes
291 AC_CHECK_HEADERS([speex/speex.h], [], [HAVE_SPEEX=no])
292 AC_CHECK_LIB([speex], [speex_decoder_init], [], [HAVE_SPEEX=no])
293 LIB_SUBST_FLAGS(speex)
294 UNSTASH_FLAGS
295 ######################################################################### opus
296 STASH_FLAGS
297 LIB_ARG_WITH([opus], [-lopus])
298 HAVE_OPUS=yes
299 AC_CHECK_HEADERS([opus/opus.h], [], [HAVE_OPUS=no])
300 AC_CHECK_LIB([opus], [opus_multistream_decode], [], [HAVE_OPUS=no])
301 LIB_SUBST_FLAGS(opus)
302 UNSTASH_FLAGS
303 ########################################################################### flac
304 STASH_FLAGS
305 LIB_ARG_WITH([flac], [-lFLAC -lm])
306 HAVE_FLAC=yes
307 AC_CHECK_HEADER(FLAC/stream_decoder.h, [], HAVE_FLAC=no)
308 AC_CHECK_LIB([FLAC], [FLAC__stream_decoder_init_file], [], HAVE_FLAC=no)
309 LIB_SUBST_FLAGS(flac)
310 UNSTASH_FLAGS
311
312 # some helper functions for codecs which use the ogg container format
313 AC_DEFUN([NEED_OGG_OBJECTS], [{
314         test "$HAVE_OGG" = 'yes' -a \( \
315                  "$HAVE_VORBIS" = 'yes' \
316                 -o "$HAVE_SPEEX" = 'yes' \
317                 -o "$HAVE_OPUS" = 'yes' \
318                 -o "$HAVE_FLAC" = 'yes' \
319         \)
320 }])
321 AC_DEFUN([NEED_VORBIS_OBJECTS], [{
322         test "$HAVE_OGG" = 'yes' -a "$HAVE_VORBIS" = 'yes'
323 }])
324 AC_DEFUN([NEED_SPEEX_OBJECTS], [{
325         test "$HAVE_OGG" = 'yes' -a "$HAVE_SPEEX" = 'yes'
326 }])
327 AC_DEFUN([NEED_OPUS_OBJECTS], [{
328         test "$HAVE_OGG" = 'yes' -a "$HAVE_OPUS" = 'yes'
329 }])
330 AC_DEFUN([NEED_FLAC_OBJECTS], [{
331         test "$HAVE_OGG" = 'yes' -a "$HAVE_FLAC" = 'yes'
332 }])
333 ########################################################################### faad
334 STASH_FLAGS
335 LIB_ARG_WITH([faad], [-lfaad])
336 HAVE_FAAD=yes
337 AC_CHECK_HEADER(neaacdec.h, [], HAVE_FAAD=no)
338 AC_CHECK_LIB([faad], [NeAACDecOpen], [], HAVE_FAAD=no)
339 LIB_SUBST_FLAGS(faad)
340 UNSTASH_FLAGS
341 ########################################################################### mad
342 STASH_FLAGS
343 LIB_ARG_WITH([mad], [-lmad])
344 HAVE_MAD=yes
345 AC_CHECK_HEADER(mad.h, [], HAVE_MAD=no)
346 AC_CHECK_LIB([mad], [mad_stream_init], [], HAVE_MAD=no)
347 LIB_SUBST_FLAGS(mad)
348 UNSTASH_FLAGS
349 ###################################################################### libid3tag
350 STASH_FLAGS
351 LIB_ARG_WITH([id3tag], [-lid3tag -lz])
352 HAVE_ID3TAG=yes
353 AC_CHECK_HEADER(id3tag.h, [], HAVE_ID3TAG=no)
354 AC_CHECK_LIB([id3tag], [id3_file_fdopen], [], HAVE_ID3TAG=no)
355 LIB_SUBST_FLAGS(id3tag)
356 UNSTASH_FLAGS
357 ########################################################################### oss
358 STASH_FLAGS
359 LIB_ARG_WITH([oss], [])
360 AC_CHECK_HEADER(sys/soundcard.h, [HAVE_OSS=yes], [HAVE_OSS=no])
361 AC_CHECK_LIB(ossaudio, _oss_ioctl, [oss_ldflags="$oss_ldflags -lossaudio"], [])
362 LIB_SUBST_FLAGS(oss)
363 UNSTASH_FLAGS
364 ########################################################################### alsa
365 STASH_FLAGS
366 LIB_ARG_WITH([alsa], [-lasound])
367 HAVE_ALSA=yes
368 AC_CHECK_HEADER(alsa/asoundlib.h, [], HAVE_ALSA=no)
369 AC_CHECK_LIB([asound], [snd_pcm_open], [], HAVE_ALSA=no)
370 LIB_SUBST_FLAGS(alsa)
371 UNSTASH_FLAGS
372 ######################################################################### pthread
373 STASH_FLAGS
374 LIB_ARG_WITH([pthread], [-lpthread])
375 HAVE_PTHREAD=yes
376 AC_CHECK_HEADER(pthread.h, [], HAVE_PTHREAD=no)
377 AC_CHECK_LIB([pthread], [pthread_create], [], HAVE_PTHREAD=no)
378 LIB_SUBST_FLAGS(pthread)
379 UNSTASH_FLAGS
380 ########################################################################### libao
381 STASH_FLAGS
382 LIB_ARG_WITH([ao], [-lao])
383 HAVE_AO=yes
384 AC_CHECK_HEADER(ao/ao.h, [], HAVE_AO=no)
385 AC_CHECK_LIB([ao], [ao_initialize], [], HAVE_AO=no)
386 LIB_SUBST_FLAGS(ao)
387 UNSTASH_FLAGS
388 AC_DEFUN([NEED_AO_OBJECTS], [{ test $HAVE_AO = yes -a $HAVE_PTHREAD = yes; }])
389 ######################################################################## readline
390 STASH_FLAGS
391 AC_SEARCH_LIBS([tgetent], [tinfo curses terminfo termcap])
392 LIB_ARG_WITH([readline], [-lreadline $LIBS])
393 HAVE_READLINE=yes
394 AC_CHECK_HEADER([readline/readline.h], [], [HAVE_READLINE=no])
395 AC_CHECK_LIB([readline], [rl_free_keymap], [], HAVE_READLINE=no)
396 AC_CHECK_DECL(
397         [rl_free_keymap],
398         [AC_DEFINE(RL_FREE_KEYMAP_DECLARED, 1, readline >= 6.3)],
399         [],
400         [
401                 #include <stdio.h>
402                 #include <readline/readline.h>
403         ]
404 )
405 LIB_SUBST_FLAGS(readline)
406 UNSTASH_FLAGS
407 ############################################################# libsamplerate
408 STASH_FLAGS
409 LIB_ARG_WITH([samplerate], [-lsamplerate])
410 HAVE_SAMPLERATE=yes
411 AC_CHECK_HEADER(samplerate.h, [], HAVE_SAMPLERATE=no)
412 AC_CHECK_LIB([samplerate], [src_process], [], HAVE_SAMPLERATE=no)
413 LIB_SUBST_FLAGS(samplerate)
414 UNSTASH_FLAGS
415 ######################################################################### server
416 if test -n "$CRYPTOLIB" && test $HAVE_OSL = yes; then
417         build_server="yes"
418         executables="$executables server"
419         server_cmdline_objs="server"
420         server_errlist_objs="
421                 server
422                 afh_common
423                 mp3_afh
424                 vss
425                 command
426                 net
427                 string
428                 signal
429                 time
430                 daemon
431                 http_send
432                 close_on_fork
433                 mm
434                 crypt_common
435                 ipc
436                 dccp_send
437                 fd
438                 user_list
439                 chunk_queue
440                 afs
441                 aft
442                 mood
443                 score
444                 attribute
445                 blob
446                 playlist
447                 sched
448                 acl
449                 send_common
450                 udp_send
451                 color
452                 fec
453                 wma_afh
454                 wma_common
455                 sideband
456                 version
457                 ggo
458         "
459         if test "$CRYPTOLIB" = openssl; then
460                 server_errlist_objs="$server_errlist_objs crypt"
461         else
462                 server_errlist_objs="$server_errlist_objs gcrypt"
463         fi
464         NEED_OGG_OBJECTS() && server_errlist_objs="$server_errlist_objs ogg_afh_common"
465         NEED_VORBIS_OBJECTS() && server_errlist_objs="$server_errlist_objs ogg_afh"
466         NEED_SPEEX_OBJECTS() && server_errlist_objs="$server_errlist_objs spx_afh spx_common"
467         NEED_OPUS_OBJECTS() && server_errlist_objs="$server_errlist_objs opus_afh opus_common"
468         NEED_FLAC_OBJECTS && server_errlist_objs="$server_errlist_objs flac_afh"
469         test $HAVE_FAAD = yes && server_errlist_objs="$server_errlist_objs aac_afh aac_common"
470         server_objs="add_cmdline($server_cmdline_objs) $server_errlist_objs"
471         AC_SUBST(server_objs, add_dot_o($server_objs))
472         AC_DEFINE_UNQUOTED(INIT_SERVER_ERRLISTS,
473                 objlist_to_errlist($server_errlist_objs), errors used by para_server)
474 else
475         build_server="no"
476 fi
477 ############################################################# client
478 if test -n "$CRYPTOLIB"; then
479         build_client="yes"
480         executables="$executables client"
481         client_cmdline_objs="client"
482         client_errlist_objs="
483                 client
484                 net
485                 string
486                 fd
487                 sched
488                 stdin
489                 stdout
490                 time
491                 sideband
492                 client_common
493                 buffer_tree
494                 crypt_common
495                 version
496                 ggo
497         "
498         if test "$CRYPTOLIB" = openssl; then
499                 client_errlist_objs="$client_errlist_objs crypt"
500         else
501                 client_errlist_objs="$client_errlist_objs gcrypt"
502         fi
503         if test $HAVE_READLINE = yes; then
504                 client_errlist_objs="$client_errlist_objs interactive"
505         fi
506         client_objs="add_cmdline($client_cmdline_objs) $client_errlist_objs"
507         AC_SUBST(client_objs, add_dot_o($client_objs))
508         AC_DEFINE_UNQUOTED(INIT_CLIENT_ERRLISTS,
509                 objlist_to_errlist($client_errlist_objs), errors used by para_client)
510 else
511         build_client="no"
512 fi
513 ############################################################# audiod
514 if test -n "$CRYPTOLIB"; then
515         build_audiod="yes"
516         executables="$executables audiod"
517         audiod_audio_formats="wma"
518         audiod_cmdline_objs="$audiod_cmdline_objs
519                 audiod
520                 compress_filter
521                 http_recv
522                 dccp_recv
523                 file_write
524                 client
525                 amp_filter
526                 udp_recv
527                 prebuffer_filter
528                 sync_filter
529         "
530         audiod_errlist_objs="$audiod_errlist_objs
531                 audiod
532                 signal
533                 string
534                 daemon
535                 stat
536                 net
537                 crypt_common
538                 sideband
539                 time
540                 grab_client
541                 filter_common
542                 wav_filter
543                 compress_filter
544                 amp_filter
545                 http_recv
546                 dccp_recv
547                 recv_common
548                 fd
549                 sched
550                 write_common
551                 file_write
552                 audiod_command
553                 fecdec_filter
554                 client_common
555                 ggo
556                 udp_recv
557                 color
558                 fec
559                 prebuffer_filter
560                 version
561                 bitstream
562                 imdct
563                 wma_common
564                 wmadec_filter
565                 buffer_tree
566                 sync_filter
567         "
568         if test "$CRYPTOLIB" = openssl; then
569                 audiod_errlist_objs="$audiod_errlist_objs crypt"
570         else
571                 audiod_errlist_objs="$audiod_errlist_objs gcrypt"
572         fi
573         if test "$have_core_audio" = "yes"; then
574                 audiod_errlist_objs="$audiod_errlist_objs osx_write ipc"
575                 audiod_cmdline_objs="$audiod_cmdline_objs osx_write"
576         fi
577         NEED_VORBIS_OBJECTS && {
578                 audiod_errlist_objs="$audiod_errlist_objs oggdec_filter"
579                 audiod_audio_formats="$audiod_audio_formats ogg"
580         }
581         NEED_SPEEX_OBJECTS && {
582                 audiod_errlist_objs="$audiod_errlist_objs spxdec_filter spx_common"
583                 audiod_audio_formats="$audiod_audio_formats spx"
584         }
585         NEED_OPUS_OBJECTS && {
586                 audiod_errlist_objs="$audiod_errlist_objs opusdec_filter opus_common"
587                 audiod_audio_formats="$audiod_audio_formats opus"
588         }
589         NEED_FLAC_OBJECTS && {
590                 audiod_errlist_objs="$audiod_errlist_objs flacdec_filter"
591                 audiod_audio_formats="$audiod_audio_formats flac"
592         }
593         if test $HAVE_FAAD = yes; then
594                 audiod_errlist_objs="$audiod_errlist_objs aacdec_filter aac_common"
595                 audiod_audio_formats="$audiod_audio_formats aac"
596         fi
597         if test $HAVE_MAD = yes; then
598                 audiod_audio_formats="$audiod_audio_formats mp3"
599                 audiod_cmdline_objs="$audiod_cmdline_objs mp3dec_filter"
600                 audiod_errlist_objs="$audiod_errlist_objs mp3dec_filter"
601         fi
602         if test $HAVE_OSS = yes; then
603                 audiod_errlist_objs="$audiod_errlist_objs oss_write"
604                 audiod_cmdline_objs="$audiod_cmdline_objs oss_write"
605         fi
606         if test $HAVE_ALSA = yes; then
607                 audiod_errlist_objs="$audiod_errlist_objs alsa_write"
608                 audiod_cmdline_objs="$audiod_cmdline_objs alsa_write"
609         fi
610         NEED_AO_OBJECTS && {
611                 audiod_errlist_objs="$audiod_errlist_objs ao_write"
612                 audiod_cmdline_objs="$audiod_cmdline_objs ao_write"
613         }
614         if test $HAVE_SAMPLERATE = yes; then
615                 audiod_errlist_objs="$audiod_errlist_objs resample_filter check_wav"
616                 audiod_cmdline_objs="$audiod_cmdline_objs resample_filter"
617         fi
618         audiod_objs="add_cmdline($audiod_cmdline_objs) $audiod_errlist_objs"
619         AC_SUBST(audiod_objs, add_dot_o($audiod_objs))
620         AC_DEFINE_UNQUOTED(INIT_AUDIOD_ERRLISTS, objlist_to_errlist($audiod_errlist_objs),
621                 errors used by para_audiod)
622
623         enum="$(for i in $audiod_audio_formats; do printf "AUDIO_FORMAT_${i}, " | tr '[a-z]' '[A-Z]'; done)"
624         AC_DEFINE_UNQUOTED(AUDIOD_AUDIO_FORMATS_ENUM, $enum NUM_AUDIO_FORMATS,
625                 enum of audio formats supported by audiod)
626         names="$(for i in $audiod_audio_formats; do printf \"$i\",' ' ; done)"
627         AC_DEFINE_UNQUOTED(AUDIOD_AUDIO_FORMAT_ARRAY, $names, array of audio formats supported by audiod)
628 else
629         build_audiod="no"
630 fi
631 ########################################################################### fade
632 if test $HAVE_OSS = yes -o $HAVE_ALSA = yes; then
633         build_fade="yes"
634         executables="$executables fade"
635         fade_cmdline_objs="fade"
636         fade_errlist_objs="fade exec string fd version ggo"
637         if test $HAVE_OSS = yes; then
638                 fade_errlist_objs="$fade_errlist_objs oss_mix"
639                 mixers="${mixers}oss "
640                 default_mixer="OSS_MIX"
641         fi
642         if test $HAVE_ALSA = yes; then
643                 fade_errlist_objs="$fade_errlist_objs alsa_mix"
644                 mixers="${mixers}alsa "
645                 default_mixer="ALSA_MIX"
646         fi
647         fade_objs="add_cmdline($fade_cmdline_objs) $fade_errlist_objs"
648         AC_SUBST(fade_objs, add_dot_o($fade_objs))
649         AC_DEFINE_UNQUOTED(INIT_FADE_ERRLISTS,
650                 objlist_to_errlist($fade_errlist_objs),
651                 errors used by para_fade)
652         enum="$(
653                 for i in $mixers; do
654                         printf "${i}_MIX, " | tr '[a-z]' '[A-Z]'
655                 done
656         )"
657         AC_DEFINE_UNQUOTED(MIXER_ENUM, $enum NUM_SUPPORTED_MIXERS,
658                 enum of supported mixers)
659         AC_DEFINE_UNQUOTED(DEFAULT_MIXER, $default_mixer,
660                 use this mixer if none was specified)
661         names="$(for i in $mixers; do printf \"$i\",' ' ; done)"
662         AC_DEFINE_UNQUOTED(MIXER_NAMES, $names, supported mixer names)
663         inits="$(
664                 for i in $mixers; do
665                         printf 'extern void '$i'_mix_init(struct mixer *); '
666                 done
667         )"
668         AC_DEFINE_UNQUOTED(DECLARE_MIXER_INITS, $inits,
669                 init functions of the supported mixers)
670         array="$(for i in $mixers; do printf '{.init = '$i'_mix_init},'; done)"
671         AC_DEFINE_UNQUOTED(MIXER_ARRAY, $array, array of supported mixers)
672 else
673         build_fade="no"
674         AC_MSG_WARN([no mixer support])
675 fi
676 ########################################################################### gui
677 if test $HAVE_CURSES = yes; then
678         build_gui="yes"
679         executables="$executables gui"
680         gui_cmdline_objs="gui"
681         gui_errlist_objs="
682                 exec
683                 signal
684                 string
685                 stat
686                 ringbuffer
687                 fd
688                 gui
689                 gui_theme
690                 time
691                 sched
692                 version
693                 ggo
694         "
695         gui_objs="add_cmdline($gui_cmdline_objs) $gui_errlist_objs"
696         AC_SUBST(gui_objs, add_dot_o($gui_objs))
697         AC_DEFINE_UNQUOTED(INIT_GUI_ERRLISTS,
698                 objlist_to_errlist($gui_errlist_objs), errors used by para_gui)
699 else
700         build_gui="no"
701         AC_MSG_WARN([no curses lib, cannot build para_gui])
702 fi
703 ######################################################################## filter
704 filters="
705         compress
706         wav
707         amp
708         fecdec
709         wmadec
710         prebuffer
711         sync
712 "
713 filter_errlist_objs="
714         filter_common
715         wav_filter
716         compress_filter
717         filter
718         string
719         stdin
720         stdout
721         sched
722         fd
723         amp_filter
724         ggo
725         fecdec_filter
726         fec
727         version
728         prebuffer_filter
729         time
730         bitstream
731         imdct
732         wma_common
733         wmadec_filter
734         buffer_tree
735         net
736         sync_filter
737 "
738 filter_cmdline_objs="
739         filter
740         compress_filter
741         amp_filter
742         prebuffer_filter
743         sync_filter
744 "
745 NEED_VORBIS_OBJECTS && {
746         filters="$filters oggdec"
747         filter_errlist_objs="$filter_errlist_objs oggdec_filter"
748 }
749 NEED_SPEEX_OBJECTS && {
750         filters="$filters spxdec"
751         filter_errlist_objs="$filter_errlist_objs spxdec_filter spx_common"
752 }
753 NEED_OPUS_OBJECTS && {
754         filters="$filters opusdec"
755         filter_errlist_objs="$filter_errlist_objs opusdec_filter opus_common"
756 }
757 NEED_FLAC_OBJECTS && {
758         filter_errlist_objs="$filter_errlist_objs flacdec_filter"
759         filters="$filters flacdec"
760 }
761 if test $HAVE_FAAD = yes; then
762         filter_errlist_objs="$filter_errlist_objs aacdec_filter aac_common"
763         filters="$filters aacdec"
764 fi
765 if test $HAVE_MAD = yes; then
766         filter_cmdline_objs="$filter_cmdline_objs mp3dec_filter"
767         filter_errlist_objs="$filter_errlist_objs mp3dec_filter"
768         filters="$filters mp3dec"
769 fi
770 if test $HAVE_SAMPLERATE = yes; then
771         filter_errlist_objs="$filter_errlist_objs resample_filter check_wav"
772         filter_cmdline_objs="$filter_cmdline_objs resample_filter"
773         filters="$filters resample"
774 fi
775 filters="$(echo $filters)"
776 AC_SUBST(filters)
777 filter_objs="add_cmdline($filter_cmdline_objs) $filter_errlist_objs"
778
779 AC_SUBST(filter_objs, add_dot_o($filter_objs))
780 AC_DEFINE_UNQUOTED(INIT_FILTER_ERRLISTS,
781         objlist_to_errlist($filter_errlist_objs), errors used by para_filter)
782
783 enum="$(for i in $filters; do printf "${i}_FILTER, " | tr '[a-z]' '[A-Z]'; done)"
784 AC_DEFINE_UNQUOTED(FILTER_ENUM, $enum NUM_SUPPORTED_FILTERS,
785         enum of supported filters)
786 inits="$(for i in $filters; do printf 'extern void '$i'_filter_init(struct filter *f); '; done)"
787 AC_DEFINE_UNQUOTED(DECLARE_FILTER_INITS, $inits, init functions of the supported filters)
788 array="$(for i in $filters; do printf '{.name = "'$i'", .init = '$i'_filter_init},'; done)"
789 AC_DEFINE_UNQUOTED(FILTER_ARRAY, $array, array of supported filters)
790 ########################################################################## recv
791 recv_cmdline_objs="
792         recv
793         http_recv
794         dccp_recv
795         udp_recv
796         afh_recv
797 "
798
799 recv_errlist_objs="
800         http_recv
801         recv_common
802         recv
803         time
804         string
805         net
806         dccp_recv
807         fd
808         sched
809         stdout
810         ggo
811         udp_recv
812         buffer_tree
813         afh_recv
814         afh_common
815         wma_afh
816         wma_common
817         mp3_afh
818         version
819 "
820 NEED_OGG_OBJECTS && recv_errlist_objs="$recv_errlist_objs ogg_afh_common"
821 NEED_VORBIS_OBJECTS && recv_errlist_objs="$recv_errlist_objs ogg_afh"
822 NEED_SPEEX_OBJECTS && recv_errlist_objs="$recv_errlist_objs spx_afh spx_common"
823 NEED_OPUS_OBJECTS && recv_errlist_objs="$recv_errlist_objs opus_afh opus_common"
824 NEED_FLAC_OBJECTS && recv_errlist_objs="$recv_errlist_objs flac_afh"
825
826 if test $HAVE_FAAD = yes; then
827         recv_errlist_objs="$recv_errlist_objs aac_afh aac_common"
828 fi
829 recv_objs="add_cmdline($recv_cmdline_objs) $recv_errlist_objs"
830 AC_SUBST(receivers, "http dccp udp afh")
831 AC_SUBST(recv_objs, add_dot_o($recv_objs))
832 AC_DEFINE_UNQUOTED(INIT_RECV_ERRLISTS, objlist_to_errlist($recv_errlist_objs),
833         errors used by para_recv)
834 ########################################################################### afh
835 audio_format_handlers="mp3 wma"
836 afh_cmdline_objs="afh"
837 afh_errlist_objs="
838         afh
839         string
840         fd
841         mp3_afh
842         afh_common
843         time
844         wma_afh
845         wma_common
846         version
847         ggo
848 "
849 NEED_OGG_OBJECTS && afh_errlist_objs="$afh_errlist_objs ogg_afh_common"
850 NEED_VORBIS_OBJECTS && {
851         afh_errlist_objs="$afh_errlist_objs ogg_afh"
852         audio_format_handlers="$audio_format_handlers ogg"
853 }
854 NEED_SPEEX_OBJECTS && {
855         afh_errlist_objs="$afh_errlist_objs spx_afh spx_common"
856         audio_format_handlers="$audio_format_handlers spx"
857 }
858 NEED_OPUS_OBJECTS && {
859         afh_errlist_objs="$afh_errlist_objs opus_afh opus_common"
860         audio_format_handlers="$audio_format_handlers opus"
861 }
862 NEED_FLAC_OBJECTS && {
863         afh_errlist_objs="$afh_errlist_objs flac_afh"
864         audio_format_handlers="$audio_format_handlers flac"
865 }
866 if test $HAVE_FAAD = yes; then
867         afh_errlist_objs="$afh_errlist_objs aac_common aac_afh"
868         audio_format_handlers="$audio_format_handlers aac"
869 fi
870
871 afh_objs="add_cmdline($afh_cmdline_objs) $afh_errlist_objs"
872
873 AC_SUBST(afh_objs, add_dot_o($afh_objs))
874 AC_DEFINE_UNQUOTED(INIT_AFH_ERRLISTS,
875         objlist_to_errlist($afh_errlist_objs), errors used by para_afh)
876 ########################################################################## play
877 play_errlist_objs="
878         play
879         fd
880         sched
881         ggo
882         buffer_tree
883         time
884         string
885         net
886         afh_recv
887         afh_common
888         wma_afh
889         wma_common
890         mp3_afh
891         recv_common
892         udp_recv
893         http_recv
894         dccp_recv
895         filter_common
896         fec
897         bitstream
898         imdct
899         wav_filter
900         compress_filter
901         amp_filter
902         prebuffer_filter
903         fecdec_filter
904         wmadec_filter
905         write_common
906         file_write
907         version
908         sync_filter
909 "
910 play_cmdline_objs="
911         http_recv
912         dccp_recv
913         udp_recv
914         afh_recv
915         compress_filter
916         amp_filter
917         prebuffer_filter
918         file_write
919         play
920         sync_filter
921 "
922 if test "$have_core_audio" = "yes"; then
923         play_errlist_objs="$play_errlist_objs osx_write ipc"
924         play_cmdline_objs="$play_cmdline_objs osx_write"
925 fi
926 NEED_OGG_OBJECTS && play_errlist_objs="$play_errlist_objs ogg_afh_common"
927 NEED_VORBIS_OBJECTS && {
928         play_errlist_objs="$play_errlist_objs oggdec_filter ogg_afh"
929 }
930 NEED_SPEEX_OBJECTS && {
931         play_errlist_objs="$play_errlist_objs spxdec_filter spx_afh spx_common"
932 }
933 NEED_OPUS_OBJECTS &&
934         play_errlist_objs="$play_errlist_objs
935                 opusdec_filter
936                 opus_afh
937                 opus_common
938         "
939 NEED_FLAC_OBJECTS && {
940         play_errlist_objs="$play_errlist_objs flacdec_filter flac_afh"
941 }
942 if test $HAVE_FAAD = yes; then
943         play_errlist_objs="$play_errlist_objs aacdec_filter aac_afh aac_common"
944 fi
945 if test $HAVE_MAD = yes; then
946         play_cmdline_objs="$play_cmdline_objs mp3dec_filter"
947         play_errlist_objs="$play_errlist_objs mp3dec_filter"
948 fi
949 if test $HAVE_OSS = yes; then
950         play_errlist_objs="$play_errlist_objs oss_write"
951         play_cmdline_objs="$play_cmdline_objs oss_write"
952 fi
953 if test $HAVE_ALSA = yes; then
954         play_errlist_objs="$play_errlist_objs alsa_write"
955         play_cmdline_objs="$play_cmdline_objs alsa_write"
956 fi
957 NEED_AO_OBJECTS && {
958         play_errlist_objs="$play_errlist_objs ao_write"
959         play_cmdline_objs="$play_cmdline_objs ao_write"
960 }
961 if test $HAVE_READLINE = yes; then
962         play_errlist_objs="$play_errlist_objs interactive"
963 fi
964 if test $HAVE_SAMPLERATE = yes; then
965         play_errlist_objs="$play_errlist_objs resample_filter check_wav"
966         play_cmdline_objs="$play_cmdline_objs resample_filter"
967 fi
968
969 play_objs="add_cmdline($play_cmdline_objs) $play_errlist_objs"
970 AC_SUBST(play_objs, add_dot_o($play_objs))
971 AC_DEFINE_UNQUOTED(INIT_PLAY_ERRLISTS,
972         objlist_to_errlist($play_errlist_objs), errors used by para_play)
973 ######################################################################### write
974 write_cmdline_objs="
975         write
976         file_write
977 "
978 write_errlist_objs="
979         write
980         write_common
981         file_write
982         time
983         fd
984         string
985         sched
986         stdin
987         buffer_tree
988         ggo
989         check_wav
990         version
991 "
992 writers="file"
993 default_writer="FILE_WRITE"
994
995 if test "$have_core_audio" = "yes"; then
996         write_errlist_objs="$write_errlist_objs osx_write ipc"
997         write_cmdline_objs="$write_cmdline_objs osx_write"
998         writers="$writers osx"
999         default_writer="OSX_WRITE"
1000 fi
1001 NEED_AO_OBJECTS && {
1002         write_errlist_objs="$write_errlist_objs ao_write"
1003         write_cmdline_objs="$write_cmdline_objs ao_write"
1004         writers="$writers ao"
1005         default_writer="AO_WRITE"
1006 }
1007 if test $HAVE_OSS = yes; then
1008         write_errlist_objs="$write_errlist_objs oss_write"
1009         write_cmdline_objs="$write_cmdline_objs oss_write"
1010         writers="$writers oss"
1011         default_writer="OSS_WRITE"
1012 fi
1013 if test $HAVE_ALSA = yes; then
1014         write_errlist_objs="$write_errlist_objs alsa_write"
1015         write_cmdline_objs="$write_cmdline_objs alsa_write"
1016         writers="$writers alsa"
1017         default_writer="ALSA_WRITE"
1018 fi
1019 AC_SUBST(writers)
1020 write_objs="add_cmdline($write_cmdline_objs) $write_errlist_objs"
1021 AC_SUBST(write_objs, add_dot_o($write_objs))
1022 AC_DEFINE_UNQUOTED(INIT_WRITE_ERRLISTS,
1023         objlist_to_errlist($write_errlist_objs), errors used by para_write)
1024 enum="$(for i in $writers; do printf "${i}_WRITE, " | tr '[a-z]' '[A-Z]'; done)"
1025 AC_DEFINE_UNQUOTED(WRITER_ENUM, $enum NUM_SUPPORTED_WRITERS,
1026         enum of supported writers)
1027 AC_DEFINE_UNQUOTED(DEFAULT_WRITER, $default_writer, use this writer if none was specified)
1028 names="$(for i in $writers; do printf \"$i\",' ' ; done)"
1029 AC_DEFINE_UNQUOTED(WRITER_NAMES, $names, supported writer names)
1030 inits="$(for i in $writers; do printf 'extern void '$i'_write_init(struct writer *); '; done)"
1031 AC_DEFINE_UNQUOTED(DECLARE_WRITER_INITS, $inits, init functions of the supported writers)
1032 array="$(for i in $writers; do printf '{.init = '$i'_write_init},'; done)"
1033 AC_DEFINE_UNQUOTED(WRITER_ARRAY, $array, array of supported writers)
1034 ######################################################################## audioc
1035 audioc_cmdline_objs="audioc"
1036 audioc_errlist_objs="
1037         audioc
1038         string
1039         net
1040         fd
1041         version
1042         ggo
1043 "
1044 if test $HAVE_READLINE = yes; then
1045         audioc_errlist_objs="$audioc_errlist_objs
1046                 buffer_tree
1047                 interactive
1048                 sched
1049                 time
1050         "
1051 fi
1052 audioc_objs="add_cmdline($audioc_cmdline_objs) $audioc_errlist_objs"
1053 AC_SUBST(audioc_objs, add_dot_o($audioc_objs))
1054 AC_DEFINE_UNQUOTED(INIT_AUDIOC_ERRLISTS,
1055         objlist_to_errlist($audioc_errlist_objs), errors used by para_audioc)
1056 ############################################################# error2.h
1057 # these are always built
1058 all_errlist_objs="
1059         $recv_errlist_objs
1060         $filter_errlist_objs
1061         $audioc_errlist_objs
1062         $write_errlist_objs
1063         $afh_errlist_objs
1064         $play_errlist_objs
1065 "
1066
1067 # optional executables
1068 if test "$build_server" = "yes"; then
1069         all_errlist_objs="$all_errlist_objs $server_errlist_objs"
1070 fi
1071 if test "$build_gui" = "yes"; then
1072         all_errlist_objs="$all_errlist_objs $gui_errlist_objs"
1073 fi
1074 if test "$build_fade" = "yes"; then
1075         all_errlist_objs="$all_errlist_objs $fade_errlist_objs"
1076 fi
1077 if test "$build_client" = "yes"; then
1078         all_errlist_objs="$all_errlist_objs $client_errlist_objs"
1079 fi
1080 if test "$build_audiod" = "yes"; then
1081         all_errlist_objs="$all_errlist_objs $audiod_errlist_objs"
1082 fi
1083
1084 all_errlist_objs="$(echo $all_errlist_objs | tr ' ' '\n' | sort | uniq)"
1085
1086 object_executable_matrix=
1087 for i in $executables; do
1088         eval objs=\$${i}_errlist_objs
1089         object_executable_matrix="$object_executable_matrix $i: $objs"
1090 done
1091 # use echo to replace newlines by space
1092 AC_SUBST(object_executable_matrix, $(echo $object_executable_matrix))
1093
1094 SS=$(for obj in $all_errlist_objs; do
1095         printf '%s' " SS_$obj,"; done | tr 'a-z' 'A-Z')
1096 AC_DEFINE_UNQUOTED(DEFINE_ERRLIST_OBJECT_ENUM,
1097         [enum {$SS NUM_SS}],
1098         [list of all objects that use the paraslash error facility]
1099 )
1100 ################################################################## status items
1101
1102 status_items="basename status num_played mtime bitrate frequency file_size
1103 status_flags format score techinfo afs_mode
1104 attributes_txt decoder_flags audiod_status play_time attributes_bitmap
1105 offset seconds_total stream_start current_time audiod_uptime image_id
1106 lyrics_id duration directory lyrics_name image_name path hash channels
1107 last_played num_chunks chunk_time amplification artist title year album
1108 comment"
1109
1110 result=
1111 for i in $status_items; do
1112         result="$result SI_$(echo $i | tr 'a-z' 'A-Z'), "
1113 done
1114 AC_DEFINE_UNQUOTED(STATUS_ITEM_ENUM, [$result],
1115         [enum of all status items])
1116
1117 result=
1118 for i in $status_items; do
1119         result="$result \"$i\", "
1120 done
1121 AC_DEFINE_UNQUOTED(STATUS_ITEM_ARRAY, [$result],
1122         [char * array of all status items])
1123
1124 AC_DEFINE_UNQUOTED(AUDIO_FORMAT_HANDLERS, "$audio_format_handlers",
1125         [formats supported by para_server and para_afh])
1126
1127 AC_SUBST(executables)
1128
1129 AC_OUTPUT
1130 AC_MSG_NOTICE([
1131 paraslash configuration:
1132 ~~~~~~~~~~~~~~~~~~~~~~~~
1133 crypto lib: ${CRYPTOLIB:-[none]}
1134 unix socket credentials: $have_ucred
1135 readline (interactive CLIs): $HAVE_READLINE
1136 audio formats handlers: $audio_format_handlers
1137 id3 version 2 support: $HAVE_ID3TAG
1138 filters: $filters
1139 writers: $writers
1140
1141 para_fade: $build_fade
1142 para_server: $build_server
1143 para_gui: $build_gui
1144 para_fade: $build_fade
1145 para_client: $build_client
1146 para_audiod: $build_audiod
1147 ])