Implement support for libao via the new ao writer.
[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_HEADER_STDBOOL
35 AC_CHECK_HEADERS([arpa/inet.h ctype.h fcntl.h limits.h netdb.h netinet/in.h \
36         stdlib.h string.h sys/socket.h sys/time.h sys/timeb.h sys/un.h \
37         sys/ipc.h unistd.h utime.h stddef.h],
38         [], [AC_MSG_ERROR([$ac_header not found])])
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_INT8_T
49 AC_TYPE_INT16_T
50 AC_TYPE_INT32_T
51 AC_TYPE_INT64_T
52 AC_TYPE_MODE_T
53 AC_TYPE_SSIZE_T
54 AC_TYPE_UID_T
55 AC_TYPE_UINT8_T
56 AC_TYPE_UINT16_T
57 AC_TYPE_UINT32_T
58 AC_TYPE_UINT64_T
59
60 # Checks for library functions.
61 AC_FUNC_FORK
62 AC_PROG_GCC_TRADITIONAL
63 AC_FUNC_MALLOC
64 AC_FUNC_MEMCMP
65 AC_FUNC_MKTIME
66 AC_FUNC_MMAP
67 AC_FUNC_REALLOC
68 AC_FUNC_SELECT_ARGTYPES
69 AC_TYPE_SIGNAL
70 AC_FUNC_STAT
71 AC_FUNC_STRFTIME
72 AC_FUNC_VPRINTF
73 AC_FUNC_CLOSEDIR_VOID
74 AC_FUNC_LSTAT
75
76 AC_CHECK_FUNCS([atexit dup2 memchr memmove memset \
77         regcomp select strchr strdup strerror strstr strtol uname \
78         fchdir gettimeofday localtime_r munmap strcasecmp strcspn \
79         strncasecmp strrchr strspn alarm mkdir inet_ntoa socket], [],
80         [AC_MSG_ERROR([function not found, cannot live without it])])
81
82 cmdline_dir="cmdline"
83 AC_SUBST(cmdline_dir)
84 AC_DEFUN([add_cmdline],[$(for i in $@; do printf "${i}.cmdline "; done)])
85
86
87 all_errlist_objs="server mp3_afh afh_common vss command net string signal time
88 daemon stat crypt http_send close_on_fork ipc acl afh fade amp_filter
89 dccp_send fd user_list chunk_queue afs aft mood score attribute blob ringbuffer
90 playlist sha1 sched audiod grab_client filter_common wav_filter compress_filter
91 http_recv dccp_recv recv_common write_common file_write audiod_command
92 client_common recv stdout filter stdin audioc write client exec send_common ggo
93 udp_recv udp_send color fec fecdec_filter prebuffer_filter mm
94 server_command_list afs_command_list audiod_command_list bitstream imdct wma_afh
95 wma_common wmadec_filter buffer_tree
96 "
97
98 executables="recv filter audioc write client afh audiod"
99
100 recv_cmdline_objs="add_cmdline(recv http_recv dccp_recv udp_recv)"
101
102 recv_errlist_objs="http_recv recv_common recv time string net dccp_recv
103         fd sched stdout ggo udp_recv fec buffer_tree"
104 recv_ldflags=""
105
106 filter_cmdline_objs="add_cmdline(filter compress_filter amp_filter prebuffer_filter)"
107 filter_errlist_objs="filter_common wav_filter compress_filter filter string
108         stdin stdout sched fd amp_filter ggo fecdec_filter fec
109         prebuffer_filter time bitstream imdct wma_common wmadec_filter buffer_tree"
110 filter_ldflags="-lm"
111 filters=" compress wav amp fecdec wmadec prebuffer"
112
113 audioc_cmdline_objs="add_cmdline(audioc)"
114 audioc_errlist_objs="audioc string net fd"
115 audioc_ldflags=""
116
117 audiod_cmdline_objs="add_cmdline(audiod compress_filter http_recv dccp_recv file_write client amp_filter udp_recv prebuffer_filter)"
118 audiod_errlist_objs="audiod signal string daemon stat net
119         time grab_client filter_common wav_filter compress_filter amp_filter http_recv dccp_recv
120         recv_common fd sched write_common file_write audiod_command crypt fecdec_filter
121         client_common ggo udp_recv color fec prebuffer_filter sha1 audiod_command_list
122         bitstream imdct wma_common wmadec_filter buffer_tree"
123 audiod_ldflags="-lm"
124 audiod_audio_formats="wma"
125
126 afh_cmdline_objs="add_cmdline(afh)"
127 afh_errlist_objs="afh string fd mp3_afh afh_common time wma_afh wma_common"
128 afh_ldflags=""
129
130 server_cmdline_objs="add_cmdline(server)"
131 server_errlist_objs="server afh_common mp3_afh vss command net string signal
132         time daemon crypt http_send close_on_fork mm
133         ipc dccp_send fd user_list chunk_queue afs aft mood score attribute
134         blob playlist sha1 sched acl send_common udp_send color fec
135         server_command_list afs_command_list wma_afh wma_common"
136 server_ldflags=""
137 server_audio_formats="mp3 wma"
138
139 write_cmdline_objs="add_cmdline(write file_write)"
140 write_errlist_objs="write write_common file_write time fd string sched stdin
141         buffer_tree ggo"
142 write_ldflags=""
143 writers=" file"
144 default_writer="FILE_WRITE"
145
146 client_cmdline_objs="add_cmdline(client)"
147 client_errlist_objs="client net string crypt fd sched stdin stdout time
148         client_common sha1 buffer_tree"
149 client_ldflags=""
150
151 gui_cmdline_objs="add_cmdline(gui)"
152 gui_errlist_objs="exec signal string stat ringbuffer fd"
153 gui_other_objs="gui gui_theme"
154 gui_objs="$gui_cmdline_objs $gui_errlist_objs $gui_other_objs"
155
156 fade_cmdline_objs="add_cmdline(fade)"
157 fade_errlist_objs="fade exec string fd"
158
159
160 ########################################################################### snprintf
161 # ===========================================================================
162 #        http://www.nongnu.org/autoconf-archive/ax_func_snprintf.html
163 # ===========================================================================
164 #
165 # SYNOPSIS
166 #
167 #   AX_FUNC_SNPRINTF
168 #
169 # DESCRIPTION
170 #
171 #   Checks for a fully C99 compliant snprintf, in particular checks whether
172 #   it does bounds checking and returns the correct string length; does the
173 #   same check for vsnprintf. If no working snprintf or vsnprintf is found,
174 #   it prints an error message and aborts.
175 #
176 # LICENSE
177 #
178 #   Copyright (c) 2008 Ruediger Kuhlmann <info@ruediger-kuhlmann.de>
179 #
180 #   Copying and distribution of this file, with or without modification, are
181 #   permitted in any medium without royalty provided the copyright notice
182 #   and this notice are preserved.
183
184 AU_ALIAS([AC_FUNC_SNPRINTF], [AX_FUNC_SNPRINTF])
185 AC_DEFUN([AX_FUNC_SNPRINTF],
186 [AC_CHECK_FUNCS(snprintf vsnprintf)
187 AC_MSG_CHECKING(for working snprintf)
188 AC_CACHE_VAL(ac_cv_have_working_snprintf,
189 [AC_TRY_RUN(
190 [#include <stdio.h>
191
192 int main(void)
193 {
194     char bufs[5] = { 'x', 'x', 'x', '\0', '\0' };
195     char bufd[5] = { 'x', 'x', 'x', '\0', '\0' };
196     int i;
197     i = snprintf (bufs, 2, "%s", "111");
198     if (strcmp (bufs, "1")) exit (1);
199     if (i != 3) exit (1);
200     i = snprintf (bufd, 2, "%d", 111);
201     if (strcmp (bufd, "1")) exit (1);
202     if (i != 3) exit (1);
203     exit(0);
204 }], ac_cv_have_working_snprintf=yes, ac_cv_have_working_snprintf=no, ac_cv_have_working_snprintf=cross)])
205 AC_MSG_RESULT([$ac_cv_have_working_snprintf])
206 AC_MSG_CHECKING(for working vsnprintf)
207 AC_CACHE_VAL(ac_cv_have_working_vsnprintf,
208 [AC_TRY_RUN(
209 [#include <stdio.h>
210 #include <stdarg.h>
211
212 int my_vsnprintf (char *buf, const char *tmpl, ...)
213 {
214     int i;
215     va_list args;
216     va_start (args, tmpl);
217     i = vsnprintf (buf, 2, tmpl, args);
218     va_end (args);
219     return i;
220 }
221
222 int main(void)
223 {
224     char bufs[5] = { 'x', 'x', 'x', '\0', '\0' };
225     char bufd[5] = { 'x', 'x', 'x', '\0', '\0' };
226     int i;
227     i = my_vsnprintf (bufs, "%s", "111");
228     if (strcmp (bufs, "1")) exit (1);
229     if (i != 3) exit (1);
230     i = my_vsnprintf (bufd, "%d", 111);
231     if (strcmp (bufd, "1")) exit (1);
232     if (i != 3) exit (1);
233     exit(0);
234 }], ac_cv_have_working_vsnprintf=yes, ac_cv_have_working_vsnprintf=no, ac_cv_have_working_vsnprintf=cross)])
235 AC_MSG_RESULT([$ac_cv_have_working_vsnprintf])
236 if test x$ac_cv_have_working_snprintf$ac_cv_have_working_vsnprintf != "xyesyes"; then
237 AC_MSG_ERROR([fatal: buggy snprintf() detected])
238 fi])
239 AX_FUNC_SNPRINTF()
240 ########################################################################### osl
241 have_osl=yes
242 OLD_CPPFLAGS="$CPPFLAGS"
243 OLD_LD_FLAGS="$LDFLAGS"
244 OLD_LIBS="$LIBS"
245 AC_ARG_WITH(osl_headers, [AC_HELP_STRING(--with-osl-headers=dir,
246         [look for osl.h also in dir])])
247 if test -n "$with_osl_headers"; then
248         osl_cppflags="-I$with_osl_headers"
249         CPPFLAGS="$CPPFLAGS $osl_cppflags"
250 fi
251 AC_ARG_WITH(osl_libs, [AC_HELP_STRING(--with-osl-libs=dir,
252         [look for libosl also in dir])])
253 if test -n "$with_osl_libs"; then
254         osl_libs="-L$with_osl_libs"
255         LDFLAGS="$LDFLAGS $osl_libs"
256 fi
257
258 AC_CHECK_HEADER(osl.h, [], have_osl=no)
259 AC_CHECK_LIB([osl], [osl_open_table], [], have_osl=no)
260 if test "$have_osl" = "no"; then
261         AC_MSG_WARN([libosl not found, can not build para_server.
262 Download libosl at
263         http://systemlinux.org/~maan/osl
264 or execute
265         git clone git://git.tuebingen.mpg.de/osl
266         ])
267 else
268         extras="$extras server"
269         executables="$executables server"
270         AC_SUBST(osl_cppflags)
271         server_ldflags="$server_ldflags $osl_libs -losl"
272 fi
273 CPPFLAGS="$OLD_CPPFLAGS"
274 LDFLAGS="$OLD_LDFLAGS"
275 LIBS="$OLD_LIBS"
276 ########################################################################### ssl
277 dnl @synopsis CHECK_SSL
278 dnl
279 dnl based on the follwing macro from the autoconf archive
280 dnl
281 dnl @category InstalledPackages
282 dnl @author Mark Ethan Trostler <trostler@juniper.net>
283 dnl @version 2003-01-28
284 dnl @license AllPermissive
285
286 AC_DEFUN([CHECK_SSL],
287 [
288         for ssldir in $1 /usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr; do
289                 AC_MSG_CHECKING(for openssl in $ssldir)
290                 if test -f "$ssldir/include/openssl/ssl.h"; then
291                         found_ssl="yes"
292                         AC_MSG_RESULT(yes)
293                         SSL_CFLAGS="-I$ssldir/include"
294                         SSL_CPPFLAGS="-I$ssldir/include"
295                         break
296                 fi
297                 AC_MSG_RESULT(no)
298         done
299         if test x_$found_ssl != x_yes; then
300                 AC_MSG_ERROR(Cannot find ssl libraries)
301         else
302                 SSL_LIBS="-lssl -lcrypto";
303                 SSL_LDFLAGS="-L$ssldir/lib";
304         fi
305         AC_SUBST(SSL_CPPFLAGS)
306 ])dnl
307
308 AC_ARG_ENABLE(ssldir, [AS_HELP_STRING(--enable-ssldir=path,
309         [Search for openssl also in path.])])
310 if test "$enable_ssldir" = "yes"; then enable_ssldir=""; fi
311 CHECK_SSL($enable_ssldir)
312 server_ldflags="$server_ldflags $SSL_LDFLAGS $SSL_LIBS"
313 client_ldflags="$client_ldflags $SSL_LDFLAGS $SSL_LIBS"
314 audiod_ldflags="$audiod_ldflags $SSL_LDFLAGS $SSL_LIBS"
315
316 ########################################################################### libsocket
317 AC_CHECK_LIB([c], [socket],
318         [socket_lib=],
319         [socket_lib="-lsocket"]
320 )
321 server_ldflags="$server_ldflags $socket_lib"
322 client_ldflags="$client_ldflags $socket_lib"
323 audioc_ldflags="$audioc_ldflags $socket_lib"
324 audiod_ldflags="$audiod_ldflags $socket_lib"
325 recv_ldflags="$recv_ldflags $socket_lib"
326 AC_SEARCH_LIBS([connect],[socket],[],[
327         AC_MSG_ERROR([Fatal: Did not find connect().])
328 ],[])
329 ########################################################################### libnsl
330 AC_CHECK_LIB([c], [gethostbyname],
331         [nsl_lib=],
332         [nsl_lib="-lnsl"]
333 )
334 server_ldflags="$server_ldflags $nsl_lib"
335 client_ldflags="$client_ldflags $nsl_lib"
336 audioc_ldflags="$audioc_ldflags $nsl_lib"
337 recv_ldflags="$recv_ldflags $nsl_lib"
338 AC_SEARCH_LIBS([inet_ntoa],[nsl],[],[
339         AC_MSG_ERROR([Fatal: Did not find inet_ntoa().])
340 ],[])
341 ########################################################################### ucred
342 AC_MSG_CHECKING(for struct ucred)
343 AC_TRY_LINK([
344         #define _GNU_SOURCE
345         #include <sys/types.h>
346         #include <sys/socket.h>
347 ],[
348         struct ucred sucred; sucred.pid=0;
349 ],[have_ucred=yes],[have_ucred=no])
350 AC_MSG_RESULT($have_ucred)
351 if test ${have_ucred} = yes; then
352         AC_DEFINE(HAVE_UCRED, 1, define to 1 you have struct ucred)
353 fi
354
355 ########################################################################### curses
356 have_curses="yes"
357 OLD_CPPFLAGS="$CPPFLAGS"
358 OLD_LD_FLAGS="$LDFLAGS"
359 OLD_LIBS="$LIBS"
360 AC_ARG_WITH(curses_headers, [AC_HELP_STRING(--with-curses-headers=dir,
361         [look for curses.h also in dir])])
362 if test -n "$with_curses_headers"; then
363         curses_cppflags="-I$with_curses_headers"
364         CPPFLAGS="$CPPFLAGS $curses_cppflags"
365 fi
366 AC_ARG_WITH(curses_libs, [AC_HELP_STRING(--with-curses-libs=dir,
367         [look for libcurses also in dir])])
368 if test -n "$with_curses_libs"; then
369         curses_libs="-L$with_curses_libs"
370         LDFLAGS="$LDFLAGS $curses_libs"
371 fi
372 AC_CHECK_HEADER(curses.h, [], [
373         have_curses="no"
374 ])
375 AC_CHECK_LIB([curses], [initscr], [], [
376         have_curses="no"
377 ])
378 if test "$have_curses" = "yes"; then
379         AC_SUBST(curses_cppflags)
380         AC_DEFINE(HAVE_NCURSES, 1, [define to 1 to turn on curses support])
381         extras="$extras gui"
382         executables="$executables gui"
383 else
384         AC_MSG_WARN([cannot build para_gui])
385 fi
386 CPPFLAGS="$OLD_CPPFLAGS"
387 LDFLAGS="$OLD_LDFLAGS"
388 LIBS="$OLD_LIBS"
389
390 ########################################################################### ip_mreqn
391 AC_MSG_CHECKING(for struct ip_mreqn (UDPv4 multicast))
392 AC_TRY_LINK([
393         #include <netdb.h>
394         #include <net/if.h>
395 ],[
396         struct ip_mreqn mn;
397         mn.imr_ifindex = 0;
398 ],[have_ip_mreqn=yes],[have_ip_mreqn=no])
399 AC_MSG_RESULT($have_ip_mreqn)
400 if test ${have_ip_mreqn} = yes; then
401         AC_DEFINE(HAVE_IP_MREQN, 1, define to 1 you have struct ip_mreqn)
402 fi
403 ########################################################################### osx
404
405 AC_MSG_CHECKING(for CoreAudio (MacOs))
406 AC_TRY_LINK([
407         #include <CoreAudio/CoreAudio.h>
408 ],[
409         AudioDeviceID id;
410 ],[have_core_audio=yes],[have_core_audio=no])
411 AC_MSG_RESULT($have_core_audio)
412 if test ${have_core_audio} = yes; then
413         f1="-framework CoreAudio"
414         f2="-framework AudioToolbox"
415         f3="-framework AudioUnit"
416         f4="-framework CoreServices"
417         f="$f1 $f2 $f3 $f4"
418
419         all_errlist_objs="$all_errlist_objs osx_write"
420         audiod_errlist_objs="$audiod_errlist_objs osx_write"
421         audiod_cmdline_objs="$audiod_cmdline_objs osx_write.cmdline"
422         audiod_ldflags="$audiod_ldflags $f"
423
424         write_errlist_objs="$write_errlist_objs osx_write"
425         write_cmdline_objs="$write_cmdline_objs osx_write.cmdline"
426         write_ldflags="$write_ldflags $f"
427         writers="$writers osx"
428         default_writer="OSX_WRITE"
429         AC_DEFINE(HAVE_CORE_AUDIO, 1, define to 1 on Mac Os X)
430 fi
431 ########################################################### ogg/vorbis/speex
432 have_ogg="yes"
433 OLD_CPPFLAGS="$CPPFLAGS"
434 OLD_LD_FLAGS="$LDFLAGS"
435 OLD_LIBS="$LIBS"
436 AC_ARG_WITH(ogg_headers, [AC_HELP_STRING(--with-ogg-headers=dir,
437         [look for ogg headers also in dir])])
438 AC_ARG_WITH(ogg_libs, [AC_HELP_STRING(--with-ogg-libs=dir,
439         [look for ogg libs also in dir])])
440 AC_ARG_WITH(vorbis_headers, [AC_HELP_STRING(--with-vorbis-headers=dir,
441         [look for vorbis headers also in dir])])
442 AC_ARG_WITH(vorbis_libs, [AC_HELP_STRING(--with-vorbis-libs=dir,
443         [look for vorbis libs also in dir])])
444 AC_ARG_WITH(speex_headers, [AC_HELP_STRING(--with-speex-headers=dir,
445         [look for speex headers also in dir])])
446 AC_ARG_WITH(speex_libs, [AC_HELP_STRING(--with-speex-libs=dir,
447         [look for speex libs also in dir])])
448
449 if test -n "$with_ogg_headers"; then
450         ogg_cppflags="-I$with_ogg_headers"
451         CPPFLAGS="$CPPFLAGS $ogg_cppflags"
452 fi
453 if test -n "$with_ogg_libs"; then
454         ogg_libs="-L$with_ogg_libs"
455         LDFLAGS="$LDFLAGS $ogg_libs"
456 fi
457 AC_CHECK_HEADERS([ogg/ogg.h], [], [ have_ogg="no"; ])
458 AC_CHECK_LIB([ogg], [ogg_stream_init], [], [ have_ogg="no" ])
459
460 have_vorbis="yes"
461 have_speex="yes"
462 if test "$have_ogg" = "yes"; then
463         # vorbis
464         if test -n "$with_vorbis_headers"; then
465                 vorbis_cppflags="-I$with_vorbis_headers"
466                 CPPFLAGS="$CPPFLAGS $vorbis_cppflags"
467         fi
468         if test -n "$with_vorbis_libs"; then
469                 vorbis_libs="-L$with_vorbis_libs"
470                 LDFLAGS="$LDFLAGS $vorbis_libs"
471         fi
472         AC_CHECK_HEADERS([vorbis/codec.h], [], [ have_vorbis="no" ])
473         AC_CHECK_LIB([vorbis], [vorbis_info_init], [], [ have_vorbis="no" ])
474
475         # speex
476         if test -n "$with_speex_headers"; then
477                 speex_cppflags="-I$with_speex_headers"
478                 CPPFLAGS="$CPPFLAGS $speex_cppflags"
479         fi
480         if test -n "$with_speex_libs"; then
481                 speex_libs="-L$with_speex_libs"
482                 LDFLAGS="$LDFLAGS $speex_libs"
483         fi
484         AC_CHECK_LIB([speex], [speex_decoder_init], [], [ have_speex="no" ])
485         AC_CHECK_HEADERS([speex/speex.h], [], [ have_speex="no" ])
486 else
487         have_vorbis="no"
488         have_speex="no"
489 fi
490
491 msg="support in para_server/para_filter/para_afh"
492 if test "$have_vorbis" = "yes" || test "$have_speex" = "yes"; then
493         AC_SUBST(ogg_cppflags)
494         ogg_libs="$ogg_libs -logg"
495         if test "$OSTYPE" = "Darwin"; then
496                 ogg_libs="-Wl,-bind_at_load $ogg_libs"
497         fi
498         server_ldflags="$server_ldflags $ogg_libs"
499         filter_ldflags="$filter_ldflags $ogg_libs"
500         audiod_ldflags="$audiod_ldflags $ogg_libs"
501         afh_ldflags="$afh_ldflags $ogg_libs"
502         all_errlist_objs="$all_errlist_objs ogg_afh_common"
503         afh_errlist_objs="$afh_errlist_objs ogg_afh_common"
504         server_errlist_objs="$server_errlist_objs ogg_afh_common"
505 else
506         AC_MSG_WARN([vorbis/speex require ogg])
507 fi
508 if test "$have_vorbis" = "yes"; then
509         all_errlist_objs="$all_errlist_objs oggdec_filter ogg_afh"
510         AC_DEFINE(HAVE_OGGVORBIS, 1, define to 1 to turn on ogg/vorbis support)
511         filters="$filters oggdec"
512         vorbis_libs="-lvorbis -lvorbisfile"
513         server_ldflags="$server_ldflags $vorbis_libs"
514         filter_ldflags="$filter_ldflags $vorbis_libs"
515         audiod_ldflags="$audiod_ldflags $vorbis_libs"
516         afh_ldflags="$afh_ldflags $vorbis_libs"
517
518         server_errlist_objs="$server_errlist_objs ogg_afh"
519         filter_errlist_objs="$filter_errlist_objs oggdec_filter"
520         audiod_errlist_objs="$audiod_errlist_objs oggdec_filter"
521         afh_errlist_objs="$afh_errlist_objs ogg_afh"
522
523         audiod_audio_formats="$audiod_audio_formats ogg"
524         server_audio_formats="$server_audio_formats ogg"
525 else
526         AC_MSG_WARN([no ogg/vorbis $msg])
527 fi
528 if test "$have_speex" = "yes"; then
529         all_errlist_objs="$all_errlist_objs spxdec_filter spx_afh spx_common"
530         AC_DEFINE(HAVE_SPEEX, 1, define to 1 to turn on ogg/speex support)
531         filters="$filters spxdec"
532         speex_libs="-lspeex"
533         server_ldflags="$server_ldflags $speex_libs"
534         filter_ldflags="$filter_ldflags $speex_libs"
535         audiod_ldflags="$audiod_ldflags $speex_libs"
536         afh_ldflags="$afh_ldflags $speex_libs"
537
538         server_errlist_objs="$server_errlist_objs spx_afh spx_common"
539         filter_errlist_objs="$filter_errlist_objs spxdec_filter spx_common"
540         audiod_errlist_objs="$audiod_errlist_objs spxdec_filter spx_common"
541         afh_errlist_objs="$afh_errlist_objs spx_afh spx_common"
542
543         audiod_audio_formats="$audiod_audio_formats spx"
544         server_audio_formats="$server_audio_formats spx"
545 else
546         AC_MSG_WARN([no ogg/speex $msg])
547 fi
548 CPPFLAGS="$OLD_CPPFLAGS"
549 LDFLAGS="$OLD_LDFLAGS"
550 LIBS="$OLD_LIBS"
551 ########################################################################### faad
552 have_faad=yes
553 OLD_CPPFLAGS="$CPPFLAGS"
554 OLD_LD_FLAGS="$LDFLAGS"
555 OLD_LIBS="$LIBS"
556 AC_ARG_WITH(faad_headers, [AC_HELP_STRING(--with-faad-headers=dir,
557         [look for neaacdec.h also in dir])])
558 if test -n "$with_faad_headers"; then
559         faad_cppflags="-I$with_faad_headers"
560         CPPFLAGS="$CPPFLAGS $faad_cppflags"
561 fi
562 AC_ARG_WITH(faad_libs, [AC_HELP_STRING(--with-faad-libs=dir,
563         [look for libfaad also in dir])])
564 if test -n "$with_faad_libs"; then
565         faad_libs="-L$with_faad_libs"
566         LDFLAGS="$LDFLAGS $faad_libs"
567 fi
568 AC_CHECK_HEADER(neaacdec.h, [], have_faad=no)
569 AC_CHECK_LIB([faad], [NeAACDecOpen], [], have_faad=no)
570 if test "$have_faad" = "yes"; then
571         AC_DEFINE(HAVE_FAAD, 1, define to 1 if you want to build the aacdec filter)
572         all_errlist_objs="$all_errlist_objs aac_common aacdec_filter aac_afh"
573         filter_errlist_objs="$filter_errlist_objs aacdec_filter aac_common"
574         afh_errlist_objs="$afh_errlist_objs aac_common aac_afh"
575         audiod_errlist_objs="$audiod_errlist_objs aacdec_filter aac_common"
576         server_errlist_objs="$server_errlist_objs aac_afh aac_common"
577         server_ldflags="$server_ldflags $faad_libs -lfaad"
578         filter_ldflags="$filter_ldflags $faad_libs -lfaad"
579         audiod_ldflags="$audiod_ldflags $faad_libs -lfaad"
580         afh_ldflags="$afh_ldflags $faad_libs -lfaad"
581         audiod_audio_formats="$audiod_audio_formats aac"
582         server_audio_formats="$server_audio_formats aac"
583         filters="$filters aacdec"
584         AC_SUBST(faad_cppflags)
585 else
586         AC_MSG_WARN([no aac support in para_audiod/para_filter])
587 fi
588 CPPFLAGS="$OLD_CPPFLAGS"
589 LDFLAGS="$OLD_LDFLAGS"
590 LIBS="$OLD_LIBS"
591 ########################################################################### mad
592 have_mad="yes"
593 OLD_CPPFLAGS="$CPPFLAGS"
594 OLD_LD_FLAGS="$LDFLAGS"
595 OLD_LIBS="$LIBS"
596
597 AC_ARG_WITH(mad_headers, [AC_HELP_STRING(--with-mad-headers=dir,
598         [look for mad.h also in dir])])
599 if test -n "$with_mad_headers"; then
600         mad_cppflags="-I$with_mad_headers"
601         CPPFLAGS="$CPPFLAGS $mad_cppflags"
602 fi
603 AC_ARG_WITH(mad_libs, [AC_HELP_STRING(--with-mad-libs=dir,
604         [look for libmad also in dir])])
605 if test -n "$with_mad_libs"; then
606         mad_libs="-L$with_mad_libs"
607         LDFLAGS="$LDFLAGS $mad_libs"
608 fi
609 AC_CHECK_HEADERS([mad.h], [], [
610         have_mad="no"
611 ])
612 AC_CHECK_LIB([mad], [mad_stream_init], [], [
613         have_mad="no"
614 ])
615 if test "$have_mad" = "yes"; then
616         AC_DEFINE(HAVE_MAD, 1, define to 1 if you want to build the mp3dec filter)
617         filter_cmdline_objs="$filter_cmdline_objs add_cmdline(mp3dec_filter)"
618         audiod_cmdline_objs="$audiod_cmdline_objs add_cmdline(mp3dec_filter)"
619         all_errlist_objs="$all_errlist_objs mp3dec_filter"
620         filter_errlist_objs="$filter_errlist_objs mp3dec_filter"
621         audiod_errlist_objs="$audiod_errlist_objs mp3dec_filter"
622         filter_ldflags="$filter_ldflags $mad_libs -lmad"
623         audiod_ldflags="$audiod_ldflags $mad_libs -lmad"
624         audiod_audio_formats="$audiod_audio_formats mp3"
625         filters="$filters mp3dec"
626         AC_SUBST(mad_cppflags)
627 else
628         AC_MSG_WARN([no mp3dec support in para_audiod/para_filter])
629 fi
630 CPPFLAGS="$OLD_CPPFLAGS"
631 LDFLAGS="$OLD_LDFLAGS"
632 LIBS="$OLD_LIBS"
633 ###################################################################### libid3tag
634 AC_MSG_CHECKING(for libid3tag)
635 AC_TRY_LINK([
636         #include <id3tag.h>
637 ],[
638         struct id3_tag t = {.flags = 0};
639 ],[have_libid3tag=yes],[have_libid3tag=no])
640 AC_MSG_RESULT($have_libid3tag)
641 if test ${have_libid3tag} = yes; then
642         AC_DEFINE(HAVE_LIBID3TAG, 1, define to 1 you have libid3tag)
643         server_ldflags="$server_ldflags -lid3tag"
644         afh_ldflags="$afh_ldflags -lid3tag"
645 else
646         AC_MSG_WARN([no support for id3v2 tags])
647 fi
648 ########################################################################### oss
649 OLD_CPPFLAGS="$CPPFLAGS"
650 OLD_LD_FLAGS="$LDFLAGS"
651 OLD_LIBS="$LIBS"
652
653 have_oss="yes"
654 msg="=> will not build para_fade/oss writer"
655
656 AC_CHECK_HEADER(sys/soundcard.h, [
657         extras="$extras fade"
658         executables="$executables fade"
659         all_errlist_objs="$all_errlist_objs oss_write"
660         audiod_errlist_objs="$audiod_errlist_objs oss_write"
661         audiod_cmdline_objs="$audiod_cmdline_objs add_cmdline(oss_write)"
662
663         write_errlist_objs="$write_errlist_objs oss_write"
664         write_cmdline_objs="$write_cmdline_objs add_cmdline(oss_write)"
665         writers="$writers oss"
666         default_writer="OSS_WRITE"
667         AC_CHECK_LIB(ossaudio, _oss_ioctl, [
668                         audiod_ldflags="$audiod_ldflags -lossaudio"
669                         write_ldflags="$write_ldflags -lossaudio"
670                         fade_ldflags="$write_ldflags -lossaudio"
671                 ]
672         )
673         ],
674         [
675                 have_oss="no"
676                 AC_MSG_WARN([no sys/soundcard.h $msg])
677         ]
678 )
679 CPPFLAGS="$OLD_CPPFLAGS"
680 LDFLAGS="$OLD_LDFLAGS"
681 LIBS="$OLD_LIBS"
682
683 ########################################################################### alsa
684 OLD_CPPFLAGS="$CPPFLAGS"
685 OLD_LD_FLAGS="$LDFLAGS"
686 OLD_LIBS="$LIBS"
687
688 msg="=> no alsa support for para_audiod/para_write"
689 if test "$OSTYPE" != "Linux"; then
690         have_alsa="no"
691 else
692         have_alsa="yes"
693 fi
694 if test "$have_alsa" = "yes"; then
695         AC_CHECK_HEADERS([alsa/asoundlib.h], [], [
696                 have_alsa="no"
697                 AC_MSG_WARN([no alsa/asoundlib $msg])
698         ])
699 fi
700
701 if test "$have_alsa" = "yes"; then
702         AC_CHECK_LIB([asound], [snd_pcm_open], [], [
703                 have_alsa="no"
704                 AC_MSG_WARN([no libasound $msg])
705         ])
706 fi
707
708 if test "$have_alsa" = "yes"; then
709         all_errlist_objs="$all_errlist_objs alsa_write"
710         audiod_errlist_objs="$audiod_errlist_objs alsa_write"
711         audiod_cmdline_objs="$audiod_cmdline_objs add_cmdline(alsa_write)"
712         audiod_ldflags="$audiod_ldflags -lasound"
713
714         write_errlist_objs="$write_errlist_objs alsa_write"
715         write_cmdline_objs="$write_cmdline_objs add_cmdline(alsa_write)"
716         write_ldflags="$write_ldflags -lasound"
717         writers="$writers alsa"
718         default_writer="ALSA_WRITE"
719 fi
720
721 CPPFLAGS="$OLD_CPPFLAGS"
722 LDFLAGS="$OLD_LDFLAGS"
723 LIBS="$OLD_LIBS"
724 ########################################################################### libao
725 OLD_CPPFLAGS="$CPPFLAGS"
726 OLD_LD_FLAGS="$LDFLAGS"
727 OLD_LIBS="$LIBS"
728
729 have_ao="yes"
730 AC_ARG_WITH(ao_headers, [AC_HELP_STRING(--with-ao-headers=dir,
731         [look for ao/ao.h also in dir])])
732 if test -n "$with_ao_headers"; then
733         ao_cppflags="-I$with_ao_headers"
734         CPPFLAGS="$CPPFLAGS $ao_cppflags"
735 fi
736 AC_ARG_WITH(ao_libs, [AC_HELP_STRING(--with-ao-libs=dir,
737         [look for libao also in dir])])
738 if test -n "$with_ao_libs"; then
739         ao_libs="-L$with_ao_libs"
740         LDFLAGS="$LDFLAGS $ao_libs"
741 fi
742 msg="no libao support for para_audiod/para_write"
743 AC_CHECK_HEADERS([ao/ao.h], [
744         ], [
745         have_ao="no"
746         AC_MSG_WARN([ao.h not found, $msg])
747 ])
748 if test "$have_ao" = "yes"; then
749         AC_CHECK_LIB([ao], [ao_initialize], [], [
750                 have_ao="no"
751                 AC_MSG_WARN([ao lib not found or not working, $msg])
752         ])
753 fi
754 if test "$have_ao" = "yes"; then
755         AC_CHECK_HEADERS([pthread.h], [
756                 ], [
757                 have_ao="no"
758                 AC_MSG_WARN([pthread.h not found, $msg])
759         ])
760 fi
761 if test "$have_ao" = "yes"; then
762         AC_CHECK_LIB([pthread], [pthread_create], [], [
763                 have_ao="no"
764                 AC_MSG_WARN([pthread lib not found or not working, $msg])
765         ])
766 fi
767 if test "$have_ao" = "yes"; then
768         all_errlist_objs="$all_errlist_objs ao_write"
769         audiod_errlist_objs="$audiod_errlist_objs ao_write"
770         audiod_cmdline_objs="$audiod_cmdline_objs add_cmdline(ao_write)"
771         audiod_ldflags="$audiod_ldflags -lao -lpthread"
772
773         write_errlist_objs="$write_errlist_objs ao_write"
774         write_cmdline_objs="$write_cmdline_objs add_cmdline(ao_write)"
775         write_ldflags="$write_ldflags $ao_libs -lao -lpthread"
776         writers="$writers ao"
777         AC_SUBST(ao_cppflags)
778 fi
779
780 CPPFLAGS="$OLD_CPPFLAGS"
781 LDFLAGS="$OLD_LDFLAGS"
782 LIBS="$OLD_LIBS"
783
784
785
786 AC_SUBST(install_sh, [$INSTALL])
787 AC_CONFIG_FILES([Makefile])
788
789
790 AC_DEFUN([add_dot_o],[$(for i in $@; do printf "$i.o "; done)])
791 AC_DEFUN([add_para],[$(for i in $@; do printf "para_$i "; done)])
792 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) }])
793 ############################################################# error2.h
794 AC_MSG_NOTICE(creating error2.h)
795 for i in $executables; do
796         echo "$i: "
797         eval echo \$${i}_errlist_objs
798 done | ./error2.pl > error2.h
799 for obj in $all_errlist_objs; do
800         SS="$SS SS_$(echo $obj | tr 'a-z' 'A-Z'),"
801 done
802 AC_DEFINE_UNQUOTED(DEFINE_ERRLIST_OBJECT_ENUM,
803         [enum {$SS NUM_SS}],
804         [list of all objects that use paraslash's error facility]
805 )
806
807 ################################################################## status items
808
809 status_items="basename status num_played mtime bitrate frequency file_size
810 status_flags format score techinfo afs_mode
811 attributes_txt decoder_flags audiod_status play_time attributes_bitmap
812 offset seconds_total stream_start current_time audiod_uptime image_id
813 lyrics_id duration directory lyrics_name image_name path hash channels
814 last_played num_chunks chunk_time amplification artist title year album
815 comment"
816
817 result=
818 for i in $status_items; do
819         result="$result SI_$(echo $i | tr 'a-z' 'A-Z'), "
820 done
821 AC_DEFINE_UNQUOTED(STATUS_ITEM_ENUM, [$result],
822         [enum of all status items])
823
824 result=
825 for i in $status_items; do
826         result="$result \"$i\", "
827 done
828 AC_DEFINE_UNQUOTED(STATUS_ITEM_ARRAY, [$result],
829         [char * array of all status items])
830
831 AC_DEFINE_UNQUOTED(SERVER_AUDIO_FORMATS, "$server_audio_formats",
832         [formats supported by para_server and para_afh])
833
834 AC_SUBST(executables, add_para($executables))
835
836 recv_objs="$recv_cmdline_objs $recv_errlist_objs"
837 filter_objs="$filter_cmdline_objs $filter_errlist_objs"
838 audiod_objs="$audiod_cmdline_objs $audiod_errlist_objs"
839 server_objs="$server_cmdline_objs $server_errlist_objs"
840 write_objs="$write_cmdline_objs $write_errlist_objs"
841 client_objs="$client_cmdline_objs $client_errlist_objs"
842 audioc_objs="$audioc_cmdline_objs $audioc_errlist_objs"
843 afh_objs="$afh_cmdline_objs $afh_errlist_objs"
844 fade_objs="$fade_cmdline_objs $fade_errlist_objs"
845
846 AC_SUBST(recv_objs, add_dot_o($recv_objs))
847 AC_SUBST(recv_ldflags, $recv_ldflags)
848 AC_DEFINE_UNQUOTED(INIT_RECV_ERRLISTS, objlist_to_errlist($recv_errlist_objs),
849         errors used by para_recv)
850
851 AC_SUBST(filter_objs, add_dot_o($filter_objs))
852 AC_SUBST(filter_ldflags, $filter_ldflags)
853 AC_DEFINE_UNQUOTED(INIT_FILTER_ERRLISTS,
854         objlist_to_errlist($filter_errlist_objs), errors used by para_filter)
855
856 AC_SUBST(audiod_objs, add_dot_o($audiod_objs))
857 AC_SUBST(audiod_ldflags, $audiod_ldflags)
858 AC_DEFINE_UNQUOTED(INIT_AUDIOD_ERRLISTS, objlist_to_errlist($audiod_errlist_objs),
859         errors used by para_audiod)
860
861 AC_SUBST(server_objs, add_dot_o($server_objs))
862 AC_SUBST(server_ldflags, $server_ldflags)
863 AC_DEFINE_UNQUOTED(INIT_SERVER_ERRLISTS,
864         objlist_to_errlist($server_errlist_objs), errors used by para_server)
865
866 AC_SUBST(afh_objs, add_dot_o($afh_objs))
867 AC_SUBST(afh_ldflags, $afh_ldflags)
868 AC_DEFINE_UNQUOTED(INIT_AFH_ERRLISTS,
869         objlist_to_errlist($afh_errlist_objs), errors used by para_afh)
870
871 AC_SUBST(write_objs, add_dot_o($write_objs))
872 AC_SUBST(write_ldflags, $write_ldflags)
873 AC_DEFINE_UNQUOTED(INIT_WRITE_ERRLISTS,
874         objlist_to_errlist($write_errlist_objs), errors used by para_write)
875
876 AC_SUBST(client_objs, add_dot_o($client_objs))
877 AC_SUBST(client_ldflags, $client_ldflags)
878 AC_DEFINE_UNQUOTED(INIT_CLIENT_ERRLISTS,
879         objlist_to_errlist($client_errlist_objs), errors used by para_client)
880
881 AC_SUBST(audioc_objs, add_dot_o($audioc_objs))
882 AC_SUBST(audioc_ldflags, $audioc_ldflags)
883 AC_DEFINE_UNQUOTED(INIT_AUDIOC_ERRLISTS,
884         objlist_to_errlist($audioc_errlist_objs), errors used by para_audioc)
885
886 AC_SUBST(gui_objs, add_dot_o($gui_objs))
887 AC_DEFINE_UNQUOTED(INIT_GUI_ERRLISTS,
888         objlist_to_errlist($gui_errlist_objs), errors used by para_gui)
889
890 AC_SUBST(fade_objs, add_dot_o($fade_objs))
891 AC_SUBST(fade_ldflags, $fade_ldflags)
892 AC_DEFINE_UNQUOTED(INIT_FADE_ERRLISTS,
893         objlist_to_errlist($fade_errlist_objs), errors used by para_fade)
894
895
896 enum="$(for i in $filters; do printf "${i}_FILTER, " | tr '[a-z]' '[A-Z]'; done)"
897 AC_DEFINE_UNQUOTED(FILTER_ENUM, $enum NUM_SUPPORTED_FILTERS,
898         enum of supported filters)
899 inits="$(for i in $filters; do printf 'extern void '$i'_filter_init(struct filter *f); '; done)"
900 AC_DEFINE_UNQUOTED(DECLARE_FILTER_INITS, $inits, init functions of the supported filters)
901 array="$(for i in $filters; do printf '{.name = "'$i'", .init = '$i'_filter_init},'; done)"
902 AC_DEFINE_UNQUOTED(FILTER_ARRAY, $array, array of supported filters)
903
904 enum="$(for i in $writers; do printf "${i}_WRITE, " | tr '[a-z]' '[A-Z]'; done)"
905 AC_DEFINE_UNQUOTED(WRITER_ENUM, $enum NUM_SUPPORTED_WRITERS,
906         enum of supported writers)
907 AC_DEFINE_UNQUOTED(DEFAULT_WRITER, $default_writer, use this writer if none was specified)
908 names="$(for i in $writers; do printf \"$i\",' ' ; done)"
909 AC_DEFINE_UNQUOTED(WRITER_NAMES, $names, supported writer names)
910 inits="$(for i in $writers; do printf 'extern void '$i'_write_init(struct writer *); '; done)"
911 AC_DEFINE_UNQUOTED(DECLARE_WRITER_INITS, $inits, init functions of the supported writers)
912 array="$(for i in $writers; do printf '{.init = '$i'_write_init},'; done)"
913 AC_DEFINE_UNQUOTED(WRITER_ARRAY, $array, array of supported writers)
914
915 enum="$(for i in $audiod_audio_formats; do printf "AUDIO_FORMAT_${i}, " | tr '[a-z]' '[A-Z]'; done)"
916 AC_DEFINE_UNQUOTED(AUDIOD_AUDIO_FORMATS_ENUM, $enum NUM_AUDIO_FORMATS,
917         enum of audio formats supported by audiod)
918 names="$(for i in $audiod_audio_formats; do printf \"$i\",' ' ; done)"
919 AC_DEFINE_UNQUOTED(AUDIOD_AUDIO_FORMAT_ARRAY, $names, array of audio formats supported by audiod)
920
921 AC_OUTPUT
922 AC_MSG_NOTICE([
923 paraslash configuration:
924 ~~~~~~~~~~~~~~~~~~~~~~~~
925 unix socket credentials: $have_ucred
926 audio formats supported by para_server/para_afh: $server_audio_formats
927 id3 version2 support: $have_libid3tag
928 filters supported by para_audiod/para_filter: $filters
929 writers supported by para_audiod/para_write: $writers
930 optional executables: $extras
931 ])