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