paraslash 0.3.1
[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.3.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 all_errlist_objs="server mp3_afh afh_common vss command net string signal time
82 daemon stat crypt http_send close_on_fork ipc acl
83 dccp_send fd user_list chunk_queue afs osl aft mood score attribute blob ringbuffer
84 playlist sha1 rbtree sched audiod grab_client filter_chain wav compress
85 http_recv dccp_recv recv_common write_common file_write audiod_command
86 client_common recv stdout filter stdin audioc write client fsck exec send_common"
87 all_executables="server audiod recv filter audioc write client fsck"
88
89 recv_cmdline_objs="recv.cmdline http_recv.cmdline dccp_recv.cmdline"
90 recv_errlist_objs="http_recv recv_common recv time string net dccp_recv
91 fd sched stdout"
92 recv_ldflags=""
93
94 receivers=" http dccp"
95 senders=" http dccp"
96
97 filter_cmdline_objs="filter.cmdline compress_filter.cmdline"
98 filter_errlist_objs="filter_chain wav compress filter string stdin stdout sched fd"
99 filter_ldflags=""
100 filters=" compress wav"
101
102 audioc_cmdline_objs="audioc.cmdline"
103 audioc_errlist_objs="audioc string net fd"
104 audioc_ldflags=""
105
106 audiod_cmdline_objs="audiod.cmdline grab_client.cmdline compress_filter.cmdline
107 http_recv.cmdline dccp_recv.cmdline file_write.cmdline client.cmdline
108 audiod_command_list"
109 audiod_errlist_objs="audiod signal string daemon stat net
110 time grab_client filter_chain wav compress http_recv dccp_recv
111 recv_common fd sched write_common file_write audiod_command crypt
112 client_common"
113 audiod_ldflags=""
114 audiod_audio_formats=""
115
116 server_cmdline_objs="server.cmdline server_command_list afs_command_list"
117 server_errlist_objs="server afh_common mp3_afh vss command net string signal
118 time daemon stat crypt http_send close_on_fork
119 ipc dccp_send fd user_list chunk_queue afs osl aft mood score attribute
120 blob playlist sha1 rbtree sched acl send_common"
121 server_ldflags=""
122 server_audio_formats=" mp3"
123
124 write_cmdline_objs="write.cmdline file_write.cmdline"
125 write_errlist_objs="write write_common file_write time fd string sched stdin"
126 write_ldflags=""
127 writers=" file"
128 default_writer="FILE_WRITE"
129
130 client_cmdline_objs="client.cmdline"
131 client_errlist_objs="client net string crypt fd sched stdin stdout client_common"
132 client_ldflags=""
133
134 fsck_cmdline_objs="fsck.cmdline"
135 fsck_errlist_objs="osl rbtree fsck string sha1 fd"
136
137 gui_cmdline_objs="gui.cmdline"
138 gui_errlist_objs="exec close_on_fork signal string stat ringbuffer fd"
139 gui_other_objs="gui gui_theme"
140 gui_objs="$gui_cmdline_objs $gui_errlist_objs $gui_other_objs"
141
142 ########################################################################### ssl
143 dnl @synopsis CHECK_SSL
144 dnl
145 dnl based on the follwing macro from the autoconf archive
146 dnl
147 dnl @category InstalledPackages
148 dnl @author Mark Ethan Trostler <trostler@juniper.net>
149 dnl @version 2003-01-28
150 dnl @license AllPermissive
151
152 AC_DEFUN([CHECK_SSL],
153 [
154 for ssldir in $1 /usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr; do
155 AC_MSG_CHECKING(for openssl in $ssldir)
156 if test -f "$ssldir/include/openssl/ssl.h"; then
157 found_ssl="yes"
158 AC_MSG_RESULT(yes)
159 SSL_CFLAGS="-I$ssldir/include"
160 SSL_CPPFLAGS="-I$ssldir/include"
161 break
162 fi
163 AC_MSG_RESULT(no)
164 done
165 if test x_$found_ssl != x_yes; then
166 AC_MSG_ERROR(Cannot find ssl libraries)
167 else
168 SSL_LIBS="-lssl -lcrypto";
169 SSL_LDFLAGS="-L$ssldir/lib";
170 fi
171 AC_SUBST(SSL_CPPFLAGS)
172 AC_SUBST(SSL_CFLAGS)
173 AC_SUBST(SSL_LIBS)
174 AC_SUBST(SSL_LDFLAGS)
175 ])dnl
176
177 AC_ARG_ENABLE(ssldir, [AS_HELP_STRING(--enable-ssldir=path,
178 [Search for openssl also in path.])])
179 if test "$enable_ssldir" = "yes"; then enable_ssldir=""; fi
180 CHECK_SSL($enable_ssldir)
181 server_ldflags="$srver_ldflags $SSL_LDFLAGS $SSL_LIBS"
182 client_ldflags="$client_ldflags $SSL_LDFLAGS $SSL_LIBS"
183 audiod_ldflags="$audiod_ldflags $SSL_LDFLAGS $SSL_LIBS"
184 fsck_ldflags="$fsck_ldflags $SSL_LDFLAGS $SSL_LIBS"
185
186 ########################################################################### libsocket
187 AC_CHECK_LIB([c], [socket],
188 [socket_lib=],
189 [socket_lib="-lsocket"]
190 )
191 server_ldflags="$server_ldflags $socket_lib"
192 client_ldflags="$client_ldflags $socket_lib"
193 audioc_ldflags="$audioc_ldflags $socket_lib"
194 audiod_ldflags="$audiod_ldflags $socket_lib"
195 recv_ldflags="$recv_ldflags $socket_lib"
196 AC_SEARCH_LIBS([connect],[socket],[],[
197 AC_MSG_ERROR([Fatal: Did not find connect().])
198 ],[])
199 ########################################################################### libnsl
200 AC_CHECK_LIB([c], [gethostbyname],
201 [nsl_lib=],
202 [nsl_lib="-lnsl"]
203 )
204 server_ldflags="$server_ldflags $nsl_lib"
205 client_ldflags="$client_ldflags $nsl_lib"
206 audioc_ldflags="$audioc_ldflags $nsl_lib"
207 recv_ldflags="$recv_ldflags $nsl_lib"
208 AC_SEARCH_LIBS([inet_ntoa],[nsl],[],[
209 AC_MSG_ERROR([Fatal: Did not find inet_ntoa().])
210 ],[])
211 ########################################################################### ucred
212 AC_MSG_CHECKING(for struct ucred)
213 AC_TRY_LINK([
214 #include <sys/types.h>
215 #include <sys/socket.h>
216 ],[
217 struct ucred sucred; sucred.pid=0;
218 ],[have_ucred=yes],[have_ucred=no])
219 AC_MSG_RESULT($have_ucred)
220 if test ${have_ucred} = yes; then
221 AC_DEFINE(HAVE_UCRED, 1, define to 1 you have struct ucred)
222 fi
223
224 ########################################################################### curses
225 have_ncurses="yes"
226 OLD_CPPFLAGS="$CPPFLAGS"
227 OLD_LD_FLAGS="$LDFLAGS"
228 OLD_LIBS="$LIBS"
229 AC_ARG_WITH(ncurses_headers, [AC_HELP_STRING(--with-ncurses-headers=dir,
230 [look for ncurses.h also in dir])])
231 if test -n "$with_ncurses_headers"; then
232 ncurses_cppflags="-I$with_ncurses_headers"
233 CPPFLAGS="$CPPFLAGS $ncurses_cppflags"
234 fi
235 AC_ARG_WITH(ncurses_libs, [AC_HELP_STRING(--with-ncurses-libs=dir,
236 [look for libncurses also in dir])])
237 if test -n "$with_ncurses_libs"; then
238 ncurses_libs="-L$with_ncurses_libs"
239 LDFLAGS="$LDFLAGS $ncurses_libs"
240 fi
241 AC_CHECK_HEADER(curses.h, [], [
242 have_ncurses="no"
243 ])
244 AC_CHECK_LIB([ncurses], [initscr], [], [
245 have_ncurses="no"
246 ])
247 if test "$have_ncurses" = "yes"; then
248 AC_SUBST(ncurses_cppflags)
249 AC_SUBST(ncurses_libs)
250 AC_DEFINE(HAVE_NCURSES, 1, [define to 1 to turn on ncurses support])
251 extras="$extras para_gui"
252 all_executables="$all_executables gui"
253 else
254 AC_MSG_WARN([cannot build para_gui])
255 fi
256 CPPFLAGS="$OLD_CPPFLAGS"
257 LDFLAGS="$OLD_LDFLAGS"
258 LIBS="$OLD_LIBS"
259 ########################################################################### osx
260
261 AC_MSG_CHECKING(for CoreAudio (MacOs))
262 AC_TRY_LINK([
263 #include <CoreAudio/CoreAudio.h>
264 ],[
265 AudioDeviceID id;
266 ],[have_core_audio=yes],[have_core_audio=no])
267 AC_MSG_RESULT($have_core_audio)
268 if test ${have_core_audio} = yes; then
269 f1="-framework CoreAudio"
270 f2="-framework AudioToolbox"
271 f3="-framework AudioUnit"
272 f4="-framework CoreServices"
273 f="$f1 $f2 $f3 $f4"
274
275 all_errlist_objs="$all_errlist_objs osx_write"
276 audiod_errlist_objs="$audiod_errlist_objs osx_write"
277 audiod_cmdline_objs="$audiod_cmdline_objs osx_write.cmdline"
278 audiod_ldflags="$audiod_ldflags $f"
279
280 write_errlist_objs="$write_errlist_objs osx_write"
281 write_cmdline_objs="$write_cmdline_objs osx_write.cmdline"
282 write_ldflags="$write_ldflags $f"
283 writers="$writers osx"
284 default_writer="OSX_WRITE"
285 AC_DEFINE(HAVE_CORE_AUDIO, 1, define to 1 on Mac Os X)
286 fi
287 ########################################################################### ogg
288 have_ogg="yes"
289 OLD_CPPFLAGS="$CPPFLAGS"
290 OLD_LD_FLAGS="$LDFLAGS"
291 OLD_LIBS="$LIBS"
292 AC_ARG_WITH(oggvorbis_headers, [AC_HELP_STRING(--with-oggvorbis-headers=dir,
293 [look for vorbis/codec.h also in dir])])
294 if test -n "$with_oggvorbis_headers"; then
295 oggvorbis_cppflags="-I$with_oggvorbis_headers"
296 CPPFLAGS="$CPPFLAGS $oggvorbis_cppflags"
297 fi
298 AC_ARG_WITH(oggvorbis_libs, [AC_HELP_STRING(--with-oggvorbis-libs=dir,
299 [look for oggvorbis libs also in dir])])
300 if test -n "$with_oggvorbis_libs"; then
301 oggvorbis_libs="-L$with_oggvorbis_libs"
302 LDFLAGS="$LDFLAGS $oggvorbis_libs"
303 fi
304
305 AC_CHECK_LIB([ogg], [ogg_stream_init], [], [ have_ogg="no" ])
306 AC_CHECK_LIB([vorbis], [vorbis_info_init], [], [ have_ogg="no" ])
307 AC_CHECK_HEADERS([ogg/ogg.h vorbis/codec.h], [], [ have_ogg="no" ])
308 if test "$have_ogg" = "yes"; then
309 all_errlist_objs="$all_errlist_objs oggdec ogg_afh"
310 AC_DEFINE(HAVE_OGGVORBIS, 1, define to 1 to turn on ogg vorbis support)
311 filters="$filters oggdec"
312 if test "$OSTYPE" = "Darwin"; then
313 oggvorbis_libs="-Wl,-bind_at_load $oggvorbis_libs"
314 fi
315 server_ldflags="$server_ldflags $oggvorbis_libs -logg -lvorbis -lvorbisfile"
316 filter_ldflags="$filter_ldflags $oggvorbis_libs -lvorbis -lvorbisfile"
317 audiod_ldflags="$audiod_ldflags $oggvorbis_libs -lvorbis -lvorbisfile"
318
319 filter_cmdline_objs="$filter_cmdline_objs oggdec_filter.cmdline"
320 audiod_cmdline_objs="$audiod_cmdline_objs oggdec_filter.cmdline"
321
322 server_errlist_objs="$server_errlist_objs ogg_afh"
323 filter_errlist_objs="$filter_errlist_objs oggdec"
324 audiod_errlist_objs="$audiod_errlist_objs oggdec"
325
326 audiod_audio_formats="ogg"
327 server_audio_formats="$server_audio_formats ogg"
328 filter_filters="$filter_filters oggdec"
329 AC_SUBST(oggvorbis_cppflags)
330 AC_SUBST(oggvorbis_libs)
331 else
332 AC_MSG_WARN([no ogg vorbis support in para_server/para_filter])
333 fi
334 CPPFLAGS="$OLD_CPPFLAGS"
335 LDFLAGS="$OLD_LDFLAGS"
336 LIBS="$OLD_LIBS"
337 ########################################################################### faad
338 have_faad=yes
339 OLD_CPPFLAGS="$CPPFLAGS"
340 OLD_LD_FLAGS="$LDFLAGS"
341 OLD_LIBS="$LIBS"
342 AC_ARG_WITH(faad_headers, [AC_HELP_STRING(--with-faad-headers=dir,
343 [look for neaacdec.h also in dir])])
344 if test -n "$with_faad_headers"; then
345 faad_cppflags="-I$with_faad_headers"
346 CPPFLAGS="$CPPFLAGS $faad_cppflags"
347 fi
348 AC_ARG_WITH(faad_libs, [AC_HELP_STRING(--with-faad-libs=dir,
349 [look for libfaad also in dir])])
350 if test -n "$with_faad_libs"; then
351 faad_libs="-L$with_faad_libs"
352 LDFLAGS="$LDFLAGS $faad_libs"
353 fi
354 AC_CHECK_HEADER(neaacdec.h, [], have_faad=no)
355 AC_CHECK_LIB([faad], [NeAACDecOpen], [], have_faad=no)
356 if test "$have_faad" = "yes"; then
357 AC_DEFINE(HAVE_FAAD, 1, define to 1 if you want to build the aacdec filter)
358 all_errlist_objs="$all_errlist_objs aac_common aacdec aac_afh"
359 filter_errlist_objs="$filter_errlist_objs aacdec aac_common"
360 filter_filters="$filter_filters aacdec"
361 audiod_errlist_objs="$audiod_errlist_objs aacdec aac_common"
362 server_errlist_objs="$server_errlist_objs aac_afh aac_common"
363 server_ldflags="$server_ldflags $faad_libs -lfaad"
364 filter_ldflags="$filter_ldflags $faad_libs -lfaad"
365 audiod_ldflags="$audiod_ldflags $faad_libs -lfaad"
366 audiod_audio_formats="$audiod_audio_formats aac"
367 server_audio_formats="$server_audio_formats aac"
368 filters="$filters aacdec"
369 AC_SUBST(faad_cppflags)
370 AC_SUBST(faad_libs)
371 else
372 AC_MSG_WARN([no aac support in para_audiod/para_filter])
373 fi
374 CPPFLAGS="$OLD_CPPFLAGS"
375 LDFLAGS="$OLD_LDFLAGS"
376 LIBS="$OLD_LIBS"
377 ########################################################################### mad
378 have_mad="yes"
379 OLD_CPPFLAGS="$CPPFLAGS"
380 OLD_LD_FLAGS="$LDFLAGS"
381 OLD_LIBS="$LIBS"
382
383 AC_ARG_WITH(mad_headers, [AC_HELP_STRING(--with-mad-headers=dir,
384 [look for mad.h also in dir])])
385 if test -n "$with_mad_headers"; then
386 mad_cppflags="-I$with_mad_headers"
387 CPPFLAGS="$CPPFLAGS $mad_cppflags"
388 fi
389 AC_ARG_WITH(mad_libs, [AC_HELP_STRING(--with-mad-libs=dir,
390 [look for libmad also in dir])])
391 if test -n "$with_mad_libs"; then
392 mad_libs="-L$with_mad_libs"
393 LDFLAGS="$LDFLAGS $mad_libs"
394 fi
395 AC_CHECK_HEADERS([mad.h], [], [
396 have_mad="no"
397 ])
398 AC_CHECK_LIB([mad], [mad_stream_init], [], [
399 have_mad="no"
400 ])
401 if test "$have_mad" = "yes"; then
402 AC_DEFINE(HAVE_MAD, 1, define to 1 if you want to build the mp3dec filter)
403 all_errlist_objs="$all_errlist_objs mp3dec"
404 filter_errlist_objs="$filter_errlist_objs mp3dec"
405 audiod_errlist_objs="$audiod_errlist_objs mp3dec"
406 filter_ldflags="$filter_ldflags $mad_libs -lmad"
407 audiod_ldflags="$audiod_ldflags $mad_libs -lmad"
408 audiod_audio_formats="$audiod_audio_formats mp3"
409 filters="$filters mp3dec"
410 AC_SUBST(mad_cppflags)
411 AC_SUBST(mad_libs)
412 else
413 AC_MSG_WARN([no mp3dec support in para_audiod/para_filter])
414 fi
415 if test -n "$audiod_audio_formats"; then
416 extras="$extras para_audiod"
417 else
418 AC_MSG_WARN([can not build para_audiod (no supported audio formats)])
419 fi
420 CPPFLAGS="$OLD_CPPFLAGS"
421 LDFLAGS="$OLD_LDFLAGS"
422 LIBS="$OLD_LIBS"
423 ########################################################################### alsa
424 have_alsa="yes"
425 OLD_CPPFLAGS="$CPPFLAGS"
426 OLD_LD_FLAGS="$LDFLAGS"
427 OLD_LIBS="$LIBS"
428 if test "$OSTYPE" != "Linux"; then
429 have_alsa="no"
430 fi
431 msg="=> can not build para_fade, and no alsa support for para_audiod/para_write"
432 if test "$have_alsa" = "yes"; then
433 AC_CHECK_HEADER(linux/soundcard.h,
434 [extras="$extras para_fade"],
435 [
436 have_alsa="no"
437 AC_MSG_WARN([no linux/soundcard.h $msg])
438 ]
439 )
440 fi
441
442 if test "$have_alsa" = "yes"; then
443 AC_CHECK_HEADERS([alsa/asoundlib.h], [], [
444 have_alsa="no"
445 AC_MSG_WARN([no alsa/asoundlib $msg])
446 ])
447 fi
448
449 if test "$have_alsa" = "yes"; then
450 AC_CHECK_LIB([asound], [snd_pcm_open], [], [
451 have_alsa="no"
452 AC_MSG_WARN([no libasound $msg])
453 ])
454 fi
455
456 if test "$have_alsa" = "yes"; then
457 all_errlist_objs="$all_errlist_objs alsa_write"
458 audiod_errlist_objs="$audiod_errlist_objs alsa_write"
459 audiod_cmdline_objs="$audiod_cmdline_objs alsa_write.cmdline"
460 audiod_ldflags="$audiod_ldflags -lasound"
461
462 write_errlist_objs="$write_errlist_objs alsa_write"
463 write_cmdline_objs="$write_cmdline_objs alsa_write.cmdline"
464 write_ldflags="$write_ldflags -lasound"
465 writers="$writers alsa"
466 default_writer="ALSA_WRITE"
467 fi
468 CPPFLAGS="$OLD_CPPFLAGS"
469 LDFLAGS="$OLD_LDFLAGS"
470 LIBS="$OLD_LIBS"
471 ########################################################################### ortp
472 have_ortp="yes"
473 OLD_CPPFLAGS="$CPPFLAGS"
474 OLD_LD_FLAGS="$LDFLAGS"
475 OLD_LIBS="$LIBS"
476 AC_ARG_WITH(ortp_headers, [AC_HELP_STRING(--with-ortp-headers=dir,
477 [look for ortp/ortp.h also in dir])])
478 if test -n "$with_ortp_headers"; then
479 ortp_cppflags="-I$with_ortp_headers"
480 CPPFLAGS="$CPPFLAGS $ortp_cppflags"
481 fi
482 AC_ARG_WITH(ortp_libs, [AC_HELP_STRING(--with-ortp-libs=dir,
483 [look for libortp also in dir])])
484 if test -n "$with_ortp_libs"; then
485 ortp_libs="-L$with_ortp_libs"
486 LDFLAGS="$LDFLAGS $ortp_libs"
487 fi
488 AC_CHECK_HEADERS([ortp/ortp.h], [], [have_ortp="no"])
489 AC_CHECK_LIB([ortp], [ortp_init], [], [have_ortp="no"])
490 if test "$have_ortp" = "yes"; then
491 all_errlist_objs="$all_errlist_objs ortp_recv ortp_send"
492
493 recv_cmdline_objs="$recv_cmdline_objs ortp_recv.cmdline"
494 recv_errlist_objs="$recv_errlist_objs ortp_recv"
495
496 audiod_cmdline_objs="$audiod_cmdline_objs ortp_recv.cmdline"
497 audiod_errlist_objs="$audiod_errlist_objs ortp_recv"
498
499 server_errlist_objs="$server_errlist_objs ortp_send"
500
501 recv_ldflags="$recv_ldflags $ortp_libs -lortp"
502 server_ldflags="$server_ldflags $ortp_libs -lortp"
503 audiod_ldflags="$audiod_ldflags $ortp_libs -lortp"
504
505 receivers="$receivers ortp"
506 senders="$senders ortp"
507 AC_DEFINE(HAVE_ORTP, 1, [define to 1 to turn on ortp support])
508 AC_SUBST(ortp_cppflags)
509 AC_SUBST(ortp_libs)
510 else
511 AC_MSG_NOTICE([deactivating ortp sender/receiver])
512 fi
513 CPPFLAGS="$OLD_CPPFLAGS"
514 LDFLAGS="$OLD_LDFLAGS"
515 LIBS="$OLD_LIBS"
516
517
518 AC_SUBST(extra_binaries, [$extras])
519 AC_SUBST(extra_filter_objs, [$extra_filter_objs])
520 AC_SUBST(extra_filter_libs, [$extra_filter_libs])
521 AC_SUBST(install_sh, [$INSTALL])
522 AC_CONFIG_FILES([Makefile])
523
524
525 AC_DEFUN([add_dot_o],[$(for i in $@; do printf "$i.o "; done)])
526 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) }])
527
528 ############################################################# error2.h
529
530 AC_DEFUN([define_safe_error_enums],
531 [
532 exe=""
533 for i in $all_executables; do
534 # eval echo checking if $1 is linked into $i
535 for j in $(eval echo \$${i}_errlist_objs); do
536 if test $j = $1; then
537 exe="$exe $i"
538 break;
539 fi
540 done
541 done
542 #echo "$1 gets linked into $exe"
543 safe_errlists=""
544 for i in $all_errlist_objs; do
545 for j in $exe; do
546 found=0
547 for k in $(eval echo \$${j}_errlist_objs); do
548 if test $k = $i; then
549 found=1
550 break;
551 fi
552 done
553 if test $found -eq 0; then
554 break;
555 fi
556 done
557 if test $found -eq 1; then
558 safe_errlists="$safe_errlists $i"
559 fi
560 done
561 #echo "safe errlists for $1: $safe_errlists"
562 ss_defs=""
563 for i in $safe_errlists; do
564 echo "SS_ENUM($(echo $i | tr 'a-z' 'A-Z'));"
565 done
566 ]
567 )
568
569
570 AC_MSG_NOTICE(creating error2.h)
571 for obj in $all_errlist_objs; do
572 SS="$SS SS_$(echo $obj | tr 'a-z' 'A-Z'),"
573 echo "#ifdef MAIN_INPUT_FILE_IS_$obj"
574 define_safe_error_enums($obj)
575 echo "#endif"
576 done > error2.h
577 AC_DEFINE_UNQUOTED(DEFINE_ERRLIST_OBJECT_ENUM,
578 [enum {$SS NUM_SS}],
579 [list of all objects that use paraslash's error facility]
580 )
581
582 ################################################################## status items
583
584 status_items="basename status num_played mtime bitrate frequency file_size
585 status_flags format score audio_file_info taginfo1 taginfo2 afs_mode
586 attributes_txt decoder_flags audiod_status play_time attributes_bitmap
587 offset seconds_total stream_start current_time audiod_uptime image_id
588 lyrics_id duration directory lyrics_name image_name path hash channels
589 last_played num_chunks chunk_time"
590
591 # $1: prefix, $2: items
592 AC_DEFUN([make_enum_items], [$(
593 for i in $2; do
594 printf "$1_$(echo $i | tr 'a-z' 'A-Z'), "
595 done
596 )])
597
598 # $1: prefix, $2: items
599 AC_DEFUN([make_enum_array], [$(
600 for i in $2; do
601 printf "\"$i\", "
602 done
603 )])
604
605 AC_DEFINE_UNQUOTED(STATUS_ITEM_ENUM,
606 make_enum_items(SI, $status_items),
607 [enum of all status items]
608 )
609 AC_DEFINE_UNQUOTED(STATUS_ITEM_ARRAY,
610 make_enum_array(SI, $status_items),
611 [char * array of all status items]
612 )
613
614
615 recv_objs="$recv_cmdline_objs $recv_errlist_objs"
616 filter_objs="$filter_cmdline_objs $filter_errlist_objs"
617 audiod_objs="$audiod_cmdline_objs $audiod_errlist_objs"
618 server_objs="$server_cmdline_objs $server_errlist_objs"
619 write_objs="$write_cmdline_objs $write_errlist_objs"
620 client_objs="$client_cmdline_objs $client_errlist_objs"
621 fsck_objs="$fsck_cmdline_objs $fsck_errlist_objs"
622 audioc_objs="$audioc_cmdline_objs $audioc_errlist_objs"
623
624 AC_SUBST(recv_objs, add_dot_o($recv_objs))
625 AC_SUBST(recv_ldflags, $recv_ldflags)
626 AC_DEFINE_UNQUOTED(INIT_RECV_ERRLISTS, objlist_to_errlist($recv_errlist_objs),
627 errors used by para_recv)
628
629 AC_SUBST(filter_objs, add_dot_o($filter_objs))
630 AC_SUBST(filter_ldflags, $filter_ldflags)
631 AC_DEFINE_UNQUOTED(INIT_FILTER_ERRLISTS,
632 objlist_to_errlist($filter_errlist_objs), errors used by para_filter)
633
634 AC_SUBST(audiod_objs, add_dot_o($audiod_objs))
635 AC_SUBST(audiod_ldflags, $audiod_ldflags)
636 AC_DEFINE_UNQUOTED(INIT_AUDIOD_ERRLISTS, objlist_to_errlist($audiod_errlist_objs),
637 errors used by para_audiod)
638
639 AC_SUBST(server_objs, add_dot_o($server_objs))
640 AC_SUBST(server_ldflags, $server_ldflags)
641 AC_DEFINE_UNQUOTED(INIT_SERVER_ERRLISTS,
642 objlist_to_errlist($server_errlist_objs), errors used by para_server)
643
644 AC_SUBST(write_objs, add_dot_o($write_objs))
645 AC_SUBST(write_ldflags, $write_ldflags)
646 AC_DEFINE_UNQUOTED(INIT_WRITE_ERRLISTS,
647 objlist_to_errlist($write_errlist_objs), errors used by para_write)
648
649 AC_SUBST(client_objs, add_dot_o($client_objs))
650 AC_SUBST(client_ldflags, $client_ldflags)
651 AC_DEFINE_UNQUOTED(INIT_CLIENT_ERRLISTS,
652 objlist_to_errlist($client_errlist_objs), errors used by para_client)
653
654 AC_SUBST(fsck_objs, add_dot_o($fsck_objs))
655 AC_SUBST(fsck_ldflags, $fsck_ldflags)
656 AC_DEFINE_UNQUOTED(INIT_FSCK_ERRLISTS,
657 objlist_to_errlist($fsck_errlist_objs), errors used by para_fsck)
658
659 AC_SUBST(audioc_objs, add_dot_o($audioc_objs))
660 AC_SUBST(audioc_ldflags, $audioc_ldflags)
661 AC_DEFINE_UNQUOTED(INIT_AUDIOC_ERRLISTS,
662 objlist_to_errlist($audioc_errlist_objs), errors used by para_audioc)
663
664 AC_SUBST(gui_objs, add_dot_o($gui_objs))
665 AC_DEFINE_UNQUOTED(INIT_GUI_ERRLISTS,
666 objlist_to_errlist($gui_errlist_objs), errors used by para_gui)
667
668 enum="$(for i in $writers; do printf "${i}_WRITE, " | tr '[a-z]' '[A-Z]'; done)"
669 AC_DEFINE_UNQUOTED(WRITER_ENUM, $enum NUM_SUPPORTED_WRITERS,
670 enum of supported writers)
671 AC_DEFINE_UNQUOTED(DEFAULT_WRITER, $default_writer, use this writer if none was specified)
672 names="$(for i in $writers; do printf \"$i\",' ' ; done)"
673 AC_DEFINE_UNQUOTED(WRITER_NAMES, $names, supported writer names)
674 inits="$(for i in $writers; do printf 'extern void '$i'_write_init(struct writer *); '; done)"
675 AC_DEFINE_UNQUOTED(DECLARE_WRITER_INITS, $inits, init functions of the supported writers)
676 array="$(for i in $writers; do printf '{.init = '$i'_write_init},'; done)"
677 AC_DEFINE_UNQUOTED(WRITER_ARRAY, $array, array of supported writers)
678 enum="$(for i in $audiod_audio_formats; do printf "AUDIO_FORMAT_${i}, " | tr '[a-z]' '[A-Z]'; done)"
679 AC_DEFINE_UNQUOTED(AUDIOD_AUDIO_FORMATS_ENUM, $enum NUM_AUDIO_FORMATS,
680 enum of audio formats supported by audiod)
681 names="$(for i in $audiod_audio_formats; do printf \"$i\",' ' ; done)"
682 AC_DEFINE_UNQUOTED(AUDIOD_AUDIO_FORMAT_ARRAY, $names, array of audio formats supported by audiod)
683
684 AC_OUTPUT
685 AC_MSG_NOTICE([creating Makefile.deps])
686 gcc -MM -MG $faad_cppflags $mad_cppflags $ortp_cppflags $oggvorbis_cppflags *.c > Makefile.deps
687 AC_MSG_NOTICE([
688 paraslash configuration:
689 ~~~~~~~~~~~~~~~~~~~~~~~~
690 unix socket credentials: $have_ucred
691 audio formats supported by para_server: $server_audio_formats
692 senders supported by para_server/para_send: $senders
693 receivers supported by para_audiod/para_recv: $receivers
694 filters supported by para_audiod/para_filter: $filters
695 writers supported by para_audiod/para_write: $writers
696 optional executables: $extras
697 ])