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