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