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