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