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