Use non-blocking API for signal handling.
[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="server 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_ERROR([libosl not found, download it at
261 http://systemlinux.org/~maan/osl
262 or execute
263 git clone git://git.tuebingen.mpg.de/osl
264 ])
265 fi
266 AC_SUBST(osl_cppflags)
267 server_ldflags="$server_ldflags -L$with_osl_libs"
268 CPPFLAGS="$OLD_CPPFLAGS"
269 LDFLAGS="$OLD_LDFLAGS"
270 LIBS="$OLD_LIBS"
271 ########################################################################### ssl
272 dnl @synopsis CHECK_SSL
273 dnl
274 dnl based on the follwing macro from the autoconf archive
275 dnl
276 dnl @category InstalledPackages
277 dnl @author Mark Ethan Trostler <trostler@juniper.net>
278 dnl @version 2003-01-28
279 dnl @license AllPermissive
280
281 AC_DEFUN([CHECK_SSL],
282 [
283 for ssldir in $1 /usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr; do
284 AC_MSG_CHECKING(for openssl in $ssldir)
285 if test -f "$ssldir/include/openssl/ssl.h"; then
286 found_ssl="yes"
287 AC_MSG_RESULT(yes)
288 SSL_CFLAGS="-I$ssldir/include"
289 SSL_CPPFLAGS="-I$ssldir/include"
290 break
291 fi
292 AC_MSG_RESULT(no)
293 done
294 if test x_$found_ssl != x_yes; then
295 AC_MSG_ERROR(Cannot find ssl libraries)
296 else
297 SSL_LIBS="-lssl -lcrypto";
298 SSL_LDFLAGS="-L$ssldir/lib";
299 fi
300 AC_SUBST(SSL_CPPFLAGS)
301 ])dnl
302
303 AC_ARG_ENABLE(ssldir, [AS_HELP_STRING(--enable-ssldir=path,
304 [Search for openssl also in path.])])
305 if test "$enable_ssldir" = "yes"; then enable_ssldir=""; fi
306 CHECK_SSL($enable_ssldir)
307 server_ldflags="$server_ldflags $SSL_LDFLAGS $SSL_LIBS"
308 client_ldflags="$client_ldflags $SSL_LDFLAGS $SSL_LIBS"
309 audiod_ldflags="$audiod_ldflags $SSL_LDFLAGS $SSL_LIBS"
310
311 ########################################################################### libsocket
312 AC_CHECK_LIB([c], [socket],
313 [socket_lib=],
314 [socket_lib="-lsocket"]
315 )
316 server_ldflags="$server_ldflags $socket_lib"
317 client_ldflags="$client_ldflags $socket_lib"
318 audioc_ldflags="$audioc_ldflags $socket_lib"
319 audiod_ldflags="$audiod_ldflags $socket_lib"
320 recv_ldflags="$recv_ldflags $socket_lib"
321 AC_SEARCH_LIBS([connect],[socket],[],[
322 AC_MSG_ERROR([Fatal: Did not find connect().])
323 ],[])
324 ########################################################################### libnsl
325 AC_CHECK_LIB([c], [gethostbyname],
326 [nsl_lib=],
327 [nsl_lib="-lnsl"]
328 )
329 server_ldflags="$server_ldflags $nsl_lib"
330 client_ldflags="$client_ldflags $nsl_lib"
331 audioc_ldflags="$audioc_ldflags $nsl_lib"
332 recv_ldflags="$recv_ldflags $nsl_lib"
333 AC_SEARCH_LIBS([inet_ntoa],[nsl],[],[
334 AC_MSG_ERROR([Fatal: Did not find inet_ntoa().])
335 ],[])
336 ########################################################################### ucred
337 AC_MSG_CHECKING(for struct ucred)
338 AC_TRY_LINK([
339 #define _GNU_SOURCE
340 #include <sys/types.h>
341 #include <sys/socket.h>
342 ],[
343 struct ucred sucred; sucred.pid=0;
344 ],[have_ucred=yes],[have_ucred=no])
345 AC_MSG_RESULT($have_ucred)
346 if test ${have_ucred} = yes; then
347 AC_DEFINE(HAVE_UCRED, 1, define to 1 you have struct ucred)
348 fi
349
350 ########################################################################### curses
351 have_ncurses="yes"
352 OLD_CPPFLAGS="$CPPFLAGS"
353 OLD_LD_FLAGS="$LDFLAGS"
354 OLD_LIBS="$LIBS"
355 AC_ARG_WITH(ncurses_headers, [AC_HELP_STRING(--with-ncurses-headers=dir,
356 [look for ncurses.h also in dir])])
357 if test -n "$with_ncurses_headers"; then
358 ncurses_cppflags="-I$with_ncurses_headers"
359 CPPFLAGS="$CPPFLAGS $ncurses_cppflags"
360 fi
361 AC_ARG_WITH(ncurses_libs, [AC_HELP_STRING(--with-ncurses-libs=dir,
362 [look for libncurses also in dir])])
363 if test -n "$with_ncurses_libs"; then
364 ncurses_libs="-L$with_ncurses_libs"
365 LDFLAGS="$LDFLAGS $ncurses_libs"
366 fi
367 AC_CHECK_HEADER(curses.h, [], [
368 have_ncurses="no"
369 ])
370 AC_CHECK_LIB([ncurses], [initscr], [], [
371 have_ncurses="no"
372 ])
373 if test "$have_ncurses" = "yes"; then
374 AC_SUBST(ncurses_cppflags)
375 AC_DEFINE(HAVE_NCURSES, 1, [define to 1 to turn on ncurses support])
376 extras="$extras gui"
377 executables="$executables gui"
378 else
379 AC_MSG_WARN([cannot build para_gui])
380 fi
381 CPPFLAGS="$OLD_CPPFLAGS"
382 LDFLAGS="$OLD_LDFLAGS"
383 LIBS="$OLD_LIBS"
384
385 ########################################################################### ip_mreqn
386 AC_MSG_CHECKING(for struct ip_mreqn (UDPv4 multicast))
387 AC_TRY_LINK([
388 #include <netdb.h>
389 #include <net/if.h>
390 ],[
391 struct ip_mreqn mn;
392 mn.imr_ifindex = 0;
393 ],[have_ip_mreqn=yes],[have_ip_mreqn=no])
394 AC_MSG_RESULT($have_ip_mreqn)
395 if test ${have_ip_mreqn} = yes; then
396 AC_DEFINE(HAVE_IP_MREQN, 1, define to 1 you have struct ip_mreqn)
397 fi
398 ########################################################################### osx
399
400 AC_MSG_CHECKING(for CoreAudio (MacOs))
401 AC_TRY_LINK([
402 #include <CoreAudio/CoreAudio.h>
403 ],[
404 AudioDeviceID id;
405 ],[have_core_audio=yes],[have_core_audio=no])
406 AC_MSG_RESULT($have_core_audio)
407 if test ${have_core_audio} = yes; then
408 f1="-framework CoreAudio"
409 f2="-framework AudioToolbox"
410 f3="-framework AudioUnit"
411 f4="-framework CoreServices"
412 f="$f1 $f2 $f3 $f4"
413
414 all_errlist_objs="$all_errlist_objs osx_write"
415 audiod_errlist_objs="$audiod_errlist_objs osx_write"
416 audiod_cmdline_objs="$audiod_cmdline_objs osx_write.cmdline"
417 audiod_ldflags="$audiod_ldflags $f"
418
419 write_errlist_objs="$write_errlist_objs osx_write"
420 write_cmdline_objs="$write_cmdline_objs osx_write.cmdline"
421 write_ldflags="$write_ldflags $f"
422 writers="$writers osx"
423 default_writer="OSX_WRITE"
424 AC_DEFINE(HAVE_CORE_AUDIO, 1, define to 1 on Mac Os X)
425 fi
426 ########################################################################### ogg
427 have_ogg="yes"
428 OLD_CPPFLAGS="$CPPFLAGS"
429 OLD_LD_FLAGS="$LDFLAGS"
430 OLD_LIBS="$LIBS"
431 AC_ARG_WITH(oggvorbis_headers, [AC_HELP_STRING(--with-oggvorbis-headers=dir,
432 [look for vorbis/codec.h also in dir])])
433 if test -n "$with_oggvorbis_headers"; then
434 oggvorbis_cppflags="-I$with_oggvorbis_headers"
435 CPPFLAGS="$CPPFLAGS $oggvorbis_cppflags"
436 fi
437 AC_ARG_WITH(oggvorbis_libs, [AC_HELP_STRING(--with-oggvorbis-libs=dir,
438 [look for oggvorbis libs also in dir])])
439 if test -n "$with_oggvorbis_libs"; then
440 oggvorbis_libs="-L$with_oggvorbis_libs"
441 LDFLAGS="$LDFLAGS $oggvorbis_libs"
442 fi
443
444 AC_CHECK_LIB([ogg], [ogg_stream_init], [], [ have_ogg="no" ])
445 AC_CHECK_LIB([vorbis], [vorbis_info_init], [], [ have_ogg="no" ])
446 AC_CHECK_HEADERS([ogg/ogg.h vorbis/codec.h], [], [ have_ogg="no" ])
447 if test "$have_ogg" = "yes"; then
448 all_errlist_objs="$all_errlist_objs oggdec_filter ogg_afh"
449 AC_DEFINE(HAVE_OGGVORBIS, 1, define to 1 to turn on ogg vorbis support)
450 filters="$filters oggdec"
451 if test "$OSTYPE" = "Darwin"; then
452 oggvorbis_libs="-Wl,-bind_at_load $oggvorbis_libs"
453 fi
454 server_ldflags="$server_ldflags $oggvorbis_libs -logg -lvorbis -lvorbisfile"
455 filter_ldflags="$filter_ldflags $oggvorbis_libs -lvorbis -lvorbisfile"
456 audiod_ldflags="$audiod_ldflags $oggvorbis_libs -lvorbis -lvorbisfile"
457 afh_ldflags="$afh_ldflags $oggvorbis_libs -logg -lvorbis -lvorbisfile"
458
459 filter_cmdline_objs="$filter_cmdline_objs add_cmdline(oggdec_filter)"
460 audiod_cmdline_objs="$audiod_cmdline_objs add_cmdline(oggdec_filter)"
461
462 server_errlist_objs="$server_errlist_objs ogg_afh"
463 filter_errlist_objs="$filter_errlist_objs oggdec_filter"
464 audiod_errlist_objs="$audiod_errlist_objs oggdec_filter"
465 afh_errlist_objs="$afh_errlist_objs ogg_afh"
466
467 audiod_audio_formats="$audiod_audio_formats ogg"
468 server_audio_formats="$server_audio_formats ogg"
469 AC_SUBST(oggvorbis_cppflags)
470 else
471 AC_MSG_WARN([no ogg vorbis support in para_server/para_filter])
472 fi
473 CPPFLAGS="$OLD_CPPFLAGS"
474 LDFLAGS="$OLD_LDFLAGS"
475 LIBS="$OLD_LIBS"
476 ########################################################################### faad
477 have_faad=yes
478 OLD_CPPFLAGS="$CPPFLAGS"
479 OLD_LD_FLAGS="$LDFLAGS"
480 OLD_LIBS="$LIBS"
481 AC_ARG_WITH(faad_headers, [AC_HELP_STRING(--with-faad-headers=dir,
482 [look for neaacdec.h also in dir])])
483 if test -n "$with_faad_headers"; then
484 faad_cppflags="-I$with_faad_headers"
485 CPPFLAGS="$CPPFLAGS $faad_cppflags"
486 fi
487 AC_ARG_WITH(faad_libs, [AC_HELP_STRING(--with-faad-libs=dir,
488 [look for libfaad also in dir])])
489 if test -n "$with_faad_libs"; then
490 faad_libs="-L$with_faad_libs"
491 LDFLAGS="$LDFLAGS $faad_libs"
492 fi
493 AC_CHECK_HEADER(neaacdec.h, [], have_faad=no)
494 AC_CHECK_LIB([faad], [NeAACDecOpen], [], have_faad=no)
495 if test "$have_faad" = "yes"; then
496 AC_DEFINE(HAVE_FAAD, 1, define to 1 if you want to build the aacdec filter)
497 all_errlist_objs="$all_errlist_objs aac_common aacdec_filter aac_afh"
498 filter_errlist_objs="$filter_errlist_objs aacdec_filter aac_common"
499 afh_errlist_objs="$afh_errlist_objs aac_common aac_afh"
500 audiod_errlist_objs="$audiod_errlist_objs aacdec_filter aac_common"
501 server_errlist_objs="$server_errlist_objs aac_afh aac_common"
502 server_ldflags="$server_ldflags $faad_libs -lfaad"
503 filter_ldflags="$filter_ldflags $faad_libs -lfaad"
504 audiod_ldflags="$audiod_ldflags $faad_libs -lfaad"
505 afh_ldflags="$afh_ldflags $faad_libs -lfaad"
506 audiod_audio_formats="$audiod_audio_formats aac"
507 server_audio_formats="$server_audio_formats aac"
508 filters="$filters aacdec"
509 AC_SUBST(faad_cppflags)
510 else
511 AC_MSG_WARN([no aac support in para_audiod/para_filter])
512 fi
513 CPPFLAGS="$OLD_CPPFLAGS"
514 LDFLAGS="$OLD_LDFLAGS"
515 LIBS="$OLD_LIBS"
516 ########################################################################### mad
517 have_mad="yes"
518 OLD_CPPFLAGS="$CPPFLAGS"
519 OLD_LD_FLAGS="$LDFLAGS"
520 OLD_LIBS="$LIBS"
521
522 AC_ARG_WITH(mad_headers, [AC_HELP_STRING(--with-mad-headers=dir,
523 [look for mad.h also in dir])])
524 if test -n "$with_mad_headers"; then
525 mad_cppflags="-I$with_mad_headers"
526 CPPFLAGS="$CPPFLAGS $mad_cppflags"
527 fi
528 AC_ARG_WITH(mad_libs, [AC_HELP_STRING(--with-mad-libs=dir,
529 [look for libmad also in dir])])
530 if test -n "$with_mad_libs"; then
531 mad_libs="-L$with_mad_libs"
532 LDFLAGS="$LDFLAGS $mad_libs"
533 fi
534 AC_CHECK_HEADERS([mad.h], [], [
535 have_mad="no"
536 ])
537 AC_CHECK_LIB([mad], [mad_stream_init], [], [
538 have_mad="no"
539 ])
540 if test "$have_mad" = "yes"; then
541 AC_DEFINE(HAVE_MAD, 1, define to 1 if you want to build the mp3dec filter)
542 filter_cmdline_objs="$filter_cmdline_objs add_cmdline(mp3dec_filter)"
543 audiod_cmdline_objs="$audiod_cmdline_objs add_cmdline(mp3dec_filter)"
544 all_errlist_objs="$all_errlist_objs mp3dec_filter"
545 filter_errlist_objs="$filter_errlist_objs mp3dec_filter"
546 audiod_errlist_objs="$audiod_errlist_objs mp3dec_filter"
547 filter_ldflags="$filter_ldflags $mad_libs -lmad"
548 audiod_ldflags="$audiod_ldflags $mad_libs -lmad"
549 audiod_audio_formats="$audiod_audio_formats mp3"
550 filters="$filters mp3dec"
551 AC_SUBST(mad_cppflags)
552 else
553 AC_MSG_WARN([no mp3dec support in para_audiod/para_filter])
554 fi
555 CPPFLAGS="$OLD_CPPFLAGS"
556 LDFLAGS="$OLD_LDFLAGS"
557 LIBS="$OLD_LIBS"
558 ###################################################################### libid3tag
559 AC_MSG_CHECKING(for libid3tag)
560 AC_TRY_LINK([
561 #include <id3tag.h>
562 ],[
563 struct id3_tag t = {.flags = 0};
564 ],[have_libid3tag=yes],[have_libid3tag=no])
565 AC_MSG_RESULT($have_libid3tag)
566 if test ${have_libid3tag} = yes; then
567 AC_DEFINE(HAVE_LIBID3TAG, 1, define to 1 you have libid3tag)
568 server_ldflags="$server_ldflags -lid3tag"
569 afh_ldflags="$afh_ldflags -lid3tag"
570 else
571 AC_MSG_WARN([no support for id3v2 tags])
572 fi
573 ########################################################################### oss
574 OLD_CPPFLAGS="$CPPFLAGS"
575 OLD_LD_FLAGS="$LDFLAGS"
576 OLD_LIBS="$LIBS"
577
578 have_oss="yes"
579 msg="=> will not build para_fade/oss writer"
580
581 AC_CHECK_HEADER(sys/soundcard.h, [
582 extras="$extras fade"
583 executables="$executables fade"
584 all_errlist_objs="$all_errlist_objs oss_write"
585 audiod_errlist_objs="$audiod_errlist_objs oss_write"
586 audiod_cmdline_objs="$audiod_cmdline_objs add_cmdline(oss_write)"
587
588 write_errlist_objs="$write_errlist_objs oss_write"
589 write_cmdline_objs="$write_cmdline_objs add_cmdline(oss_write)"
590 writers="$writers oss"
591 default_writer="OSS_WRITE"
592 AC_CHECK_LIB(ossaudio, _oss_ioctl, [
593 audiod_ldflags="$audiod_ldflags -lossaudio"
594 write_ldflags="$write_ldflags -lossaudio"
595 fade_ldflags="$write_ldflags -lossaudio"
596 ]
597 )
598 ],
599 [
600 have_oss="no"
601 AC_MSG_WARN([no sys/soundcard.h $msg])
602 ]
603 )
604 CPPFLAGS="$OLD_CPPFLAGS"
605 LDFLAGS="$OLD_LDFLAGS"
606 LIBS="$OLD_LIBS"
607
608 ########################################################################### alsa
609 OLD_CPPFLAGS="$CPPFLAGS"
610 OLD_LD_FLAGS="$LDFLAGS"
611 OLD_LIBS="$LIBS"
612
613 msg="=> no alsa support for para_audiod/para_write"
614 if test "$OSTYPE" != "Linux"; then
615 have_alsa="no"
616 else
617 have_alsa="yes"
618 fi
619 if test "$have_alsa" = "yes"; then
620 AC_CHECK_HEADERS([alsa/asoundlib.h], [], [
621 have_alsa="no"
622 AC_MSG_WARN([no alsa/asoundlib $msg])
623 ])
624 fi
625
626 if test "$have_alsa" = "yes"; then
627 AC_CHECK_LIB([asound], [snd_pcm_open], [], [
628 have_alsa="no"
629 AC_MSG_WARN([no libasound $msg])
630 ])
631 fi
632
633 if test "$have_alsa" = "yes"; then
634 all_errlist_objs="$all_errlist_objs alsa_write"
635 audiod_errlist_objs="$audiod_errlist_objs alsa_write"
636 audiod_cmdline_objs="$audiod_cmdline_objs add_cmdline(alsa_write)"
637 audiod_ldflags="$audiod_ldflags -lasound"
638
639 write_errlist_objs="$write_errlist_objs alsa_write"
640 write_cmdline_objs="$write_cmdline_objs add_cmdline(alsa_write)"
641 write_ldflags="$write_ldflags -lasound"
642 writers="$writers alsa"
643 default_writer="ALSA_WRITE"
644 fi
645
646 CPPFLAGS="$OLD_CPPFLAGS"
647 LDFLAGS="$OLD_LDFLAGS"
648 LIBS="$OLD_LIBS"
649
650 AC_SUBST(install_sh, [$INSTALL])
651 AC_CONFIG_FILES([Makefile])
652
653
654 AC_DEFUN([add_dot_o],[$(for i in $@; do printf "$i.o "; done)])
655 AC_DEFUN([add_para],[$(for i in $@; do printf "para_$i "; done)])
656 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) }])
657 ############################################################# error2.h
658 AC_DEFUN([define_safe_error_enums],
659 [
660 exe=""
661 for i in $executables; do
662 # eval echo checking if $1 is linked into $i
663 for j in $(eval echo \$${i}_errlist_objs); do
664 if test $j = $1; then
665 exe="$exe $i"
666 break;
667 fi
668 done
669 done
670 #echo "$1 gets linked into $exe"
671 safe_errlists=""
672 for i in $all_errlist_objs; do
673 for j in $exe; do
674 found=0
675 for k in $(eval echo \$${j}_errlist_objs); do
676 if test $k = $i; then
677 found=1
678 break;
679 fi
680 done
681 if test $found -eq 0; then
682 break;
683 fi
684 done
685 if test $found -eq 1; then
686 safe_errlists="$safe_errlists $i"
687 fi
688 done
689 #echo "safe errlists for $1: $safe_errlists"
690 ss_defs=""
691 for i in $safe_errlists; do
692 echo "SS_ENUM($(echo $i | tr 'a-z' 'A-Z'));"
693 done
694 ]
695 )
696
697
698 AC_MSG_NOTICE(creating error2.h)
699 for obj in $all_errlist_objs; do
700 SS="$SS SS_$(echo $obj | tr 'a-z' 'A-Z'),"
701 echo "#ifdef MAIN_INPUT_FILE_IS_$obj"
702 define_safe_error_enums($obj)
703 echo "#endif"
704 done > error2.h
705 AC_DEFINE_UNQUOTED(DEFINE_ERRLIST_OBJECT_ENUM,
706 [enum {$SS NUM_SS}],
707 [list of all objects that use paraslash's error facility]
708 )
709
710 ################################################################## status items
711
712 status_items="basename status num_played mtime bitrate frequency file_size
713 status_flags format score techinfo afs_mode
714 attributes_txt decoder_flags audiod_status play_time attributes_bitmap
715 offset seconds_total stream_start current_time audiod_uptime image_id
716 lyrics_id duration directory lyrics_name image_name path hash channels
717 last_played num_chunks chunk_time amplification artist title year album
718 comment"
719
720 # $1: prefix, $2: items
721 AC_DEFUN([make_enum_items], [$(
722 for i in $2; do
723 printf "$1_$(echo $i | tr 'a-z' 'A-Z'), "
724 done
725 )])
726
727 # $1: prefix, $2: items
728 AC_DEFUN([make_enum_array], [$(
729 for i in $2; do
730 printf "\"$i\", "
731 done
732 )])
733
734 AC_DEFINE_UNQUOTED(STATUS_ITEM_ENUM,
735 make_enum_items(SI, $status_items),
736 [enum of all status items]
737 )
738 AC_DEFINE_UNQUOTED(STATUS_ITEM_ARRAY,
739 make_enum_array(SI, $status_items),
740 [char * array of all status items]
741 )
742
743
744 AC_SUBST(executables, add_para($executables))
745
746 recv_objs="$recv_cmdline_objs $recv_errlist_objs"
747 filter_objs="$filter_cmdline_objs $filter_errlist_objs"
748 audiod_objs="$audiod_cmdline_objs $audiod_errlist_objs"
749 server_objs="$server_cmdline_objs $server_errlist_objs"
750 write_objs="$write_cmdline_objs $write_errlist_objs"
751 client_objs="$client_cmdline_objs $client_errlist_objs"
752 audioc_objs="$audioc_cmdline_objs $audioc_errlist_objs"
753 afh_objs="$afh_cmdline_objs $afh_errlist_objs"
754 fade_objs="$fade_cmdline_objs $fade_errlist_objs"
755
756 AC_SUBST(recv_objs, add_dot_o($recv_objs))
757 AC_SUBST(recv_ldflags, $recv_ldflags)
758 AC_DEFINE_UNQUOTED(INIT_RECV_ERRLISTS, objlist_to_errlist($recv_errlist_objs),
759 errors used by para_recv)
760
761 AC_SUBST(filter_objs, add_dot_o($filter_objs))
762 AC_SUBST(filter_ldflags, $filter_ldflags)
763 AC_DEFINE_UNQUOTED(INIT_FILTER_ERRLISTS,
764 objlist_to_errlist($filter_errlist_objs), errors used by para_filter)
765
766 AC_SUBST(audiod_objs, add_dot_o($audiod_objs))
767 AC_SUBST(audiod_ldflags, $audiod_ldflags)
768 AC_DEFINE_UNQUOTED(INIT_AUDIOD_ERRLISTS, objlist_to_errlist($audiod_errlist_objs),
769 errors used by para_audiod)
770
771 AC_SUBST(server_objs, add_dot_o($server_objs))
772 AC_SUBST(server_ldflags, $server_ldflags)
773 AC_DEFINE_UNQUOTED(INIT_SERVER_ERRLISTS,
774 objlist_to_errlist($server_errlist_objs), errors used by para_server)
775
776 AC_SUBST(afh_objs, add_dot_o($afh_objs))
777 AC_SUBST(afh_ldflags, $afh_ldflags)
778 AC_DEFINE_UNQUOTED(INIT_AFH_ERRLISTS,
779 objlist_to_errlist($afh_errlist_objs), errors used by para_afh)
780
781 AC_SUBST(write_objs, add_dot_o($write_objs))
782 AC_SUBST(write_ldflags, $write_ldflags)
783 AC_DEFINE_UNQUOTED(INIT_WRITE_ERRLISTS,
784 objlist_to_errlist($write_errlist_objs), errors used by para_write)
785
786 AC_SUBST(client_objs, add_dot_o($client_objs))
787 AC_SUBST(client_ldflags, $client_ldflags)
788 AC_DEFINE_UNQUOTED(INIT_CLIENT_ERRLISTS,
789 objlist_to_errlist($client_errlist_objs), errors used by para_client)
790
791 AC_SUBST(audioc_objs, add_dot_o($audioc_objs))
792 AC_SUBST(audioc_ldflags, $audioc_ldflags)
793 AC_DEFINE_UNQUOTED(INIT_AUDIOC_ERRLISTS,
794 objlist_to_errlist($audioc_errlist_objs), errors used by para_audioc)
795
796 AC_SUBST(gui_objs, add_dot_o($gui_objs))
797 AC_DEFINE_UNQUOTED(INIT_GUI_ERRLISTS,
798 objlist_to_errlist($gui_errlist_objs), errors used by para_gui)
799
800 AC_SUBST(fade_objs, add_dot_o($fade_objs))
801 AC_SUBST(fade_ldflags, $fade_ldflags)
802 AC_DEFINE_UNQUOTED(INIT_FADE_ERRLISTS,
803 objlist_to_errlist($fade_errlist_objs), errors used by para_fade)
804
805
806 enum="$(for i in $filters; do printf "${i}_FILTER, " | tr '[a-z]' '[A-Z]'; done)"
807 AC_DEFINE_UNQUOTED(FILTER_ENUM, $enum NUM_SUPPORTED_FILTERS,
808 enum of supported filters)
809 inits="$(for i in $filters; do printf 'extern void '$i'_filter_init(struct filter *f); '; done)"
810 AC_DEFINE_UNQUOTED(DECLARE_FILTER_INITS, $inits, init functions of the supported filters)
811 array="$(for i in $filters; do printf '{.name = "'$i'", .init = '$i'_filter_init},'; done)"
812 AC_DEFINE_UNQUOTED(FILTER_ARRAY, $array, array of supported filters)
813
814 enum="$(for i in $writers; do printf "${i}_WRITE, " | tr '[a-z]' '[A-Z]'; done)"
815 AC_DEFINE_UNQUOTED(WRITER_ENUM, $enum NUM_SUPPORTED_WRITERS,
816 enum of supported writers)
817 AC_DEFINE_UNQUOTED(DEFAULT_WRITER, $default_writer, use this writer if none was specified)
818 names="$(for i in $writers; do printf \"$i\",' ' ; done)"
819 AC_DEFINE_UNQUOTED(WRITER_NAMES, $names, supported writer names)
820 inits="$(for i in $writers; do printf 'extern void '$i'_write_init(struct writer *); '; done)"
821 AC_DEFINE_UNQUOTED(DECLARE_WRITER_INITS, $inits, init functions of the supported writers)
822 array="$(for i in $writers; do printf '{.init = '$i'_write_init},'; done)"
823 AC_DEFINE_UNQUOTED(WRITER_ARRAY, $array, array of supported writers)
824
825 enum="$(for i in $audiod_audio_formats; do printf "AUDIO_FORMAT_${i}, " | tr '[a-z]' '[A-Z]'; done)"
826 AC_DEFINE_UNQUOTED(AUDIOD_AUDIO_FORMATS_ENUM, $enum NUM_AUDIO_FORMATS,
827 enum of audio formats supported by audiod)
828 names="$(for i in $audiod_audio_formats; do printf \"$i\",' ' ; done)"
829 AC_DEFINE_UNQUOTED(AUDIOD_AUDIO_FORMAT_ARRAY, $names, array of audio formats supported by audiod)
830
831 AC_OUTPUT
832 AC_MSG_NOTICE([
833 paraslash configuration:
834 ~~~~~~~~~~~~~~~~~~~~~~~~
835 unix socket credentials: $have_ucred
836 audio formats supported by para_server/para_afh: $server_audio_formats
837 id3 version2 support: $have_libid3tag
838 filters supported by para_audiod/para_filter: $filters
839 writers supported by para_audiod/para_write: $writers
840 optional executables: $extras
841 ])