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