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