doxify stdout.c
[paraslash.git] / configure.ac
1 #                                               -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
3
4 AC_PREREQ(2.53)
5
6
7 AC_INIT(paraslash, [git], maan@systemlinux.org)
8 AC_CONFIG_HEADER([config.h])
9
10 ########################################################################### generic
11 AC_PROG_CC
12 AC_PROG_CPP
13 AC_PROG_INSTALL
14
15 AC_HEADER_DIRENT
16 AC_HEADER_STDC
17 AC_HEADER_SYS_WAIT
18 AC_CHECK_HEADERS([arpa/inet.h ctype.h fcntl.h limits.h netdb.h netinet/in.h stdlib.h \
19         string.h sys/socket.h sys/time.h sys/timeb.h sys/un.h sys/ipc.h unistd.h utime.h malloc.h], \
20         [], [AC_MSG_ERROR([$ac_header not found])])
21
22 AC_CHECK_HEADER(linux/soundcard.h, [extras="$extras para_fade"], 
23         [AC_MSG_WARN([linux/soundcard.h not found, \
24         cannot build para_fade])])
25
26 # Checks for typedefs, structures, and compiler characteristics.
27 AC_C_CONST
28 AC_TYPE_OFF_T
29 AC_TYPE_PID_T
30 AC_TYPE_SIZE_T
31 AC_HEADER_TIME
32 AC_STRUCT_TM
33
34 # Checks for library functions.
35 AC_FUNC_FORK
36 AC_PROG_GCC_TRADITIONAL
37 AC_FUNC_MALLOC
38 AC_FUNC_MEMCMP
39 AC_FUNC_MKTIME
40 AC_FUNC_MMAP
41 AC_FUNC_REALLOC
42 AC_FUNC_SELECT_ARGTYPES
43 AC_TYPE_SIGNAL
44 AC_FUNC_STAT
45 AC_FUNC_STRFTIME
46 AC_FUNC_VPRINTF
47 AC_CHECK_FUNCS([atexit dup2 gethostbyname inet_ntoa memchr memmove memset \
48         regcomp select socket strchr strdup strerror strstr strtol uname], [], 
49         [AC_MSG_ERROR([function not found, cannot live without it])])
50 ########################################################################### curses
51 AC_CHECK_LIB([ncurses], [initscr], [], 
52         [AC_MSG_ERROR([libncurses not found])])
53
54 AC_CHECK_LIB([menu], [new_menu], [extras="$extras para_dbadm"],
55         [AC_MSG_WARN([libmenu not found,  cannot build para_dbadm])])
56
57
58 recv_cmdline_objs="recv.cmdline http_recv.cmdline dccp_recv.cmdline"
59 recv_errlist_objs="http_recv recv_common recv time string net dccp_recv
60         dccp fd sched stdout"
61 recv_ldflags=""
62
63 filter_cmdline_objs="filter.cmdline compress_filter.cmdline"
64 filter_errlist_objs="filter_chain wav compress filter string stdin stdout sched fd"
65 filter_ldflags=""
66
67 audioc_cmdline_objs="audioc.cmdline"
68 audioc_errlist_objs="audioc string net fd"
69
70 audiod_cmdline_objs="audiod.cmdline grab_client.cmdline compress_filter.cmdline
71         http_recv.cmdline dccp_recv.cmdline file_write.cmdline"
72 audiod_errlist_objs="audiod exec close_on_fork signal string daemon stat net
73         time grab_client filter_chain wav compress http_recv dccp dccp_recv
74         recv_common fd sched write_common file_writer audiod_command"
75 audiod_ldflags=""
76
77 server_cmdline_objs="server.cmdline"
78 server_errlist_objs="server mp3_afh afs command net string signal random_selector
79         time daemon stat crypt http_send db close_on_fork playlist_selector
80         ipc dccp dccp_send fd"
81 server_ldflags=""
82
83 write_cmdline_objs="write.cmdline file_write.cmdline"
84 write_errlist_objs="write write_common file_writer time fd string sched stdin"
85 write_ldflags=""
86 write_writers="file"
87
88 client_cmdline_objs="client.cmdline"
89 client_errlist_objs="client net string crypt fd sched stdin stdout"
90 client_ldflags=""
91
92 ########################################################################### ssl
93 dnl @synopsis CHECK_SSL
94 dnl
95 dnl based on the follwing macro from the autoconf archive
96 dnl
97 dnl @category InstalledPackages
98 dnl @author Mark Ethan Trostler <trostler@juniper.net>
99 dnl @version 2003-01-28
100 dnl @license AllPermissive
101
102 AC_DEFUN([CHECK_SSL],
103 [
104         for ssldir in $1 /usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr; do
105                 AC_MSG_CHECKING(for openssl in $ssldir)
106                 if test -f "$ssldir/include/openssl/ssl.h"; then
107                         found_ssl="yes"
108                         AC_MSG_RESULT(yes)
109                         SSL_CFLAGS="-I$ssldir/include/openssl"
110                         SSL_CPPFLAGS="-I$ssldir/include/openssl"
111                         break
112                 fi
113                 if test -f "$ssldir/include/ssl.h"; then
114                         found_ssl="yes";
115                         AC_MSG_RESULT(yes)
116                         SSL_CFLAGS="-I$ssldir/include/";
117                         SSL_CPPFLAGS="-I$ssldir/include/";
118                         break
119                 fi
120                 AC_MSG_RESULT(no)
121         done
122         if test x_$found_ssl != x_yes; then
123                 AC_MSG_ERROR(Cannot find ssl libraries)
124         else
125                 SSL_LIBS="-lssl -lcrypto";
126                 SSL_LDFLAGS="-L$ssldir/lib";
127         fi
128         AC_SUBST(SSL_CPPFLAGS)
129         AC_SUBST(SSL_CFLAGS)
130         AC_SUBST(SSL_LIBS)
131         AC_SUBST(SSL_LDFLAGS)
132 ])dnl
133
134 AC_ARG_ENABLE(ssldir, [AS_HELP_STRING(--enable-ssldir=path,
135         [Search for openssl also in path.])])
136 if test "$enable_ssldir" = "yes"; then enable_ssldir=""; fi
137 CHECK_SSL($enable_ssldir)
138 server_ldflags="$srver_ldflags $SSL_LDFLAGS $SSL_LIBS"
139 client_ldflags="$client_ldflags $SSL_LDFLAGS $SSL_LIBS"
140
141 ########################################################################### ucred
142
143 AC_MSG_CHECKING(for struct ucred)
144 AC_TRY_LINK([
145         #include <sys/types.h>
146         #include <sys/socket.h>
147 ],[
148         struct ucred sucred; sucred.pid=0;
149 ],[have_ucred=yes],[have_ucred=no])
150 AC_MSG_RESULT($have_ucred)
151 if test ${have_ucred} = yes; then
152         AC_DEFINE(HAVE_UCRED, 1, define to 1 you have struct ucred)
153 fi
154
155 ########################################################################### gtk2
156
157 pkg_modules="gtk+-2.0 >= 2.0.0"
158 PKG_CHECK_MODULES(GTK, [$pkg_modules], [extras="$extras para_krell.so"], [
159         AC_MSG_WARN([gtk+-2 not found, can not build para_krell])
160 ])
161 AC_SUBST(GTK_CFLAGS)
162 AC_SUBST(GTK_LIBS)
163
164 ########################################################################### sdl
165 AC_CHECK_LIB([SDL_image], [SDL_Init], [extras="$extras para_sdl_gui"], [
166         AC_MSG_WARN([libSDL_image not found, cannot build para_sdl_gui])
167 ])
168 AC_CHECK_HEADER(SDL/SDL.h, [], 
169         [AC_MSG_WARN([SDL/SDL.h not found])])
170
171 ########################################################################### mysql
172 have_mysql="yes"
173 AC_ARG_ENABLE(mysql_headers, [AC_HELP_STRING(--enable-mysql-headers=dir,
174         [look for mysql.h also in dir])])
175 if test -n "$enable_mysql_headers"; then
176         mysql_cppflags="-I$enable_mysql_headers"
177         CPPFLAGS="$CPPFLAGS $mysql_cppflags"
178 fi
179 AC_ARG_ENABLE(mysql_libs, [AC_HELP_STRING(--enable-mysql-libs=dir,
180         [look for libmysqlclient also in dir])])
181 if test -n "$enable_mysql_libs"; then
182         mysql_libs="-L$enable_mysql_libs"
183         LDFLAGS="$LDFLAGS $mysql_libs"
184 fi
185 AC_CHECK_HEADER(mysql/mysql.h, [], [
186         have_mysql="no"
187 ])
188 AC_CHECK_LIB([mysqlclient], [mysql_init], [], [
189         have_mysql="no"
190 ])
191 if test "$have_mysql" = "yes"; then
192         server_ldflags="$server_ldflags $mysql_libs -lmysqlclient"
193         server_errlist_objs="$server_errlist_objs mysql_selector"
194         AC_SUBST(mysql_cppflags)
195         AC_SUBST(mysql_libs)
196         AC_DEFINE(HAVE_MYSQL, 1, [define to 1 to turn on mysql support])
197 else
198         AC_MSG_WARN([cannot build mysql-based audio file selector])
199 fi
200 ########################################################################### ogg
201 have_ogg="yes"
202 AC_CHECK_LIB([ogg], [ogg_stream_init], [], [
203         have_ogg="no"
204 ])
205 AC_CHECK_LIB([vorbis], [vorbis_info_init], [], [
206         have_ogg="no"
207 ])
208 AC_CHECK_HEADERS([ogg/ogg.h vorbis/codec.h], [], [
209         have_ogg="no"
210 ])
211 if test "$have_ogg" = "yes"; then
212         AC_DEFINE(HAVE_OGGVORBIS, 1, define to 1 to turn on ogg vorbis support)
213         server_ldflags="$server_ldflags -logg -lvorbis -lvorbisfile"
214         filter_ldflags="$filter_ldflags -lvorbis -lvorbisfile"
215         audiod_ldflags="$audiod_ldflags -lvorbis -lvorbisfile"
216
217         filter_cmdline_objs="$filter_cmdline_objs oggdec_filter.cmdline"
218         audiod_cmdline_objs="$audiod_cmdline_objs oggdec_filter.cmdline"
219
220         server_errlist_objs="$server_errlist_objs ogg_afh"
221         filter_errlist_objs="$filter_errlist_objs oggdec"
222         audiod_errlist_objs="$audiod_errlist_objs oggdec"
223 else
224         AC_MSG_WARN([no ogg vorbis support in para_server/para_filter])
225 fi
226 ########################################################################### faad
227 have_faad=yes
228 AC_ARG_ENABLE(faad_headers, [AC_HELP_STRING(--enable-faad-headers=dir,
229         [look for neaacdec.h also in dir])])
230 if test -n "$enable_faad_headers"; then
231         faad_cppflags="-I$enable_faad_headers"
232         CPPFLAGS="$CPPFLAGS $faad_cppflags"
233 fi
234 AC_ARG_ENABLE(faad_libs, [AC_HELP_STRING(--enable-fadd-libs=dir,
235         [look for libfaad also in dir])])
236 if test -n "$enable_faad_libs"; then
237         faad_libs="-L$enable_faad_libs"
238         LDFLAGS="$LDFLAGS $faad_libs"
239 fi
240 AC_CHECK_HEADER(neaacdec.h, [], have_faad=no)
241 AC_CHECK_LIB([faad], [NeAACDecOpen], [], have_faad=no)
242 if test "$have_faad" = "yes"; then
243         AC_DEFINE(HAVE_FAAD, 1, define to 1 if you want to build the aacdec filter)
244         filter_errlist_objs="$filter_errlist_objs aacdec aac_common"
245         audiod_errlist_objs="$audiod_errlist_objs aacdec aac_common"
246         server_errlist_objs="$server_errlist_objs aac_afh aac_common"
247         server_ldflags="$server_ldflags $faad_libs -lfaad"
248         filter_ldflags="$filter_ldflags $faad_libs -lfaad"
249         audiod_ldflags="$audiod_ldflags $faad_libs -lfaad"
250         AC_SUBST(faad_cppflags)
251         AC_SUBST(faad_libs)
252 else
253         AC_MSG_WARN([no aac support in para_audiod/para_filter])
254 fi
255 ########################################################################### mad
256 have_mad="yes"
257 AC_CHECK_HEADERS([mad.h], [], [
258         have_mad="no"
259 ])
260 AC_CHECK_LIB([mad], [mad_stream_init], [], [
261         have_mad="no"
262 ])
263 if test "$have_mad" = "yes"; then
264         AC_DEFINE(HAVE_MAD, 1, define to 1 if you want to build the mp3dec filter)
265         filter_errlist_objs="$filter_errlist_objs mp3dec"
266         audiod_errlist_objs="$audiod_errlist_objs mp3dec"
267         filter_ldflags="$filter_ldflags -lmad"
268         audiod_ldflags="$audiod_ldflags -lmad"
269 else
270         AC_MSG_WARN([no mp3dec support in para_audiod/para_filter])
271 fi
272 ########################################################################### alsa
273 have_alsa="yes"
274 msg="=> no alsa support for para_audiod/para_write"
275 AC_CHECK_HEADERS([alsa/asoundlib.h], [], [
276         AC_MSG_WARN([no alsa/asoundlib $msg])
277         have_alsa="no"
278 ])
279 AC_CHECK_LIB([asound], [snd_pcm_open], [], [
280         AC_MSG_WARN([no libasound $msg])
281         have_alsa="no"
282 ])
283 if test "$have_alsa" = "yes"; then
284         audiod_errlist_objs="$audiod_errlist_objs alsa_writer"
285         audiod_cmdline_objs="$audiod_cmdline_objs alsa_write.cmdline"
286         audiod_ldflags="$audiod_ldflags -lasound"
287
288         write_errlist_objs="$write_errlist_objs alsa_writer"
289         write_cmdline_objs="$write_cmdline_objs alsa_write.cmdline"
290         write_ldflags="$write_ldflags -lasound"
291         write_writers="$write_writers alsa"
292 fi
293 ########################################################################### ortp
294 have_ortp="yes"
295 AC_ARG_ENABLE(ortp, AC_HELP_STRING([--disable-ortp], [Disable ortp support]),
296         if test x$enableval = xno; then
297                 have_ortp=no
298         fi
299 )
300 if test "$have_ortp" = "yes"; then
301         AC_CHECK_HEADERS([ortp/ortp.h], [], [
302                 have_ortp="no"
303         ])
304         AC_CHECK_LIB([ortp], [ortp_init], [], [
305                 have_ortp="no"
306         ])
307 fi
308 if test "$have_ortp" = "yes"; then
309         recv_cmdline_objs="$recv_cmdline_objs ortp_recv.cmdline"
310         recv_errlist_objs="$recv_errlist_objs ortp_recv"
311
312         audiod_cmdline_objs="$audiod_cmdline_objs ortp_recv.cmdline"
313         audiod_errlist_objs="$audiod_errlist_objs ortp_recv"
314
315         server_errlist_objs="$server_errlist_objs ortp_send"
316
317         recv_ldflags="$recv_ldflags -lortp"
318         server_ldflags="$server_ldflags -lortp"
319         audiod_ldflags="$audiod_ldflags -lortp"
320         AC_DEFINE(HAVE_ORTP, 1, [define to 1 to turn on ortp support])
321
322 else
323         AC_MSG_NOTICE([deactivating ortp support])
324 fi
325 AC_SUBST(GLIB_CFLAGS)
326 AC_SUBST(GLIB_LIBS)
327
328 ########################################################################### zmw
329 slide="para_slider"
330 msg="can not build para_slider"
331 CPPFLAGS="$GTK_CFLAGS"
332 LDFLAGS="$LDFLAGS $GTK_LIBS"
333 AC_CHECK_HEADERS([zmw/zmw.h], [], [
334         AC_MSG_WARN([zero memory widget header files not found, $msg])
335         slide=""
336 ])
337 AC_CHECK_LIB([zmw], [zmw_init], [], [
338         AC_MSG_WARN([zero memory widget library not found, $msg])
339         slide=""
340 ])
341 extras="$extras $slide"
342
343
344
345
346
347 AC_SUBST(extra_binaries, [$extras])
348 AC_SUBST(extra_filter_objs, [$extra_filter_objs])
349 AC_SUBST(extra_filter_libs, [$extra_filter_libs])
350 AC_SUBST(install_sh, [$INSTALL])
351 AC_CONFIG_FILES([Makefile])
352
353
354
355 AC_DEFUN([add_dot_o],[$(for i in $@; do printf "$i.o "; done)])
356 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) }])
357
358 recv_objs="$recv_cmdline_objs $recv_errlist_objs"
359 filter_objs="$filter_cmdline_objs $filter_errlist_objs"
360 audiod_objs="$audiod_cmdline_objs $audiod_errlist_objs"
361 server_objs="$server_cmdline_objs $server_errlist_objs"
362 write_objs="$write_cmdline_objs $write_errlist_objs"
363 client_objs="$client_cmdline_objs $client_errlist_objs"
364 audioc_objs="$audioc_cmdline_objs $audioc_errlist_objs"
365
366 AC_SUBST(recv_objs, add_dot_o($recv_objs))
367 AC_SUBST(recv_ldflags, $recv_ldflags)
368 AC_DEFINE_UNQUOTED(INIT_RECV_ERRLISTS, objlist_to_errlist($recv_errlist_objs),
369         errors used by para_recv)
370
371 AC_SUBST(filter_objs, add_dot_o($filter_objs))
372 AC_SUBST(filter_ldflags, $filter_ldflags)
373 AC_DEFINE_UNQUOTED(INIT_FILTER_ERRLISTS,
374         objlist_to_errlist($filter_errlist_objs), errors used by para_filter)
375
376 AC_SUBST(audiod_objs, add_dot_o($audiod_objs))
377 AC_SUBST(audiod_ldflags, $audiod_ldflags)
378 AC_DEFINE_UNQUOTED(INIT_AUDIOD_ERRLISTS, objlist_to_errlist($audiod_errlist_objs),
379         errors used by para_audiod)
380
381 AC_SUBST(server_objs, add_dot_o($server_objs))
382 AC_SUBST(server_ldflags, $server_ldflags)
383 AC_DEFINE_UNQUOTED(INIT_SERVER_ERRLISTS,
384         objlist_to_errlist($server_errlist_objs), errors used by para_server)
385
386 AC_SUBST(write_objs, add_dot_o($write_objs))
387 AC_SUBST(write_ldflags, $write_ldflags)
388 AC_DEFINE_UNQUOTED(INIT_WRITE_ERRLISTS,
389         objlist_to_errlist($write_errlist_objs), errors used by para_write)
390
391 AC_SUBST(client_objs, add_dot_o($client_objs))
392 AC_SUBST(client_ldflags, $client_ldflags)
393 AC_DEFINE_UNQUOTED(INIT_CLIENT_ERRLISTS,
394         objlist_to_errlist($client_errlist_objs), errors used by para_client)
395
396 AC_SUBST(audioc_objs, add_dot_o($audioc_objs))
397 AC_DEFINE_UNQUOTED(INIT_AUDIOC_ERRLISTS,
398         objlist_to_errlist($audioc_errlist_objs), errors used by para_audioc)
399
400 enum="$(for i in $write_writers; do printf "${i}_WRITE, " | tr '[a-z]' '[A-Z]'; done)"
401 AC_DEFINE_UNQUOTED(WRITER_ENUM, $enum NUM_SUPPORTED_WRITERS,
402         enum of supported writers)
403 names="$(for i in $write_writers; do printf \"$i\",' ' ; done)"
404 AC_DEFINE_UNQUOTED(WRITER_NAMES, $names, supported writer names)
405 inits="$(for i in $write_writers; do printf 'extern void '$i'_writer_init(struct writer *); '; done)"
406 AC_DEFINE_UNQUOTED(DECLARE_WRITER_INITS, $inits, init functions of the supported writers)
407 array="$(for i in $write_writers; do printf '{.init = '$i'_writer_init},'; done)"
408 AC_DEFINE_UNQUOTED(WRITER_ARRAY, $array, array of supported writers)
409
410 gui_cmdline_objs="gui.cmdline"
411 gui_errlist_objs="exec close_on_fork signal string stat ringbuffer fd"
412 gui_other_objs="gui gui_common gui_theme"
413 gui_objs="$gui_cmdline_objs $gui_errlist_objs $gui_other_objs"
414 AC_DEFINE_UNQUOTED(INIT_GUI_ERRLISTS,
415         objlist_to_errlist($gui_errlist_objs), errors used by para_gui)
416 AC_SUBST(gui_objs, add_dot_o($gui_objs))
417
418 AC_OUTPUT
419 AC_MSG_NOTICE([creating Makefile.deps])
420 gcc -MM -MG $mysql_cppflags $faad_cppflags *.c > Makefile.deps
421 AC_MSG_NOTICE([
422 paraslash configuration:
423 ~~~~~~~~~~~~~~~~~~~~~~~~
424 mysql support: $have_mysql
425 ogg vorbis support: $have_ogg
426 mp3dec support (libmad): $have_mad
427 aac support (libfaad): $have_faad
428 ortp support: $have_ortp
429 unix socket credentials: $have_ucred
430 supported writers for para_write: $write_writers
431 ])