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