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