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