build: Unify spelling of commands and directories.
[paraslash.git] / configure.ac
1 #                                               -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
3
4 AC_PREREQ([2.61])
5
6 AC_INIT([paraslash], [m4_esyscmd_s(./GIT-VERSION-GEN)],
7         [maan@tuebingen.mpg.de], [], [http://people.tuebingen.mpg.de/maan/paraslash/])
8 AC_CONFIG_HEADERS([config.h])
9
10 AC_CONFIG_FILES([Makefile])
11 AC_DEFUN([add_dot_o],[$(for i in $@; do printf "$i.o "; done)])
12 AC_DEFUN([add_cmdline],[$(for i in $@; do printf "${i}.cmdline "; done)])
13 AC_DEFUN([make_errlist_defines], \
14         $(for i in $@; do \
15                 printf "DEFINE_ERRLIST($(echo $i | tr 'a-z' 'A-Z'));"; \
16         done) \
17 )
18 AC_DEFUN([make_para_errlists], \
19         $(for i in $@; do \
20                 printf "PARA_ERRLIST($(echo $i | tr 'a-z' 'A-Z')), "; \
21         done) \
22 )
23 AC_DEFUN([objlist_to_errlist],[ \
24         make_errlist_defines($@) \
25         [const char **para_errlist[[]]] = {make_para_errlists($@)} \
26 ])
27 AC_DEFUN([LIB_ARG_WITH], [
28         AC_ARG_WITH($1-headers, [AS_HELP_STRING(--with-$1-headers=dir,
29                 [look for $1 headers in dir])])
30         AC_ARG_WITH($1-libs, [AS_HELP_STRING(--with-$1-libs=dir,
31                 [look for $1 libraries in dir])])
32         if test -n "$with_$1_headers"; then
33                 $1_cppflags="-I$with_$1_headers"
34                 CPPFLAGS="$CPPFLAGS $$1_cppflags"
35         fi
36         if test -n "$with_$1_libs"; then
37                 $1_ldflags="-L$with_$1_libs $2"
38         else
39                 $1_ldflags="$2"
40         fi
41         LDFLAGS="$LDFLAGS $$1_ldflags"
42 ])
43
44 AC_DEFUN([STASH_FLAGS], [
45         OLD_CPPFLAGS="$CPPFLAGS"
46         OLD_LDFLAGS="$LDFLAGS"
47         OLD_LIBS="$LIBS"
48 ])
49
50 AC_DEFUN([UNSTASH_FLAGS], [
51         CPPFLAGS="$OLD_CPPFLAGS"
52         LDFLAGS="$OLD_LDFLAGS"
53         LIBS="$OLD_LIBS"
54 ])
55 AC_DEFUN([LIB_SUBST_FLAGS], [
56         if test "$HAVE_[]m4_toupper([$1])" == 'yes'; then
57                 AC_DEFINE(HAVE_[]m4_toupper([$1]), 1,
58                         define to 1 to turn on $1 support)
59         else
60                 $1_cppflags=
61                 $1_ldflags=
62         fi
63         AC_SUBST(HAVE_[]m4_toupper([$1]))
64         AC_SUBST($1_cppflags)
65         AC_SUBST($1_ldflags)
66 ])
67
68 AC_PATH_PROG(UNAMEPATH, uname, no)
69 if test "$UNAMEPATH" = "no"; then
70         AC_MSG_ERROR(unable to determine system type)
71 fi
72 AC_MSG_CHECKING(os type)
73 OSTYPE="`$UNAMEPATH -s`"
74 AC_MSG_RESULT("$OSTYPE")
75
76 if test "$OSTYPE" = "SunOS"; then
77         # needed on SunOS for socket magic
78         arch_cppflags="-D_XOPEN_SOURCE=500 -D__EXTENSIONS__"
79         AC_SUBST(arch_cppflags)
80 fi
81
82 AC_C_BIGENDIAN()
83
84 AC_PATH_PROG([GENGETOPT], [gengetopt])
85 test -z "$GENGETOPT" && AC_MSG_ERROR(
86         [gengetopt is required to build this package])
87
88 AC_PATH_PROG([HELP2MAN], [help2man])
89 test -z "$HELP2MAN" && AC_MSG_ERROR(
90         [help2man is required to build this package])
91
92 AC_PATH_PROG([INSTALL], [install])
93 test -z "$INSTALL" && AC_MSG_ERROR(
94         [The install program is required to build this package])
95
96 AC_PROG_CC
97 AC_PROG_CPP
98
99 executables="recv filter audioc write afh play"
100 ################################################################## clock_gettime
101 clock_gettime_lib=
102 AC_CHECK_LIB([c], [clock_gettime], [clock_gettime_lib=c], [
103         AC_CHECK_LIB([rt], [clock_gettime], [clock_gettime_lib=rt], [], [])
104 ])
105 if test -n "$clock_gettime_lib"; then
106         AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [
107                 define to 1 if clock_gettime() is supported])
108 fi
109 if test "$clock_gettime_lib" = "rt"; then
110         AC_SUBST(clock_gettime_ldflags, -lrt)
111 fi
112
113 ########################################################################### osl
114 STASH_FLAGS
115 LIB_ARG_WITH([osl], [-losl])
116 HAVE_OSL=yes
117 AC_CHECK_HEADER(osl.h, [], [HAVE_OSL=no])
118 AC_CHECK_LIB([osl], [osl_open_table], [], [HAVE_OSL=no])
119 LIB_SUBST_FLAGS(osl)
120 UNSTASH_FLAGS
121 ######################################################################## openssl
122 STASH_FLAGS
123 HAVE_OPENSSL=yes
124 LIB_ARG_WITH([openssl], [-lssl -lcrypto])
125 AC_CHECK_HEADER(openssl/ssl.h, [], [HAVE_OPENSSL=no])
126 AC_CHECK_LIB([crypto], [RAND_bytes], [], [HAVE_OPENSSL=no])
127 LIB_SUBST_FLAGS(openssl)
128 UNSTASH_FLAGS
129 ######################################################################### gcrypt
130 STASH_FLAGS
131 HAVE_GCRYPT=yes
132 LIB_ARG_WITH([gcrypt], [-lgcrypt])
133 AC_CHECK_HEADER(gcrypt.h, [], [HAVE_GCRYPT=no])
134 AC_CHECK_LIB([gcrypt], [gcry_randomize], [], [HAVE_GCRYPT=no])
135 LIB_SUBST_FLAGS(gcrypt)
136 UNSTASH_FLAGS
137 ######################################################################### crypto
138 AC_ARG_ENABLE(cryptolib, [AS_HELP_STRING(--enable-cryptolib=lib, [
139         Force using crypto library "lib". This package requires either
140         openssl or libgcrypt being installed. Possible values for "lib"
141         are thus "openssl" and "gcrypt". If this option is not given,
142         openssl is tried first. If openssl was not found, gcrypt is
143         tried next.])])
144
145 CRYPTOLIB="$enable_cryptolib"
146 case "$enable_cryptolib" in
147 "openssl")
148         test $HAVE_OPENSSL = no && AC_MSG_ERROR(openssl not found)
149         crypto_ldflags="$openssl_ldflags"
150         ;;
151 "gcrypt")
152         test $HAVE_GCRYPT = no && AC_MSG_ERROR(gcrypt not found)
153         crypto_ldflags="$gcrypt_ldflags"
154         ;;
155 "")
156         crypto_ldflags=
157         if test $HAVE_GCRYPT = yes; then
158                 CRYPTOLIB=gcrypt
159                 crypto_ldflags="$gcrypt_ldflags"
160         fi
161         if test $HAVE_OPENSSL = yes; then
162                 CRYPTOLIB=openssl
163                 crypto_ldflags="$openssl_ldflags"
164         fi
165         ;;
166 *)
167         AC_MSG_ERROR([invalid value "$enable_cryptolib" for --enable-cryptolib])
168         ;;
169 esac
170 AC_SUBST(crypto_ldflags)
171 ########################################################################### libsocket
172 AC_CHECK_LIB([c], [socket],
173         [socket_ldlflags=],
174         [socket_ldflags="-lsocket"]
175 )
176 AC_SUBST(socket_ldflags)
177 ########################################################################### libnsl
178 AC_CHECK_LIB([c], [gethostbyname],
179         [nsl_ldflags=],
180         [nsl_ldflags="-lnsl"]
181 )
182 AC_SUBST(nsl_ldflags)
183 ########################################################################### ucred
184 AC_MSG_CHECKING(for struct ucred)
185 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
186         #define _GNU_SOURCE
187         #include <sys/types.h>
188         #include <sys/socket.h>
189 ]], [[
190         struct ucred sucred; sucred.pid=0;
191 ]])],[have_ucred=yes],[have_ucred=no])
192 AC_MSG_RESULT($have_ucred)
193 if test ${have_ucred} = yes; then
194         AC_DEFINE(HAVE_UCRED, 1, define to 1 you have struct ucred)
195 fi
196 ########################################################################### gengetopt
197 echo 'option "z" z "" flag off' | $GENGETOPT --file-name conftest-ggo &&
198 AC_CHECK_DECL(
199         [gengetopt_args_info_description],
200         [ggo_descriptions_declared=yes],
201         [ggo_descriptions_declared=no],
202         [#include "conftest-ggo.h"]
203 )
204 AC_SUBST(ggo_descriptions_declared)
205 ########################################################################### curses
206 STASH_FLAGS
207 LIB_ARG_WITH([curses], [])
208 HAVE_CURSES=yes
209 AC_CHECK_HEADER(curses.h, [], [HAVE_CURSES=no])
210 AC_SEARCH_LIBS([initscr], [ncursesw curses], [], [HAVE_CURSES=no])
211 curses_ldflags="$curses_ldflags $LIBS"
212 LIB_SUBST_FLAGS(curses)
213 UNSTASH_FLAGS
214 ########################################################################### ip_mreqn
215 AC_MSG_CHECKING(for struct ip_mreqn (UDPv4 multicast))
216 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
217         #include <netdb.h>
218         #include <net/if.h>
219 ]], [[
220         struct ip_mreqn mn;
221         mn.imr_ifindex = 0;
222 ]])],[have_ip_mreqn=yes],[have_ip_mreqn=no])
223 AC_MSG_RESULT($have_ip_mreqn)
224 if test ${have_ip_mreqn} = yes; then
225         AC_DEFINE(HAVE_IP_MREQN, 1, define to 1 you have struct ip_mreqn)
226 fi
227 ########################################################################### osx
228
229 AC_MSG_CHECKING(for CoreAudio (MacOs))
230 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
231         #include <CoreAudio/CoreAudio.h>
232 ]], [[
233         AudioDeviceID id;
234 ]])],[have_core_audio=yes],[have_core_audio=no])
235 AC_MSG_RESULT($have_core_audio)
236 if test ${have_core_audio} = yes; then
237         f1="-framework CoreAudio"
238         f2="-framework AudioToolbox"
239         f3="-framework AudioUnit"
240         f4="-framework CoreServices"
241         core_audio_ldflags="$f1 $f2 $f3 $f4"
242         AC_SUBST(core_audio_ldflags)
243         AC_DEFINE(HAVE_CORE_AUDIO, 1, define to 1 on Mac Os X)
244 fi
245 ########################################################################### ogg
246 STASH_FLAGS
247 LIB_ARG_WITH([ogg], [-logg])
248 HAVE_OGG=yes
249 AC_CHECK_HEADERS([ogg/ogg.h], [], [HAVE_OGG=no])
250 AC_CHECK_LIB([ogg], [ogg_stream_init], [], [HAVE_OGG=no])
251 LIB_SUBST_FLAGS(ogg)
252 UNSTASH_FLAGS
253 ######################################################################### vorbis
254 STASH_FLAGS
255 LIB_ARG_WITH([vorbis], [-lvorbis -lvorbisfile])
256 HAVE_VORBIS=yes
257 AC_CHECK_HEADERS([vorbis/codec.h], [], [HAVE_VORBIS=no])
258 AC_CHECK_LIB([vorbis], [vorbis_info_init], [], [HAVE_VORBIS=no])
259 LIB_SUBST_FLAGS(vorbis)
260 UNSTASH_FLAGS
261 ######################################################################### speex
262 STASH_FLAGS
263 LIB_ARG_WITH([speex], [-lspeex])
264 HAVE_SPEEX=yes
265 AC_CHECK_HEADERS([speex/speex.h], [], [HAVE_SPEEX=no])
266 AC_CHECK_LIB([speex], [speex_decoder_init], [], [HAVE_SPEEX=no])
267 LIB_SUBST_FLAGS(speex)
268 UNSTASH_FLAGS
269 ######################################################################### opus
270 STASH_FLAGS
271 LIB_ARG_WITH([opus], [-lopus])
272 HAVE_OPUS=yes
273 AC_CHECK_HEADERS([opus/opus.h], [], [HAVE_OPUS=no])
274 AC_CHECK_LIB([opus], [opus_multistream_decode], [], [HAVE_OPUS=no])
275 LIB_SUBST_FLAGS(opus)
276 UNSTASH_FLAGS
277 ########################################################################### flac
278 STASH_FLAGS
279 LIB_ARG_WITH([flac], [-lFLAC -lm])
280 HAVE_FLAC=yes
281 AC_CHECK_HEADER(FLAC/stream_decoder.h, [], HAVE_FLAC=no)
282 AC_CHECK_LIB([FLAC], [FLAC__stream_decoder_init_file], [], HAVE_FLAC=no)
283 LIB_SUBST_FLAGS(flac)
284 UNSTASH_FLAGS
285
286 # some helper functions for codecs which use the ogg container format
287 AC_DEFUN([NEED_OGG_OBJECTS], [{
288         test "$HAVE_OGG" = 'yes' -a \( \
289                  "$HAVE_VORBIS" = 'yes' \
290                 -o "$HAVE_SPEEX" = 'yes' \
291                 -o "$HAVE_OPUS" = 'yes' \
292                 -o "$HAVE_FLAC" = 'yes' \
293         \)
294 }])
295 AC_DEFUN([NEED_VORBIS_OBJECTS], [{
296         test "$HAVE_OGG" = 'yes' -a "$HAVE_VORBIS" = 'yes'
297 }])
298 AC_DEFUN([NEED_SPEEX_OBJECTS], [{
299         test "$HAVE_OGG" = 'yes' -a "$HAVE_SPEEX" = 'yes'
300 }])
301 AC_DEFUN([NEED_OPUS_OBJECTS], [{
302         test "$HAVE_OGG" = 'yes' -a "$HAVE_OPUS" = 'yes'
303 }])
304 AC_DEFUN([NEED_FLAC_OBJECTS], [{
305         test "$HAVE_OGG" = 'yes' -a "$HAVE_FLAC" = 'yes'
306 }])
307 ########################################################################### faad
308 STASH_FLAGS
309 LIB_ARG_WITH([faad], [-lfaad])
310 HAVE_FAAD=yes
311 AC_CHECK_HEADER(neaacdec.h, [], HAVE_FAAD=no)
312 AC_CHECK_LIB([faad], [NeAACDecOpen], [], HAVE_FAAD=no)
313 LIB_SUBST_FLAGS(faad)
314 UNSTASH_FLAGS
315 ########################################################################### mad
316 STASH_FLAGS
317 LIB_ARG_WITH([mad], [-lmad])
318 HAVE_MAD=yes
319 AC_CHECK_HEADER(mad.h, [], HAVE_MAD=no)
320 AC_CHECK_LIB([mad], [mad_stream_init], [], HAVE_MAD=no)
321 LIB_SUBST_FLAGS(mad)
322 UNSTASH_FLAGS
323 ###################################################################### libid3tag
324 STASH_FLAGS
325 LIB_ARG_WITH([id3tag], [-lid3tag -lz])
326 HAVE_ID3TAG=yes
327 AC_CHECK_HEADER(id3tag.h, [], HAVE_ID3TAG=no)
328 AC_CHECK_LIB([id3tag], [id3_file_fdopen], [], HAVE_ID3TAG=no)
329 LIB_SUBST_FLAGS(id3tag)
330 UNSTASH_FLAGS
331 ########################################################################### oss
332 STASH_FLAGS
333 LIB_ARG_WITH([oss], [])
334 AC_CHECK_HEADER(sys/soundcard.h, [HAVE_OSS=yes], [HAVE_OSS=no])
335 AC_CHECK_LIB(ossaudio, _oss_ioctl, [oss_ldflags="$oss_ldflags -lossaudio"], [])
336 LIB_SUBST_FLAGS(oss)
337 UNSTASH_FLAGS
338 ########################################################################### alsa
339 STASH_FLAGS
340 LIB_ARG_WITH([alsa], [-lasound])
341 HAVE_ALSA=yes
342 AC_CHECK_HEADER(alsa/asoundlib.h, [], HAVE_ALSA=no)
343 AC_CHECK_LIB([asound], [snd_pcm_open], [], HAVE_ALSA=no)
344 LIB_SUBST_FLAGS(alsa)
345 UNSTASH_FLAGS
346 ######################################################################### pthread
347 STASH_FLAGS
348 LIB_ARG_WITH([pthread], [-lpthread])
349 HAVE_PTHREAD=yes
350 AC_CHECK_HEADER(pthread.h, [], HAVE_PTHREAD=no)
351 AC_CHECK_LIB([pthread], [pthread_create], [], HAVE_PTHREAD=no)
352 LIB_SUBST_FLAGS(pthread)
353 UNSTASH_FLAGS
354 ########################################################################### libao
355 STASH_FLAGS
356 LIB_ARG_WITH([ao], [-lao])
357 HAVE_AO=yes
358 AC_CHECK_HEADER(ao/ao.h, [], HAVE_AO=no)
359 AC_CHECK_LIB([ao], [ao_initialize], [], HAVE_AO=no)
360 LIB_SUBST_FLAGS(ao)
361 UNSTASH_FLAGS
362 AC_DEFUN([NEED_AO_OBJECTS], [{ test $HAVE_AO = yes -a $HAVE_PTHREAD = yes; }])
363 ######################################################################## readline
364 STASH_FLAGS
365 AC_SEARCH_LIBS([tgetent], [tinfo curses terminfo termcap])
366 LIB_ARG_WITH([readline], [-lreadline $LIBS])
367 HAVE_READLINE=yes
368 AC_CHECK_HEADER([readline/readline.h], [], [HAVE_READLINE=no])
369 AC_CHECK_LIB([readline], [rl_free_keymap], [], HAVE_READLINE=no)
370 AC_CHECK_DECL(
371         [rl_free_keymap],
372         [AC_DEFINE(RL_FREE_KEYMAP_DECLARED, 1, readline >= 6.3)],
373         [],
374         [
375                 #include <stdio.h>
376                 #include <readline/readline.h>
377         ]
378 )
379 LIB_SUBST_FLAGS(readline)
380 UNSTASH_FLAGS
381 ############################################################# libsamplerate
382 STASH_FLAGS
383 LIB_ARG_WITH([samplerate], [-lsamplerate])
384 HAVE_SAMPLERATE=yes
385 AC_CHECK_HEADER(samplerate.h, [], HAVE_SAMPLERATE=no)
386 AC_CHECK_LIB([samplerate], [src_process], [], HAVE_SAMPLERATE=no)
387 LIB_SUBST_FLAGS(samplerate)
388 UNSTASH_FLAGS
389 ######################################################################### server
390 if test -n "$CRYPTOLIB" && test $HAVE_OSL = yes; then
391         build_server="yes"
392         executables="$executables server"
393         server_cmdline_objs="server"
394         server_errlist_objs="
395                 server
396                 afh_common
397                 mp3_afh
398                 vss
399                 command
400                 net
401                 string
402                 signal
403                 time
404                 daemon
405                 http_send
406                 close_on_fork
407                 mm
408                 crypt_common
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         test $HAVE_FAAD = yes && server_errlist_objs="$server_errlist_objs aac_afh aac_common"
444         server_objs="add_cmdline($server_cmdline_objs) $server_errlist_objs"
445         AC_SUBST(server_objs, add_dot_o($server_objs))
446         AC_DEFINE_UNQUOTED(INIT_SERVER_ERRLISTS,
447                 objlist_to_errlist($server_errlist_objs), errors used by para_server)
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                 version
470                 ggo
471         "
472         if test "$CRYPTOLIB" = openssl; then
473                 client_errlist_objs="$client_errlist_objs crypt"
474         else
475                 client_errlist_objs="$client_errlist_objs gcrypt"
476         fi
477         if test $HAVE_READLINE = yes; then
478                 client_errlist_objs="$client_errlist_objs interactive"
479         fi
480         client_objs="add_cmdline($client_cmdline_objs) $client_errlist_objs"
481         AC_SUBST(client_objs, add_dot_o($client_objs))
482         AC_DEFINE_UNQUOTED(INIT_CLIENT_ERRLISTS,
483                 objlist_to_errlist($client_errlist_objs), errors used by para_client)
484 else
485         build_client="no"
486 fi
487 ############################################################# audiod
488 if test -n "$CRYPTOLIB"; then
489         build_audiod="yes"
490         executables="$executables audiod"
491         audiod_audio_formats="wma"
492         audiod_cmdline_objs="$audiod_cmdline_objs
493                 audiod
494                 compress_filter
495                 http_recv
496                 dccp_recv
497                 file_write
498                 client
499                 amp_filter
500                 udp_recv
501                 prebuffer_filter
502                 sync_filter
503         "
504         audiod_errlist_objs="$audiod_errlist_objs
505                 audiod
506                 signal
507                 string
508                 daemon
509                 stat
510                 net
511                 crypt_common
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         AC_DEFINE_UNQUOTED(INIT_AUDIOD_ERRLISTS, objlist_to_errlist($audiod_errlist_objs),
595                 errors used by para_audiod)
596
597         enum="$(for i in $audiod_audio_formats; do printf "AUDIO_FORMAT_${i}, " | tr '[a-z]' '[A-Z]'; done)"
598         AC_DEFINE_UNQUOTED(AUDIOD_AUDIO_FORMATS_ENUM, $enum NUM_AUDIO_FORMATS,
599                 enum of audio formats supported by audiod)
600         names="$(for i in $audiod_audio_formats; do printf \"$i\",' ' ; done)"
601         AC_DEFINE_UNQUOTED(AUDIOD_AUDIO_FORMAT_ARRAY, $names, array of audio formats supported by audiod)
602 else
603         build_audiod="no"
604 fi
605 ########################################################################### fade
606 if test $HAVE_OSS = yes -o $HAVE_ALSA = yes; then
607         build_fade="yes"
608         executables="$executables fade"
609         fade_cmdline_objs="fade"
610         fade_errlist_objs="fade exec string fd version ggo"
611         if test $HAVE_OSS = yes; then
612                 fade_errlist_objs="$fade_errlist_objs oss_mix"
613                 mixers="${mixers}oss "
614                 default_mixer="OSS_MIX"
615         fi
616         if test $HAVE_ALSA = yes; then
617                 fade_errlist_objs="$fade_errlist_objs alsa_mix"
618                 mixers="${mixers}alsa "
619                 default_mixer="ALSA_MIX"
620         fi
621         fade_objs="add_cmdline($fade_cmdline_objs) $fade_errlist_objs"
622         AC_SUBST(fade_objs, add_dot_o($fade_objs))
623         AC_DEFINE_UNQUOTED(INIT_FADE_ERRLISTS,
624                 objlist_to_errlist($fade_errlist_objs),
625                 errors used by para_fade)
626         enum="$(
627                 for i in $mixers; do
628                         printf "${i}_MIX, " | tr '[a-z]' '[A-Z]'
629                 done
630         )"
631         AC_DEFINE_UNQUOTED(MIXER_ENUM, $enum NUM_SUPPORTED_MIXERS,
632                 enum of supported mixers)
633         AC_DEFINE_UNQUOTED(DEFAULT_MIXER, $default_mixer,
634                 use this mixer if none was specified)
635         names="$(for i in $mixers; do printf \"$i\",' ' ; done)"
636         AC_DEFINE_UNQUOTED(MIXER_NAMES, $names, supported mixer names)
637         inits="$(
638                 for i in $mixers; do
639                         printf 'extern void '$i'_mix_init(struct mixer *); '
640                 done
641         )"
642         AC_DEFINE_UNQUOTED(DECLARE_MIXER_INITS, $inits,
643                 init functions of the supported mixers)
644         array="$(for i in $mixers; do printf '{.init = '$i'_mix_init},'; done)"
645         AC_DEFINE_UNQUOTED(MIXER_ARRAY, $array, array of supported mixers)
646 else
647         build_fade="no"
648         AC_MSG_WARN([no mixer support])
649 fi
650 ########################################################################### gui
651 if test $HAVE_CURSES = yes; then
652         build_gui="yes"
653         executables="$executables gui"
654         gui_cmdline_objs="gui"
655         gui_errlist_objs="
656                 exec
657                 signal
658                 string
659                 stat
660                 ringbuffer
661                 fd
662                 gui
663                 gui_theme
664                 time
665                 sched
666                 version
667                 ggo
668         "
669         gui_objs="add_cmdline($gui_cmdline_objs) $gui_errlist_objs"
670         AC_SUBST(gui_objs, add_dot_o($gui_objs))
671         AC_DEFINE_UNQUOTED(INIT_GUI_ERRLISTS,
672                 objlist_to_errlist($gui_errlist_objs), errors used by para_gui)
673 else
674         build_gui="no"
675         AC_MSG_WARN([no curses lib, cannot build para_gui])
676 fi
677 ######################################################################## filter
678 filters="
679         compress
680         wav
681         amp
682         fecdec
683         wmadec
684         prebuffer
685         sync
686 "
687 filter_errlist_objs="
688         filter_common
689         wav_filter
690         compress_filter
691         filter
692         string
693         stdin
694         stdout
695         sched
696         fd
697         amp_filter
698         ggo
699         fecdec_filter
700         fec
701         version
702         prebuffer_filter
703         time
704         bitstream
705         imdct
706         wma_common
707         wmadec_filter
708         buffer_tree
709         net
710         sync_filter
711 "
712 filter_cmdline_objs="
713         filter
714         compress_filter
715         amp_filter
716         prebuffer_filter
717         sync_filter
718 "
719 NEED_VORBIS_OBJECTS && {
720         filters="$filters oggdec"
721         filter_errlist_objs="$filter_errlist_objs oggdec_filter"
722 }
723 NEED_SPEEX_OBJECTS && {
724         filters="$filters spxdec"
725         filter_errlist_objs="$filter_errlist_objs spxdec_filter spx_common"
726 }
727 NEED_OPUS_OBJECTS && {
728         filters="$filters opusdec"
729         filter_errlist_objs="$filter_errlist_objs opusdec_filter opus_common"
730 }
731 NEED_FLAC_OBJECTS && {
732         filter_errlist_objs="$filter_errlist_objs flacdec_filter"
733         filters="$filters flacdec"
734 }
735 if test $HAVE_FAAD = yes; then
736         filter_errlist_objs="$filter_errlist_objs aacdec_filter aac_common"
737         filters="$filters aacdec"
738 fi
739 if test $HAVE_MAD = yes; then
740         filter_cmdline_objs="$filter_cmdline_objs mp3dec_filter"
741         filter_errlist_objs="$filter_errlist_objs mp3dec_filter"
742         filters="$filters mp3dec"
743 fi
744 if test $HAVE_SAMPLERATE = yes; then
745         filter_errlist_objs="$filter_errlist_objs resample_filter check_wav"
746         filter_cmdline_objs="$filter_cmdline_objs resample_filter"
747         filters="$filters resample"
748 fi
749 filters="$(echo $filters)"
750 AC_SUBST(filters)
751 filter_objs="add_cmdline($filter_cmdline_objs) $filter_errlist_objs"
752
753 AC_SUBST(filter_objs, add_dot_o($filter_objs))
754 AC_DEFINE_UNQUOTED(INIT_FILTER_ERRLISTS,
755         objlist_to_errlist($filter_errlist_objs), errors used by para_filter)
756
757 enum="$(for i in $filters; do printf "${i}_FILTER, " | tr '[a-z]' '[A-Z]'; done)"
758 AC_DEFINE_UNQUOTED(FILTER_ENUM, $enum NUM_SUPPORTED_FILTERS,
759         enum of supported filters)
760 inits="$(for i in $filters; do printf 'extern void '$i'_filter_init(struct filter *f); '; done)"
761 AC_DEFINE_UNQUOTED(DECLARE_FILTER_INITS, $inits, init functions of the supported filters)
762 array="$(for i in $filters; do printf '{.name = "'$i'", .init = '$i'_filter_init},'; done)"
763 AC_DEFINE_UNQUOTED(FILTER_ARRAY, $array, array of supported filters)
764 ########################################################################## recv
765 recv_cmdline_objs="
766         recv
767         http_recv
768         dccp_recv
769         udp_recv
770         afh_recv
771 "
772
773 recv_errlist_objs="
774         http_recv
775         recv_common
776         recv
777         time
778         string
779         net
780         dccp_recv
781         fd
782         sched
783         stdout
784         ggo
785         udp_recv
786         buffer_tree
787         afh_recv
788         afh_common
789         wma_afh
790         wma_common
791         mp3_afh
792         version
793 "
794 NEED_OGG_OBJECTS && recv_errlist_objs="$recv_errlist_objs ogg_afh_common"
795 NEED_VORBIS_OBJECTS && recv_errlist_objs="$recv_errlist_objs ogg_afh"
796 NEED_SPEEX_OBJECTS && recv_errlist_objs="$recv_errlist_objs spx_afh spx_common"
797 NEED_OPUS_OBJECTS && recv_errlist_objs="$recv_errlist_objs opus_afh opus_common"
798 NEED_FLAC_OBJECTS && recv_errlist_objs="$recv_errlist_objs flac_afh"
799
800 if test $HAVE_FAAD = yes; then
801         recv_errlist_objs="$recv_errlist_objs aac_afh aac_common"
802 fi
803 recv_objs="add_cmdline($recv_cmdline_objs) $recv_errlist_objs"
804 AC_SUBST(receivers, "http dccp udp afh")
805 AC_SUBST(recv_objs, add_dot_o($recv_objs))
806 AC_DEFINE_UNQUOTED(INIT_RECV_ERRLISTS, objlist_to_errlist($recv_errlist_objs),
807         errors used by para_recv)
808 ########################################################################### afh
809 audio_format_handlers="mp3 wma"
810 afh_cmdline_objs="afh"
811 afh_errlist_objs="
812         afh
813         string
814         fd
815         mp3_afh
816         afh_common
817         time
818         wma_afh
819         wma_common
820         version
821         ggo
822 "
823 NEED_OGG_OBJECTS && afh_errlist_objs="$afh_errlist_objs ogg_afh_common"
824 NEED_VORBIS_OBJECTS && {
825         afh_errlist_objs="$afh_errlist_objs ogg_afh"
826         audio_format_handlers="$audio_format_handlers ogg"
827 }
828 NEED_SPEEX_OBJECTS && {
829         afh_errlist_objs="$afh_errlist_objs spx_afh spx_common"
830         audio_format_handlers="$audio_format_handlers spx"
831 }
832 NEED_OPUS_OBJECTS && {
833         afh_errlist_objs="$afh_errlist_objs opus_afh opus_common"
834         audio_format_handlers="$audio_format_handlers opus"
835 }
836 NEED_FLAC_OBJECTS && {
837         afh_errlist_objs="$afh_errlist_objs flac_afh"
838         audio_format_handlers="$audio_format_handlers flac"
839 }
840 if test $HAVE_FAAD = yes; then
841         afh_errlist_objs="$afh_errlist_objs aac_common aac_afh"
842         audio_format_handlers="$audio_format_handlers aac"
843 fi
844
845 afh_objs="add_cmdline($afh_cmdline_objs) $afh_errlist_objs"
846
847 AC_SUBST(afh_objs, add_dot_o($afh_objs))
848 AC_DEFINE_UNQUOTED(INIT_AFH_ERRLISTS,
849         objlist_to_errlist($afh_errlist_objs), errors used by para_afh)
850 ########################################################################## play
851 play_errlist_objs="
852         play
853         fd
854         sched
855         ggo
856         buffer_tree
857         time
858         string
859         net
860         afh_recv
861         afh_common
862         wma_afh
863         wma_common
864         mp3_afh
865         recv_common
866         udp_recv
867         http_recv
868         dccp_recv
869         filter_common
870         fec
871         bitstream
872         imdct
873         wav_filter
874         compress_filter
875         amp_filter
876         prebuffer_filter
877         fecdec_filter
878         wmadec_filter
879         write_common
880         file_write
881         version
882         sync_filter
883 "
884 play_cmdline_objs="
885         http_recv
886         dccp_recv
887         udp_recv
888         afh_recv
889         compress_filter
890         amp_filter
891         prebuffer_filter
892         file_write
893         play
894         sync_filter
895 "
896 if test "$have_core_audio" = "yes"; then
897         play_errlist_objs="$play_errlist_objs osx_write ipc"
898         play_cmdline_objs="$play_cmdline_objs osx_write"
899 fi
900 NEED_OGG_OBJECTS && play_errlist_objs="$play_errlist_objs ogg_afh_common"
901 NEED_VORBIS_OBJECTS && {
902         play_errlist_objs="$play_errlist_objs oggdec_filter ogg_afh"
903 }
904 NEED_SPEEX_OBJECTS && {
905         play_errlist_objs="$play_errlist_objs spxdec_filter spx_afh spx_common"
906 }
907 NEED_OPUS_OBJECTS &&
908         play_errlist_objs="$play_errlist_objs
909                 opusdec_filter
910                 opus_afh
911                 opus_common
912         "
913 NEED_FLAC_OBJECTS && {
914         play_errlist_objs="$play_errlist_objs flacdec_filter flac_afh"
915 }
916 if test $HAVE_FAAD = yes; then
917         play_errlist_objs="$play_errlist_objs aacdec_filter aac_afh aac_common"
918 fi
919 if test $HAVE_MAD = yes; then
920         play_cmdline_objs="$play_cmdline_objs mp3dec_filter"
921         play_errlist_objs="$play_errlist_objs mp3dec_filter"
922 fi
923 if test $HAVE_OSS = yes; then
924         play_errlist_objs="$play_errlist_objs oss_write"
925         play_cmdline_objs="$play_cmdline_objs oss_write"
926 fi
927 if test $HAVE_ALSA = yes; then
928         play_errlist_objs="$play_errlist_objs alsa_write"
929         play_cmdline_objs="$play_cmdline_objs alsa_write"
930 fi
931 NEED_AO_OBJECTS && {
932         play_errlist_objs="$play_errlist_objs ao_write"
933         play_cmdline_objs="$play_cmdline_objs ao_write"
934 }
935 if test $HAVE_READLINE = yes; then
936         play_errlist_objs="$play_errlist_objs interactive"
937 fi
938 if test $HAVE_SAMPLERATE = yes; then
939         play_errlist_objs="$play_errlist_objs resample_filter check_wav"
940         play_cmdline_objs="$play_cmdline_objs resample_filter"
941 fi
942
943 play_objs="add_cmdline($play_cmdline_objs) $play_errlist_objs"
944 AC_SUBST(play_objs, add_dot_o($play_objs))
945 AC_DEFINE_UNQUOTED(INIT_PLAY_ERRLISTS,
946         objlist_to_errlist($play_errlist_objs), errors used by para_play)
947 ######################################################################### write
948 write_cmdline_objs="
949         write
950         file_write
951 "
952 write_errlist_objs="
953         write
954         write_common
955         file_write
956         time
957         fd
958         string
959         sched
960         stdin
961         buffer_tree
962         ggo
963         check_wav
964         version
965 "
966 writers="file"
967 default_writer="FILE_WRITE"
968
969 if test "$have_core_audio" = "yes"; then
970         write_errlist_objs="$write_errlist_objs osx_write ipc"
971         write_cmdline_objs="$write_cmdline_objs osx_write"
972         writers="$writers osx"
973         default_writer="OSX_WRITE"
974 fi
975 NEED_AO_OBJECTS && {
976         write_errlist_objs="$write_errlist_objs ao_write"
977         write_cmdline_objs="$write_cmdline_objs ao_write"
978         writers="$writers ao"
979         default_writer="AO_WRITE"
980 }
981 if test $HAVE_OSS = yes; then
982         write_errlist_objs="$write_errlist_objs oss_write"
983         write_cmdline_objs="$write_cmdline_objs oss_write"
984         writers="$writers oss"
985         default_writer="OSS_WRITE"
986 fi
987 if test $HAVE_ALSA = yes; then
988         write_errlist_objs="$write_errlist_objs alsa_write"
989         write_cmdline_objs="$write_cmdline_objs alsa_write"
990         writers="$writers alsa"
991         default_writer="ALSA_WRITE"
992 fi
993 AC_SUBST(writers)
994 write_objs="add_cmdline($write_cmdline_objs) $write_errlist_objs"
995 AC_SUBST(write_objs, add_dot_o($write_objs))
996 AC_DEFINE_UNQUOTED(INIT_WRITE_ERRLISTS,
997         objlist_to_errlist($write_errlist_objs), errors used by para_write)
998 enum="$(for i in $writers; do printf "${i}_WRITE, " | tr '[a-z]' '[A-Z]'; done)"
999 AC_DEFINE_UNQUOTED(WRITER_ENUM, $enum NUM_SUPPORTED_WRITERS,
1000         enum of supported writers)
1001 AC_DEFINE_UNQUOTED(DEFAULT_WRITER, $default_writer, use this writer if none was specified)
1002 names="$(for i in $writers; do printf \"$i\",' ' ; done)"
1003 AC_DEFINE_UNQUOTED(WRITER_NAMES, $names, supported writer names)
1004 inits="$(for i in $writers; do printf 'extern void '$i'_write_init(struct writer *); '; done)"
1005 AC_DEFINE_UNQUOTED(DECLARE_WRITER_INITS, $inits, init functions of the supported writers)
1006 array="$(for i in $writers; do printf '{.init = '$i'_write_init},'; done)"
1007 AC_DEFINE_UNQUOTED(WRITER_ARRAY, $array, array of supported writers)
1008 ######################################################################## audioc
1009 audioc_cmdline_objs="audioc"
1010 audioc_errlist_objs="
1011         audioc
1012         string
1013         net
1014         fd
1015         version
1016         ggo
1017 "
1018 if test $HAVE_READLINE = yes; then
1019         audioc_errlist_objs="$audioc_errlist_objs
1020                 buffer_tree
1021                 interactive
1022                 sched
1023                 time
1024         "
1025 fi
1026 audioc_objs="add_cmdline($audioc_cmdline_objs) $audioc_errlist_objs"
1027 AC_SUBST(audioc_objs, add_dot_o($audioc_objs))
1028 AC_DEFINE_UNQUOTED(INIT_AUDIOC_ERRLISTS,
1029         objlist_to_errlist($audioc_errlist_objs), errors used by para_audioc)
1030 ############################################################# error2.h
1031 # these are always built
1032 all_errlist_objs="
1033         $recv_errlist_objs
1034         $filter_errlist_objs
1035         $audioc_errlist_objs
1036         $write_errlist_objs
1037         $afh_errlist_objs
1038         $play_errlist_objs
1039 "
1040
1041 # optional executables
1042 if test "$build_server" = "yes"; then
1043         all_errlist_objs="$all_errlist_objs $server_errlist_objs"
1044 fi
1045 if test "$build_gui" = "yes"; then
1046         all_errlist_objs="$all_errlist_objs $gui_errlist_objs"
1047 fi
1048 if test "$build_fade" = "yes"; then
1049         all_errlist_objs="$all_errlist_objs $fade_errlist_objs"
1050 fi
1051 if test "$build_client" = "yes"; then
1052         all_errlist_objs="$all_errlist_objs $client_errlist_objs"
1053 fi
1054 if test "$build_audiod" = "yes"; then
1055         all_errlist_objs="$all_errlist_objs $audiod_errlist_objs"
1056 fi
1057
1058 all_errlist_objs="$(echo $all_errlist_objs | tr ' ' '\n' | sort | uniq)"
1059
1060 object_executable_matrix=
1061 for i in $executables; do
1062         eval objs=\$${i}_errlist_objs
1063         object_executable_matrix="$object_executable_matrix $i: $objs"
1064 done
1065 # use echo to replace newlines by space
1066 AC_SUBST(object_executable_matrix, $(echo $object_executable_matrix))
1067
1068 SS=$(for obj in $all_errlist_objs; do
1069         printf '%s' " SS_$obj,"; done | tr 'a-z' 'A-Z')
1070 AC_DEFINE_UNQUOTED(DEFINE_ERRLIST_OBJECT_ENUM,
1071         [enum {$SS NUM_SS}],
1072         [list of all objects that use the paraslash error facility]
1073 )
1074 ################################################################## status items
1075
1076 status_items="basename status num_played mtime bitrate frequency file_size
1077 status_flags format score techinfo afs_mode
1078 attributes_txt decoder_flags audiod_status play_time attributes_bitmap
1079 offset seconds_total stream_start current_time audiod_uptime image_id
1080 lyrics_id duration directory lyrics_name image_name path hash channels
1081 last_played num_chunks chunk_time amplification artist title year album
1082 comment"
1083
1084 result=
1085 for i in $status_items; do
1086         result="$result SI_$(echo $i | tr 'a-z' 'A-Z'), "
1087 done
1088 AC_DEFINE_UNQUOTED(STATUS_ITEM_ENUM, [$result],
1089         [enum of all status items])
1090
1091 result=
1092 for i in $status_items; do
1093         result="$result \"$i\", "
1094 done
1095 AC_DEFINE_UNQUOTED(STATUS_ITEM_ARRAY, [$result],
1096         [char * array of all status items])
1097
1098 AC_DEFINE_UNQUOTED(AUDIO_FORMAT_HANDLERS, "$audio_format_handlers",
1099         [formats supported by para_server and para_afh])
1100
1101 AC_SUBST(executables)
1102
1103 AC_OUTPUT
1104 AC_MSG_NOTICE([
1105 paraslash configuration:
1106 ~~~~~~~~~~~~~~~~~~~~~~~~
1107 crypto lib: ${CRYPTOLIB:-[none]}
1108 unix socket credentials: $have_ucred
1109 readline (interactive CLIs): $HAVE_READLINE
1110 audio formats handlers: $audio_format_handlers
1111 id3 version 2 support: $HAVE_ID3TAG
1112 filters: $filters
1113 writers: $writers
1114
1115 para_fade: $build_fade
1116 para_server: $build_server
1117 para_gui: $build_gui
1118 para_fade: $build_fade
1119 para_client: $build_client
1120 para_audiod: $build_audiod
1121 ])