chiark / gitweb /
Set resource limits on the server to prevent more than FD_SETSIZE
[disorder] / configure.ac
CommitLineData
460b9539 1# Process this file with autoconf to produce a configure script.
2#
3# This file is part of DisOrder.
5aff007d 4# Copyright (C) 2004-2008 Richard Kettlewell
313acc77 5# Portions copyright (C) 2007 Ross Younger
460b9539 6#
e7eb3a27 7# This program is free software: you can redistribute it and/or modify
460b9539 8# it under the terms of the GNU General Public License as published by
e7eb3a27 9# the Free Software Foundation, either version 3 of the License, or
460b9539 10# (at your option) any later version.
11#
e7eb3a27
RK
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15# GNU General Public License for more details.
16#
460b9539 17# You should have received a copy of the GNU General Public License
e7eb3a27 18# along with this program. If not, see <http://www.gnu.org/licenses/>.
460b9539 19#
20
d8b95785 21AC_INIT([disorder], [4.2+], [richard+disorder@sfere.greenend.org.uk])
460b9539 22AC_CONFIG_AUX_DIR([config.aux])
d8b95785 23AM_INIT_AUTOMAKE(disorder, [4.2+])
460b9539 24AC_CONFIG_SRCDIR([server/disorderd.c])
25AM_CONFIG_HEADER([config.h])
26
dea8f8aa
RK
27# Find host type
28AC_CANONICAL_HOST
29
460b9539 30# What we want to build
460b9539 31want_gtk=yes
32want_python=yes
7affb407 33want_tests=yes
4cbafe13
RK
34want_server=yes
35want_cgi=yes
460b9539 36
e2f0c461
RK
37# APIs we want
38want_alsa=yes
39want_oss=yes
40want_coreaudio=yes
41
a9f0ad12
RK
42# Checks for programs.
43AC_PROG_CC
419893d7 44AC_PROG_AWK
a9f0ad12
RK
45AC_SET_MAKE
46if test "x$GCC" = xyes; then
47 gcc_werror=-Werror
439c12ca
RK
48 case "$CC" in
49 *-std=* )
50 ;;
51 * )
52 CC="${CC} -std=gnu99"
53 ;;
54 esac
a9f0ad12 55else
fdca70ee 56 AC_MSG_ERROR([GNU C is required to build this program])
a9f0ad12
RK
57 gcc_werror=""
58fi
59
e2f0c461
RK
60AC_ARG_WITH([alsa],
61 [AS_HELP_STRING([--without-alsa],
62 [do not build with ALSA support])],
63 [want_alsa=$withval])
64AC_ARG_WITH([oss],
65 [AS_HELP_STRING([--without-oss],
66 [do not build with OSS support])],
67 [want_oss=$withval])
68AC_ARG_WITH([coreaudio],
69 [AS_HELP_STRING([--without-coreaudio],
70 [do not build with Core Audio support])],
71 [want_coreaudio=$withval])
7affb407
RK
72AC_ARG_WITH([tests],
73 [AS_HELP_STRING([--without-tests],
74 [do not build test suit])],
75 [want_tests=$withval])
e2f0c461 76
a9f0ad12 77AC_MSG_CHECKING([for a known target platform])
dea8f8aa 78case "$host" in
a9f0ad12 79*empeg* )
e3426f7b 80 AC_MSG_RESULT([empeg car stereo])
a9f0ad12
RK
81 AC_DEFINE([EMPEG_HOST],[1],[define if host is an empeg car stereo])
82 # work around broken toolchain
83 AC_CHECK_LIB([gpg-error], [gpg_strerror])
e3426f7b 84 AC_CHECK_LIB([pthread], [pthread_create])
a9f0ad12 85 want_server=no
4cbafe13 86 want_cgi=no
a9f0ad12 87 ;;
dea8f8aa 88*linux* | *Linux* )
a9f0ad12 89 AC_MSG_RESULT([Linux])
dea8f8aa 90 ;;
9086a105 91*-apple-darwin* )
e3426f7b 92 AC_MSG_RESULT([Mac OS X])
e2f0c461
RK
93 if test $want_coreaudio = yes; then
94 COREAUDIO="-framework CoreAudio"
95 fi
0ec4c5e6 96 browser=open
8fcf5c48
RK
97 AC_MSG_CHECKING([Mac OS X target version])
98 # We honor MACOSX_DEPLOYMENT_TARGET in the environment, emulating gcc's
99 # behaviour. But we provide a command line option to override it and
100 # we default to wide support instead of supporting only the build platform.
101 #
102 # Currently if you ask for 10.5 you will get a deprecation warning
103 # when building the CoreAudio support code. For the time being the
104 # answer to this is "don't do that then". If a good reason to ask
105 # for a 10.5 deployment target emerges then this will be fixed.
106 if test -z "$MACOSX_DEPLOYMENT_TARGET"; then
107 MACOSX_DEPLOYMENT_TARGET=10.0
108 fi
109 AC_ARG_WITH([deployment-target],
110 [AS_HELP_STRING([--with-deployment-target=TARGET],
111 [set target OS X version])],
112 [MACOSX_DEPLOYMENT_TARGET=$withval])
113 # Convert to desired format
114 underscored=`echo $MACOSX_DEPLOYMENT_TARGET|sed 's/\./_/'`
115 minver="MAC_OS_X_VERSION_$underscored"
116 AC_MSG_RESULT([$minver])
117 AC_DEFINE_UNQUOTED([MAC_OS_X_VERSION_MIN_REQUIRED], [$minver],
118 [define to minimum version of Mac OS X to support])
467b6eb1
RK
119
120 # Fink's GTK+ is hopelessly broken
121 PKG_CONFIG_PATH=${PKG_CONFIG_PATH:-/sw/lib/pango-ft219/lib/pkgconfig}
122 export PKG_CONFIG_PATH
123
9086a105 124 ;;
70f47acd
RK
125*-freebsd* )
126 AC_MSG_RESULT([FreeBSD])
edbd470f 127 # Ports install to /usr/local but the compiler stupidly doesn't look
128 # there by default
70f47acd 129 LDFLAGS="${LDFLAGS} -L/usr/local/lib"
e6ea27d8 130 CPPFLAGS="${CPPFLAGS} -isystem /usr/local/include"
42f43a11
RK
131 # Look for a suitable version of libdb among the versions found in FreeBSD 7.0
132 AC_CACHE_CHECK([looking for a libdb install],[rjk_cv_libdb],[
133 rjk_cv_libdb="none"
134 for db in db43 db44 db45 db46; do
135 if test -e /usr/local/lib/$db; then
136 rjk_cv_libdb=$db
137 break
138 fi
139 done
140 ])
141 if test $rjk_cv_libdb != none; then
142 LDFLAGS="${LDFLAGS} -L/usr/local/lib/$rjk_cv_libdb"
143 CPPFLAGS="${CPPFLAGS} -isystem /usr/local/include/$rjk_cv_libdb"
144 fi
70f47acd 145 ;;
dea8f8aa 146* )
a9f0ad12 147 AC_MSG_RESULT([unknown, winging it])
dea8f8aa
RK
148 ;;
149esac
9086a105 150AC_SUBST([COREAUDIO])
dea8f8aa 151
f486ea18
RK
152AC_ARG_WITH([browser],
153 [AS_HELP_STRING([--with-browser=BROWSER],
154 [use BROWSER to display HTML])],
155 [browser=$withval])
156
157AC_CACHE_CHECK([default HTML viewer],[rjk_cv_browser],[
158 rjk_cv_browser=UNKNOWN
58d97da4 159 for candidate in x-www-browser sensible-browser firefox mozilla konqueror netscape; do
f486ea18
RK
160 if type $candidate >/dev/null 2>&1; then
161 rjk_cv_browser="$candidate"
162 break
163 fi
164 done
165])
166if test -z "$browser"; then
167 browser="$rjk_cv_browser"
168fi
169AC_DEFINE_UNQUOTED([BROWSER],["$browser"],[HTML viewer])
170
419893d7
RK
171# Figure out what version of sox is installed
172AC_CACHE_CHECK([sox version],[rjk_cv_soxver],[
173 rjk_cv_soxver=UNKNOWN
174 if sox --version > /dev/null 2>&1; then
175 rjk_cv_soxver=`sox --version|$AWK '{ if(match($0, /[[0-9\.]]+/)) print substr($0,RSTART,RLENGTH)}'`
176 else
177 rjk_cv_soxver=`sox -h 2>&1|$AWK '/Version/ { if(match($0, /[[0-9\.]]+/)) print substr($0,RSTART,RLENGTH)}'`
178 fi
179])
180
181# Decide what command line options to use
182#
183# sox version endian bits deployed
184# 12.17.9 -x -[bwld] debian etch, ubuntu dapper
185# 14.0.0 -x/-[BL] -[bwld] ubuntu hardy
186# 14.0.1 -x/-[BL] -[1248] debian lenny
187# 14.2.0 -x/-[BL] -[1248] debian sid (at 2008-12)
188
189AC_CACHE_CHECK([default sox generation],[rjk_cv_soxgen],[
190 case $rjk_cv_soxver in
a4846a87 191 [[0-9]].* | 1[[0123]].* )
419893d7
RK
192 rjk_cv_soxgen=0
193 ;;
194 * )
195 rjk_cv_soxgen=1
196 ;;
197 esac
198])
199AC_DEFINE_UNQUOTED([DEFAULT_SOX_GENERATION],[$rjk_cv_soxgen],
200 [default sox generation])
201
460b9539 202AC_ARG_WITH([server],
203 [AS_HELP_STRING([--without-server],
204 [do not build server])],
205 [want_server=$withval])
4cbafe13
RK
206AC_ARG_WITH([cgi],
207 [AS_HELP_STRING([--without-cgi],
208 [do not build CGI])],
209 [want_cgi=$withval])
460b9539 210AC_ARG_WITH([gtk],
211 [AS_HELP_STRING([--without-gtk],
212 [do not build GTK+ client])],
213 [want_gtk=$withval])
214AC_ARG_WITH([python],
215 [AS_HELP_STRING([--without-python],
216 [do not build Python support])],
217 [want_python=$withval])
218
4cbafe13
RK
219if test $want_server = no; then
220 want_cgi=no
221fi
222
64ac73bb
RK
223#
224# OS Document Root CGI directory
225# == ============= =============
226# Debian /var/www /usr/lib/cgi-bin
227# Ubuntu /var/www /usr/lib/cgi-bin
228# Red Hat /var/www/html /var/www/cgi-bin
229# or: /home/httpd/html/ /home/httpd/cgi-bin
230# Slackware /var/www/htdocs (unknown)
231# SuSE /srv/www/html /srv/www/cgi-bin
232# Gentoo /var/www/localhost/htdocs /var/www/localhost/cgi-bin/
233# FreeBSD /usr/local/www/data /usr/local/www/cgi-bin
234# or: /usr/local/www/???/data /usr/local/www/???/cgi-bin
235# OS X /Library/WebServer/Documents /Library/WebServer/CGI-Executables
236# Apache /usr/local/apache/htdocs (none)
237#
238# Sources:
239# http://wiki.linuxquestions.org/wiki/Apache
240# http://mapserver.gis.umn.edu/docs/howto/suse-linux
241# http://www.yolinux.com/TUTORIALS/LinuxTutorialWebSiteConfig.html
242# http://sources.gentoo.org/viewcvs.py/apache/trunk/dist/2.2/conf/vhosts.d/default_vhost.include?rev=198&view=log
243# http://httpd.apache.org/docs/
244#
4cbafe13 245if test $want_cgi = yes; then
64ac73bb
RK
246 if test -z "$httpdir"; then
247 AC_CACHE_CHECK([for httpd document root],[rjk_cv_httpdir],[
248 rjk_cv_httpdir="not found"
249 for dir in /var/www/html \
250 /var/www/htdocs \
251 /var/www/localhost/htdocs \
252 /var/www \
253 /home/httpd/html \
254 /srv/www/html \
255 /usr/local/www/data \
256 /usr/local/www/*/data \
257 /Library/WebServer/Documents \
258 /usr/local/apache/htdocs; do
259 if test -d "$dir"; then
260 rjk_cv_httpdir="$dir"
261 fi
262 done
263 ])
f03d4184 264 if test "$rjk_cv_cgiexecdir" = "not found"; then
64ac73bb
RK
265 AC_MSG_ERROR([cannot identify httpd documentroot. Set httpdir on configure command line])
266 fi
267 httpdir="$rjk_cv_httpdir"
268 fi
f03d4184
RK
269 if test ! -z "$cgidir"; then
270 # This is a bit harsh but should stop any disasters
271 AC_MSG_ERROR([cgidir has been renamed to cgiexecdir])
272 fi
273 if test -z "$cgiexecdir"; then
274 AC_CACHE_CHECK([for CGI directory],[rjk_cv_cgiexecdir],[
275 rjk_cv_cgiexecdir="not found"
4cbafe13
RK
276 for dir in /usr/lib/cgi-bin \
277 /Library/WebServer/CGI-Executables \
64ac73bb
RK
278 /srv/www/cgi-bin \
279 /var/www/cgi-bin \
280 /home/httpd/cgi-bin \
281 /var/www/localhost/cgi-bin \
4cbafe13
RK
282 /usr/local/lib/cgi-bin \
283 /usr/local/www/cgi-bin \
284 /usr/local/www/*/cgi-bin; do
285 if test -d "$dir"; then
f03d4184 286 rjk_cv_cgiexecdir="$dir"
4cbafe13
RK
287 break
288 fi
289 done
290 ])
f03d4184
RK
291 if test "$rjk_cv_cgiexecdir" = "not found"; then
292 AC_MSG_ERROR([cannot identify CGI install directory. Set cgiexecdir on configure command line])
4cbafe13 293 fi
f03d4184 294 cgiexecdir="$rjk_cv_cgiexecdir"
4cbafe13
RK
295 fi
296fi
f03d4184 297AC_ARG_VAR([cgiexecdir], [location of cgi-bin directory, e.g. /usr/lib/cgi-bin])
64ac73bb
RK
298AC_ARG_VAR([httpdir], [location of http document root, e.g. /var/www/htdocs])
299if test -z "$pkghttpdir"; then
300 pkghttpdir='$(httpdir)/disorder'
301fi
302AC_SUBST([pkghttpdir])
4cbafe13 303
7affb407
RK
304subdirs="scripts lib"
305if test $want_tests = yes; then
306 subdirs="${subdirs} libtests"
307fi
308subdirs="${subdirs} clients doc examples debian"
460b9539 309
310if test $want_server = yes; then
4cbafe13
RK
311 subdirs="${subdirs} server plugins driver sounds"
312fi
313if test $want_cgi = yes; then
314 subdirs="${subdirs} cgi templates images"
460b9539 315fi
460b9539 316if test $want_gtk = yes; then
317 subdirs="${subdirs} disobedience"
318 if test $want_server = no; then
319 subdirs="${subdirs} images"
320 fi
321fi
7affb407 322if test $want_tests = yes && test $want_python = yes; then
56fac00d
RK
323 AM_PATH_PYTHON([2.4])
324 subdirs="${subdirs} python tests"
325fi
460b9539 326AC_SUBST([subdirs])
327
328# libtool config
329AC_LIBTOOL_DLOPEN
330AC_DISABLE_STATIC
331
332AC_PROG_LIBTOOL
333
edbd470f 334AC_CACHE_CHECK([for GNU sed],[rjk_cv_gnused],[
335 rjk_cv_gnused="not found"
336 for candidate in sed gsed; do
337 if $candidate --version >/dev/null 2>&1; then
338 rjk_cv_gnused=$candidate
339 fi
340 done
341])
342GNUSED="${GNUSED:-$rjk_cv_gnused}"
343if test "$GNUSED" = "not found"; then
344 AC_MSG_ERROR([GNU sed is required to build this program])
345fi
346AC_SUBST([GNUSED])
347
4b9b77a6
RK
348AC_CHECK_PROGS([GROG],[grog])
349AM_CONDITIONAL([GROG],[test "x$GROG" != xnone])
350
460b9539 351missing_libraries=""
352missing_headers=""
353missing_functions=""
354
355AC_DEFINE(_GNU_SOURCE, 1, [required for e.g. strsignal])
356
2eee4b0c
RK
357AC_PATH_PROG([SENDMAIL],[sendmail],[none],[$PATH:/usr/sbin:/usr/lib])
358
460b9539 359# Macs might have libraries under fink's root
360AC_PATH_PROG([FINK],[fink],[none],[$PATH:/sw/bin])
361if test "x$FINK" != xnone; then
362 AC_CACHE_CHECK([fink install directory],[rjk_cv_finkprefix],[
363 rjk_cv_finkprefix="`echo "$FINK" | sed 's,/bin/fink$,,'`"
364 ])
f9592fe7 365 finkdir="${rjk_cv_finkprefix}"
e83d0967 366 finkbindir="${rjk_cv_finkprefix}/bin"
762f2539 367 CPPFLAGS="${CPPFLAGS} -I${rjk_cv_finkprefix}/include/gc -I${rjk_cv_finkprefix}/include"
460b9539 368 if test $want_server = yes; then
369 CPPFLAGS="${CPPFLAGS} -I${rjk_cv_finkprefix}/include/db4"
370 fi
371 LDFLAGS="${LDFLAGS} -L${rjk_cv_finkprefix}/lib"
e83d0967
RK
372else
373 finkbindir=""
460b9539 374fi
f9592fe7 375AC_SUBST([finkdir])
e83d0967 376AC_SUBST([finkbindir])
460b9539 377
378# Checks for libraries.
379# We save up a list of missing libraries that we can't do without
380# and report them all at once.
381AC_CHECK_LIB(gc, GC_malloc, [AC_SUBST(LIBGC,[-lgc])],
382 [missing_libraries="$missing_libraries libgc"])
383AC_CHECK_LIB(gcrypt, gcry_md_open,
384 [AC_SUBST(LIBGCRYPT,[-lgcrypt])],
385 [missing_libraries="$missing_libraries libgcrypt"])
386AC_CHECK_LIB(pcre, pcre_compile,
387 [AC_SUBST(LIBPCRE,[-lpcre])],
388 [missing_libraries="$missing_libraries libpcre"])
e2f0c461
RK
389if test $want_alsa = yes; then
390 AC_CHECK_LIB([asound], [snd_pcm_open],
391 [AC_SUBST(LIBASOUND,[-lasound])])
392fi
460b9539 393if test $want_server = yes; then
394 RJK_CHECK_LIB(db, db_create, [#include <db.h>],
395 [AC_SUBST(LIBDB,[-ldb])],
396 [missing_libraries="$missing_libraries libdb"])
397 AC_CHECK_LIB(vorbis, vorbis_info_clear,
398 [:],
399 [missing_libraries="$missing_libraries libvorbis"])
400 AC_CHECK_LIB(vorbisfile, ov_open,
401 [AC_SUBST(LIBVORBISFILE,["-lvorbisfile -lvorbis"])],
402 [missing_libraries="$missing_libraries libvorbisfile"],
403 [-lvorbis])
404 AC_CHECK_LIB(mad, mad_stream_init,
405 [AC_SUBST(LIBMAD,[-lmad])],
406 [missing_libraries="$missing_libraries libmad"])
407 AC_CHECK_LIB([ao], [ao_initialize],
408 [AC_SUBST(LIBAO,[-lao])],
409 [missing_libraries="$missing_libraries libao"])
c57f1201 410 AC_CHECK_LIB([FLAC], [FLAC__stream_decoder_new],
411 [AC_SUBST(LIBFLAC,[-lFLAC])],
412 [missing_libraries="$missing_libraries libFLAC"])
d19ccd72 413fi
edbd470f 414AC_CHECK_LIB([pthread], [pthread_create],
415 [AC_SUBST(LIBPTHREAD,[-lpthread])],
416 [missing_libraries="$missing_libraries libpthread"])
460b9539 417
418if test $want_gtk = yes; then
419 AM_PATH_GLIB_2_0([],[],[missing_libraries="$missing_libraries libglib"])
420 AM_PATH_GTK_2_0([],[],[missing_libraries="$missing_libraries libgtk"])
421fi
422
423# Some platforms have iconv already
424AC_CHECK_FUNC(iconv_open, [:],
425 [RJK_CHECK_LIB(iconv, iconv_open, [#include <iconv.h>],
426 [AC_SUBST(LIBICONV,[-liconv])],
427 [missing_functions="$missing_functions iconv_open"])])
428AC_CHECK_FUNC([gethostbyname],[:],[
429 AC_CHECK_LIB(nsl,gethostbyname,
430 [AC_SUBST(LIBNSL,[-lnsl])],
431 [missing_functions="$missing_functions gethostbyname"])])
432AC_CHECK_FUNC([socket],[:],[
433 AC_CHECK_LIB(socket,socket,
434 [AC_SUBST(LIBSOCKET,[-lsocket])],
435 [missing_functions="$missing_functions socket"])])
436AC_CHECK_FUNC([dlopen],[:],[
437 AC_CHECK_LIB(dl,dlopen,
438 [AC_SUBST(LIBDL,[-ldl])],
439 [missing_functions="$missing_functions dlopen"])])
440
441if test ! -z "$missing_libraries"; then
442 AC_MSG_ERROR([missing libraries:$missing_libraries])
443fi
444
460b9539 445# Checks for header files.
446RJK_FIND_GC_H
e2f0c461
RK
447if test $want_oss = yes; then
448 AC_CHECK_HEADERS([sys/soundcard.h])
449fi
450if test $want_alsa = yes; then
451 AC_CHECK_HEADERS([alsa/asoundlib.h])
452fi
453if test $want_coreaudio = yes; then
454 AC_CHECK_HEADERS([CoreAudio/AudioHardware.h])
455fi
456AC_CHECK_HEADERS([inttypes.h])
146e86fb 457# We don't bother checking very standard stuff
460b9539 458# Compilation will fail if any of these headers are missing, so we
459# check for them here and fail early.
460b9539 460if test $want_server = yes; then
461 AC_CHECK_HEADERS([db.h],[:],[
462 missing_headers="$missing_headers $ac_header"
463 ])
762806f1 464 AC_CHECK_HEADERS([FLAC/file_decoder.h])
460b9539 465fi
466AC_CHECK_HEADERS([dlfcn.h gcrypt.h \
467 getopt.h iconv.h langinfo.h \
468 pcre.h sys/ioctl.h \
469 syslog.h unistd.h],[:],[
470 missing_headers="$missing_headers $ac_header"
471])
472
473if test ! -z "$missing_headers"; then
474 AC_MSG_ERROR([missing headers:$missing_headers])
475fi
476
70f47acd
RK
477# We require that libpcre support UTF-8
478RJK_REQUIRE_PCRE_UTF8([-lpcre])
479
460b9539 480# Checks for typedefs, structures, and compiler characteristics.
481AC_C_CONST
482AC_TYPE_SIZE_T
483AC_C_INLINE
5330d674 484AC_C_BIGENDIAN
460b9539 485AC_CHECK_TYPES([struct sockaddr_in6],,,[AC_INCLUDES_DEFAULT
486#include <netinet/in.h>])
487
488# enable -Werror when we check for certain characteristics:
489
490old_CFLAGS="${CFLAGS}"
491CFLAGS="${CFLAGS} $gcc_werror"
492AC_CHECK_TYPES([long long,uint32_t,uint8_t,intmax_t,uintmax_t])
493
494# Some GCC invocations warn for converting function pointers to void *.
495# This is fair enough, as it's technically forbidden, but we use dlsym()
496# which can pretty much only exist if object and function pointers are
497# interconvertable. So we disable -Werror if need be.
498if test ! -z "$gcc_werror"; then
499 AC_CACHE_CHECK([whether function pointers can be converted to void * without a warning],
500 [rjk_cv_function_pointer_cast],[
501 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
502 void somefunction(void);],
503 [(void *)somefunction])],
504 [rjk_cv_function_pointer_cast=yes],
505 [rjk_cv_function_pointer_cast=no])])
506 if test $rjk_cv_function_pointer_cast = no; then
507 gcc_werror=""
508 fi
509fi
510
511CFLAGS="${old_CFLAGS}"
512
513# gcrypt maintainers keep changing everything. Design your interface
514# first, then implement it once, rather than getting it wrong three or
515# four times and shipping between each attempt.
516AC_CACHE_CHECK([for hash handle type in <grypt.h>],
517 [rjk_cv_gcrypt_hash_handle],[
518 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
519#include <gcrypt.h>
520],
521 [gcry_md_hd_t h;])],
522 [rjk_cv_gcrypt_hash_handle=gcry_md_hd_t],[
523 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
524#include <gcrypt.h>
525],
526 [GcryMDHd h;])],
527 [rjk_cv_gcrypt_hash_handle=GcryMDHd],
528 [rjk_cv_gcrypt_hash_handle=GCRY_MD_HD])])])
529AC_DEFINE_UNQUOTED([gcrypt_hash_handle],[$rjk_cv_gcrypt_hash_handle],
530 [libgcrypt hash handle type])
531
532AC_CACHE_CHECK([for gcry_error_t in <grypt.h>],
533 [rjk_cv_have_gcry_error_t],[
534 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
535#include <gcrypt.h>
536],
537 [gcry_error_t e;])],
538 [rjk_cv_have_gcry_error_t=yes],
539 [rjk_cv_have_gcry_error_t=no])])
540if test $rjk_cv_have_gcry_error_t = yes; then
541 AC_DEFINE([HAVE_GCRY_ERROR_T],1,[define if <gcrypt.h> defines gcry_error_t])
542fi
543
544# Checks for functions
545if test $ac_cv_type_long_long = yes; then
546 AC_CHECK_FUNCS([atoll strtoll],[:],[
547 missing_functions="$missing_functions $ac_func"
548 ])
549 # Darwin sometimes fails to declare strtoll (e.g. if you ask for -std=c99)
550 AC_CACHE_CHECK([whether strtoll is declared in <stdlib.h>],
551 [rjk_cv_strtoll_declared],[
552 AC_EGREP_HEADER([strtoll], [stdlib.h],
553 [rjk_cv_strtoll_declared=yes],
554 [rjk_cv_strtoll_declared=no])])
555 if test $rjk_cv_strtoll_declared = yes; then
556 AC_DEFINE([DECLARES_STRTOLL],[1],[define if <stdlib.h> declares strtoll])
557 fi
558 AC_CACHE_CHECK([whether atoll is declared in <stdlib.h>],
559 [rjk_cv_atoll_declared],[
560 AC_EGREP_HEADER([atoll], [stdlib.h],
561 [rjk_cv_atoll_declared=yes],
562 [rjk_cv_atoll_declared=no])])
563 if test $rjk_cv_atoll_declared = yes; then
564 AC_DEFINE([DECLARES_ATOLL],[1],[define if <stdlib.h> declares atoll])
565 fi
566fi
5b708e0c 567AC_CHECK_FUNCS([ioctl nl_langinfo strsignal setenv unsetenv],[:],[
460b9539 568 missing_functions="$missing_functions $ac_func"
569])
570# fsync will do if fdatasync not available
571AC_CHECK_FUNCS([fdatasync],[:],[
572 AC_CHECK_FUNCS([fsync],
573 [AC_DEFINE([fdatasync],[fsync],[define fdatasync to fsync if not available])],
574 [missing_functions="$missing_functions fdatasync"])])
575if test ! -z "$missing_functions"; then
576 AC_MSG_ERROR([missing functions:$missing_functions])
577fi
7c8c2fc9
RK
578
579# Functions we can take or leave
580AC_CHECK_FUNCS([fls])
581
460b9539 582if test $want_server = yes; then
583 # <db.h> had better be version 3 or later
584 AC_CACHE_CHECK([db.h version],[rjk_cv_db_version],[
585 AC_PREPROC_IFELSE([
586 #include <db.h>
587 #ifndef DB_VERSION_MAJOR
588 # error cannot determine db version
589 #endif
590 #if DB_VERSION_MAJOR < 4
591 # error inadequate db version
592 #endif
87573ede 593 #if DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR <= 2
460b9539 594 # error inadequate db version
595 #endif
596 ],
597 [rjk_cv_db_version=ok],
598 [rjk_cv_db_version=inadequate])
12f09e37
RK
599 if test $rjk_cv_db_version = ok; then
600 AC_PREPROC_IFELSE([
601 #include <db.h>
602 #if DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 6
603 # error http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=510270
604 #endif
605 ],
606 [rjk_cv_db_version=ok],
607 [rjk_cv_db_version=toxic])
608 fi
460b9539 609 ])
12f09e37
RK
610 case $rjk_cv_db_version in
611 ok )
612 ;;
613 inadequate )
614 AC_MSG_ERROR([need db version at least 4.3 (but not 4.6)])
615 ;;
616 toxic )
617 AC_MSG_ERROR([db version 4.6.x does not work - see debian bug 510270])
618 ;;
619 esac
460b9539 620fi
621
e63c38e8 622AM_CONDITIONAL([SERVER], [test x$want_server = xyes])
588b2763
RK
623if test $want_gtk = yes; then
624 AC_DEFINE([WITH_GTK], [1], [define if using GTK+])
625fi
e63c38e8 626
460b9539 627if test "x$GCC" = xyes; then
e84ca290
RK
628 # We need LLONG_MAX and annoyingly GCC doesn't always give it to us
629 # by default.
630 AC_CACHE_CHECK([what C version to ask for],[rjk_cv_cstd],[
631 AC_TRY_COMPILE([#include <limits.h>],[
632 long long n = LLONG_MAX;
633 ],[rjk_cv_cstd=default],[
634 old_CC="$CC"
635 CC="${CC} -std=gnu99"
636 AC_TRY_COMPILE([#include <limits.h>],[
637 long long n = LLONG_MAX;
638 ],[rjk_cv_cstd=gnu99],[rjk_cv_cstd=unknown])
639 CC="$old_CC"
640 ])
641 ])
642 case $rjk_cv_cstd in
643 default | unknown )
644 ;;
645 * )
646 CC="${CC} -std=${rjk_cv_cstd}"
647 ;;
648 esac
649
f368d6c7
RK
650 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29478
651 AC_CACHE_CHECK([checking for GCC bug 29478],[rjk_cv_pr29478],[
652 old_CC="$CC"
653 if test $GCC = yes; then
654 CC="$CC -Wall -Werror"
655 fi
656 AC_COMPILE_IFELSE([
657 static int x(char *f) {
658 return *f;
659 }
660 int z(const char *g) {
661 return x((char *)g);
662 }],
663 [rjk_cv_pr29478=no],
664 [rjk_cv_pr29478=yes]
665 )
666 CC="$old_CC"
667 ])
668 if test $rjk_cv_pr29478 = yes; then
669 gcc_werror=''
670 fi
671
460b9539 672 # a reasonable default set of warnings
673 CC="${CC} -Wall -W -Wpointer-arith -Wbad-function-cast \
674 -Wwrite-strings -Wmissing-prototypes \
675 -Wmissing-declarations -Wnested-externs"
676
677 # Fix up GTK+ and GLib compiler flags
678 GTK_CFLAGS="`echo \"$GTK_CFLAGS\"|sed 's/-I/-isystem /g'`"
679 GLIB_CFLAGS="`echo \"$GLIB_CFLAGS\"|sed 's/-I/-isystem /g'`"
680
f368d6c7
RK
681 if test "$gcc_werror" != ''; then
682 # GCC 2.95 doesn't know to ignore warnings from system headers
683 AC_CACHE_CHECK([whether -Werror is usable],
684 rjk_cv_werror, [
685 save_CFLAGS="${CFLAGS}"
686 CFLAGS="${CFLAGS} ${GTK_CFLAGS} -Werror"
588b2763
RK
687 AC_TRY_COMPILE([#if WITH_GTK
688 #include <gtk/gtk.h>
689#endif
690
691struct s { int a, b; };
692const struct s sv = { .a = 1 };],
f368d6c7
RK
693 [],
694 [rjk_cv_werror=yes],
695 [rjk_cv_werror=no])
696 CFLAGS="${save_CFLAGS}"
697 ])
698 if test $rjk_cv_werror = no; then
699 gcc_werror=''
700 fi
460b9539 701 fi
702 CC="${CC} $gcc_werror"
703
704 # for older GCCs that don't know %ju (etc)
9a5f7aba 705 AC_CACHE_CHECK([whether -Wno-format is required],
460b9539 706 rjk_cv_noformat,
707 AC_TRY_COMPILE([#include <stdio.h>
708#include <stdint.h>
709],
710 [printf("%ju", (uintmax_t)0);],
711 [rjk_cv_noformat=no],
712 [rjk_cv_noformat=yes]))
713 if test $rjk_cv_noformat = yes; then
714 CC="${CC} -Wno-format"
715 fi
716
9a5f7aba 717 AC_CACHE_CHECK([whether -Wshadow is OK],
460b9539 718 rjk_cv_shadow,
719 oldCC="${CC}"
720 CC="${CC} -Wshadow"
721 [AC_TRY_COMPILE([
722#include <unistd.h>
723#include <vorbis/vorbisfile.h>
724],
725 [],
726 [rjk_cv_shadow=yes],
727 [rjk_cv_shadow=no])
728 CC="${oldCC}"])
729 if test $rjk_cv_shadow = yes; then
730 CC="${CC} -Wshadow"
731 fi
460b9539 732fi
733
1a00f590
RK
734RJK_GCOV
735
460b9539 736AH_BOTTOM([#ifdef __GNUC__
737# define attribute(x) __attribute__(x)
738#else
739# define attribute(x)
740#endif])
741
742AC_CONFIG_FILES([Makefile
460b9539 743 images/Makefile
744 scripts/Makefile
745 lib/Makefile
746 server/Makefile
05b75f8d 747 cgi/Makefile
460b9539 748 clients/Makefile
749 disobedience/Makefile
750 doc/Makefile
3e1616b6 751 templates/Makefile
460b9539 752 plugins/Makefile
753 driver/Makefile
754 debian/Makefile
755 sounds/Makefile
756 python/Makefile
c5dbcd79 757 examples/Makefile
7affb407 758 libtests/Makefile
c5dbcd79 759 tests/Makefile])
460b9539 760AC_OUTPUT
f368d6c7
RK
761
762if test $GCC = yes && test "$gcc_werror" = ''; then
763 AC_MSG_WARN([building without -Werror])
764fi
56fac00d
RK
765if test $want_python = no; then
766 AC_MSG_WARN([cannot run the test suit without Python])
767fi
4cbafe13
RK
768
769# Local Variables:
770# indent-tabs-mode:nil
771# End: