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