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