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