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