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