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