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