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