chiark / gitweb /
Automate installation of the CGI at last.
[disorder] / configure.ac
CommitLineData
460b9539 1# Process this file with autoconf to produce a configure script.
2#
3# This file is part of DisOrder.
5aff007d 4# Copyright (C) 2004-2008 Richard Kettlewell
313acc77 5# Portions copyright (C) 2007 Ross Younger
460b9539 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
bea6f6d5 23AC_INIT([disorder], [3.0+], [richard+disorder@sfere.greenend.org.uk])
460b9539 24AC_CONFIG_AUX_DIR([config.aux])
bea6f6d5 25AM_INIT_AUTOMAKE(disorder, [3.0+])
460b9539 26AC_CONFIG_SRCDIR([server/disorderd.c])
27AM_CONFIG_HEADER([config.h])
28
dea8f8aa
RK
29# Find host type
30AC_CANONICAL_HOST
31
460b9539 32# What we want to build
460b9539 33want_gtk=yes
34want_python=yes
7affb407 35want_tests=yes
4cbafe13
RK
36want_server=yes
37want_cgi=yes
460b9539 38
e2f0c461
RK
39# APIs we want
40want_alsa=yes
41want_oss=yes
42want_coreaudio=yes
43
a9f0ad12
RK
44# Checks for programs.
45AC_PROG_CC
46AC_SET_MAKE
47if test "x$GCC" = xyes; then
48 gcc_werror=-Werror
49else
fdca70ee 50 AC_MSG_ERROR([GNU C is required to build this program])
a9f0ad12
RK
51 gcc_werror=""
52fi
53
e2f0c461
RK
54AC_ARG_WITH([alsa],
55 [AS_HELP_STRING([--without-alsa],
56 [do not build with ALSA support])],
57 [want_alsa=$withval])
58AC_ARG_WITH([oss],
59 [AS_HELP_STRING([--without-oss],
60 [do not build with OSS support])],
61 [want_oss=$withval])
62AC_ARG_WITH([coreaudio],
63 [AS_HELP_STRING([--without-coreaudio],
64 [do not build with Core Audio support])],
65 [want_coreaudio=$withval])
7affb407
RK
66AC_ARG_WITH([tests],
67 [AS_HELP_STRING([--without-tests],
68 [do not build test suit])],
69 [want_tests=$withval])
e2f0c461 70
a9f0ad12 71AC_MSG_CHECKING([for a known target platform])
dea8f8aa 72case "$host" in
a9f0ad12 73*empeg* )
e3426f7b 74 AC_MSG_RESULT([empeg car stereo])
a9f0ad12
RK
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])
e3426f7b 78 AC_CHECK_LIB([pthread], [pthread_create])
a9f0ad12 79 want_server=no
4cbafe13 80 want_cgi=no
a9f0ad12 81 ;;
dea8f8aa 82*linux* | *Linux* )
a9f0ad12 83 AC_MSG_RESULT([Linux])
dea8f8aa 84 ;;
9086a105 85*-apple-darwin* )
e3426f7b 86 AC_MSG_RESULT([Mac OS X])
e2f0c461
RK
87 if test $want_coreaudio = yes; then
88 COREAUDIO="-framework CoreAudio"
89 fi
0ec4c5e6 90 browser=open
8fcf5c48
RK
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])
9086a105 113 ;;
70f47acd
RK
114*-freebsd* )
115 AC_MSG_RESULT([FreeBSD])
edbd470f 116 # Ports install to /usr/local but the compiler stupidly doesn't look
117 # there by default
70f47acd 118 LDFLAGS="${LDFLAGS} -L/usr/local/lib"
e6ea27d8 119 CPPFLAGS="${CPPFLAGS} -isystem /usr/local/include"
42f43a11
RK
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
70f47acd 134 ;;
dea8f8aa 135* )
a9f0ad12 136 AC_MSG_RESULT([unknown, winging it])
dea8f8aa
RK
137 ;;
138esac
9086a105 139AC_SUBST([COREAUDIO])
dea8f8aa 140
f486ea18
RK
141AC_ARG_WITH([browser],
142 [AS_HELP_STRING([--with-browser=BROWSER],
143 [use BROWSER to display HTML])],
144 [browser=$withval])
145
146AC_CACHE_CHECK([default HTML viewer],[rjk_cv_browser],[
147 rjk_cv_browser=UNKNOWN
58d97da4 148 for candidate in x-www-browser sensible-browser firefox mozilla konqueror netscape; do
f486ea18
RK
149 if type $candidate >/dev/null 2>&1; then
150 rjk_cv_browser="$candidate"
151 break
152 fi
153 done
154])
155if test -z "$browser"; then
156 browser="$rjk_cv_browser"
157fi
158AC_DEFINE_UNQUOTED([BROWSER],["$browser"],[HTML viewer])
159
460b9539 160AC_ARG_WITH([server],
161 [AS_HELP_STRING([--without-server],
162 [do not build server])],
163 [want_server=$withval])
4cbafe13
RK
164AC_ARG_WITH([cgi],
165 [AS_HELP_STRING([--without-cgi],
166 [do not build CGI])],
167 [want_cgi=$withval])
460b9539 168AC_ARG_WITH([gtk],
169 [AS_HELP_STRING([--without-gtk],
170 [do not build GTK+ client])],
171 [want_gtk=$withval])
172AC_ARG_WITH([python],
173 [AS_HELP_STRING([--without-python],
174 [do not build Python support])],
175 [want_python=$withval])
176
4cbafe13
RK
177if test $want_server = no; then
178 want_cgi=no
179fi
180
181if test $want_cgi = yes; then
182 if test -z "$cgidir"; then
183 AC_CACHE_CHECK([for CGI directory],[rjk_cv_cgidir],[
184 rjk_cv_cgidir="not found"
185 for dir in /usr/lib/cgi-bin \
186 /Library/WebServer/CGI-Executables \
187 /usr/local/lib/cgi-bin \
188 /usr/local/www/cgi-bin \
189 /usr/local/www/*/cgi-bin; do
190 if test -d "$dir"; then
191 rjk_cv_cgidir="$dir"
192 break
193 fi
194 done
195 ])
196 if test "$rjk_cv_cgidir" = "not found"; then
197 AC_MSG_ERROR([cannot identify CGI install directory. Set cgidir on configure command line])
198 fi
199 cgidir="$rjk_cv_cgidir"
200 fi
201fi
202AC_ARG_VAR([cgidir], [location of cgi-bin directory, e.g. /usr/lib/cgi-bin])
203
7affb407
RK
204subdirs="scripts lib"
205if test $want_tests = yes; then
206 subdirs="${subdirs} libtests"
207fi
208subdirs="${subdirs} clients doc examples debian"
460b9539 209
210if test $want_server = yes; then
4cbafe13
RK
211 subdirs="${subdirs} server plugins driver sounds"
212fi
213if test $want_cgi = yes; then
214 subdirs="${subdirs} cgi templates images"
460b9539 215fi
460b9539 216if test $want_gtk = yes; then
217 subdirs="${subdirs} disobedience"
218 if test $want_server = no; then
219 subdirs="${subdirs} images"
220 fi
221fi
7affb407 222if test $want_tests = yes && test $want_python = yes; then
56fac00d
RK
223 AM_PATH_PYTHON([2.4])
224 subdirs="${subdirs} python tests"
225fi
460b9539 226AC_SUBST([subdirs])
227
228# libtool config
229AC_LIBTOOL_DLOPEN
230AC_DISABLE_STATIC
231
232AC_PROG_LIBTOOL
233
edbd470f 234AC_CACHE_CHECK([for GNU sed],[rjk_cv_gnused],[
235 rjk_cv_gnused="not found"
236 for candidate in sed gsed; do
237 if $candidate --version >/dev/null 2>&1; then
238 rjk_cv_gnused=$candidate
239 fi
240 done
241])
242GNUSED="${GNUSED:-$rjk_cv_gnused}"
243if test "$GNUSED" = "not found"; then
244 AC_MSG_ERROR([GNU sed is required to build this program])
245fi
246AC_SUBST([GNUSED])
247
4b9b77a6
RK
248AC_CHECK_PROGS([GROG],[grog])
249AM_CONDITIONAL([GROG],[test "x$GROG" != xnone])
250
460b9539 251missing_libraries=""
252missing_headers=""
253missing_functions=""
254
255AC_DEFINE(_GNU_SOURCE, 1, [required for e.g. strsignal])
256
2eee4b0c
RK
257AC_PATH_PROG([SENDMAIL],[sendmail],[none],[$PATH:/usr/sbin:/usr/lib])
258
460b9539 259# Macs might have libraries under fink's root
260AC_PATH_PROG([FINK],[fink],[none],[$PATH:/sw/bin])
261if test "x$FINK" != xnone; then
262 AC_CACHE_CHECK([fink install directory],[rjk_cv_finkprefix],[
263 rjk_cv_finkprefix="`echo "$FINK" | sed 's,/bin/fink$,,'`"
264 ])
f9592fe7 265 finkdir="${rjk_cv_finkprefix}"
e83d0967 266 finkbindir="${rjk_cv_finkprefix}/bin"
762f2539 267 CPPFLAGS="${CPPFLAGS} -I${rjk_cv_finkprefix}/include/gc -I${rjk_cv_finkprefix}/include"
460b9539 268 if test $want_server = yes; then
269 CPPFLAGS="${CPPFLAGS} -I${rjk_cv_finkprefix}/include/db4"
270 fi
271 LDFLAGS="${LDFLAGS} -L${rjk_cv_finkprefix}/lib"
e83d0967
RK
272else
273 finkbindir=""
460b9539 274fi
f9592fe7 275AC_SUBST([finkdir])
e83d0967 276AC_SUBST([finkbindir])
460b9539 277
278# Checks for libraries.
279# We save up a list of missing libraries that we can't do without
280# and report them all at once.
281AC_CHECK_LIB(gc, GC_malloc, [AC_SUBST(LIBGC,[-lgc])],
282 [missing_libraries="$missing_libraries libgc"])
283AC_CHECK_LIB(gcrypt, gcry_md_open,
284 [AC_SUBST(LIBGCRYPT,[-lgcrypt])],
285 [missing_libraries="$missing_libraries libgcrypt"])
286AC_CHECK_LIB(pcre, pcre_compile,
287 [AC_SUBST(LIBPCRE,[-lpcre])],
288 [missing_libraries="$missing_libraries libpcre"])
e2f0c461
RK
289if test $want_alsa = yes; then
290 AC_CHECK_LIB([asound], [snd_pcm_open],
291 [AC_SUBST(LIBASOUND,[-lasound])])
292fi
460b9539 293if test $want_server = yes; then
294 RJK_CHECK_LIB(db, db_create, [#include <db.h>],
295 [AC_SUBST(LIBDB,[-ldb])],
296 [missing_libraries="$missing_libraries libdb"])
297 AC_CHECK_LIB(vorbis, vorbis_info_clear,
298 [:],
299 [missing_libraries="$missing_libraries libvorbis"])
300 AC_CHECK_LIB(vorbisfile, ov_open,
301 [AC_SUBST(LIBVORBISFILE,["-lvorbisfile -lvorbis"])],
302 [missing_libraries="$missing_libraries libvorbisfile"],
303 [-lvorbis])
304 AC_CHECK_LIB(mad, mad_stream_init,
305 [AC_SUBST(LIBMAD,[-lmad])],
306 [missing_libraries="$missing_libraries libmad"])
307 AC_CHECK_LIB([ao], [ao_initialize],
308 [AC_SUBST(LIBAO,[-lao])],
309 [missing_libraries="$missing_libraries libao"])
c57f1201 310 AC_CHECK_LIB([FLAC], [FLAC__stream_decoder_new],
311 [AC_SUBST(LIBFLAC,[-lFLAC])],
312 [missing_libraries="$missing_libraries libFLAC"])
d19ccd72 313fi
edbd470f 314AC_CHECK_LIB([pthread], [pthread_create],
315 [AC_SUBST(LIBPTHREAD,[-lpthread])],
316 [missing_libraries="$missing_libraries libpthread"])
460b9539 317
318if test $want_gtk = yes; then
319 AM_PATH_GLIB_2_0([],[],[missing_libraries="$missing_libraries libglib"])
320 AM_PATH_GTK_2_0([],[],[missing_libraries="$missing_libraries libgtk"])
321fi
322
323# Some platforms have iconv already
324AC_CHECK_FUNC(iconv_open, [:],
325 [RJK_CHECK_LIB(iconv, iconv_open, [#include <iconv.h>],
326 [AC_SUBST(LIBICONV,[-liconv])],
327 [missing_functions="$missing_functions iconv_open"])])
328AC_CHECK_FUNC([gethostbyname],[:],[
329 AC_CHECK_LIB(nsl,gethostbyname,
330 [AC_SUBST(LIBNSL,[-lnsl])],
331 [missing_functions="$missing_functions gethostbyname"])])
332AC_CHECK_FUNC([socket],[:],[
333 AC_CHECK_LIB(socket,socket,
334 [AC_SUBST(LIBSOCKET,[-lsocket])],
335 [missing_functions="$missing_functions socket"])])
336AC_CHECK_FUNC([dlopen],[:],[
337 AC_CHECK_LIB(dl,dlopen,
338 [AC_SUBST(LIBDL,[-ldl])],
339 [missing_functions="$missing_functions dlopen"])])
340
341if test ! -z "$missing_libraries"; then
342 AC_MSG_ERROR([missing libraries:$missing_libraries])
343fi
344
460b9539 345# Checks for header files.
346RJK_FIND_GC_H
e2f0c461
RK
347if test $want_oss = yes; then
348 AC_CHECK_HEADERS([sys/soundcard.h])
349fi
350if test $want_alsa = yes; then
351 AC_CHECK_HEADERS([alsa/asoundlib.h])
352fi
353if test $want_coreaudio = yes; then
354 AC_CHECK_HEADERS([CoreAudio/AudioHardware.h])
355fi
356AC_CHECK_HEADERS([inttypes.h])
146e86fb 357# We don't bother checking very standard stuff
460b9539 358# Compilation will fail if any of these headers are missing, so we
359# check for them here and fail early.
460b9539 360if test $want_server = yes; then
361 AC_CHECK_HEADERS([db.h],[:],[
362 missing_headers="$missing_headers $ac_header"
363 ])
762806f1 364 AC_CHECK_HEADERS([FLAC/file_decoder.h])
460b9539 365fi
366AC_CHECK_HEADERS([dlfcn.h gcrypt.h \
367 getopt.h iconv.h langinfo.h \
368 pcre.h sys/ioctl.h \
369 syslog.h unistd.h],[:],[
370 missing_headers="$missing_headers $ac_header"
371])
372
373if test ! -z "$missing_headers"; then
374 AC_MSG_ERROR([missing headers:$missing_headers])
375fi
376
70f47acd
RK
377# We require that libpcre support UTF-8
378RJK_REQUIRE_PCRE_UTF8([-lpcre])
379
460b9539 380# Checks for typedefs, structures, and compiler characteristics.
381AC_C_CONST
382AC_TYPE_SIZE_T
383AC_C_INLINE
5330d674 384AC_C_BIGENDIAN
460b9539 385AC_CHECK_TYPES([struct sockaddr_in6],,,[AC_INCLUDES_DEFAULT
386#include <netinet/in.h>])
387
388# enable -Werror when we check for certain characteristics:
389
390old_CFLAGS="${CFLAGS}"
391CFLAGS="${CFLAGS} $gcc_werror"
392AC_CHECK_TYPES([long long,uint32_t,uint8_t,intmax_t,uintmax_t])
393
394# Some GCC invocations warn for converting function pointers to void *.
395# This is fair enough, as it's technically forbidden, but we use dlsym()
396# which can pretty much only exist if object and function pointers are
397# interconvertable. So we disable -Werror if need be.
398if test ! -z "$gcc_werror"; then
399 AC_CACHE_CHECK([whether function pointers can be converted to void * without a warning],
400 [rjk_cv_function_pointer_cast],[
401 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
402 void somefunction(void);],
403 [(void *)somefunction])],
404 [rjk_cv_function_pointer_cast=yes],
405 [rjk_cv_function_pointer_cast=no])])
406 if test $rjk_cv_function_pointer_cast = no; then
407 gcc_werror=""
408 fi
409fi
410
411CFLAGS="${old_CFLAGS}"
412
413# gcrypt maintainers keep changing everything. Design your interface
414# first, then implement it once, rather than getting it wrong three or
415# four times and shipping between each attempt.
416AC_CACHE_CHECK([for hash handle type in <grypt.h>],
417 [rjk_cv_gcrypt_hash_handle],[
418 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
419#include <gcrypt.h>
420],
421 [gcry_md_hd_t h;])],
422 [rjk_cv_gcrypt_hash_handle=gcry_md_hd_t],[
423 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
424#include <gcrypt.h>
425],
426 [GcryMDHd h;])],
427 [rjk_cv_gcrypt_hash_handle=GcryMDHd],
428 [rjk_cv_gcrypt_hash_handle=GCRY_MD_HD])])])
429AC_DEFINE_UNQUOTED([gcrypt_hash_handle],[$rjk_cv_gcrypt_hash_handle],
430 [libgcrypt hash handle type])
431
432AC_CACHE_CHECK([for gcry_error_t in <grypt.h>],
433 [rjk_cv_have_gcry_error_t],[
434 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
435#include <gcrypt.h>
436],
437 [gcry_error_t e;])],
438 [rjk_cv_have_gcry_error_t=yes],
439 [rjk_cv_have_gcry_error_t=no])])
440if test $rjk_cv_have_gcry_error_t = yes; then
441 AC_DEFINE([HAVE_GCRY_ERROR_T],1,[define if <gcrypt.h> defines gcry_error_t])
442fi
443
444# Checks for functions
445if test $ac_cv_type_long_long = yes; then
446 AC_CHECK_FUNCS([atoll strtoll],[:],[
447 missing_functions="$missing_functions $ac_func"
448 ])
449 # Darwin sometimes fails to declare strtoll (e.g. if you ask for -std=c99)
450 AC_CACHE_CHECK([whether strtoll is declared in <stdlib.h>],
451 [rjk_cv_strtoll_declared],[
452 AC_EGREP_HEADER([strtoll], [stdlib.h],
453 [rjk_cv_strtoll_declared=yes],
454 [rjk_cv_strtoll_declared=no])])
455 if test $rjk_cv_strtoll_declared = yes; then
456 AC_DEFINE([DECLARES_STRTOLL],[1],[define if <stdlib.h> declares strtoll])
457 fi
458 AC_CACHE_CHECK([whether atoll is declared in <stdlib.h>],
459 [rjk_cv_atoll_declared],[
460 AC_EGREP_HEADER([atoll], [stdlib.h],
461 [rjk_cv_atoll_declared=yes],
462 [rjk_cv_atoll_declared=no])])
463 if test $rjk_cv_atoll_declared = yes; then
464 AC_DEFINE([DECLARES_ATOLL],[1],[define if <stdlib.h> declares atoll])
465 fi
466fi
5b708e0c 467AC_CHECK_FUNCS([ioctl nl_langinfo strsignal setenv unsetenv],[:],[
460b9539 468 missing_functions="$missing_functions $ac_func"
469])
470# fsync will do if fdatasync not available
471AC_CHECK_FUNCS([fdatasync],[:],[
472 AC_CHECK_FUNCS([fsync],
473 [AC_DEFINE([fdatasync],[fsync],[define fdatasync to fsync if not available])],
474 [missing_functions="$missing_functions fdatasync"])])
475if test ! -z "$missing_functions"; then
476 AC_MSG_ERROR([missing functions:$missing_functions])
477fi
7c8c2fc9
RK
478
479# Functions we can take or leave
480AC_CHECK_FUNCS([fls])
481
460b9539 482if test $want_server = yes; then
483 # <db.h> had better be version 3 or later
484 AC_CACHE_CHECK([db.h version],[rjk_cv_db_version],[
485 AC_PREPROC_IFELSE([
486 #include <db.h>
487 #ifndef DB_VERSION_MAJOR
488 # error cannot determine db version
489 #endif
490 #if DB_VERSION_MAJOR < 4
491 # error inadequate db version
492 #endif
f4687532 493 #if DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR <= 2
460b9539 494 # error inadequate db version
495 #endif
496 ],
497 [rjk_cv_db_version=ok],
498 [rjk_cv_db_version=inadequate])
499 ])
500 if test $rjk_cv_db_version != ok; then
501 AC_MSG_ERROR([need db.h version at least 4.2])
502 fi
503fi
504
e63c38e8 505AM_CONDITIONAL([SERVER], [test x$want_server = xyes])
588b2763
RK
506if test $want_gtk = yes; then
507 AC_DEFINE([WITH_GTK], [1], [define if using GTK+])
508fi
e63c38e8 509
460b9539 510if test "x$GCC" = xyes; then
e84ca290
RK
511 # We need LLONG_MAX and annoyingly GCC doesn't always give it to us
512 # by default.
513 AC_CACHE_CHECK([what C version to ask for],[rjk_cv_cstd],[
514 AC_TRY_COMPILE([#include <limits.h>],[
515 long long n = LLONG_MAX;
516 ],[rjk_cv_cstd=default],[
517 old_CC="$CC"
518 CC="${CC} -std=gnu99"
519 AC_TRY_COMPILE([#include <limits.h>],[
520 long long n = LLONG_MAX;
521 ],[rjk_cv_cstd=gnu99],[rjk_cv_cstd=unknown])
522 CC="$old_CC"
523 ])
524 ])
525 case $rjk_cv_cstd in
526 default | unknown )
527 ;;
528 * )
529 CC="${CC} -std=${rjk_cv_cstd}"
530 ;;
531 esac
532
f368d6c7
RK
533 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29478
534 AC_CACHE_CHECK([checking for GCC bug 29478],[rjk_cv_pr29478],[
535 old_CC="$CC"
536 if test $GCC = yes; then
537 CC="$CC -Wall -Werror"
538 fi
539 AC_COMPILE_IFELSE([
540 static int x(char *f) {
541 return *f;
542 }
543 int z(const char *g) {
544 return x((char *)g);
545 }],
546 [rjk_cv_pr29478=no],
547 [rjk_cv_pr29478=yes]
548 )
549 CC="$old_CC"
550 ])
551 if test $rjk_cv_pr29478 = yes; then
552 gcc_werror=''
553 fi
554
460b9539 555 # a reasonable default set of warnings
556 CC="${CC} -Wall -W -Wpointer-arith -Wbad-function-cast \
557 -Wwrite-strings -Wmissing-prototypes \
558 -Wmissing-declarations -Wnested-externs"
559
560 # Fix up GTK+ and GLib compiler flags
561 GTK_CFLAGS="`echo \"$GTK_CFLAGS\"|sed 's/-I/-isystem /g'`"
562 GLIB_CFLAGS="`echo \"$GLIB_CFLAGS\"|sed 's/-I/-isystem /g'`"
563
f368d6c7
RK
564 if test "$gcc_werror" != ''; then
565 # GCC 2.95 doesn't know to ignore warnings from system headers
566 AC_CACHE_CHECK([whether -Werror is usable],
567 rjk_cv_werror, [
568 save_CFLAGS="${CFLAGS}"
569 CFLAGS="${CFLAGS} ${GTK_CFLAGS} -Werror"
588b2763
RK
570 AC_TRY_COMPILE([#if WITH_GTK
571 #include <gtk/gtk.h>
572#endif
573
574struct s { int a, b; };
575const struct s sv = { .a = 1 };],
f368d6c7
RK
576 [],
577 [rjk_cv_werror=yes],
578 [rjk_cv_werror=no])
579 CFLAGS="${save_CFLAGS}"
580 ])
581 if test $rjk_cv_werror = no; then
582 gcc_werror=''
583 fi
460b9539 584 fi
585 CC="${CC} $gcc_werror"
586
587 # for older GCCs that don't know %ju (etc)
9a5f7aba 588 AC_CACHE_CHECK([whether -Wno-format is required],
460b9539 589 rjk_cv_noformat,
590 AC_TRY_COMPILE([#include <stdio.h>
591#include <stdint.h>
592],
593 [printf("%ju", (uintmax_t)0);],
594 [rjk_cv_noformat=no],
595 [rjk_cv_noformat=yes]))
596 if test $rjk_cv_noformat = yes; then
597 CC="${CC} -Wno-format"
598 fi
599
9a5f7aba 600 AC_CACHE_CHECK([whether -Wshadow is OK],
460b9539 601 rjk_cv_shadow,
602 oldCC="${CC}"
603 CC="${CC} -Wshadow"
604 [AC_TRY_COMPILE([
605#include <unistd.h>
606#include <vorbis/vorbisfile.h>
607],
608 [],
609 [rjk_cv_shadow=yes],
610 [rjk_cv_shadow=no])
611 CC="${oldCC}"])
612 if test $rjk_cv_shadow = yes; then
613 CC="${CC} -Wshadow"
614 fi
460b9539 615fi
616
1a00f590
RK
617RJK_GCOV
618
460b9539 619AH_BOTTOM([#ifdef __GNUC__
620# define attribute(x) __attribute__(x)
621#else
622# define attribute(x)
623#endif])
624
625AC_CONFIG_FILES([Makefile
460b9539 626 images/Makefile
627 scripts/Makefile
628 lib/Makefile
629 server/Makefile
05b75f8d 630 cgi/Makefile
460b9539 631 clients/Makefile
632 disobedience/Makefile
633 doc/Makefile
3e1616b6 634 templates/Makefile
460b9539 635 plugins/Makefile
636 driver/Makefile
637 debian/Makefile
638 sounds/Makefile
639 python/Makefile
c5dbcd79 640 examples/Makefile
7affb407 641 libtests/Makefile
c5dbcd79 642 tests/Makefile])
460b9539 643AC_OUTPUT
f368d6c7
RK
644
645if test $GCC = yes && test "$gcc_werror" = ''; then
646 AC_MSG_WARN([building without -Werror])
647fi
56fac00d
RK
648if test $want_python = no; then
649 AC_MSG_WARN([cannot run the test suit without Python])
650fi
4cbafe13
RK
651
652# Local Variables:
653# indent-tabs-mode:nil
654# End: