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