chiark / gitweb /
Wait a bit after stopping the daemon when testsing, to stop silly
[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-2008 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 2 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, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 # 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, write to the Free Software
19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 # USA
21 #
22
23 AC_INIT([disorder], [4.2], [richard+disorder@sfere.greenend.org.uk])
24 AC_CONFIG_AUX_DIR([config.aux])
25 AM_INIT_AUTOMAKE(disorder, [4.2])
26 AC_CONFIG_SRCDIR([server/disorderd.c])
27 AM_CONFIG_HEADER([config.h])
28
29 # Find host type
30 AC_CANONICAL_HOST
31
32 # What we want to build
33 want_gtk=yes
34 want_python=yes
35 want_tests=yes
36 want_server=yes
37 want_cgi=yes
38
39 # APIs we want
40 want_alsa=yes
41 want_oss=yes
42 want_coreaudio=yes
43
44 # Checks for programs.
45 AC_PROG_CC
46 AC_SET_MAKE
47 if test "x$GCC" = xyes; then
48   gcc_werror=-Werror
49   case "$CC" in
50   *-std=* )
51     ;;
52   * )
53     CC="${CC} -std=gnu99"
54     ;;
55   esac
56 else
57   AC_MSG_ERROR([GNU C is required to build this program])
58   gcc_werror=""
59 fi
60
61 AC_ARG_WITH([alsa],
62             [AS_HELP_STRING([--without-alsa],
63                             [do not build with ALSA support])],
64             [want_alsa=$withval])
65 AC_ARG_WITH([oss],
66             [AS_HELP_STRING([--without-oss],
67                             [do not build with OSS support])],
68             [want_oss=$withval])
69 AC_ARG_WITH([coreaudio],
70             [AS_HELP_STRING([--without-coreaudio],
71                             [do not build with Core Audio support])],
72             [want_coreaudio=$withval])
73 AC_ARG_WITH([tests],
74             [AS_HELP_STRING([--without-tests],
75                             [do not build test suit])],
76             [want_tests=$withval])
77
78 AC_MSG_CHECKING([for a known target platform])
79 case "$host" in
80 *empeg* )
81   AC_MSG_RESULT([empeg car stereo])
82   AC_DEFINE([EMPEG_HOST],[1],[define if host is an empeg car stereo])
83   # work around broken toolchain
84   AC_CHECK_LIB([gpg-error], [gpg_strerror])
85   AC_CHECK_LIB([pthread], [pthread_create])
86   want_server=no
87   want_cgi=no
88  ;;
89 *linux* | *Linux* )
90   AC_MSG_RESULT([Linux])
91   ;;
92 *-apple-darwin* )
93   AC_MSG_RESULT([Mac OS X])
94   if test $want_coreaudio = yes; then
95     COREAUDIO="-framework CoreAudio"
96   fi
97   browser=open
98   AC_MSG_CHECKING([Mac OS X target version])
99   # We honor MACOSX_DEPLOYMENT_TARGET in the environment, emulating gcc's
100   # behaviour.  But we provide a command line option to override it and
101   # we default to wide support instead of supporting only the build platform.
102   #
103   # Currently if you ask for 10.5 you will get a deprecation warning
104   # when building the CoreAudio support code.  For the time being the
105   # answer to this is "don't do that then".  If a good reason to ask
106   # for a 10.5 deployment target emerges then this will be fixed.
107   if test -z "$MACOSX_DEPLOYMENT_TARGET"; then
108     MACOSX_DEPLOYMENT_TARGET=10.0
109   fi
110   AC_ARG_WITH([deployment-target],
111               [AS_HELP_STRING([--with-deployment-target=TARGET],
112                               [set target OS X version])],
113               [MACOSX_DEPLOYMENT_TARGET=$withval])
114   # Convert to desired format
115   underscored=`echo $MACOSX_DEPLOYMENT_TARGET|sed 's/\./_/'`
116   minver="MAC_OS_X_VERSION_$underscored"
117   AC_MSG_RESULT([$minver])
118   AC_DEFINE_UNQUOTED([MAC_OS_X_VERSION_MIN_REQUIRED], [$minver],
119                      [define to minimum version of Mac OS X to support])
120
121   # Fink's GTK+ is hopelessly broken
122   PKG_CONFIG_PATH=${PKG_CONFIG_PATH:-/sw/lib/pango-ft219/lib/pkgconfig}
123   export PKG_CONFIG_PATH
124
125   ;;
126 *-freebsd* )
127   AC_MSG_RESULT([FreeBSD])
128   # Ports install to /usr/local but the compiler stupidly doesn't look
129   # there by default
130   LDFLAGS="${LDFLAGS} -L/usr/local/lib"
131   CPPFLAGS="${CPPFLAGS} -isystem /usr/local/include"
132   # Look for a suitable version of libdb among the versions found in FreeBSD 7.0
133   AC_CACHE_CHECK([looking for a libdb install],[rjk_cv_libdb],[
134     rjk_cv_libdb="none"
135     for db in db43 db44 db45 db46; do
136       if test -e /usr/local/lib/$db; then
137         rjk_cv_libdb=$db
138         break
139       fi
140     done
141   ])
142   if test $rjk_cv_libdb != none; then
143     LDFLAGS="${LDFLAGS} -L/usr/local/lib/$rjk_cv_libdb"
144     CPPFLAGS="${CPPFLAGS} -isystem /usr/local/include/$rjk_cv_libdb"
145   fi
146   ;;
147 * )
148   AC_MSG_RESULT([unknown, winging it])
149   ;;
150 esac
151 AC_SUBST([COREAUDIO])
152
153 AC_ARG_WITH([browser],
154             [AS_HELP_STRING([--with-browser=BROWSER],
155                             [use BROWSER to display HTML])],
156             [browser=$withval])
157
158 AC_CACHE_CHECK([default HTML viewer],[rjk_cv_browser],[
159   rjk_cv_browser=UNKNOWN
160   for candidate in x-www-browser sensible-browser firefox mozilla konqueror netscape; do
161     if type $candidate >/dev/null 2>&1; then
162       rjk_cv_browser="$candidate"
163       break
164     fi
165   done
166 ])
167 if test -z "$browser"; then
168   browser="$rjk_cv_browser"
169 fi
170 AC_DEFINE_UNQUOTED([BROWSER],["$browser"],[HTML viewer])
171
172 AC_ARG_WITH([server],
173             [AS_HELP_STRING([--without-server],
174                             [do not build server])],
175             [want_server=$withval])
176 AC_ARG_WITH([cgi],
177             [AS_HELP_STRING([--without-cgi],
178                             [do not build CGI])],
179             [want_cgi=$withval])
180 AC_ARG_WITH([gtk],
181             [AS_HELP_STRING([--without-gtk],
182                             [do not build GTK+ client])],
183             [want_gtk=$withval])
184 AC_ARG_WITH([python],
185             [AS_HELP_STRING([--without-python],
186                             [do not build Python support])],
187             [want_python=$withval])
188
189 if test $want_server = no; then
190   want_cgi=no
191 fi
192
193 #
194 # OS          Document Root                  CGI directory
195 # ==          =============                  =============
196 # Debian      /var/www                       /usr/lib/cgi-bin
197 # Ubuntu      /var/www                       /usr/lib/cgi-bin
198 # Red Hat     /var/www/html                  /var/www/cgi-bin
199 #      or:    /home/httpd/html/              /home/httpd/cgi-bin
200 # Slackware   /var/www/htdocs                (unknown)
201 # SuSE        /srv/www/html                  /srv/www/cgi-bin
202 # Gentoo      /var/www/localhost/htdocs      /var/www/localhost/cgi-bin/
203 # FreeBSD     /usr/local/www/data            /usr/local/www/cgi-bin
204 #      or:    /usr/local/www/???/data        /usr/local/www/???/cgi-bin
205 # OS X        /Library/WebServer/Documents   /Library/WebServer/CGI-Executables
206 # Apache      /usr/local/apache/htdocs       (none)
207 #
208 # Sources:
209 #   http://wiki.linuxquestions.org/wiki/Apache
210 #   http://mapserver.gis.umn.edu/docs/howto/suse-linux
211 #   http://www.yolinux.com/TUTORIALS/LinuxTutorialWebSiteConfig.html
212 #   http://sources.gentoo.org/viewcvs.py/apache/trunk/dist/2.2/conf/vhosts.d/default_vhost.include?rev=198&view=log
213 #   http://httpd.apache.org/docs/
214 #
215 if test $want_cgi = yes; then
216   if test -z "$httpdir"; then
217     AC_CACHE_CHECK([for httpd document root],[rjk_cv_httpdir],[
218       rjk_cv_httpdir="not found"
219       for dir in /var/www/html \
220                  /var/www/htdocs \
221                  /var/www/localhost/htdocs \
222                  /var/www \
223                  /home/httpd/html \
224                  /srv/www/html \
225                  /usr/local/www/data \
226                  /usr/local/www/*/data \
227                  /Library/WebServer/Documents \
228                  /usr/local/apache/htdocs; do
229         if test -d "$dir"; then
230           rjk_cv_httpdir="$dir"
231         fi
232       done
233     ])
234     if test "$rjk_cv_cgiexecdir" = "not found"; then
235       AC_MSG_ERROR([cannot identify httpd documentroot.  Set httpdir on configure command line])
236     fi
237     httpdir="$rjk_cv_httpdir"
238   fi
239   if test ! -z "$cgidir"; then
240     # This is a bit harsh but should stop any disasters
241     AC_MSG_ERROR([cgidir has been renamed to cgiexecdir])
242   fi
243   if test -z "$cgiexecdir"; then
244     AC_CACHE_CHECK([for CGI directory],[rjk_cv_cgiexecdir],[
245       rjk_cv_cgiexecdir="not found"
246       for dir in /usr/lib/cgi-bin \
247                  /Library/WebServer/CGI-Executables \
248                  /srv/www/cgi-bin \
249                  /var/www/cgi-bin \
250                  /home/httpd/cgi-bin \
251                  /var/www/localhost/cgi-bin \
252                  /usr/local/lib/cgi-bin \
253                  /usr/local/www/cgi-bin \
254                  /usr/local/www/*/cgi-bin; do
255         if test -d "$dir"; then
256           rjk_cv_cgiexecdir="$dir"
257           break
258         fi
259       done
260     ])
261     if test "$rjk_cv_cgiexecdir" = "not found"; then
262       AC_MSG_ERROR([cannot identify CGI install directory.  Set cgiexecdir on configure command line])
263     fi
264     cgiexecdir="$rjk_cv_cgiexecdir"
265   fi
266 fi
267 AC_ARG_VAR([cgiexecdir], [location of cgi-bin directory, e.g. /usr/lib/cgi-bin])
268 AC_ARG_VAR([httpdir], [location of http document root, e.g. /var/www/htdocs])
269 if test -z "$pkghttpdir"; then
270   pkghttpdir='$(httpdir)/disorder'
271 fi
272 AC_SUBST([pkghttpdir])
273
274 subdirs="scripts lib"
275 if test $want_tests = yes; then
276   subdirs="${subdirs} libtests"
277 fi
278 subdirs="${subdirs} clients doc examples debian"
279
280 if test $want_server = yes; then
281   subdirs="${subdirs} server plugins driver sounds"
282 fi
283 if test $want_cgi = yes; then
284   subdirs="${subdirs} cgi templates images"
285 fi
286 if test $want_gtk = yes; then
287   subdirs="${subdirs} disobedience"
288   if test $want_server = no; then
289     subdirs="${subdirs} images"
290   fi
291 fi
292 if test $want_tests = yes && test $want_python = yes; then
293   AM_PATH_PYTHON([2.4])
294   subdirs="${subdirs} python tests"
295 fi
296 AC_SUBST([subdirs])
297
298 # libtool config
299 AC_LIBTOOL_DLOPEN
300 AC_DISABLE_STATIC
301
302 AC_PROG_LIBTOOL
303
304 AC_CACHE_CHECK([for GNU sed],[rjk_cv_gnused],[
305   rjk_cv_gnused="not found"
306   for candidate in sed gsed; do
307     if $candidate --version >/dev/null 2>&1; then
308       rjk_cv_gnused=$candidate 
309     fi
310   done
311 ])
312 GNUSED="${GNUSED:-$rjk_cv_gnused}"
313 if test "$GNUSED" = "not found"; then
314   AC_MSG_ERROR([GNU sed is required to build this program])
315 fi
316 AC_SUBST([GNUSED])
317
318 AC_CHECK_PROGS([GROG],[grog])
319 AM_CONDITIONAL([GROG],[test "x$GROG" != xnone])
320
321 missing_libraries=""
322 missing_headers=""
323 missing_functions=""
324
325 AC_DEFINE(_GNU_SOURCE, 1, [required for e.g. strsignal])
326
327 AC_PATH_PROG([SENDMAIL],[sendmail],[none],[$PATH:/usr/sbin:/usr/lib])
328
329 # Macs might have libraries under fink's root
330 AC_PATH_PROG([FINK],[fink],[none],[$PATH:/sw/bin])
331 if test "x$FINK" != xnone; then
332   AC_CACHE_CHECK([fink install directory],[rjk_cv_finkprefix],[
333     rjk_cv_finkprefix="`echo "$FINK" | sed 's,/bin/fink$,,'`"
334   ])
335   finkdir="${rjk_cv_finkprefix}"
336   finkbindir="${rjk_cv_finkprefix}/bin"
337   CPPFLAGS="${CPPFLAGS} -I${rjk_cv_finkprefix}/include/gc -I${rjk_cv_finkprefix}/include"
338   if test $want_server = yes; then
339     CPPFLAGS="${CPPFLAGS} -I${rjk_cv_finkprefix}/include/db4"
340   fi
341   LDFLAGS="${LDFLAGS} -L${rjk_cv_finkprefix}/lib"
342 else
343   finkbindir=""
344 fi
345 AC_SUBST([finkdir])
346 AC_SUBST([finkbindir])
347
348 # Checks for libraries.
349 # We save up a list of missing libraries that we can't do without
350 # and report them all at once.
351 AC_CHECK_LIB(gc, GC_malloc,            [AC_SUBST(LIBGC,[-lgc])],
352             [missing_libraries="$missing_libraries libgc"])
353 AC_CHECK_LIB(gcrypt, gcry_md_open,
354              [AC_SUBST(LIBGCRYPT,[-lgcrypt])],
355             [missing_libraries="$missing_libraries libgcrypt"])
356 AC_CHECK_LIB(pcre, pcre_compile,
357              [AC_SUBST(LIBPCRE,[-lpcre])],
358              [missing_libraries="$missing_libraries libpcre"])
359 if test $want_alsa = yes; then
360   AC_CHECK_LIB([asound], [snd_pcm_open],
361                [AC_SUBST(LIBASOUND,[-lasound])])
362 fi
363 if test $want_server = yes; then
364   RJK_CHECK_LIB(db, db_create, [#include <db.h>],
365                [AC_SUBST(LIBDB,[-ldb])],
366                [missing_libraries="$missing_libraries libdb"])
367   AC_CHECK_LIB(vorbis, vorbis_info_clear,
368                [:],
369                [missing_libraries="$missing_libraries libvorbis"])
370   AC_CHECK_LIB(vorbisfile, ov_open,
371                [AC_SUBST(LIBVORBISFILE,["-lvorbisfile -lvorbis"])],
372                [missing_libraries="$missing_libraries libvorbisfile"],
373                [-lvorbis])
374   AC_CHECK_LIB(mad, mad_stream_init,
375                [AC_SUBST(LIBMAD,[-lmad])],
376                [missing_libraries="$missing_libraries libmad"])
377   AC_CHECK_LIB([ao], [ao_initialize],
378                [AC_SUBST(LIBAO,[-lao])],
379                [missing_libraries="$missing_libraries libao"])
380   AC_CHECK_LIB([FLAC], [FLAC__stream_decoder_new],
381                [AC_SUBST(LIBFLAC,[-lFLAC])],
382                [missing_libraries="$missing_libraries libFLAC"])
383 fi
384 AC_CHECK_LIB([pthread], [pthread_create],
385              [AC_SUBST(LIBPTHREAD,[-lpthread])],
386              [missing_libraries="$missing_libraries libpthread"])
387
388 if test $want_gtk = yes; then
389   AM_PATH_GLIB_2_0([],[],[missing_libraries="$missing_libraries libglib"])
390   AM_PATH_GTK_2_0([],[],[missing_libraries="$missing_libraries libgtk"])
391 fi
392
393 # Some platforms have iconv already
394 AC_CHECK_FUNC(iconv_open, [:],
395               [RJK_CHECK_LIB(iconv, iconv_open, [#include <iconv.h>],
396                             [AC_SUBST(LIBICONV,[-liconv])],
397                             [missing_functions="$missing_functions iconv_open"])])
398 AC_CHECK_FUNC([gethostbyname],[:],[
399   AC_CHECK_LIB(nsl,gethostbyname,
400                [AC_SUBST(LIBNSL,[-lnsl])],
401                [missing_functions="$missing_functions gethostbyname"])])
402 AC_CHECK_FUNC([socket],[:],[
403   AC_CHECK_LIB(socket,socket,
404                [AC_SUBST(LIBSOCKET,[-lsocket])],
405                [missing_functions="$missing_functions socket"])])
406 AC_CHECK_FUNC([dlopen],[:],[
407   AC_CHECK_LIB(dl,dlopen,
408                [AC_SUBST(LIBDL,[-ldl])],
409                [missing_functions="$missing_functions dlopen"])])
410
411 if test ! -z "$missing_libraries"; then
412   AC_MSG_ERROR([missing libraries:$missing_libraries])
413 fi
414
415 # Checks for header files.
416 RJK_FIND_GC_H
417 if test $want_oss = yes; then
418   AC_CHECK_HEADERS([sys/soundcard.h])
419 fi
420 if test $want_alsa = yes; then
421   AC_CHECK_HEADERS([alsa/asoundlib.h])
422 fi
423 if test $want_coreaudio = yes; then
424   AC_CHECK_HEADERS([CoreAudio/AudioHardware.h])
425 fi
426 AC_CHECK_HEADERS([inttypes.h])
427 # We don't bother checking very standard stuff
428 # Compilation will fail if any of these headers are missing, so we
429 # check for them here and fail early.
430 if test $want_server = yes; then
431   AC_CHECK_HEADERS([db.h],[:],[
432     missing_headers="$missing_headers $ac_header"
433   ])
434   AC_CHECK_HEADERS([FLAC/file_decoder.h])
435 fi
436 AC_CHECK_HEADERS([dlfcn.h gcrypt.h \
437                  getopt.h iconv.h langinfo.h \
438                  pcre.h sys/ioctl.h \
439                  syslog.h unistd.h],[:],[
440   missing_headers="$missing_headers $ac_header"
441 ])
442
443 if test ! -z "$missing_headers"; then
444   AC_MSG_ERROR([missing headers:$missing_headers])
445 fi
446
447 # We require that libpcre support UTF-8
448 RJK_REQUIRE_PCRE_UTF8([-lpcre])
449
450 # Checks for typedefs, structures, and compiler characteristics.
451 AC_C_CONST
452 AC_TYPE_SIZE_T
453 AC_C_INLINE
454 AC_C_BIGENDIAN
455 AC_CHECK_TYPES([struct sockaddr_in6],,,[AC_INCLUDES_DEFAULT
456 #include <netinet/in.h>])
457
458 # enable -Werror when we check for certain characteristics:
459
460 old_CFLAGS="${CFLAGS}"
461 CFLAGS="${CFLAGS} $gcc_werror"
462 AC_CHECK_TYPES([long long,uint32_t,uint8_t,intmax_t,uintmax_t])
463
464 # Some GCC invocations warn for converting function pointers to void *.
465 # This is fair enough, as it's technically forbidden, but we use dlsym()
466 # which can pretty much only exist if object and function pointers are
467 # interconvertable.  So we disable -Werror if need be.
468 if test ! -z "$gcc_werror"; then
469   AC_CACHE_CHECK([whether function pointers can be converted to void * without a warning],
470                  [rjk_cv_function_pointer_cast],[
471     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
472   void somefunction(void);],
473                       [(void *)somefunction])],
474                       [rjk_cv_function_pointer_cast=yes],
475                       [rjk_cv_function_pointer_cast=no])])
476   if test $rjk_cv_function_pointer_cast = no; then
477     gcc_werror=""
478   fi
479 fi
480
481 CFLAGS="${old_CFLAGS}"
482
483 # gcrypt maintainers keep changing everything.  Design your interface
484 # first, then implement it once, rather than getting it wrong three or
485 # four times and shipping between each attempt.
486 AC_CACHE_CHECK([for hash handle type in <grypt.h>],
487                [rjk_cv_gcrypt_hash_handle],[
488   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
489 #include <gcrypt.h>
490 ],
491                [gcry_md_hd_t h;])],
492                [rjk_cv_gcrypt_hash_handle=gcry_md_hd_t],[
493     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
494 #include <gcrypt.h>
495 ],
496                  [GcryMDHd h;])],
497                  [rjk_cv_gcrypt_hash_handle=GcryMDHd],
498                  [rjk_cv_gcrypt_hash_handle=GCRY_MD_HD])])])
499 AC_DEFINE_UNQUOTED([gcrypt_hash_handle],[$rjk_cv_gcrypt_hash_handle],
500                    [libgcrypt hash handle type])
501
502 AC_CACHE_CHECK([for gcry_error_t in <grypt.h>],
503                [rjk_cv_have_gcry_error_t],[
504   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
505 #include <gcrypt.h>
506 ],
507                  [gcry_error_t e;])],
508                  [rjk_cv_have_gcry_error_t=yes],
509                  [rjk_cv_have_gcry_error_t=no])])
510 if test $rjk_cv_have_gcry_error_t = yes; then
511   AC_DEFINE([HAVE_GCRY_ERROR_T],1,[define if <gcrypt.h> defines gcry_error_t])
512 fi
513
514 # Checks for functions
515 if test $ac_cv_type_long_long = yes; then
516   AC_CHECK_FUNCS([atoll strtoll],[:],[
517     missing_functions="$missing_functions $ac_func"
518   ])
519   # Darwin sometimes fails to declare strtoll (e.g. if you ask for -std=c99)
520   AC_CACHE_CHECK([whether strtoll is declared in <stdlib.h>],
521                  [rjk_cv_strtoll_declared],[
522     AC_EGREP_HEADER([strtoll], [stdlib.h],
523                     [rjk_cv_strtoll_declared=yes],
524                     [rjk_cv_strtoll_declared=no])])
525   if test $rjk_cv_strtoll_declared = yes; then
526     AC_DEFINE([DECLARES_STRTOLL],[1],[define if <stdlib.h> declares strtoll])
527   fi
528   AC_CACHE_CHECK([whether atoll is declared in <stdlib.h>],
529                  [rjk_cv_atoll_declared],[
530     AC_EGREP_HEADER([atoll], [stdlib.h],
531                     [rjk_cv_atoll_declared=yes],
532                     [rjk_cv_atoll_declared=no])])
533   if test $rjk_cv_atoll_declared = yes; then
534     AC_DEFINE([DECLARES_ATOLL],[1],[define if <stdlib.h> declares atoll])
535   fi
536 fi
537 AC_CHECK_FUNCS([ioctl nl_langinfo strsignal setenv unsetenv],[:],[
538   missing_functions="$missing_functions $ac_func"
539 ])
540 # fsync will do if fdatasync not available
541 AC_CHECK_FUNCS([fdatasync],[:],[
542   AC_CHECK_FUNCS([fsync],
543                  [AC_DEFINE([fdatasync],[fsync],[define fdatasync to fsync if not available])],
544                  [missing_functions="$missing_functions fdatasync"])])
545 if test ! -z "$missing_functions"; then
546   AC_MSG_ERROR([missing functions:$missing_functions])
547 fi
548
549 # Functions we can take or leave
550 AC_CHECK_FUNCS([fls])
551
552 if test $want_server = yes; then
553   # <db.h> had better be version 3 or later
554   AC_CACHE_CHECK([db.h version],[rjk_cv_db_version],[
555     AC_PREPROC_IFELSE([
556                        #include <db.h>
557                        #ifndef DB_VERSION_MAJOR
558                        # error cannot determine db version
559                        #endif
560                        #if DB_VERSION_MAJOR < 4
561                        # error inadequate db version
562                        #endif
563                        #if DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR <= 2
564                        # error inadequate db version
565                        #endif
566                       ],
567                       [rjk_cv_db_version=ok],
568                       [rjk_cv_db_version=inadequate])
569   ])
570   if test $rjk_cv_db_version != ok; then
571     AC_MSG_ERROR([need db.h version at least 4.2])
572   fi
573 fi
574
575 AM_CONDITIONAL([SERVER], [test x$want_server = xyes])
576 if test $want_gtk = yes; then
577   AC_DEFINE([WITH_GTK], [1], [define if using GTK+])
578 fi
579
580 if test "x$GCC" = xyes; then
581   # We need LLONG_MAX and annoyingly GCC doesn't always give it to us
582   # by default.
583   AC_CACHE_CHECK([what C version to ask for],[rjk_cv_cstd],[
584     AC_TRY_COMPILE([#include <limits.h>],[
585       long long n = LLONG_MAX;
586     ],[rjk_cv_cstd=default],[
587       old_CC="$CC"
588       CC="${CC} -std=gnu99"
589       AC_TRY_COMPILE([#include <limits.h>],[
590         long long n = LLONG_MAX;
591       ],[rjk_cv_cstd=gnu99],[rjk_cv_cstd=unknown])
592       CC="$old_CC"
593     ])
594   ])
595   case $rjk_cv_cstd in
596   default | unknown )
597     ;;
598   * )
599     CC="${CC} -std=${rjk_cv_cstd}"
600     ;;
601   esac
602
603   # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29478
604   AC_CACHE_CHECK([checking for GCC bug 29478],[rjk_cv_pr29478],[
605     old_CC="$CC"
606     if test $GCC = yes; then
607       CC="$CC -Wall -Werror"
608     fi
609     AC_COMPILE_IFELSE([
610       static int x(char *f) {
611        return *f;
612       }
613       int z(const char *g) {
614         return x((char *)g);
615       }],
616       [rjk_cv_pr29478=no],
617       [rjk_cv_pr29478=yes]
618     )
619     CC="$old_CC"
620   ])
621   if test $rjk_cv_pr29478 = yes; then
622     gcc_werror=''
623   fi
624
625   # a reasonable default set of warnings
626   CC="${CC} -Wall -W -Wpointer-arith -Wbad-function-cast \
627         -Wwrite-strings -Wmissing-prototypes \
628         -Wmissing-declarations -Wnested-externs"
629
630   # Fix up GTK+ and GLib compiler flags
631   GTK_CFLAGS="`echo \"$GTK_CFLAGS\"|sed 's/-I/-isystem /g'`"
632   GLIB_CFLAGS="`echo \"$GLIB_CFLAGS\"|sed 's/-I/-isystem /g'`"
633
634   if test "$gcc_werror" != ''; then
635     # GCC 2.95 doesn't know to ignore warnings from system headers
636     AC_CACHE_CHECK([whether -Werror is usable],
637                     rjk_cv_werror, [
638       save_CFLAGS="${CFLAGS}"
639       CFLAGS="${CFLAGS} ${GTK_CFLAGS} -Werror"
640       AC_TRY_COMPILE([#if WITH_GTK
641  #include <gtk/gtk.h>
642 #endif
643
644 struct s { int a, b; };
645 const struct s sv = { .a = 1 };],
646                      [],
647                      [rjk_cv_werror=yes],
648                      [rjk_cv_werror=no])
649       CFLAGS="${save_CFLAGS}"
650     ])
651     if test $rjk_cv_werror = no; then
652       gcc_werror=''
653     fi
654   fi
655   CC="${CC} $gcc_werror"
656
657   # for older GCCs that don't know %ju (etc)
658   AC_CACHE_CHECK([whether -Wno-format is required],
659                  rjk_cv_noformat,
660                  AC_TRY_COMPILE([#include <stdio.h>
661 #include <stdint.h>
662 ],
663                                 [printf("%ju", (uintmax_t)0);],
664                                 [rjk_cv_noformat=no],
665                                 [rjk_cv_noformat=yes]))
666   if test $rjk_cv_noformat = yes; then
667     CC="${CC} -Wno-format"
668   fi
669
670   AC_CACHE_CHECK([whether -Wshadow is OK],
671                  rjk_cv_shadow,
672                  oldCC="${CC}"
673                  CC="${CC} -Wshadow"
674                  [AC_TRY_COMPILE([
675 #include <unistd.h>
676 #include <vorbis/vorbisfile.h>
677 ],
678                                 [],
679                                 [rjk_cv_shadow=yes],
680                                 [rjk_cv_shadow=no])
681                  CC="${oldCC}"])
682   if test $rjk_cv_shadow = yes; then
683     CC="${CC} -Wshadow"
684   fi
685 fi
686
687 RJK_GCOV
688
689 AH_BOTTOM([#ifdef __GNUC__
690 # define attribute(x) __attribute__(x)
691 #else
692 # define attribute(x)
693 #endif])
694
695 AC_CONFIG_FILES([Makefile
696                  images/Makefile
697                  scripts/Makefile
698                  lib/Makefile
699                  server/Makefile
700                  cgi/Makefile
701                  clients/Makefile
702                  disobedience/Makefile
703                  doc/Makefile
704                  templates/Makefile
705                  plugins/Makefile
706                  driver/Makefile
707                  debian/Makefile
708                  sounds/Makefile
709                  python/Makefile
710                  examples/Makefile
711                  libtests/Makefile
712                  tests/Makefile])
713 AC_OUTPUT
714
715 if test $GCC = yes && test "$gcc_werror" = ''; then
716   AC_MSG_WARN([building without -Werror])
717 fi
718 if test $want_python = no; then
719   AC_MSG_WARN([cannot run the test suit without Python])
720 fi
721
722 # Local Variables:
723 # indent-tabs-mode:nil
724 # End: