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