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