Only declare error codes that are safe to use.
[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 AC_C_BIGENDIAN()
19
20 AC_PROG_CC
21 AC_PROG_CPP
22 AC_PROG_INSTALL
23
24
25 AC_HEADER_DIRENT
26 AC_HEADER_STDC
27 AC_HEADER_SYS_WAIT
28 AC_CHECK_HEADERS([arpa/inet.h ctype.h fcntl.h limits.h netdb.h netinet/in.h \
29 stdlib.h string.h sys/socket.h sys/time.h sys/timeb.h sys/un.h \
30 sys/ipc.h unistd.h utime.h stddef.h],
31 [], [AC_MSG_ERROR([$ac_header not found])])
32
33 AC_CHECK_HEADER(linux/soundcard.h, [extras="$extras para_fade"],
34 [AC_MSG_WARN([linux/soundcard.h not found, cannot build para_fade])])
35
36 # Checks for typedefs, structures, and compiler characteristics.
37 AC_C_CONST
38 AC_C_INLINE
39 AC_TYPE_OFF_T
40 AC_TYPE_PID_T
41 AC_TYPE_SIZE_T
42 AC_HEADER_TIME
43 AC_STRUCT_TM
44 AC_TYPE_INT16_T
45 AC_TYPE_MODE_T
46 AC_TYPE_SSIZE_T
47 AC_TYPE_UID_T
48 AC_TYPE_UINT16_T
49 AC_TYPE_UINT32_T
50 AC_TYPE_UINT8_T
51
52 # Checks for library functions.
53 AC_FUNC_FORK
54 AC_PROG_GCC_TRADITIONAL
55 AC_FUNC_MALLOC
56 AC_FUNC_MEMCMP
57 AC_FUNC_MKTIME
58 AC_FUNC_MMAP
59 AC_FUNC_REALLOC
60 AC_FUNC_SELECT_ARGTYPES
61 AC_TYPE_SIGNAL
62 AC_FUNC_STAT
63 AC_FUNC_STRFTIME
64 AC_FUNC_VPRINTF
65 AC_FUNC_CLOSEDIR_VOID
66 AC_FUNC_LSTAT
67
68 AC_CHECK_FUNCS([atexit dup2 memchr memmove memset \
69 regcomp select strchr strdup strerror strstr strtol uname \
70 fchdir gettimeofday localtime_r munmap strcasecmp strcspn \
71 strncasecmp strrchr strspn alarm], [],
72 [AC_MSG_ERROR([function not found, cannot live without it])])
73
74 all_errlist_objs="server mp3_afh vss command net string signal random_selector time
75 daemon stat crypt http_send afs_common close_on_fork playlist_selector ipc dccp
76 dccp_send fd user_list chunk_queue afs osl aft mood score attribute blob ringbuffer
77 playlist sha1 rbtree sched audiod grab_client filter_chain wav compress
78 http_recv dccp_recv recv_common write_common file_write audiod_command
79 client_common recv stdout filter stdin audioc write client fsck exec"
80 all_executables="server audiod recv filter audioc write client fsck"
81
82
83 recv_cmdline_objs="recv.cmdline http_recv.cmdline dccp_recv.cmdline"
84 recv_errlist_objs="http_recv recv_common recv time string net dccp_recv
85 dccp fd sched stdout"
86 recv_ldflags=""
87
88 receivers=" http dccp"
89 senders=" http dccp"
90 selectors=" random playlist"
91
92 filter_cmdline_objs="filter.cmdline compress_filter.cmdline"
93 filter_errlist_objs="filter_chain wav compress filter string stdin stdout sched fd"
94 filter_ldflags=""
95 filters=" compress wav"
96
97 audioc_cmdline_objs="audioc.cmdline"
98 audioc_errlist_objs="audioc string net fd"
99 audioc_ldflags=""
100
101 audiod_cmdline_objs="audiod.cmdline grab_client.cmdline compress_filter.cmdline
102 http_recv.cmdline dccp_recv.cmdline file_write.cmdline client.cmdline
103 audiod_command_list"
104 audiod_errlist_objs="audiod signal string daemon stat net
105 time grab_client filter_chain wav compress http_recv dccp dccp_recv
106 recv_common fd sched write_common file_write audiod_command crypt
107 client_common"
108 audiod_ldflags=""
109 audiod_audio_formats=""
110
111 server_cmdline_objs="server.cmdline server_command_list random_selector_command_list
112 playlist_selector_command_list afs_command_list"
113 server_errlist_objs="server mp3_afh vss command net string signal random_selector
114 time daemon stat crypt http_send afs_common close_on_fork playlist_selector
115 ipc dccp dccp_send fd user_list chunk_queue afs osl aft mood score attribute
116 blob playlist sha1 rbtree sched"
117 server_ldflags=""
118 server_audio_formats=" mp3"
119
120 write_cmdline_objs="write.cmdline file_write.cmdline"
121 write_errlist_objs="write write_common file_write time fd string sched stdin"
122 write_ldflags=""
123 writers=" file"
124 default_writer="FILE_WRITE"
125
126 client_cmdline_objs="client.cmdline"
127 client_errlist_objs="client net string crypt fd sched stdin stdout client_common"
128 client_ldflags=""
129
130 fsck_cmdline_objs="fsck.cmdline"
131 fsck_errlist_objs="osl rbtree fsck string sha1 fd"
132
133 gui_cmdline_objs="gui.cmdline"
134 gui_errlist_objs="exec close_on_fork signal string stat ringbuffer fd"
135 gui_other_objs="gui gui_common gui_theme"
136 gui_objs="$gui_cmdline_objs $gui_errlist_objs $gui_other_objs"
137
138 ########################################################################### ssl
139 dnl @synopsis CHECK_SSL
140 dnl
141 dnl based on the follwing macro from the autoconf archive
142 dnl
143 dnl @category InstalledPackages
144 dnl @author Mark Ethan Trostler <trostler@juniper.net>
145 dnl @version 2003-01-28
146 dnl @license AllPermissive
147
148 AC_DEFUN([CHECK_SSL],
149 [
150 for ssldir in $1 /usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr; do
151 AC_MSG_CHECKING(for openssl in $ssldir)
152 if test -f "$ssldir/include/openssl/ssl.h"; then
153 found_ssl="yes"
154 AC_MSG_RESULT(yes)
155 SSL_CFLAGS="-I$ssldir/include"
156 SSL_CPPFLAGS="-I$ssldir/include"
157 break
158 fi
159 AC_MSG_RESULT(no)
160 done
161 if test x_$found_ssl != x_yes; then
162 AC_MSG_ERROR(Cannot find ssl libraries)
163 else
164 SSL_LIBS="-lssl -lcrypto";
165 SSL_LDFLAGS="-L$ssldir/lib";
166 fi
167 AC_SUBST(SSL_CPPFLAGS)
168 AC_SUBST(SSL_CFLAGS)
169 AC_SUBST(SSL_LIBS)
170 AC_SUBST(SSL_LDFLAGS)
171 ])dnl
172
173 AC_ARG_ENABLE(ssldir, [AS_HELP_STRING(--enable-ssldir=path,
174 [Search for openssl also in path.])])
175 if test "$enable_ssldir" = "yes"; then enable_ssldir=""; fi
176 CHECK_SSL($enable_ssldir)
177 server_ldflags="$srver_ldflags $SSL_LDFLAGS $SSL_LIBS"
178 client_ldflags="$client_ldflags $SSL_LDFLAGS $SSL_LIBS"
179 audiod_ldflags="$audiod_ldflags $SSL_LDFLAGS $SSL_LIBS"
180 fsck_ldflags="$fsck_ldflags $SSL_LDFLAGS $SSL_LIBS"
181
182 ########################################################################### libsocket
183 AC_CHECK_LIB([c], [socket],
184 [socket_lib=],
185 [socket_lib="-lsocket"]
186 )
187 server_ldflags="$server_ldflags $socket_lib"
188 client_ldflags="$client_ldflags $socket_lib"
189 audioc_ldflags="$audioc_ldflags $socket_lib"
190 recv_ldflags="$recv_ldflags $socket_lib"
191 ########################################################################### libnsl
192 AC_CHECK_LIB([c], [gethostbyname],
193 [nsl_lib=],
194 [nsl_lib="-lnsl"]
195 )
196 server_ldflags="$server_ldflags $nsl_lib"
197 client_ldflags="$client_ldflags $nsl_lib"
198 audioc_ldflags="$audioc_ldflags $nsl_lib"
199 recv_ldflags="$recv_ldflags $nsl_lib"
200 ########################################################################### ucred
201 AC_MSG_CHECKING(for struct ucred)
202 AC_TRY_LINK([
203 #include <sys/types.h>
204 #include <sys/socket.h>
205 ],[
206 struct ucred sucred; sucred.pid=0;
207 ],[have_ucred=yes],[have_ucred=no])
208 AC_MSG_RESULT($have_ucred)
209 if test ${have_ucred} = yes; then
210 AC_DEFINE(HAVE_UCRED, 1, define to 1 you have struct ucred)
211 fi
212
213 ########################################################################### curses
214 have_ncurses="yes"
215 OLD_CPPFLAGS="$CPPFLAGS"
216 OLD_LD_FLAGS="$LDFLAGS"
217 OLD_LIBS="$LIBS"
218 AC_ARG_WITH(ncurses_headers, [AC_HELP_STRING(--with-ncurses-headers=dir,
219 [look for ncurses.h also in dir])])
220 if test -n "$with_ncurses_headers"; then
221 ncurses_cppflags="-I$with_ncurses_headers"
222 CPPFLAGS="$CPPFLAGS $ncurses_cppflags"
223 fi
224 AC_ARG_WITH(ncurses_libs, [AC_HELP_STRING(--with-ncurses-libs=dir,
225 [look for libncurses also in dir])])
226 if test -n "$with_ncurses_libs"; then
227 ncurses_libs="-L$with_ncurses_libs"
228 LDFLAGS="$LDFLAGS $ncurses_libs"
229 fi
230 AC_CHECK_HEADER(curses.h, [], [
231 have_ncurses="no"
232 ])
233 AC_CHECK_LIB([ncurses], [initscr], [], [
234 have_ncurses="no"
235 ])
236 if test "$have_ncurses" = "yes"; then
237 AC_SUBST(ncurses_cppflags)
238 AC_SUBST(ncurses_libs)
239 AC_DEFINE(HAVE_NCURSES, 1, [define to 1 to turn on ncurses support])
240 extras="$extras para_gui"
241 all_executables="$all_executables gui"
242 else
243 AC_MSG_WARN([cannot build para_gui])
244 fi
245 CPPFLAGS="$OLD_CPPFLAGS"
246 LDFLAGS="$OLD_LDFLAGS"
247 LIBS="$OLD_LIBS"
248 ########################################################################### osx
249
250 AC_MSG_CHECKING(for CoreAudio (MacOs))
251 AC_TRY_LINK([
252 #include <CoreAudio/CoreAudio.h>
253 ],[
254 AudioDeviceID id;
255 ],[have_core_audio=yes],[have_core_audio=no])
256 AC_MSG_RESULT($have_core_audio)
257 if test ${have_core_audio} = yes; then
258 f1="-framework CoreAudio"
259 f2="-framework AudioToolbox"
260 f3="-framework AudioUnit"
261 f4="-framework CoreServices"
262 f="$f1 $f2 $f3 $f4"
263
264 all_errlist_objs="$all_errlist_objs osx_write"
265 audiod_errlist_objs="$audiod_errlist_objs osx_write"
266 audiod_cmdline_objs="$audiod_cmdline_objs osx_write.cmdline"
267 audiod_ldflags="$audiod_ldflags $f"
268
269 write_errlist_objs="$write_errlist_objs osx_write"
270 write_cmdline_objs="$write_cmdline_objs osx_write.cmdline"
271 write_ldflags="$write_ldflags $f"
272 writers="$writers osx"
273 default_writer="OSX_WRITE"
274 AC_DEFINE(HAVE_CORE_AUDIO, 1, define to 1 on Mac Os X)
275 fi
276 ########################################################################### gtk2
277 build_para_krell="yes"
278 OLD_CPPFLAGS="$CPPFLAGS"
279 OLD_LD_FLAGS="$LDFLAGS"
280 OLD_LIBS="$LIBS"
281 pkg_modules="gtk+-2.0 >= 2.0.0"
282 PKG_CHECK_MODULES(GLIB, [glib-2.0 >= 2.0.4], [], [build_para_krell="no"])
283 PKG_CHECK_MODULES(GTK, [$pkg_modules], [], [build_para_krell="no"])
284 CPPFLAGS="$GTK_CFLAGS $GLIB_CFLAGS"
285 LDFLAGS="$LDFLAGS $GTK_LIBS"
286 AC_CHECK_HEADER(gkrellm2/gkrellm.h, [], [build_para_krell="no"])
287 if test "$build_para_krell" = "yes"; then
288 AC_SUBST(GTK_CFLAGS)
289 AC_SUBST(GTK_LIBS)
290 extras="$extras para_krell.so"
291 else
292 AC_MSG_WARN([can not build para_krell])
293 fi
294 CPPFLAGS="$OLD_CPPFLAGS"
295 LDFLAGS="$OLD_LDFLAGS"
296 LIBS="$OLD_LIBS"
297 ########################################################################### sdl
298 # FIXME
299 AC_CHECK_LIB([SDL_image], [SDL_Init], [extras="$extras para_sdl_gui"], [
300 AC_MSG_WARN([libSDL_image not found, cannot build para_sdl_gui])
301 ])
302 AC_CHECK_HEADER(SDL/SDL.h, [],
303 [AC_MSG_WARN([SDL/SDL.h not found])])
304
305 ########################################################################### mysql
306 have_mysql="yes"
307 OLD_CPPFLAGS="$CPPFLAGS"
308 OLD_LD_FLAGS="$LDFLAGS"
309 OLD_LIBS="$LIBS"
310 AC_ARG_WITH(mysql_headers, [AC_HELP_STRING(--with-mysql-headers=dir,
311 [look for mysql.h also in dir])])
312 if test -n "$with_mysql_headers"; then
313 mysql_cppflags="-I$with_mysql_headers"
314 CPPFLAGS="$CPPFLAGS $mysql_cppflags"
315 fi
316 AC_ARG_WITH(mysql_libs, [AC_HELP_STRING(--with-mysql-libs=dir,
317 [look for libmysqlclient also in dir])])
318 if test -n "$with_mysql_libs"; then
319 mysql_libs="-L$with_mysql_libs"
320 LDFLAGS="$LDFLAGS $mysql_libs"
321 fi
322 AC_CHECK_HEADER(mysql/mysql.h, [], [
323 have_mysql="no"
324 ])
325 AC_CHECK_LIB([mysqlclient], [mysql_init], [], [
326 have_mysql="no"
327 ])
328 if test "$have_mysql" = "yes"; then
329 selectors="$selectors mysql"
330 server_ldflags="$server_ldflags $mysql_libs -lmysqlclient"
331 server_errlist_objs="$server_errlist_objs mysql_selector"
332 all_errlist_objs="$all_errlist_objs mysql_selector"
333 server_cmdline_objs="$server_cmdline_objs mysql_selector_command_list"
334 AC_SUBST(mysql_cppflags)
335 AC_SUBST(mysql_libs)
336 AC_DEFINE(HAVE_MYSQL, 1, [define to 1 to turn on mysql support])
337 else
338 AC_MSG_WARN([cannot build mysql-based audio file selector])
339 fi
340 CPPFLAGS="$OLD_CPPFLAGS"
341 LDFLAGS="$OLD_LDFLAGS"
342 LIBS="$OLD_LIBS"
343 ########################################################################### ogg
344 have_ogg="yes"
345 OLD_CPPFLAGS="$CPPFLAGS"
346 OLD_LD_FLAGS="$LDFLAGS"
347 OLD_LIBS="$LIBS"
348 AC_ARG_WITH(oggvorbis_headers, [AC_HELP_STRING(--with-oggvorbis-headers=dir,
349 [look for vorbis/codec.h also in dir])])
350 if test -n "$with_oggvorbis_headers"; then
351 oggvorbis_cppflags="-I$with_oggvorbis_headers"
352 CPPFLAGS="$CPPFLAGS $oggvorbis_cppflags"
353 fi
354 AC_ARG_WITH(oggvorbis_libs, [AC_HELP_STRING(--with-oggvorbis-libs=dir,
355 [look for oggvorbis libs also in dir])])
356 if test -n "$with_oggvorbis_libs"; then
357 oggvorbis_libs="-L$with_oggvorbis_libs"
358 LDFLAGS="$LDFLAGS $oggvorbis_libs"
359 fi
360
361 AC_CHECK_LIB([ogg], [ogg_stream_init], [], [ have_ogg="no" ])
362 AC_CHECK_LIB([vorbis], [vorbis_info_init], [], [ have_ogg="no" ])
363 AC_CHECK_HEADERS([ogg/ogg.h vorbis/codec.h], [], [ have_ogg="no" ])
364 if test "$have_ogg" = "yes"; then
365 all_errlist_objs="$all_errlist_objs oggdec ogg_afh"
366 AC_DEFINE(HAVE_OGGVORBIS, 1, define to 1 to turn on ogg vorbis support)
367 filters="$filters oggdec"
368 if test "$OSTYPE" = "Darwin"; then
369 oggvorbis_libs="-Wl,-bind_at_load $oggvorbis_libs"
370 fi
371 server_ldflags="$server_ldflags $oggvorbis_libs -logg -lvorbis -lvorbisfile"
372 filter_ldflags="$filter_ldflags $oggvorbis_libs -lvorbis -lvorbisfile"
373 audiod_ldflags="$audiod_ldflags $oggvorbis_libs -lvorbis -lvorbisfile"
374
375 filter_cmdline_objs="$filter_cmdline_objs oggdec_filter.cmdline"
376 audiod_cmdline_objs="$audiod_cmdline_objs oggdec_filter.cmdline"
377
378 server_errlist_objs="$server_errlist_objs ogg_afh"
379 filter_errlist_objs="$filter_errlist_objs oggdec"
380 audiod_errlist_objs="$audiod_errlist_objs oggdec"
381
382 audiod_audio_formats="ogg"
383 server_audio_formats="$server_audio_formats ogg"
384 filter_filters="$filter_filters oggdec"
385 AC_SUBST(oggvorbis_cppflags)
386 AC_SUBST(oggvorbis_libs)
387 else
388 AC_MSG_WARN([no ogg vorbis support in para_server/para_filter])
389 fi
390 CPPFLAGS="$OLD_CPPFLAGS"
391 LDFLAGS="$OLD_LDFLAGS"
392 LIBS="$OLD_LIBS"
393 ########################################################################### faad
394 have_faad=yes
395 OLD_CPPFLAGS="$CPPFLAGS"
396 OLD_LD_FLAGS="$LDFLAGS"
397 OLD_LIBS="$LIBS"
398 AC_ARG_WITH(faad_headers, [AC_HELP_STRING(--with-faad-headers=dir,
399 [look for neaacdec.h also in dir])])
400 if test -n "$with_faad_headers"; then
401 faad_cppflags="-I$with_faad_headers"
402 CPPFLAGS="$CPPFLAGS $faad_cppflags"
403 fi
404 AC_ARG_WITH(faad_libs, [AC_HELP_STRING(--with-faad-libs=dir,
405 [look for libfaad also in dir])])
406 if test -n "$with_faad_libs"; then
407 faad_libs="-L$with_faad_libs"
408 LDFLAGS="$LDFLAGS $faad_libs"
409 fi
410 AC_CHECK_HEADER(neaacdec.h, [], have_faad=no)
411 AC_CHECK_LIB([faad], [NeAACDecOpen], [], have_faad=no)
412 if test "$have_faad" = "yes"; then
413 AC_DEFINE(HAVE_FAAD, 1, define to 1 if you want to build the aacdec filter)
414 all_errlist_objs="$all_errlist_objs aac_common aacdec aac_afh"
415 filter_errlist_objs="$filter_errlist_objs aacdec aac_common"
416 filter_filters="$filter_filters aacdec"
417 audiod_errlist_objs="$audiod_errlist_objs aacdec aac_common"
418 server_errlist_objs="$server_errlist_objs aac_afh aac_common"
419 server_ldflags="$server_ldflags $faad_libs -lfaad"
420 filter_ldflags="$filter_ldflags $faad_libs -lfaad"
421 audiod_ldflags="$audiod_ldflags $faad_libs -lfaad"
422 audiod_audio_formats="$audiod_audio_formats aac"
423 server_audio_formats="$server_audio_formats aac"
424 filters="$filters aacdec"
425 AC_SUBST(faad_cppflags)
426 AC_SUBST(faad_libs)
427 else
428 AC_MSG_WARN([no aac support in para_audiod/para_filter])
429 fi
430 CPPFLAGS="$OLD_CPPFLAGS"
431 LDFLAGS="$OLD_LDFLAGS"
432 LIBS="$OLD_LIBS"
433 ########################################################################### mad
434 have_mad="yes"
435 OLD_CPPFLAGS="$CPPFLAGS"
436 OLD_LD_FLAGS="$LDFLAGS"
437 OLD_LIBS="$LIBS"
438
439 AC_ARG_WITH(mad_headers, [AC_HELP_STRING(--with-mad-headers=dir,
440 [look for mad.h also in dir])])
441 if test -n "$with_mad_headers"; then
442 mad_cppflags="-I$with_mad_headers"
443 CPPFLAGS="$CPPFLAGS $mad_cppflags"
444 fi
445 AC_ARG_WITH(mad_libs, [AC_HELP_STRING(--with-mad-libs=dir,
446 [look for libmad also in dir])])
447 if test -n "$with_mad_libs"; then
448 mad_libs="-L$with_mad_libs"
449 LDFLAGS="$LDFLAGS $mad_libs"
450 fi
451 AC_CHECK_HEADERS([mad.h], [], [
452 have_mad="no"
453 ])
454 AC_CHECK_LIB([mad], [mad_stream_init], [], [
455 have_mad="no"
456 ])
457 if test "$have_mad" = "yes"; then
458 AC_DEFINE(HAVE_MAD, 1, define to 1 if you want to build the mp3dec filter)
459 all_errlist_objs="$all_errlist_objs mp3dec"
460 filter_errlist_objs="$filter_errlist_objs mp3dec"
461 audiod_errlist_objs="$audiod_errlist_objs mp3dec"
462 filter_ldflags="$filter_ldflags $mad_libs -lmad"
463 audiod_ldflags="$audiod_ldflags $mad_libs -lmad"
464 audiod_audio_formats="$audiod_audio_formats mp3"
465 filters="$filters mp3dec"
466 AC_SUBST(mad_cppflags)
467 AC_SUBST(mad_libs)
468 else
469 AC_MSG_WARN([no mp3dec support in para_audiod/para_filter])
470 fi
471 if test -n "$audiod_audio_formats"; then
472 extras="$extras para_audiod"
473 else
474 AC_MSG_WARN([can not build para_audiod (no supported audio formats)])
475 fi
476 CPPFLAGS="$OLD_CPPFLAGS"
477 LDFLAGS="$OLD_LDFLAGS"
478 LIBS="$OLD_LIBS"
479 ########################################################################### alsa
480 have_alsa="yes"
481 OLD_CPPFLAGS="$CPPFLAGS"
482 OLD_LD_FLAGS="$LDFLAGS"
483 OLD_LIBS="$LIBS"
484 msg="=> no alsa support for para_audiod/para_write"
485 AC_CHECK_HEADERS([alsa/asoundlib.h], [], [
486 AC_MSG_WARN([no alsa/asoundlib $msg])
487 have_alsa="no"
488 ])
489 AC_CHECK_LIB([asound], [snd_pcm_open], [], [
490 AC_MSG_WARN([no libasound $msg])
491 have_alsa="no"
492 ])
493 if test "$have_alsa" = "yes"; then
494 all_errlist_objs="$all_errlist_objs alsa_write"
495 audiod_errlist_objs="$audiod_errlist_objs alsa_write"
496 audiod_cmdline_objs="$audiod_cmdline_objs alsa_write.cmdline"
497 audiod_ldflags="$audiod_ldflags -lasound"
498
499 write_errlist_objs="$write_errlist_objs alsa_write"
500 write_cmdline_objs="$write_cmdline_objs alsa_write.cmdline"
501 write_ldflags="$write_ldflags -lasound"
502 writers="$writers alsa"
503 default_writer="ALSA_WRITE"
504 fi
505 CPPFLAGS="$OLD_CPPFLAGS"
506 LDFLAGS="$OLD_LDFLAGS"
507 LIBS="$OLD_LIBS"
508 ########################################################################### ortp
509 have_ortp="yes"
510 OLD_CPPFLAGS="$CPPFLAGS"
511 OLD_LD_FLAGS="$LDFLAGS"
512 OLD_LIBS="$LIBS"
513 AC_ARG_WITH(ortp_headers, [AC_HELP_STRING(--with-ortp-headers=dir,
514 [look for ortp/ortp.h also in dir])])
515 if test -n "$with_ortp_headers"; then
516 ortp_cppflags="-I$with_ortp_headers"
517 CPPFLAGS="$CPPFLAGS $ortp_cppflags"
518 fi
519 AC_ARG_WITH(ortp_libs, [AC_HELP_STRING(--with-ortp-libs=dir,
520 [look for libortp also in dir])])
521 if test -n "$with_ortp_libs"; then
522 ortp_libs="-L$with_ortp_libs"
523 LDFLAGS="$LDFLAGS $ortp_libs"
524 fi
525 AC_CHECK_HEADERS([ortp/ortp.h], [], [have_ortp="no"])
526 AC_CHECK_LIB([ortp], [ortp_init], [], [have_ortp="no"])
527 if test "$have_ortp" = "yes"; then
528 all_errlist_objs="$all_errlist_objs ortp_recv ortp_send"
529
530 recv_cmdline_objs="$recv_cmdline_objs ortp_recv.cmdline"
531 recv_errlist_objs="$recv_errlist_objs ortp_recv"
532
533 audiod_cmdline_objs="$audiod_cmdline_objs ortp_recv.cmdline"
534 audiod_errlist_objs="$audiod_errlist_objs ortp_recv"
535
536 server_errlist_objs="$server_errlist_objs ortp_send"
537
538 recv_ldflags="$recv_ldflags $ortp_libs -lortp"
539 server_ldflags="$server_ldflags $ortp_libs -lortp"
540 audiod_ldflags="$audiod_ldflags $ortp_libs -lortp"
541
542 receivers="$receivers ortp"
543 senders="$senders ortp"
544 AC_DEFINE(HAVE_ORTP, 1, [define to 1 to turn on ortp support])
545 AC_SUBST(ortp_cppflags)
546 AC_SUBST(ortp_libs)
547 else
548 AC_MSG_NOTICE([deactivating ortp sender/receiver])
549 fi
550 CPPFLAGS="$OLD_CPPFLAGS"
551 LDFLAGS="$OLD_LDFLAGS"
552 LIBS="$OLD_LIBS"
553 ########################################################################### zmw
554 build_slider="yes"
555 OLD_CPPFLAGS="$CPPFLAGS"
556 OLD_LD_FLAGS="$LDFLAGS"
557 OLD_LIBS="$LIBS"
558 PKG_CHECK_MODULES(GTK, [$pkg_modules], [], [build_para_slider="no"])
559 PKG_CHECK_MODULES(GLIB, [glib-2.0 >= 2.0.4], [], [build_slider="no"])
560 CPPFLAGS="$GTK_CFLAGS $GLIB_CFLAGS"
561 LDFLAGS="$LDFLAGS $GTK_LIBS"
562 AC_CHECK_HEADERS([zmw/zmw.h], [], [build_slider="no"])
563 AC_CHECK_LIB([zmw], [zmw_init], [], [build_slider="no"])
564 if test "$build_slider" = "no"; then
565 AC_MSG_WARN([will not build para_slider])
566 else
567 extras="$extras para_slider"
568 fi
569 CPPFLAGS="$OLD_CPPFLAGS"
570 LDFLAGS="$OLD_LDFLAGS"
571 LIBS="$OLD_LIBS"
572
573
574
575
576
577 AC_SUBST(extra_binaries, [$extras])
578 AC_SUBST(extra_filter_objs, [$extra_filter_objs])
579 AC_SUBST(extra_filter_libs, [$extra_filter_libs])
580 AC_SUBST(install_sh, [$INSTALL])
581 AC_CONFIG_FILES([Makefile])
582
583
584
585 AC_DEFUN([add_dot_o],[$(for i in $@; do printf "$i.o "; done)])
586 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) }])
587
588 AC_DEFUN([define_safe_error_enums],
589 [
590 exe=""
591 for i in $all_executables; do
592 # eval echo checking if $1 is linked into $i
593 for j in $(eval echo \$${i}_errlist_objs); do
594 if test $j = $1; then
595 exe="$exe $i"
596 break;
597 fi
598 done
599 done
600 #echo "$1 gets linked into $exe"
601 safe_errlists=""
602 for i in $all_errlist_objs; do
603 for j in $exe; do
604 found=0
605 for k in $(eval echo \$${j}_errlist_objs); do
606 if test $k = $i; then
607 found=1
608 break;
609 fi
610 done
611 if test $found -eq 0; then
612 break;
613 fi
614 done
615 if test $found -eq 1; then
616 safe_errlists="$safe_errlists $i"
617 fi
618 done
619 #echo "safe errlists for $1: $safe_errlists"
620 ss_defs=""
621 for i in $safe_errlists; do
622 echo "SS_ENUM($(echo $i | tr 'a-z' 'A-Z'));"
623 done
624 ]
625 )
626
627 AC_MSG_NOTICE(creating error2.h)
628 for obj in $all_errlist_objs; do
629 SS="$SS SS_$(echo $obj | tr 'a-z' 'A-Z'),"
630 echo "#ifdef MAIN_INPUT_FILE_IS_$obj"
631 define_safe_error_enums($obj)
632 echo "#endif"
633 done > error2.h
634 AC_DEFINE_UNQUOTED(DEFINE_ERRLIST_OBJECT_ENUM,
635 [enum {$SS NUM_SS}],
636 [list of all objects that use paraslash's error facility]
637 )
638
639
640 recv_objs="$recv_cmdline_objs $recv_errlist_objs"
641 filter_objs="$filter_cmdline_objs $filter_errlist_objs"
642 audiod_objs="$audiod_cmdline_objs $audiod_errlist_objs"
643 server_objs="$server_cmdline_objs $server_errlist_objs"
644 write_objs="$write_cmdline_objs $write_errlist_objs"
645 client_objs="$client_cmdline_objs $client_errlist_objs"
646 fsck_objs="$fsck_cmdline_objs $fsck_errlist_objs"
647 audioc_objs="$audioc_cmdline_objs $audioc_errlist_objs"
648
649 AC_SUBST(recv_objs, add_dot_o($recv_objs))
650 AC_SUBST(recv_ldflags, $recv_ldflags)
651 AC_DEFINE_UNQUOTED(INIT_RECV_ERRLISTS, objlist_to_errlist($recv_errlist_objs),
652 errors used by para_recv)
653
654 AC_SUBST(filter_objs, add_dot_o($filter_objs))
655 AC_SUBST(filter_ldflags, $filter_ldflags)
656 AC_DEFINE_UNQUOTED(INIT_FILTER_ERRLISTS,
657 objlist_to_errlist($filter_errlist_objs), errors used by para_filter)
658
659 AC_SUBST(audiod_objs, add_dot_o($audiod_objs))
660 AC_SUBST(audiod_ldflags, $audiod_ldflags)
661 AC_DEFINE_UNQUOTED(INIT_AUDIOD_ERRLISTS, objlist_to_errlist($audiod_errlist_objs),
662 errors used by para_audiod)
663
664 AC_SUBST(server_objs, add_dot_o($server_objs))
665 AC_SUBST(server_ldflags, $server_ldflags)
666 AC_DEFINE_UNQUOTED(INIT_SERVER_ERRLISTS,
667 objlist_to_errlist($server_errlist_objs), errors used by para_server)
668
669 AC_SUBST(write_objs, add_dot_o($write_objs))
670 AC_SUBST(write_ldflags, $write_ldflags)
671 AC_DEFINE_UNQUOTED(INIT_WRITE_ERRLISTS,
672 objlist_to_errlist($write_errlist_objs), errors used by para_write)
673
674 AC_SUBST(client_objs, add_dot_o($client_objs))
675 AC_SUBST(client_ldflags, $client_ldflags)
676 AC_DEFINE_UNQUOTED(INIT_CLIENT_ERRLISTS,
677 objlist_to_errlist($client_errlist_objs), errors used by para_client)
678
679 AC_SUBST(fsck_objs, add_dot_o($fsck_objs))
680 AC_SUBST(fsck_ldflags, $fsck_ldflags)
681 AC_DEFINE_UNQUOTED(INIT_FSCK_ERRLISTS,
682 objlist_to_errlist($fsck_errlist_objs), errors used by para_fsck)
683
684 AC_SUBST(audioc_objs, add_dot_o($audioc_objs))
685 AC_SUBST(audioc_ldflags, $audioc_ldflags)
686 AC_DEFINE_UNQUOTED(INIT_AUDIOC_ERRLISTS,
687 objlist_to_errlist($audioc_errlist_objs), errors used by para_audioc)
688
689 AC_SUBST(gui_objs, add_dot_o($gui_objs))
690 AC_DEFINE_UNQUOTED(INIT_GUI_ERRLISTS,
691 objlist_to_errlist($gui_errlist_objs), errors used by para_gui)
692
693 enum="$(for i in $writers; do printf "${i}_WRITE, " | tr '[a-z]' '[A-Z]'; done)"
694 AC_DEFINE_UNQUOTED(WRITER_ENUM, $enum NUM_SUPPORTED_WRITERS,
695 enum of supported writers)
696 AC_DEFINE_UNQUOTED(DEFAULT_WRITER, $default_writer, use this writer if none was specified)
697 names="$(for i in $writers; do printf \"$i\",' ' ; done)"
698 AC_DEFINE_UNQUOTED(WRITER_NAMES, $names, supported writer names)
699 inits="$(for i in $writers; do printf 'extern void '$i'_write_init(struct writer *); '; done)"
700 AC_DEFINE_UNQUOTED(DECLARE_WRITER_INITS, $inits, init functions of the supported writers)
701 array="$(for i in $writers; do printf '{.init = '$i'_write_init},'; done)"
702 AC_DEFINE_UNQUOTED(WRITER_ARRAY, $array, array of supported writers)
703 enum="$(for i in $audiod_audio_formats; do printf "AUDIO_FORMAT_${i}, " | tr '[a-z]' '[A-Z]'; done)"
704 AC_DEFINE_UNQUOTED(AUDIOD_AUDIO_FORMATS_ENUM, $enum NUM_AUDIO_FORMATS,
705 enum of audio formats supported by audiod)
706 names="$(for i in $audiod_audio_formats; do printf \"$i\",' ' ; done)"
707 AC_DEFINE_UNQUOTED(AUDIOD_AUDIO_FORMAT_ARRAY, $names, array of audio formats supported by audiod)
708
709 AC_OUTPUT
710 AC_MSG_NOTICE([creating Makefile.deps])
711 gcc -MM -MG $mysql_cppflags $faad_cppflags $mad_cppflags $ortp_cppflags $oggvorbis_cppflags *.c > Makefile.deps
712 AC_MSG_NOTICE([
713 paraslash configuration:
714 ~~~~~~~~~~~~~~~~~~~~~~~~
715 unix socket credentials: $have_ucred
716 audio file selectors supported by para_server: $selectors
717 audio formats supported by para_server: $server_audio_formats
718 senders supported by para_server/para_send: $senders
719 receivers supported by para_audiod/para_recv: $receivers
720 filters supported by para_audiod/para_filter: $filters
721 writers supported by para_audiod/para_write: $writers
722 optional executables: $extras
723 ])