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