btr support for the fecdec filter.
[paraslash.git] / configure.ac
1 #                                               -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
3
4 AC_PREREQ(2.60)
5
6
7 AC_INIT(paraslash, [git], maan@systemlinux.org)
8 AC_CONFIG_HEADER([config.h])
9
10 AC_PATH_PROG(UNAMEPATH, uname, no)
11 if test "$UNAMEPATH" = "no"; then
12         AC_MSG_ERROR(unable to determine system type)
13 fi
14 AC_MSG_CHECKING(os type)
15 OSTYPE="`$UNAMEPATH -s`"
16 AC_MSG_RESULT("$OSTYPE")
17
18 if test "$OSTYPE" = "SunOS"; then
19         # needed on SunOS for socket magic
20         arch_cppflags="-D_XOPEN_SOURCE=500 -D__EXTENSIONS__"
21         AC_SUBST(arch_cppflags)
22 fi
23
24 AC_C_BIGENDIAN()
25
26 AC_PROG_CC
27 AC_PROG_CPP
28 AC_PROG_INSTALL
29 AC_REPLACE_FNMATCH
30
31 AC_HEADER_DIRENT
32 AC_HEADER_STDC
33 AC_HEADER_SYS_WAIT
34 AC_CHECK_HEADERS([arpa/inet.h ctype.h fcntl.h limits.h netdb.h netinet/in.h \
35         stdlib.h string.h sys/socket.h sys/time.h sys/timeb.h sys/un.h \
36         sys/ipc.h unistd.h utime.h stddef.h],
37         [], [AC_MSG_ERROR([$ac_header not found])])
38
39
40 # Checks for typedefs, structures, and compiler characteristics.
41 AC_C_CONST
42 AC_C_INLINE
43 AC_TYPE_OFF_T
44 AC_TYPE_PID_T
45 AC_TYPE_SIZE_T
46 AC_HEADER_TIME
47 AC_STRUCT_TM
48 AC_TYPE_INT16_T
49 AC_TYPE_INT32_T
50 AC_TYPE_INT64_T
51 AC_TYPE_MODE_T
52 AC_TYPE_SSIZE_T
53 AC_TYPE_UID_T
54 AC_TYPE_UINT8_T
55 AC_TYPE_UINT16_T
56 AC_TYPE_UINT32_T
57 AC_TYPE_UINT64_T
58
59 # Checks for library functions.
60 AC_FUNC_FORK
61 AC_PROG_GCC_TRADITIONAL
62 AC_FUNC_MALLOC
63 AC_FUNC_MEMCMP
64 AC_FUNC_MKTIME
65 AC_FUNC_MMAP
66 AC_FUNC_REALLOC
67 AC_FUNC_SELECT_ARGTYPES
68 AC_TYPE_SIGNAL
69 AC_FUNC_STAT
70 AC_FUNC_STRFTIME
71 AC_FUNC_VPRINTF
72 AC_FUNC_CLOSEDIR_VOID
73 AC_FUNC_LSTAT
74
75 AC_CHECK_FUNCS([atexit dup2 memchr memmove memset \
76         regcomp select strchr strdup strerror strstr strtol uname \
77         fchdir gettimeofday localtime_r munmap strcasecmp strcspn \
78         strncasecmp strrchr strspn alarm mkdir rmdir], [],
79         [AC_MSG_ERROR([function not found, cannot live without it])])
80
81 cmdline_dir="cmdline"
82 AC_SUBST(cmdline_dir)
83 AC_DEFUN([add_cmdline],[$(for i in $@; do printf "${i}.cmdline "; done)])
84
85
86 all_errlist_objs="server mp3_afh afh_common vss command net string signal time
87 daemon stat crypt http_send close_on_fork ipc acl afh fade amp_filter
88 dccp_send fd user_list chunk_queue afs aft mood score attribute blob ringbuffer
89 playlist sha1 sched audiod grab_client filter_common wav_filter compress_filter
90 http_recv dccp_recv recv_common write_common file_write audiod_command
91 client_common recv stdout filter stdin audioc write client exec send_common ggo
92 udp_recv udp_send color fec fecdec_filter prebuffer_filter mm
93 server_command_list afs_command_list audiod_command_list bitstream imdct wma_afh
94 wma_common wmadec_filter buffer_tree
95 "
96
97 all_executables="server recv filter audioc write client afh"
98
99 recv_cmdline_objs="add_cmdline(recv http_recv dccp_recv udp_recv)"
100
101 recv_errlist_objs="http_recv recv_common recv time string net dccp_recv
102         fd sched stdout ggo udp_recv fec buffer_tree"
103 recv_ldflags=""
104
105 receivers=" http dccp udp"
106 senders=" http dccp udp"
107
108 filter_cmdline_objs="add_cmdline(filter compress_filter amp_filter prebuffer_filter)"
109 filter_errlist_objs="filter_common wav_filter compress_filter filter string
110         stdin stdout sched fd amp_filter ggo fecdec_filter fec
111         prebuffer_filter time bitstream imdct wma_common wmadec_filter buffer_tree"
112 filter_ldflags="-lm"
113 filters=" compress wav amp fecdec wmadec prebuffer"
114
115 audioc_cmdline_objs="add_cmdline(audioc)"
116 audioc_errlist_objs="audioc string net fd"
117 audioc_ldflags=""
118
119 audiod_cmdline_objs="add_cmdline(audiod compress_filter http_recv dccp_recv file_write client amp_filter udp_recv prebuffer_filter)"
120 audiod_errlist_objs="audiod signal string daemon stat net
121         time grab_client filter_common wav_filter compress_filter amp_filter http_recv dccp_recv
122         recv_common fd sched write_common file_write audiod_command crypt fecdec_filter
123         client_common ggo udp_recv color fec prebuffer_filter sha1 audiod_command_list
124         bitstream imdct wma_common wmadec_filter buffer_tree"
125 audiod_ldflags="-lm"
126 audiod_audio_formats="wma"
127
128 afh_cmdline_objs="add_cmdline(afh)"
129 afh_errlist_objs="afh string fd mp3_afh afh_common time wma_afh wma_common"
130 afh_ldflags=""
131
132 server_cmdline_objs="add_cmdline(server)"
133 server_errlist_objs="server afh_common mp3_afh vss command net string signal
134         time daemon crypt http_send close_on_fork mm
135         ipc dccp_send fd user_list chunk_queue afs aft mood score attribute
136         blob playlist sha1 sched acl send_common udp_send color fec
137         server_command_list afs_command_list wma_afh wma_common"
138 server_ldflags="-losl"
139 server_audio_formats=" mp3"
140
141 write_cmdline_objs="add_cmdline(write file_write)"
142 write_errlist_objs="write write_common file_write time fd string sched stdin
143         buffer_tree ggo"
144 write_ldflags=""
145 writers=" file"
146 default_writer="FILE_WRITE"
147
148 client_cmdline_objs="add_cmdline(client)"
149 client_errlist_objs="client net string crypt fd sched stdin stdout
150         client_common sha1 buffer_tree"
151 client_ldflags=""
152
153 gui_cmdline_objs="add_cmdline(gui)"
154 gui_errlist_objs="exec signal string stat ringbuffer fd"
155 gui_other_objs="gui gui_theme"
156 gui_objs="$gui_cmdline_objs $gui_errlist_objs $gui_other_objs"
157
158 fade_cmdline_objs="add_cmdline(fade)"
159 fade_errlist_objs="fade exec string fd"
160
161
162 ########################################################################### osl
163 have_osl=yes
164 OLD_CPPFLAGS="$CPPFLAGS"
165 OLD_LD_FLAGS="$LDFLAGS"
166 OLD_LIBS="$LIBS"
167 AC_ARG_WITH(osl_headers, [AC_HELP_STRING(--with-osl-headers=dir,
168         [look for osl.h also in dir])])
169 if test -n "$with_osl_headers"; then
170         osl_cppflags="-I$with_osl_headers"
171         CPPFLAGS="$CPPFLAGS $osl_cppflags"
172 fi
173 AC_ARG_WITH(osl_libs, [AC_HELP_STRING(--with-osl-libs=dir,
174         [look for libosl also in dir])])
175 if test -n "$with_osl_libs"; then
176         osl_libs="-L$with_osl_libs"
177         LDFLAGS="$LDFLAGS $osl_libs"
178 fi
179
180 AC_CHECK_HEADER(osl.h, [], have_osl=no)
181 AC_CHECK_LIB([osl], [osl_open_table], [], have_osl=no)
182 if test "$have_osl" = "no"; then
183         AC_MSG_ERROR([libosl not found, download it at
184         http://systemlinux.org/~maan/osl
185 or execute
186         git clone git://git.tuebingen.mpg.de/osl
187         ])
188 fi
189 AC_SUBST(osl_cppflags)
190 server_ldflags="$server_ldflags -L$with_osl_libs"
191 CPPFLAGS="$OLD_CPPFLAGS"
192 LDFLAGS="$OLD_LDFLAGS"
193 LIBS="$OLD_LIBS"
194 ########################################################################### ssl
195 dnl @synopsis CHECK_SSL
196 dnl
197 dnl based on the follwing macro from the autoconf archive
198 dnl
199 dnl @category InstalledPackages
200 dnl @author Mark Ethan Trostler <trostler@juniper.net>
201 dnl @version 2003-01-28
202 dnl @license AllPermissive
203
204 AC_DEFUN([CHECK_SSL],
205 [
206         for ssldir in $1 /usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr; do
207                 AC_MSG_CHECKING(for openssl in $ssldir)
208                 if test -f "$ssldir/include/openssl/ssl.h"; then
209                         found_ssl="yes"
210                         AC_MSG_RESULT(yes)
211                         SSL_CFLAGS="-I$ssldir/include"
212                         SSL_CPPFLAGS="-I$ssldir/include"
213                         break
214                 fi
215                 AC_MSG_RESULT(no)
216         done
217         if test x_$found_ssl != x_yes; then
218                 AC_MSG_ERROR(Cannot find ssl libraries)
219         else
220                 SSL_LIBS="-lssl -lcrypto";
221                 SSL_LDFLAGS="-L$ssldir/lib";
222         fi
223         AC_SUBST(SSL_CPPFLAGS)
224         AC_SUBST(SSL_CFLAGS)
225         AC_SUBST(SSL_LIBS)
226         AC_SUBST(SSL_LDFLAGS)
227 ])dnl
228
229 AC_ARG_ENABLE(ssldir, [AS_HELP_STRING(--enable-ssldir=path,
230         [Search for openssl also in path.])])
231 if test "$enable_ssldir" = "yes"; then enable_ssldir=""; fi
232 CHECK_SSL($enable_ssldir)
233 server_ldflags="$server_ldflags $SSL_LDFLAGS $SSL_LIBS"
234 client_ldflags="$client_ldflags $SSL_LDFLAGS $SSL_LIBS"
235 audiod_ldflags="$audiod_ldflags $SSL_LDFLAGS $SSL_LIBS"
236
237 ########################################################################### libsocket
238 AC_CHECK_LIB([c], [socket],
239         [socket_lib=],
240         [socket_lib="-lsocket"]
241 )
242 server_ldflags="$server_ldflags $socket_lib"
243 client_ldflags="$client_ldflags $socket_lib"
244 audioc_ldflags="$audioc_ldflags $socket_lib"
245 audiod_ldflags="$audiod_ldflags $socket_lib"
246 recv_ldflags="$recv_ldflags $socket_lib"
247 AC_SEARCH_LIBS([connect],[socket],[],[
248         AC_MSG_ERROR([Fatal: Did not find connect().])
249 ],[])
250 ########################################################################### libnsl
251 AC_CHECK_LIB([c], [gethostbyname],
252         [nsl_lib=],
253         [nsl_lib="-lnsl"]
254 )
255 server_ldflags="$server_ldflags $nsl_lib"
256 client_ldflags="$client_ldflags $nsl_lib"
257 audioc_ldflags="$audioc_ldflags $nsl_lib"
258 recv_ldflags="$recv_ldflags $nsl_lib"
259 AC_SEARCH_LIBS([inet_ntoa],[nsl],[],[
260         AC_MSG_ERROR([Fatal: Did not find inet_ntoa().])
261 ],[])
262 ########################################################################### ucred
263 AC_MSG_CHECKING(for struct ucred)
264 AC_TRY_LINK([
265         #define _GNU_SOURCE
266         #include <sys/types.h>
267         #include <sys/socket.h>
268 ],[
269         struct ucred sucred; sucred.pid=0;
270 ],[have_ucred=yes],[have_ucred=no])
271 AC_MSG_RESULT($have_ucred)
272 if test ${have_ucred} = yes; then
273         AC_DEFINE(HAVE_UCRED, 1, define to 1 you have struct ucred)
274 fi
275
276 ########################################################################### curses
277 have_ncurses="yes"
278 OLD_CPPFLAGS="$CPPFLAGS"
279 OLD_LD_FLAGS="$LDFLAGS"
280 OLD_LIBS="$LIBS"
281 AC_ARG_WITH(ncurses_headers, [AC_HELP_STRING(--with-ncurses-headers=dir,
282         [look for ncurses.h also in dir])])
283 if test -n "$with_ncurses_headers"; then
284         ncurses_cppflags="-I$with_ncurses_headers"
285         CPPFLAGS="$CPPFLAGS $ncurses_cppflags"
286 fi
287 AC_ARG_WITH(ncurses_libs, [AC_HELP_STRING(--with-ncurses-libs=dir,
288         [look for libncurses also in dir])])
289 if test -n "$with_ncurses_libs"; then
290         ncurses_libs="-L$with_ncurses_libs"
291         LDFLAGS="$LDFLAGS $ncurses_libs"
292 fi
293 AC_CHECK_HEADER(curses.h, [], [
294         have_ncurses="no"
295 ])
296 AC_CHECK_LIB([ncurses], [initscr], [], [
297         have_ncurses="no"
298 ])
299 if test "$have_ncurses" = "yes"; then
300         AC_SUBST(ncurses_cppflags)
301         AC_SUBST(ncurses_libs)
302         AC_DEFINE(HAVE_NCURSES, 1, [define to 1 to turn on ncurses support])
303         extras="$extras para_gui"
304         all_executables="$all_executables gui"
305 else
306         AC_MSG_WARN([cannot build para_gui])
307 fi
308 CPPFLAGS="$OLD_CPPFLAGS"
309 LDFLAGS="$OLD_LDFLAGS"
310 LIBS="$OLD_LIBS"
311
312 ########################################################################### ip_mreqn
313 AC_MSG_CHECKING(for struct ip_mreqn (UDPv4 multicast))
314 AC_TRY_LINK([
315         #include <netdb.h>
316         #include <net/if.h>
317 ],[
318         struct ip_mreqn mn;
319         mn.imr_ifindex = 0;
320 ],[have_ip_mreqn=yes],[have_ip_mreqn=no])
321 AC_MSG_RESULT($have_ip_mreqn)
322 if test ${have_ip_mreqn} = yes; then
323         AC_DEFINE(HAVE_IP_MREQN, 1, define to 1 you have struct ip_mreqn)
324 fi
325 ########################################################################### osx
326
327 AC_MSG_CHECKING(for CoreAudio (MacOs))
328 AC_TRY_LINK([
329         #include <CoreAudio/CoreAudio.h>
330 ],[
331         AudioDeviceID id;
332 ],[have_core_audio=yes],[have_core_audio=no])
333 AC_MSG_RESULT($have_core_audio)
334 if test ${have_core_audio} = yes; then
335         f1="-framework CoreAudio"
336         f2="-framework AudioToolbox"
337         f3="-framework AudioUnit"
338         f4="-framework CoreServices"
339         f="$f1 $f2 $f3 $f4"
340
341         all_errlist_objs="$all_errlist_objs osx_write"
342         audiod_errlist_objs="$audiod_errlist_objs osx_write"
343         audiod_cmdline_objs="$audiod_cmdline_objs osx_write.cmdline"
344         audiod_ldflags="$audiod_ldflags $f"
345
346         write_errlist_objs="$write_errlist_objs osx_write"
347         write_cmdline_objs="$write_cmdline_objs osx_write.cmdline"
348         write_ldflags="$write_ldflags $f"
349         writers="$writers osx"
350         default_writer="OSX_WRITE"
351         AC_DEFINE(HAVE_CORE_AUDIO, 1, define to 1 on Mac Os X)
352 fi
353 ########################################################################### ogg
354 have_ogg="yes"
355 OLD_CPPFLAGS="$CPPFLAGS"
356 OLD_LD_FLAGS="$LDFLAGS"
357 OLD_LIBS="$LIBS"
358 AC_ARG_WITH(oggvorbis_headers, [AC_HELP_STRING(--with-oggvorbis-headers=dir,
359         [look for vorbis/codec.h also in dir])])
360 if test -n "$with_oggvorbis_headers"; then
361         oggvorbis_cppflags="-I$with_oggvorbis_headers"
362         CPPFLAGS="$CPPFLAGS $oggvorbis_cppflags"
363 fi
364 AC_ARG_WITH(oggvorbis_libs, [AC_HELP_STRING(--with-oggvorbis-libs=dir,
365         [look for oggvorbis libs also in dir])])
366 if test -n "$with_oggvorbis_libs"; then
367         oggvorbis_libs="-L$with_oggvorbis_libs"
368         LDFLAGS="$LDFLAGS $oggvorbis_libs"
369 fi
370
371 AC_CHECK_LIB([ogg], [ogg_stream_init], [], [ have_ogg="no" ])
372 AC_CHECK_LIB([vorbis], [vorbis_info_init], [], [ have_ogg="no" ])
373 AC_CHECK_HEADERS([ogg/ogg.h vorbis/codec.h], [], [ have_ogg="no" ])
374 if test "$have_ogg" = "yes"; then
375         all_errlist_objs="$all_errlist_objs oggdec_filter ogg_afh"
376         AC_DEFINE(HAVE_OGGVORBIS, 1, define to 1 to turn on ogg vorbis support)
377         filters="$filters oggdec"
378         if test "$OSTYPE" = "Darwin"; then
379                 oggvorbis_libs="-Wl,-bind_at_load  $oggvorbis_libs"
380         fi
381         server_ldflags="$server_ldflags $oggvorbis_libs -logg -lvorbis -lvorbisfile"
382         filter_ldflags="$filter_ldflags $oggvorbis_libs -lvorbis -lvorbisfile"
383         audiod_ldflags="$audiod_ldflags $oggvorbis_libs -lvorbis -lvorbisfile"
384         afh_ldflags="$afh_ldflags $oggvorbis_libs -logg -lvorbis -lvorbisfile"
385
386         filter_cmdline_objs="$filter_cmdline_objs add_cmdline(oggdec_filter)"
387         audiod_cmdline_objs="$audiod_cmdline_objs add_cmdline(oggdec_filter)"
388
389         server_errlist_objs="$server_errlist_objs ogg_afh"
390         filter_errlist_objs="$filter_errlist_objs oggdec_filter"
391         audiod_errlist_objs="$audiod_errlist_objs oggdec_filter"
392         afh_errlist_objs="$afh_errlist_objs ogg_afh"
393
394         audiod_audio_formats="$audiod_audio_formats ogg"
395         server_audio_formats="$server_audio_formats ogg"
396         AC_SUBST(oggvorbis_cppflags)
397         AC_SUBST(oggvorbis_libs)
398 else
399         AC_MSG_WARN([no ogg vorbis support in para_server/para_filter])
400 fi
401 CPPFLAGS="$OLD_CPPFLAGS"
402 LDFLAGS="$OLD_LDFLAGS"
403 LIBS="$OLD_LIBS"
404 ########################################################################### faad
405 have_faad=yes
406 OLD_CPPFLAGS="$CPPFLAGS"
407 OLD_LD_FLAGS="$LDFLAGS"
408 OLD_LIBS="$LIBS"
409 AC_ARG_WITH(faad_headers, [AC_HELP_STRING(--with-faad-headers=dir,
410         [look for neaacdec.h also in dir])])
411 if test -n "$with_faad_headers"; then
412         faad_cppflags="-I$with_faad_headers"
413         CPPFLAGS="$CPPFLAGS $faad_cppflags"
414 fi
415 AC_ARG_WITH(faad_libs, [AC_HELP_STRING(--with-faad-libs=dir,
416         [look for libfaad also in dir])])
417 if test -n "$with_faad_libs"; then
418         faad_libs="-L$with_faad_libs"
419         LDFLAGS="$LDFLAGS $faad_libs"
420 fi
421 AC_CHECK_HEADER(neaacdec.h, [], have_faad=no)
422 AC_CHECK_LIB([faad], [NeAACDecOpen], [], have_faad=no)
423 if test "$have_faad" = "yes"; then
424         AC_DEFINE(HAVE_FAAD, 1, define to 1 if you want to build the aacdec filter)
425         all_errlist_objs="$all_errlist_objs aac_common aacdec_filter aac_afh"
426         filter_errlist_objs="$filter_errlist_objs aacdec_filter aac_common"
427         afh_errlist_objs="$afh_errlist_objs aac_common aac_afh"
428         audiod_errlist_objs="$audiod_errlist_objs aacdec_filter aac_common"
429         server_errlist_objs="$server_errlist_objs aac_afh aac_common"
430         server_ldflags="$server_ldflags $faad_libs -lfaad"
431         filter_ldflags="$filter_ldflags $faad_libs -lfaad"
432         audiod_ldflags="$audiod_ldflags $faad_libs -lfaad"
433         afh_ldflags="$afh_ldflags $faad_libs -lfaad"
434         audiod_audio_formats="$audiod_audio_formats aac"
435         server_audio_formats="$server_audio_formats aac"
436         filters="$filters aacdec"
437         AC_SUBST(faad_cppflags)
438         AC_SUBST(faad_libs)
439 else
440         AC_MSG_WARN([no aac support in para_audiod/para_filter])
441 fi
442 CPPFLAGS="$OLD_CPPFLAGS"
443 LDFLAGS="$OLD_LDFLAGS"
444 LIBS="$OLD_LIBS"
445 ########################################################################### mad
446 have_mad="yes"
447 OLD_CPPFLAGS="$CPPFLAGS"
448 OLD_LD_FLAGS="$LDFLAGS"
449 OLD_LIBS="$LIBS"
450
451 AC_ARG_WITH(mad_headers, [AC_HELP_STRING(--with-mad-headers=dir,
452         [look for mad.h also in dir])])
453 if test -n "$with_mad_headers"; then
454         mad_cppflags="-I$with_mad_headers"
455         CPPFLAGS="$CPPFLAGS $mad_cppflags"
456 fi
457 AC_ARG_WITH(mad_libs, [AC_HELP_STRING(--with-mad-libs=dir,
458         [look for libmad also in dir])])
459 if test -n "$with_mad_libs"; then
460         mad_libs="-L$with_mad_libs"
461         LDFLAGS="$LDFLAGS $mad_libs"
462 fi
463 AC_CHECK_HEADERS([mad.h], [], [
464         have_mad="no"
465 ])
466 AC_CHECK_LIB([mad], [mad_stream_init], [], [
467         have_mad="no"
468 ])
469 if test "$have_mad" = "yes"; then
470         AC_DEFINE(HAVE_MAD, 1, define to 1 if you want to build the mp3dec filter)
471         filter_cmdline_objs="$filter_cmdline_objs add_cmdline(mp3dec_filter)"
472         audiod_cmdline_objs="$audiod_cmdline_objs add_cmdline(mp3dec_filter)"
473         all_errlist_objs="$all_errlist_objs mp3dec_filter"
474         filter_errlist_objs="$filter_errlist_objs mp3dec_filter"
475         audiod_errlist_objs="$audiod_errlist_objs mp3dec_filter"
476         filter_ldflags="$filter_ldflags $mad_libs -lmad"
477         audiod_ldflags="$audiod_ldflags $mad_libs -lmad"
478         audiod_audio_formats="$audiod_audio_formats mp3"
479         filters="$filters mp3dec"
480         AC_SUBST(mad_cppflags)
481         AC_SUBST(mad_libs)
482 else
483         AC_MSG_WARN([no mp3dec support in para_audiod/para_filter])
484 fi
485 if test -n "$audiod_audio_formats"; then
486         extras="$extras para_audiod"
487         all_executables="$all_executables audiod"
488 else
489         AC_MSG_WARN([can not build para_audiod (no supported audio formats)])
490 fi
491 CPPFLAGS="$OLD_CPPFLAGS"
492 LDFLAGS="$OLD_LDFLAGS"
493 LIBS="$OLD_LIBS"
494 ###################################################################### libid3tag
495 AC_MSG_CHECKING(for libid3tag)
496 AC_TRY_LINK([
497         #include <id3tag.h>
498 ],[
499         struct id3_tag t = {.flags = 0};
500 ],[have_libid3tag=yes],[have_libid3tag=no])
501 AC_MSG_RESULT($have_libid3tag)
502 if test ${have_libid3tag} = yes; then
503         AC_DEFINE(HAVE_LIBID3TAG, 1, define to 1 you have libid3tag)
504         server_ldflags="$server_ldflags -lid3tag"
505         afh_ldflags="$afh_ldflags -lid3tag"
506 else
507         AC_MSG_WARN([no support for id3v2 tags])
508 fi
509 ########################################################################### oss
510 OLD_CPPFLAGS="$CPPFLAGS"
511 OLD_LD_FLAGS="$LDFLAGS"
512 OLD_LIBS="$LIBS"
513
514 have_oss="yes"
515 msg="=> will not build para_fade/oss writer"
516
517 AC_CHECK_HEADER(sys/soundcard.h, [
518         extras="$extras para_fade"
519         all_executables="$all_executables fade"
520         all_errlist_objs="$all_errlist_objs oss_write"
521         audiod_errlist_objs="$audiod_errlist_objs oss_write"
522         audiod_cmdline_objs="$audiod_cmdline_objs add_cmdline(oss_write)"
523
524         write_errlist_objs="$write_errlist_objs oss_write"
525         write_cmdline_objs="$write_cmdline_objs add_cmdline(oss_write)"
526         writers="$writers oss"
527         default_writer="OSS_WRITE"
528         AC_CHECK_LIB(ossaudio, _oss_ioctl, [
529                         audiod_ldflags="$audiod_ldflags -lossaudio"
530                         write_ldflags="$write_ldflags -lossaudio"
531                         fade_ldflags="$write_ldflags -lossaudio"
532                 ]
533         )
534         ],
535         [
536                 have_oss="no"
537                 AC_MSG_WARN([no sys/soundcard.h $msg])
538         ]
539 )
540 CPPFLAGS="$OLD_CPPFLAGS"
541 LDFLAGS="$OLD_LDFLAGS"
542 LIBS="$OLD_LIBS"
543
544 ########################################################################### alsa
545 OLD_CPPFLAGS="$CPPFLAGS"
546 OLD_LD_FLAGS="$LDFLAGS"
547 OLD_LIBS="$LIBS"
548
549 msg="=> no alsa support for para_audiod/para_write"
550 if test "$OSTYPE" != "Linux"; then
551         have_alsa="no"
552 else
553         have_alsa="yes"
554 fi
555 if test "$have_alsa" = "yes"; then
556         AC_CHECK_HEADERS([alsa/asoundlib.h], [], [
557                 have_alsa="no"
558                 AC_MSG_WARN([no alsa/asoundlib $msg])
559         ])
560 fi
561
562 if test "$have_alsa" = "yes"; then
563         AC_CHECK_LIB([asound], [snd_pcm_open], [], [
564                 have_alsa="no"
565                 AC_MSG_WARN([no libasound $msg])
566         ])
567 fi
568
569 if test "$have_alsa" = "yes"; then
570         all_errlist_objs="$all_errlist_objs alsa_write"
571         audiod_errlist_objs="$audiod_errlist_objs alsa_write"
572         audiod_cmdline_objs="$audiod_cmdline_objs add_cmdline(alsa_write)"
573         audiod_ldflags="$audiod_ldflags -lasound"
574
575         write_errlist_objs="$write_errlist_objs alsa_write"
576         write_cmdline_objs="$write_cmdline_objs add_cmdline(alsa_write)"
577         write_ldflags="$write_ldflags -lasound"
578         writers="$writers alsa"
579         default_writer="ALSA_WRITE"
580 fi
581
582 CPPFLAGS="$OLD_CPPFLAGS"
583 LDFLAGS="$OLD_LDFLAGS"
584 LIBS="$OLD_LIBS"
585
586 AC_SUBST(extra_binaries, [$extras])
587 AC_SUBST(extra_filter_objs, [$extra_filter_objs])
588 AC_SUBST(extra_filter_libs, [$extra_filter_libs])
589 AC_SUBST(install_sh, [$INSTALL])
590 AC_CONFIG_FILES([Makefile])
591
592
593 AC_DEFUN([add_dot_o],[$(for i in $@; do printf "$i.o "; done)])
594 AC_DEFUN([objlist_to_errlist],[$(for i in $@; do printf "DEFINE_ERRLIST($(echo $i| tr 'a-z' 'A-Z'));"; done) [const char **para_errlist[[]]] = {$(for i in $@; do printf "PARA_ERRLIST($(echo $i | tr 'a-z' 'A-Z')), "; done) }])
595
596 ############################################################# error2.h
597 AC_DEFUN([define_safe_error_enums],
598 [
599         exe=""
600         for i in $all_executables; do
601 #               eval echo checking if $1 is linked into $i
602                 for j in $(eval echo \$${i}_errlist_objs); do
603                         if test $j = $1; then
604                                 exe="$exe $i"
605                                 break;
606                         fi
607                 done
608         done
609         #echo "$1 gets linked into $exe"
610         safe_errlists=""
611         for i in $all_errlist_objs; do
612                 for j in $exe; do
613                         found=0
614                         for k in $(eval echo \$${j}_errlist_objs); do
615                                 if test $k = $i; then
616                                         found=1
617                                         break;
618                                 fi
619                         done
620                         if test $found -eq 0; then
621                                 break;
622                         fi
623                 done
624                 if test $found -eq 1; then
625                         safe_errlists="$safe_errlists $i"
626                 fi
627         done
628         #echo "safe errlists for $1: $safe_errlists"
629         ss_defs=""
630         for i in $safe_errlists; do
631                 echo "SS_ENUM($(echo $i | tr 'a-z' 'A-Z'));"
632         done
633 ]
634 )
635
636
637 AC_MSG_NOTICE(creating error2.h)
638 for obj in $all_errlist_objs; do
639         SS="$SS SS_$(echo $obj | tr 'a-z' 'A-Z'),"
640         echo "#ifdef MAIN_INPUT_FILE_IS_$obj"
641         define_safe_error_enums($obj)
642         echo "#endif"
643 done > error2.h
644 AC_DEFINE_UNQUOTED(DEFINE_ERRLIST_OBJECT_ENUM,
645         [enum {$SS NUM_SS}],
646         [list of all objects that use paraslash's error facility]
647 )
648
649 ################################################################## status items
650
651 status_items="basename status num_played mtime bitrate frequency file_size
652 status_flags format score techinfo afs_mode
653 attributes_txt decoder_flags audiod_status play_time attributes_bitmap
654 offset seconds_total stream_start current_time audiod_uptime image_id
655 lyrics_id duration directory lyrics_name image_name path hash channels
656 last_played num_chunks chunk_time amplification artist title year album
657 comment"
658
659 # $1: prefix, $2: items
660 AC_DEFUN([make_enum_items], [$(
661         for i in $2; do
662                 printf "$1_$(echo $i | tr 'a-z' 'A-Z'), "
663         done
664 )])
665
666 # $1: prefix, $2: items
667 AC_DEFUN([make_enum_array], [$(
668         for i in $2; do
669                 printf "\"$i\", "
670         done
671 )])
672
673 AC_DEFINE_UNQUOTED(STATUS_ITEM_ENUM,
674         make_enum_items(SI,  $status_items),
675         [enum of all status items]
676 )
677 AC_DEFINE_UNQUOTED(STATUS_ITEM_ARRAY,
678         make_enum_array(SI,  $status_items),
679         [char * array of all status items]
680 )
681
682
683 recv_objs="$recv_cmdline_objs $recv_errlist_objs"
684 filter_objs="$filter_cmdline_objs $filter_errlist_objs"
685 audiod_objs="$audiod_cmdline_objs $audiod_errlist_objs"
686 server_objs="$server_cmdline_objs $server_errlist_objs"
687 write_objs="$write_cmdline_objs $write_errlist_objs"
688 client_objs="$client_cmdline_objs $client_errlist_objs"
689 audioc_objs="$audioc_cmdline_objs $audioc_errlist_objs"
690 afh_objs="$afh_cmdline_objs $afh_errlist_objs"
691 fade_objs="$fade_cmdline_objs $fade_errlist_objs"
692
693 AC_SUBST(recv_objs, add_dot_o($recv_objs))
694 AC_SUBST(recv_ldflags, $recv_ldflags)
695 AC_DEFINE_UNQUOTED(INIT_RECV_ERRLISTS, objlist_to_errlist($recv_errlist_objs),
696         errors used by para_recv)
697
698 AC_SUBST(filter_objs, add_dot_o($filter_objs))
699 AC_SUBST(filter_ldflags, $filter_ldflags)
700 AC_DEFINE_UNQUOTED(INIT_FILTER_ERRLISTS,
701         objlist_to_errlist($filter_errlist_objs), errors used by para_filter)
702
703 AC_SUBST(audiod_objs, add_dot_o($audiod_objs))
704 AC_SUBST(audiod_ldflags, $audiod_ldflags)
705 AC_DEFINE_UNQUOTED(INIT_AUDIOD_ERRLISTS, objlist_to_errlist($audiod_errlist_objs),
706         errors used by para_audiod)
707
708 AC_SUBST(server_objs, add_dot_o($server_objs))
709 AC_SUBST(server_ldflags, $server_ldflags)
710 AC_DEFINE_UNQUOTED(INIT_SERVER_ERRLISTS,
711         objlist_to_errlist($server_errlist_objs), errors used by para_server)
712
713 AC_SUBST(afh_objs, add_dot_o($afh_objs))
714 AC_SUBST(afh_ldflags, $afh_ldflags)
715 AC_DEFINE_UNQUOTED(INIT_AFH_ERRLISTS,
716         objlist_to_errlist($afh_errlist_objs), errors used by para_afh)
717
718 AC_SUBST(write_objs, add_dot_o($write_objs))
719 AC_SUBST(write_ldflags, $write_ldflags)
720 AC_DEFINE_UNQUOTED(INIT_WRITE_ERRLISTS,
721         objlist_to_errlist($write_errlist_objs), errors used by para_write)
722
723 AC_SUBST(client_objs, add_dot_o($client_objs))
724 AC_SUBST(client_ldflags, $client_ldflags)
725 AC_DEFINE_UNQUOTED(INIT_CLIENT_ERRLISTS,
726         objlist_to_errlist($client_errlist_objs), errors used by para_client)
727
728 AC_SUBST(audioc_objs, add_dot_o($audioc_objs))
729 AC_SUBST(audioc_ldflags, $audioc_ldflags)
730 AC_DEFINE_UNQUOTED(INIT_AUDIOC_ERRLISTS,
731         objlist_to_errlist($audioc_errlist_objs), errors used by para_audioc)
732
733 AC_SUBST(gui_objs, add_dot_o($gui_objs))
734 AC_DEFINE_UNQUOTED(INIT_GUI_ERRLISTS,
735         objlist_to_errlist($gui_errlist_objs), errors used by para_gui)
736
737 AC_SUBST(fade_objs, add_dot_o($fade_objs))
738 AC_SUBST(fade_ldflags, $fade_ldflags)
739 AC_DEFINE_UNQUOTED(INIT_FADE_ERRLISTS,
740         objlist_to_errlist($fade_errlist_objs), errors used by para_fade)
741
742
743 enum="$(for i in $filters; do printf "${i}_FILTER, " | tr '[a-z]' '[A-Z]'; done)"
744 AC_DEFINE_UNQUOTED(FILTER_ENUM, $enum NUM_SUPPORTED_FILTERS,
745         enum of supported filters)
746 inits="$(for i in $filters; do printf 'extern void '$i'_filter_init(struct filter *f); '; done)"
747 AC_DEFINE_UNQUOTED(DECLARE_FILTER_INITS, $inits, init functions of the supported filters)
748 array="$(for i in $filters; do printf '{.name = "'$i'", .init = '$i'_filter_init},'; done)"
749 AC_DEFINE_UNQUOTED(FILTER_ARRAY, $array, array of supported filters)
750
751 enum="$(for i in $writers; do printf "${i}_WRITE, " | tr '[a-z]' '[A-Z]'; done)"
752 AC_DEFINE_UNQUOTED(WRITER_ENUM, $enum NUM_SUPPORTED_WRITERS,
753         enum of supported writers)
754 AC_DEFINE_UNQUOTED(DEFAULT_WRITER, $default_writer, use this writer if none was specified)
755 names="$(for i in $writers; do printf \"$i\",' ' ; done)"
756 AC_DEFINE_UNQUOTED(WRITER_NAMES, $names, supported writer names)
757 inits="$(for i in $writers; do printf 'extern void '$i'_write_init(struct writer *); '; done)"
758 AC_DEFINE_UNQUOTED(DECLARE_WRITER_INITS, $inits, init functions of the supported writers)
759 array="$(for i in $writers; do printf '{.init = '$i'_write_init},'; done)"
760 AC_DEFINE_UNQUOTED(WRITER_ARRAY, $array, array of supported writers)
761
762 enum="$(for i in $audiod_audio_formats; do printf "AUDIO_FORMAT_${i}, " | tr '[a-z]' '[A-Z]'; done)"
763 AC_DEFINE_UNQUOTED(AUDIOD_AUDIO_FORMATS_ENUM, $enum NUM_AUDIO_FORMATS,
764         enum of audio formats supported by audiod)
765 names="$(for i in $audiod_audio_formats; do printf \"$i\",' ' ; done)"
766 AC_DEFINE_UNQUOTED(AUDIOD_AUDIO_FORMAT_ARRAY, $names, array of audio formats supported by audiod)
767
768 AC_OUTPUT
769 AC_MSG_NOTICE([
770 paraslash configuration:
771 ~~~~~~~~~~~~~~~~~~~~~~~~
772 unix socket credentials: $have_ucred
773 audio formats supported by para_server/para_afh: $server_audio_formats
774 id3 version2 support: $have_libid3tag
775 senders supported by para_server: $senders
776 receivers supported by para_audiod/para_recv: $receivers
777 filters supported by para_audiod/para_filter: $filters
778 writers supported by para_audiod/para_write: $writers
779 optional executables: $extras
780 ])