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