Merge branch 't/error2'
[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         server_errlist_objs="$server_errlist_objs ogg_afh"
460         filter_errlist_objs="$filter_errlist_objs oggdec_filter"
461         audiod_errlist_objs="$audiod_errlist_objs oggdec_filter"
462         afh_errlist_objs="$afh_errlist_objs ogg_afh"
463
464         audiod_audio_formats="$audiod_audio_formats ogg"
465         server_audio_formats="$server_audio_formats ogg"
466         AC_SUBST(oggvorbis_cppflags)
467 else
468         AC_MSG_WARN([no ogg vorbis support in para_server/para_filter])
469 fi
470 CPPFLAGS="$OLD_CPPFLAGS"
471 LDFLAGS="$OLD_LDFLAGS"
472 LIBS="$OLD_LIBS"
473 ########################################################################### faad
474 have_faad=yes
475 OLD_CPPFLAGS="$CPPFLAGS"
476 OLD_LD_FLAGS="$LDFLAGS"
477 OLD_LIBS="$LIBS"
478 AC_ARG_WITH(faad_headers, [AC_HELP_STRING(--with-faad-headers=dir,
479         [look for neaacdec.h also in dir])])
480 if test -n "$with_faad_headers"; then
481         faad_cppflags="-I$with_faad_headers"
482         CPPFLAGS="$CPPFLAGS $faad_cppflags"
483 fi
484 AC_ARG_WITH(faad_libs, [AC_HELP_STRING(--with-faad-libs=dir,
485         [look for libfaad also in dir])])
486 if test -n "$with_faad_libs"; then
487         faad_libs="-L$with_faad_libs"
488         LDFLAGS="$LDFLAGS $faad_libs"
489 fi
490 AC_CHECK_HEADER(neaacdec.h, [], have_faad=no)
491 AC_CHECK_LIB([faad], [NeAACDecOpen], [], have_faad=no)
492 if test "$have_faad" = "yes"; then
493         AC_DEFINE(HAVE_FAAD, 1, define to 1 if you want to build the aacdec filter)
494         all_errlist_objs="$all_errlist_objs aac_common aacdec_filter aac_afh"
495         filter_errlist_objs="$filter_errlist_objs aacdec_filter aac_common"
496         afh_errlist_objs="$afh_errlist_objs aac_common aac_afh"
497         audiod_errlist_objs="$audiod_errlist_objs aacdec_filter aac_common"
498         server_errlist_objs="$server_errlist_objs aac_afh aac_common"
499         server_ldflags="$server_ldflags $faad_libs -lfaad"
500         filter_ldflags="$filter_ldflags $faad_libs -lfaad"
501         audiod_ldflags="$audiod_ldflags $faad_libs -lfaad"
502         afh_ldflags="$afh_ldflags $faad_libs -lfaad"
503         audiod_audio_formats="$audiod_audio_formats aac"
504         server_audio_formats="$server_audio_formats aac"
505         filters="$filters aacdec"
506         AC_SUBST(faad_cppflags)
507 else
508         AC_MSG_WARN([no aac support in para_audiod/para_filter])
509 fi
510 CPPFLAGS="$OLD_CPPFLAGS"
511 LDFLAGS="$OLD_LDFLAGS"
512 LIBS="$OLD_LIBS"
513 ########################################################################### mad
514 have_mad="yes"
515 OLD_CPPFLAGS="$CPPFLAGS"
516 OLD_LD_FLAGS="$LDFLAGS"
517 OLD_LIBS="$LIBS"
518
519 AC_ARG_WITH(mad_headers, [AC_HELP_STRING(--with-mad-headers=dir,
520         [look for mad.h also in dir])])
521 if test -n "$with_mad_headers"; then
522         mad_cppflags="-I$with_mad_headers"
523         CPPFLAGS="$CPPFLAGS $mad_cppflags"
524 fi
525 AC_ARG_WITH(mad_libs, [AC_HELP_STRING(--with-mad-libs=dir,
526         [look for libmad also in dir])])
527 if test -n "$with_mad_libs"; then
528         mad_libs="-L$with_mad_libs"
529         LDFLAGS="$LDFLAGS $mad_libs"
530 fi
531 AC_CHECK_HEADERS([mad.h], [], [
532         have_mad="no"
533 ])
534 AC_CHECK_LIB([mad], [mad_stream_init], [], [
535         have_mad="no"
536 ])
537 if test "$have_mad" = "yes"; then
538         AC_DEFINE(HAVE_MAD, 1, define to 1 if you want to build the mp3dec filter)
539         filter_cmdline_objs="$filter_cmdline_objs add_cmdline(mp3dec_filter)"
540         audiod_cmdline_objs="$audiod_cmdline_objs add_cmdline(mp3dec_filter)"
541         all_errlist_objs="$all_errlist_objs mp3dec_filter"
542         filter_errlist_objs="$filter_errlist_objs mp3dec_filter"
543         audiod_errlist_objs="$audiod_errlist_objs mp3dec_filter"
544         filter_ldflags="$filter_ldflags $mad_libs -lmad"
545         audiod_ldflags="$audiod_ldflags $mad_libs -lmad"
546         audiod_audio_formats="$audiod_audio_formats mp3"
547         filters="$filters mp3dec"
548         AC_SUBST(mad_cppflags)
549 else
550         AC_MSG_WARN([no mp3dec support in para_audiod/para_filter])
551 fi
552 CPPFLAGS="$OLD_CPPFLAGS"
553 LDFLAGS="$OLD_LDFLAGS"
554 LIBS="$OLD_LIBS"
555 ###################################################################### libid3tag
556 AC_MSG_CHECKING(for libid3tag)
557 AC_TRY_LINK([
558         #include <id3tag.h>
559 ],[
560         struct id3_tag t = {.flags = 0};
561 ],[have_libid3tag=yes],[have_libid3tag=no])
562 AC_MSG_RESULT($have_libid3tag)
563 if test ${have_libid3tag} = yes; then
564         AC_DEFINE(HAVE_LIBID3TAG, 1, define to 1 you have libid3tag)
565         server_ldflags="$server_ldflags -lid3tag"
566         afh_ldflags="$afh_ldflags -lid3tag"
567 else
568         AC_MSG_WARN([no support for id3v2 tags])
569 fi
570 ########################################################################### oss
571 OLD_CPPFLAGS="$CPPFLAGS"
572 OLD_LD_FLAGS="$LDFLAGS"
573 OLD_LIBS="$LIBS"
574
575 have_oss="yes"
576 msg="=> will not build para_fade/oss writer"
577
578 AC_CHECK_HEADER(sys/soundcard.h, [
579         extras="$extras fade"
580         executables="$executables fade"
581         all_errlist_objs="$all_errlist_objs oss_write"
582         audiod_errlist_objs="$audiod_errlist_objs oss_write"
583         audiod_cmdline_objs="$audiod_cmdline_objs add_cmdline(oss_write)"
584
585         write_errlist_objs="$write_errlist_objs oss_write"
586         write_cmdline_objs="$write_cmdline_objs add_cmdline(oss_write)"
587         writers="$writers oss"
588         default_writer="OSS_WRITE"
589         AC_CHECK_LIB(ossaudio, _oss_ioctl, [
590                         audiod_ldflags="$audiod_ldflags -lossaudio"
591                         write_ldflags="$write_ldflags -lossaudio"
592                         fade_ldflags="$write_ldflags -lossaudio"
593                 ]
594         )
595         ],
596         [
597                 have_oss="no"
598                 AC_MSG_WARN([no sys/soundcard.h $msg])
599         ]
600 )
601 CPPFLAGS="$OLD_CPPFLAGS"
602 LDFLAGS="$OLD_LDFLAGS"
603 LIBS="$OLD_LIBS"
604
605 ########################################################################### alsa
606 OLD_CPPFLAGS="$CPPFLAGS"
607 OLD_LD_FLAGS="$LDFLAGS"
608 OLD_LIBS="$LIBS"
609
610 msg="=> no alsa support for para_audiod/para_write"
611 if test "$OSTYPE" != "Linux"; then
612         have_alsa="no"
613 else
614         have_alsa="yes"
615 fi
616 if test "$have_alsa" = "yes"; then
617         AC_CHECK_HEADERS([alsa/asoundlib.h], [], [
618                 have_alsa="no"
619                 AC_MSG_WARN([no alsa/asoundlib $msg])
620         ])
621 fi
622
623 if test "$have_alsa" = "yes"; then
624         AC_CHECK_LIB([asound], [snd_pcm_open], [], [
625                 have_alsa="no"
626                 AC_MSG_WARN([no libasound $msg])
627         ])
628 fi
629
630 if test "$have_alsa" = "yes"; then
631         all_errlist_objs="$all_errlist_objs alsa_write"
632         audiod_errlist_objs="$audiod_errlist_objs alsa_write"
633         audiod_cmdline_objs="$audiod_cmdline_objs add_cmdline(alsa_write)"
634         audiod_ldflags="$audiod_ldflags -lasound"
635
636         write_errlist_objs="$write_errlist_objs alsa_write"
637         write_cmdline_objs="$write_cmdline_objs add_cmdline(alsa_write)"
638         write_ldflags="$write_ldflags -lasound"
639         writers="$writers alsa"
640         default_writer="ALSA_WRITE"
641 fi
642
643 CPPFLAGS="$OLD_CPPFLAGS"
644 LDFLAGS="$OLD_LDFLAGS"
645 LIBS="$OLD_LIBS"
646
647 AC_SUBST(install_sh, [$INSTALL])
648 AC_CONFIG_FILES([Makefile])
649
650
651 AC_DEFUN([add_dot_o],[$(for i in $@; do printf "$i.o "; done)])
652 AC_DEFUN([add_para],[$(for i in $@; do printf "para_$i "; done)])
653 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) }])
654 ############################################################# error2.h
655 AC_MSG_NOTICE(creating error2.h)
656 for i in $executables; do
657         echo "$i: "
658         eval echo \$${i}_errlist_objs
659 done | ./error2.pl > error2.h
660 for obj in $all_errlist_objs; do
661         SS="$SS SS_$(echo $obj | tr 'a-z' 'A-Z'),"
662 done
663 AC_DEFINE_UNQUOTED(DEFINE_ERRLIST_OBJECT_ENUM,
664         [enum {$SS NUM_SS}],
665         [list of all objects that use paraslash's error facility]
666 )
667
668 ################################################################## status items
669
670 status_items="basename status num_played mtime bitrate frequency file_size
671 status_flags format score techinfo afs_mode
672 attributes_txt decoder_flags audiod_status play_time attributes_bitmap
673 offset seconds_total stream_start current_time audiod_uptime image_id
674 lyrics_id duration directory lyrics_name image_name path hash channels
675 last_played num_chunks chunk_time amplification artist title year album
676 comment"
677
678 result=
679 for i in $status_items; do
680         result="$result SI_$(echo $i | tr 'a-z' 'A-Z'), "
681 done
682 AC_DEFINE_UNQUOTED(STATUS_ITEM_ENUM, [$result],
683         [enum of all status items])
684
685 result=
686 for i in $status_items; do
687         result="$result \"$i\", "
688 done
689 AC_DEFINE_UNQUOTED(STATUS_ITEM_ARRAY, [$result],
690         [char * array of all status items])
691
692
693 AC_SUBST(executables, add_para($executables))
694
695 recv_objs="$recv_cmdline_objs $recv_errlist_objs"
696 filter_objs="$filter_cmdline_objs $filter_errlist_objs"
697 audiod_objs="$audiod_cmdline_objs $audiod_errlist_objs"
698 server_objs="$server_cmdline_objs $server_errlist_objs"
699 write_objs="$write_cmdline_objs $write_errlist_objs"
700 client_objs="$client_cmdline_objs $client_errlist_objs"
701 audioc_objs="$audioc_cmdline_objs $audioc_errlist_objs"
702 afh_objs="$afh_cmdline_objs $afh_errlist_objs"
703 fade_objs="$fade_cmdline_objs $fade_errlist_objs"
704
705 AC_SUBST(recv_objs, add_dot_o($recv_objs))
706 AC_SUBST(recv_ldflags, $recv_ldflags)
707 AC_DEFINE_UNQUOTED(INIT_RECV_ERRLISTS, objlist_to_errlist($recv_errlist_objs),
708         errors used by para_recv)
709
710 AC_SUBST(filter_objs, add_dot_o($filter_objs))
711 AC_SUBST(filter_ldflags, $filter_ldflags)
712 AC_DEFINE_UNQUOTED(INIT_FILTER_ERRLISTS,
713         objlist_to_errlist($filter_errlist_objs), errors used by para_filter)
714
715 AC_SUBST(audiod_objs, add_dot_o($audiod_objs))
716 AC_SUBST(audiod_ldflags, $audiod_ldflags)
717 AC_DEFINE_UNQUOTED(INIT_AUDIOD_ERRLISTS, objlist_to_errlist($audiod_errlist_objs),
718         errors used by para_audiod)
719
720 AC_SUBST(server_objs, add_dot_o($server_objs))
721 AC_SUBST(server_ldflags, $server_ldflags)
722 AC_DEFINE_UNQUOTED(INIT_SERVER_ERRLISTS,
723         objlist_to_errlist($server_errlist_objs), errors used by para_server)
724
725 AC_SUBST(afh_objs, add_dot_o($afh_objs))
726 AC_SUBST(afh_ldflags, $afh_ldflags)
727 AC_DEFINE_UNQUOTED(INIT_AFH_ERRLISTS,
728         objlist_to_errlist($afh_errlist_objs), errors used by para_afh)
729
730 AC_SUBST(write_objs, add_dot_o($write_objs))
731 AC_SUBST(write_ldflags, $write_ldflags)
732 AC_DEFINE_UNQUOTED(INIT_WRITE_ERRLISTS,
733         objlist_to_errlist($write_errlist_objs), errors used by para_write)
734
735 AC_SUBST(client_objs, add_dot_o($client_objs))
736 AC_SUBST(client_ldflags, $client_ldflags)
737 AC_DEFINE_UNQUOTED(INIT_CLIENT_ERRLISTS,
738         objlist_to_errlist($client_errlist_objs), errors used by para_client)
739
740 AC_SUBST(audioc_objs, add_dot_o($audioc_objs))
741 AC_SUBST(audioc_ldflags, $audioc_ldflags)
742 AC_DEFINE_UNQUOTED(INIT_AUDIOC_ERRLISTS,
743         objlist_to_errlist($audioc_errlist_objs), errors used by para_audioc)
744
745 AC_SUBST(gui_objs, add_dot_o($gui_objs))
746 AC_DEFINE_UNQUOTED(INIT_GUI_ERRLISTS,
747         objlist_to_errlist($gui_errlist_objs), errors used by para_gui)
748
749 AC_SUBST(fade_objs, add_dot_o($fade_objs))
750 AC_SUBST(fade_ldflags, $fade_ldflags)
751 AC_DEFINE_UNQUOTED(INIT_FADE_ERRLISTS,
752         objlist_to_errlist($fade_errlist_objs), errors used by para_fade)
753
754
755 enum="$(for i in $filters; do printf "${i}_FILTER, " | tr '[a-z]' '[A-Z]'; done)"
756 AC_DEFINE_UNQUOTED(FILTER_ENUM, $enum NUM_SUPPORTED_FILTERS,
757         enum of supported filters)
758 inits="$(for i in $filters; do printf 'extern void '$i'_filter_init(struct filter *f); '; done)"
759 AC_DEFINE_UNQUOTED(DECLARE_FILTER_INITS, $inits, init functions of the supported filters)
760 array="$(for i in $filters; do printf '{.name = "'$i'", .init = '$i'_filter_init},'; done)"
761 AC_DEFINE_UNQUOTED(FILTER_ARRAY, $array, array of supported filters)
762
763 enum="$(for i in $writers; do printf "${i}_WRITE, " | tr '[a-z]' '[A-Z]'; done)"
764 AC_DEFINE_UNQUOTED(WRITER_ENUM, $enum NUM_SUPPORTED_WRITERS,
765         enum of supported writers)
766 AC_DEFINE_UNQUOTED(DEFAULT_WRITER, $default_writer, use this writer if none was specified)
767 names="$(for i in $writers; do printf \"$i\",' ' ; done)"
768 AC_DEFINE_UNQUOTED(WRITER_NAMES, $names, supported writer names)
769 inits="$(for i in $writers; do printf 'extern void '$i'_write_init(struct writer *); '; done)"
770 AC_DEFINE_UNQUOTED(DECLARE_WRITER_INITS, $inits, init functions of the supported writers)
771 array="$(for i in $writers; do printf '{.init = '$i'_write_init},'; done)"
772 AC_DEFINE_UNQUOTED(WRITER_ARRAY, $array, array of supported writers)
773
774 enum="$(for i in $audiod_audio_formats; do printf "AUDIO_FORMAT_${i}, " | tr '[a-z]' '[A-Z]'; done)"
775 AC_DEFINE_UNQUOTED(AUDIOD_AUDIO_FORMATS_ENUM, $enum NUM_AUDIO_FORMATS,
776         enum of audio formats supported by audiod)
777 names="$(for i in $audiod_audio_formats; do printf \"$i\",' ' ; done)"
778 AC_DEFINE_UNQUOTED(AUDIOD_AUDIO_FORMAT_ARRAY, $names, array of audio formats supported by audiod)
779
780 AC_OUTPUT
781 AC_MSG_NOTICE([
782 paraslash configuration:
783 ~~~~~~~~~~~~~~~~~~~~~~~~
784 unix socket credentials: $have_ucred
785 audio formats supported by para_server/para_afh: $server_audio_formats
786 id3 version2 support: $have_libid3tag
787 filters supported by para_audiod/para_filter: $filters
788 writers supported by para_audiod/para_write: $writers
789 optional executables: $extras
790 ])