aacdec: detect buffer overrun and return an errror.
[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 audiod_cmdline_objs="audiod.cmdline grab_client.cmdline compress_filter.cmdline
68 http_recv.cmdline dccp_recv.cmdline file_write.cmdline"
69 audiod_errlist_objs="audiod exec close_on_fork signal string daemon stat net
70 time grab_client filter_chain wav compress http_recv dccp dccp_recv
71 recv_common fd sched write_common file_writer"
72 audiod_ldflags=""
73
74 server_cmdline_objs="server.cmdline"
75 server_errlist_objs="server mp3_afh afs command net string signal random_selector
76 time daemon stat crypt http_send db close_on_fork playlist_selector
77 ipc dccp dccp_send fd"
78 server_ldflags=""
79
80 write_cmdline_objs="write.cmdline file_write.cmdline"
81 write_errlist_objs="write write_common file_writer time fd string sched stdin"
82 write_ldflags=""
83 write_writers="file"
84
85
86 ########################################################################### ssl
87 dnl @synopsis CHECK_SSL
88 dnl
89 dnl based on the follwing macro from the autoconf archive
90 dnl
91 dnl @category InstalledPackages
92 dnl @author Mark Ethan Trostler <trostler@juniper.net>
93 dnl @version 2003-01-28
94 dnl @license AllPermissive
95
96 AC_DEFUN([CHECK_SSL],
97 [
98 for ssldir in $1 /usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr; do
99 AC_MSG_CHECKING(for openssl in $ssldir)
100 if test -f "$ssldir/include/openssl/ssl.h"; then
101 found_ssl="yes"
102 AC_MSG_RESULT(yes)
103 SSL_CFLAGS="-I$ssldir/include/openssl"
104 SSL_CPPFLAGS="-I$ssldir/include/openssl"
105 break
106 fi
107 if test -f "$ssldir/include/ssl.h"; then
108 found_ssl="yes";
109 AC_MSG_RESULT(yes)
110 SSL_CFLAGS="-I$ssldir/include/";
111 SSL_CPPFLAGS="-I$ssldir/include/";
112 break
113 fi
114 AC_MSG_RESULT(no)
115 done
116 if test x_$found_ssl != x_yes; then
117 AC_MSG_ERROR(Cannot find ssl libraries)
118 else
119 SSL_LIBS="-lssl -lcrypto";
120 SSL_LDFLAGS="-L$ssldir/lib";
121 fi
122 AC_SUBST(SSL_CPPFLAGS)
123 AC_SUBST(SSL_CFLAGS)
124 AC_SUBST(SSL_LIBS)
125 AC_SUBST(SSL_LDFLAGS)
126 ])dnl
127
128 AC_ARG_ENABLE(ssldir, [AS_HELP_STRING(--enable-ssldir=path,
129 [Search for openssl also in path.])])
130 if test "$enable_ssldir" = "yes"; then enable_ssldir=""; fi
131 CHECK_SSL($enable_ssldir)
132 server_ldflags="$srver_ldflags $SSL_LDFLAGS $SSL_LIBS"
133
134 ########################################################################### ucred
135
136 AC_MSG_CHECKING(for struct ucred)
137 AC_TRY_LINK([
138 #include <sys/types.h>
139 #include <sys/socket.h>
140 ],[
141 struct ucred sucred; sucred.pid=0;
142 ],[have_ucred=yes],[have_ucred=no])
143 AC_MSG_RESULT($have_ucred)
144 if test ${have_ucred} = yes; then
145 AC_DEFINE(HAVE_UCRED, 1, define to 1 you have struct ucred)
146 fi
147
148 ########################################################################### gtk2
149
150 pkg_modules="gtk+-2.0 >= 2.0.0"
151 PKG_CHECK_MODULES(GTK, [$pkg_modules], [extras="$extras para_krell.so"], [
152 AC_MSG_WARN([gtk+-2 not found, can not build para_krell])
153 ])
154 AC_SUBST(GTK_CFLAGS)
155 AC_SUBST(GTK_LIBS)
156
157 ########################################################################### sdl
158 AC_CHECK_LIB([SDL_image], [SDL_Init], [extras="$extras para_sdl_gui"], [
159 AC_MSG_WARN([libSDL_image not found, cannot build para_sdl_gui])
160 ])
161 AC_CHECK_HEADER(SDL/SDL.h, [],
162 [AC_MSG_WARN([SDL/SDL.h not found])])
163
164 ########################################################################### mysql
165 have_mysql="yes"
166 AC_ARG_ENABLE(mysql_headers, [AC_HELP_STRING(--enable-mysql-headers=dir,
167 [look for mysql.h also in dir])])
168 if test -n "$enable_mysql_headers"; then
169 mysql_cppflags="-I$enable_mysql_headers"
170 CPPFLAGS="$CPPFLAGS $mysql_cppflags"
171 fi
172 AC_ARG_ENABLE(mysql_libs, [AC_HELP_STRING(--enable-mysql-libs=dir,
173 [look for libmysqlclient also in dir])])
174 if test -n "$enable_mysql_libs"; then
175 mysql_libs="-L$enable_mysql_libs"
176 LDFLAGS="$LDFLAGS $mysql_libs"
177 fi
178 AC_CHECK_HEADER(mysql/mysql.h, [], [
179 have_mysql="no"
180 ])
181 AC_CHECK_LIB([mysqlclient], [mysql_init], [], [
182 have_mysql="no"
183 ])
184 if test "$have_mysql" = "yes"; then
185 server_ldflags="$server_ldflags $mysql_libs -lmysqlclient"
186 server_errlist_objs="$server_errlist_objs mysql_selector"
187 AC_SUBST(mysql_cppflags)
188 AC_SUBST(mysql_libs)
189 AC_DEFINE(HAVE_MYSQL, 1, [define to 1 to turn on mysql support])
190 else
191 AC_MSG_WARN([cannot build mysql-based audio file selector])
192 fi
193 ########################################################################### ogg
194 have_ogg="yes"
195 AC_CHECK_LIB([ogg], [ogg_stream_init], [], [
196 have_ogg="no"
197 ])
198 AC_CHECK_LIB([vorbis], [vorbis_info_init], [], [
199 have_ogg="no"
200 ])
201 AC_CHECK_HEADERS([ogg/ogg.h vorbis/codec.h], [], [
202 have_ogg="no"
203 ])
204 if test "$have_ogg" = "yes"; then
205 AC_DEFINE(HAVE_OGGVORBIS, 1, define to 1 to turn on ogg vorbis support)
206 server_ldflags="$server_ldflags -logg -lvorbis -lvorbisfile"
207 filter_ldflags="$filter_ldflags -lvorbis -lvorbisfile"
208 audiod_ldflags="$audiod_ldflags -lvorbis -lvorbisfile"
209
210 filter_cmdline_objs="$filter_cmdline_objs oggdec_filter.cmdline"
211 audiod_cmdline_objs="$audiod_cmdline_objs oggdec_filter.cmdline"
212
213 server_errlist_objs="$server_errlist_objs ogg_afh"
214 filter_errlist_objs="$filter_errlist_objs oggdec"
215 audiod_errlist_objs="$audiod_errlist_objs oggdec"
216 else
217 AC_MSG_WARN([no ogg vorbis support in para_server/para_filter])
218 fi
219 ########################################################################### faad
220 have_faad=yes
221 AC_ARG_ENABLE(faad_headers, [AC_HELP_STRING(--enable-faad-headers=dir,
222 [look for neaacdec.h also in dir])])
223 if test -n "$enable_faad_headers"; then
224 faad_cppflags="-I$enable_faad_headers"
225 CPPFLAGS="$CPPFLAGS $faad_cppflags"
226 fi
227 AC_ARG_ENABLE(faad_libs, [AC_HELP_STRING(--enable-fadd-libs=dir,
228 [look for libfaad also in dir])])
229 if test -n "$enable_faad_libs"; then
230 faad_libs="-L$enable_faad_libs"
231 LDFLAGS="$LDFLAGS $faad_libs"
232 fi
233 AC_CHECK_HEADER(neaacdec.h, [], have_faad=no)
234 AC_CHECK_LIB([faad], [NeAACDecOpen], [], have_faad=no)
235 if test "$have_faad" = "yes"; then
236 AC_DEFINE(HAVE_FAAD, 1, define to 1 if you want to build the aacdec filter)
237 filter_errlist_objs="$filter_errlist_objs aacdec aac_common"
238 audiod_errlist_objs="$audiod_errlist_objs aacdec aac_common"
239 server_errlist_objs="$server_errlist_objs aac_afh aac_common"
240 server_ldflags="$server_ldflags $faad_libs -lfaad"
241 filter_ldflags="$filter_ldflags $faad_libs -lfaad"
242 audiod_ldflags="$audiod_ldflags $faad_libs -lfaad"
243 AC_SUBST(faad_cppflags)
244 AC_SUBST(faad_libs)
245 else
246 AC_MSG_WARN([no aac support in para_audiod/para_filter])
247 fi
248 ########################################################################### mad
249 have_mad="yes"
250 AC_CHECK_HEADERS([mad.h], [], [
251 have_mad="no"
252 ])
253 AC_CHECK_LIB([mad], [mad_stream_init], [], [
254 have_mad="no"
255 ])
256 if test "$have_mad" = "yes"; then
257 AC_DEFINE(HAVE_MAD, 1, define to 1 if you want to build the mp3dec filter)
258 filter_errlist_objs="$filter_errlist_objs mp3dec"
259 audiod_errlist_objs="$audiod_errlist_objs mp3dec"
260 filter_ldflags="$filter_ldflags -lmad"
261 audiod_ldflags="$audiod_ldflags -lmad"
262 else
263 AC_MSG_WARN([no mp3dec support in para_audiod/para_filter])
264 fi
265 ########################################################################### alsa
266 have_alsa="yes"
267 msg="=> no alsa support for para_audiod/para_write"
268 AC_CHECK_HEADERS([alsa/asoundlib.h], [], [
269 AC_MSG_WARN([no alsa/asoundlib $msg])
270 have_alsa="no"
271 ])
272 AC_CHECK_LIB([asound], [snd_pcm_open], [], [
273 AC_MSG_WARN([no libasound $msg])
274 have_alsa="no"
275 ])
276 if test "$have_alsa" = "yes"; then
277 audiod_errlist_objs="$audiod_errlist_objs alsa_writer"
278 audiod_cmdline_objs="$audiod_cmdline_objs alsa_write.cmdline"
279 audiod_ldflags="$audiod_ldflags -lasound"
280
281 write_errlist_objs="$write_errlist_objs alsa_writer"
282 write_cmdline_objs="$write_cmdline_objs alsa_write.cmdline"
283 write_ldflags="$write_ldflags -lasound"
284 write_writers="$write_writers alsa"
285 fi
286 ########################################################################### ortp
287 have_ortp="yes"
288 AC_ARG_ENABLE(ortp, AC_HELP_STRING([--disable-ortp], [Disable ortp support]),
289 if test x$enableval = xno; then
290 have_ortp=no
291 fi
292 )
293 if test "$have_ortp" = "yes"; then
294 AC_CHECK_HEADERS([ortp/ortp.h], [], [
295 have_ortp="no"
296 ])
297 AC_CHECK_LIB([ortp], [ortp_init], [], [
298 have_ortp="no"
299 ])
300 fi
301 if test "$have_ortp" = "yes"; then
302 recv_cmdline_objs="$recv_cmdline_objs ortp_recv.cmdline"
303 recv_errlist_objs="$recv_errlist_objs ortp_recv"
304
305 audiod_cmdline_objs="$audiod_cmdline_objs ortp_recv.cmdline"
306 audiod_errlist_objs="$audiod_errlist_objs ortp_recv"
307
308 server_errlist_objs="$server_errlist_objs ortp_send"
309
310 recv_ldflags="$recv_ldflags -lortp"
311 server_ldflags="$server_ldflags -lortp"
312 audiod_ldflags="$audiod_ldflags -lortp"
313 AC_DEFINE(HAVE_ORTP, 1, [define to 1 to turn on ortp support])
314
315 else
316 AC_MSG_NOTICE([deactivating ortp support])
317 fi
318 AC_SUBST(GLIB_CFLAGS)
319 AC_SUBST(GLIB_LIBS)
320
321 ########################################################################### zmw
322 slide="para_slider"
323 msg="can not build para_slider"
324 CPPFLAGS="$GTK_CFLAGS"
325 LDFLAGS="$LDFLAGS $GTK_LIBS"
326 AC_CHECK_HEADERS([zmw/zmw.h], [], [
327 AC_MSG_WARN([zero memory widget header files not found, $msg])
328 slide=""
329 ])
330 AC_CHECK_LIB([zmw], [zmw_init], [], [
331 AC_MSG_WARN([zero memory widget library not found, $msg])
332 slide=""
333 ])
334 extras="$extras $slide"
335
336
337
338
339
340 AC_SUBST(extra_binaries, [$extras])
341 AC_SUBST(extra_filter_objs, [$extra_filter_objs])
342 AC_SUBST(extra_filter_libs, [$extra_filter_libs])
343 AC_SUBST(install_sh, [$INSTALL])
344 AC_CONFIG_FILES([Makefile])
345
346
347
348 AC_DEFUN([add_dot_o],[$(for i in $@; do printf "$i.o "; done)])
349 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) }])
350
351 recv_objs="$recv_cmdline_objs $recv_errlist_objs"
352 filter_objs="$filter_cmdline_objs $filter_errlist_objs"
353 audiod_objs="$audiod_cmdline_objs $audiod_errlist_objs"
354 server_objs="$server_cmdline_objs $server_errlist_objs"
355 write_objs="$write_cmdline_objs $write_errlist_objs"
356
357 AC_SUBST(recv_objs, add_dot_o($recv_objs))
358 AC_SUBST(recv_ldflags, $recv_ldflags)
359 AC_DEFINE_UNQUOTED(INIT_RECV_ERRLISTS, objlist_to_errlist($recv_errlist_objs),
360 errors used by para_recv)
361
362 AC_SUBST(filter_objs, add_dot_o($filter_objs))
363 AC_SUBST(filter_ldflags, $filter_ldflags)
364 AC_DEFINE_UNQUOTED(INIT_FILTER_ERRLISTS,
365 objlist_to_errlist($filter_errlist_objs), errors used by para_filter)
366
367 AC_SUBST(audiod_objs, add_dot_o($audiod_objs))
368 AC_SUBST(audiod_ldflags, $audiod_ldflags)
369 AC_DEFINE_UNQUOTED(INIT_AUDIOD_ERRLISTS, objlist_to_errlist($audiod_errlist_objs),
370 errors used by para_audiod)
371
372 AC_SUBST(server_objs, add_dot_o($server_objs))
373 AC_SUBST(server_ldflags, $server_ldflags)
374 AC_DEFINE_UNQUOTED(INIT_SERVER_ERRLISTS,
375 objlist_to_errlist($server_errlist_objs), errors used by para_server)
376
377 AC_SUBST(write_objs, add_dot_o($write_objs))
378 AC_SUBST(write_ldflags, $write_ldflags)
379 AC_DEFINE_UNQUOTED(INIT_WRITE_ERRLISTS,
380 objlist_to_errlist($write_errlist_objs), errors used by para_write)
381
382 enum="$(for i in $write_writers; do printf "${i}_WRITE, " | tr '[a-z]' '[A-Z]'; done)"
383 AC_DEFINE_UNQUOTED(WRITER_ENUM, $enum NUM_SUPPORTED_WRITERS,
384 enum of supported writers)
385 names="$(for i in $write_writers; do printf \"$i\",' ' ; done)"
386 AC_DEFINE_UNQUOTED(WRITER_NAMES, $names, supported writer names)
387 inits="$(for i in $write_writers; do printf 'extern void '$i'_writer_init(struct writer *); '; done)"
388 AC_DEFINE_UNQUOTED(DECLARE_WRITER_INITS, $inits, init functions of the supported writers)
389 array="$(for i in $write_writers; do printf '{.init = '$i'_writer_init},'; done)"
390 AC_DEFINE_UNQUOTED(WRITER_ARRAY, $array, array of supported writers)
391
392 gui_cmdline_objs="gui.cmdline"
393 gui_errlist_objs="exec close_on_fork signal string stat ringbuffer fd"
394 gui_other_objs="gui gui_common gui_theme"
395 gui_objs="$gui_cmdline_objs $gui_errlist_objs $gui_other_objs"
396 AC_DEFINE_UNQUOTED(INIT_GUI_ERRLISTS,
397 objlist_to_errlist($gui_errlist_objs), errors used by para_gui)
398 AC_SUBST(gui_objs, add_dot_o($gui_objs))
399
400 AC_OUTPUT
401 AC_MSG_NOTICE([creating Makefile.deps])
402 gcc -MM -MG $mysql_cppflags $faad_cppflags *.c > Makefile.deps
403 AC_MSG_NOTICE([
404 paraslash configuration:
405 ~~~~~~~~~~~~~~~~~~~~~~~~
406 mysql support: $have_mysql
407 ogg vorbis support: $have_ogg
408 mp3dec support (libmad): $have_mad
409 aac support (libfaad): $have_faad
410 ortp support: $have_ortp
411 unix socket credentials: $have_ucred
412 supported writers for para_write: $write_writers
413 ])