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