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