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