chiark / gitweb /
choose_populate() always raise choose-more-tracks rather than only
[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
439c12ca
RK
49 case "$CC" in
50 *-std=* )
51 ;;
52 * )
53 CC="${CC} -std=gnu99"
54 ;;
55 esac
a9f0ad12 56else
fdca70ee 57 AC_MSG_ERROR([GNU C is required to build this program])
a9f0ad12
RK
58 gcc_werror=""
59fi
60
e2f0c461
RK
61AC_ARG_WITH([alsa],
62 [AS_HELP_STRING([--without-alsa],
63 [do not build with ALSA support])],
64 [want_alsa=$withval])
65AC_ARG_WITH([oss],
66 [AS_HELP_STRING([--without-oss],
67 [do not build with OSS support])],
68 [want_oss=$withval])
69AC_ARG_WITH([coreaudio],
70 [AS_HELP_STRING([--without-coreaudio],
71 [do not build with Core Audio support])],
72 [want_coreaudio=$withval])
7affb407
RK
73AC_ARG_WITH([tests],
74 [AS_HELP_STRING([--without-tests],
75 [do not build test suit])],
76 [want_tests=$withval])
e2f0c461 77
a9f0ad12 78AC_MSG_CHECKING([for a known target platform])
dea8f8aa 79case "$host" in
a9f0ad12 80*empeg* )
e3426f7b 81 AC_MSG_RESULT([empeg car stereo])
a9f0ad12
RK
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])
e3426f7b 85 AC_CHECK_LIB([pthread], [pthread_create])
a9f0ad12 86 want_server=no
4cbafe13 87 want_cgi=no
a9f0ad12 88 ;;
dea8f8aa 89*linux* | *Linux* )
a9f0ad12 90 AC_MSG_RESULT([Linux])
dea8f8aa 91 ;;
9086a105 92*-apple-darwin* )
e3426f7b 93 AC_MSG_RESULT([Mac OS X])
e2f0c461
RK
94 if test $want_coreaudio = yes; then
95 COREAUDIO="-framework CoreAudio"
96 fi
0ec4c5e6 97 browser=open
8fcf5c48
RK
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])
9086a105 120 ;;
70f47acd
RK
121*-freebsd* )
122 AC_MSG_RESULT([FreeBSD])
edbd470f 123 # Ports install to /usr/local but the compiler stupidly doesn't look
124 # there by default
70f47acd 125 LDFLAGS="${LDFLAGS} -L/usr/local/lib"
e6ea27d8 126 CPPFLAGS="${CPPFLAGS} -isystem /usr/local/include"
42f43a11
RK
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
70f47acd 141 ;;
dea8f8aa 142* )
a9f0ad12 143 AC_MSG_RESULT([unknown, winging it])
dea8f8aa
RK
144 ;;
145esac
9086a105 146AC_SUBST([COREAUDIO])
dea8f8aa 147
f486ea18
RK
148AC_ARG_WITH([browser],
149 [AS_HELP_STRING([--with-browser=BROWSER],
150 [use BROWSER to display HTML])],
151 [browser=$withval])
152
153AC_CACHE_CHECK([default HTML viewer],[rjk_cv_browser],[
154 rjk_cv_browser=UNKNOWN
58d97da4 155 for candidate in x-www-browser sensible-browser firefox mozilla konqueror netscape; do
f486ea18
RK
156 if type $candidate >/dev/null 2>&1; then
157 rjk_cv_browser="$candidate"
158 break
159 fi
160 done
161])
162if test -z "$browser"; then
163 browser="$rjk_cv_browser"
164fi
165AC_DEFINE_UNQUOTED([BROWSER],["$browser"],[HTML viewer])
166
460b9539 167AC_ARG_WITH([server],
168 [AS_HELP_STRING([--without-server],
169 [do not build server])],
170 [want_server=$withval])
4cbafe13
RK
171AC_ARG_WITH([cgi],
172 [AS_HELP_STRING([--without-cgi],
173 [do not build CGI])],
174 [want_cgi=$withval])
460b9539 175AC_ARG_WITH([gtk],
176 [AS_HELP_STRING([--without-gtk],
177 [do not build GTK+ client])],
178 [want_gtk=$withval])
179AC_ARG_WITH([python],
180 [AS_HELP_STRING([--without-python],
181 [do not build Python support])],
182 [want_python=$withval])
183
4cbafe13
RK
184if test $want_server = no; then
185 want_cgi=no
186fi
187
64ac73bb
RK
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#
4cbafe13 210if test $want_cgi = yes; then
64ac73bb
RK
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
4cbafe13
RK
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 \
64ac73bb
RK
239 /srv/www/cgi-bin \
240 /var/www/cgi-bin \
241 /home/httpd/cgi-bin \
242 /var/www/localhost/cgi-bin \
4cbafe13
RK
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
257fi
258AC_ARG_VAR([cgidir], [location of cgi-bin directory, e.g. /usr/lib/cgi-bin])
64ac73bb
RK
259AC_ARG_VAR([httpdir], [location of http document root, e.g. /var/www/htdocs])
260if test -z "$pkghttpdir"; then
261 pkghttpdir='$(httpdir)/disorder'
262fi
263AC_SUBST([pkghttpdir])
4cbafe13 264
7affb407
RK
265subdirs="scripts lib"
266if test $want_tests = yes; then
267 subdirs="${subdirs} libtests"
268fi
269subdirs="${subdirs} clients doc examples debian"
460b9539 270
271if test $want_server = yes; then
4cbafe13
RK
272 subdirs="${subdirs} server plugins driver sounds"
273fi
274if test $want_cgi = yes; then
275 subdirs="${subdirs} cgi templates images"
460b9539 276fi
460b9539 277if test $want_gtk = yes; then
278 subdirs="${subdirs} disobedience"
279 if test $want_server = no; then
280 subdirs="${subdirs} images"
281 fi
282fi
7affb407 283if test $want_tests = yes && test $want_python = yes; then
56fac00d
RK
284 AM_PATH_PYTHON([2.4])
285 subdirs="${subdirs} python tests"
286fi
460b9539 287AC_SUBST([subdirs])
288
289# libtool config
290AC_LIBTOOL_DLOPEN
291AC_DISABLE_STATIC
292
293AC_PROG_LIBTOOL
294
edbd470f 295AC_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])
303GNUSED="${GNUSED:-$rjk_cv_gnused}"
304if test "$GNUSED" = "not found"; then
305 AC_MSG_ERROR([GNU sed is required to build this program])
306fi
307AC_SUBST([GNUSED])
308
4b9b77a6
RK
309AC_CHECK_PROGS([GROG],[grog])
310AM_CONDITIONAL([GROG],[test "x$GROG" != xnone])
311
460b9539 312missing_libraries=""
313missing_headers=""
314missing_functions=""
315
316AC_DEFINE(_GNU_SOURCE, 1, [required for e.g. strsignal])
317
2eee4b0c
RK
318AC_PATH_PROG([SENDMAIL],[sendmail],[none],[$PATH:/usr/sbin:/usr/lib])
319
460b9539 320# Macs might have libraries under fink's root
321AC_PATH_PROG([FINK],[fink],[none],[$PATH:/sw/bin])
322if 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 ])
f9592fe7 326 finkdir="${rjk_cv_finkprefix}"
e83d0967 327 finkbindir="${rjk_cv_finkprefix}/bin"
762f2539 328 CPPFLAGS="${CPPFLAGS} -I${rjk_cv_finkprefix}/include/gc -I${rjk_cv_finkprefix}/include"
460b9539 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"
e83d0967
RK
333else
334 finkbindir=""
460b9539 335fi
f9592fe7 336AC_SUBST([finkdir])
e83d0967 337AC_SUBST([finkbindir])
460b9539 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.
342AC_CHECK_LIB(gc, GC_malloc, [AC_SUBST(LIBGC,[-lgc])],
343 [missing_libraries="$missing_libraries libgc"])
344AC_CHECK_LIB(gcrypt, gcry_md_open,
345 [AC_SUBST(LIBGCRYPT,[-lgcrypt])],
346 [missing_libraries="$missing_libraries libgcrypt"])
347AC_CHECK_LIB(pcre, pcre_compile,
348 [AC_SUBST(LIBPCRE,[-lpcre])],
349 [missing_libraries="$missing_libraries libpcre"])
e2f0c461
RK
350if test $want_alsa = yes; then
351 AC_CHECK_LIB([asound], [snd_pcm_open],
352 [AC_SUBST(LIBASOUND,[-lasound])])
353fi
460b9539 354if 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"])
c57f1201 371 AC_CHECK_LIB([FLAC], [FLAC__stream_decoder_new],
372 [AC_SUBST(LIBFLAC,[-lFLAC])],
373 [missing_libraries="$missing_libraries libFLAC"])
d19ccd72 374fi
edbd470f 375AC_CHECK_LIB([pthread], [pthread_create],
376 [AC_SUBST(LIBPTHREAD,[-lpthread])],
377 [missing_libraries="$missing_libraries libpthread"])
460b9539 378
379if 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"])
382fi
383
384# Some platforms have iconv already
385AC_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"])])
389AC_CHECK_FUNC([gethostbyname],[:],[
390 AC_CHECK_LIB(nsl,gethostbyname,
391 [AC_SUBST(LIBNSL,[-lnsl])],
392 [missing_functions="$missing_functions gethostbyname"])])
393AC_CHECK_FUNC([socket],[:],[
394 AC_CHECK_LIB(socket,socket,
395 [AC_SUBST(LIBSOCKET,[-lsocket])],
396 [missing_functions="$missing_functions socket"])])
397AC_CHECK_FUNC([dlopen],[:],[
398 AC_CHECK_LIB(dl,dlopen,
399 [AC_SUBST(LIBDL,[-ldl])],
400 [missing_functions="$missing_functions dlopen"])])
401
402if test ! -z "$missing_libraries"; then
403 AC_MSG_ERROR([missing libraries:$missing_libraries])
404fi
405
460b9539 406# Checks for header files.
407RJK_FIND_GC_H
e2f0c461
RK
408if test $want_oss = yes; then
409 AC_CHECK_HEADERS([sys/soundcard.h])
410fi
411if test $want_alsa = yes; then
412 AC_CHECK_HEADERS([alsa/asoundlib.h])
413fi
414if test $want_coreaudio = yes; then
415 AC_CHECK_HEADERS([CoreAudio/AudioHardware.h])
416fi
417AC_CHECK_HEADERS([inttypes.h])
146e86fb 418# We don't bother checking very standard stuff
460b9539 419# Compilation will fail if any of these headers are missing, so we
420# check for them here and fail early.
460b9539 421if test $want_server = yes; then
422 AC_CHECK_HEADERS([db.h],[:],[
423 missing_headers="$missing_headers $ac_header"
424 ])
762806f1 425 AC_CHECK_HEADERS([FLAC/file_decoder.h])
460b9539 426fi
427AC_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
434if test ! -z "$missing_headers"; then
435 AC_MSG_ERROR([missing headers:$missing_headers])
436fi
437
70f47acd
RK
438# We require that libpcre support UTF-8
439RJK_REQUIRE_PCRE_UTF8([-lpcre])
440
460b9539 441# Checks for typedefs, structures, and compiler characteristics.
442AC_C_CONST
443AC_TYPE_SIZE_T
444AC_C_INLINE
5330d674 445AC_C_BIGENDIAN
460b9539 446AC_CHECK_TYPES([struct sockaddr_in6],,,[AC_INCLUDES_DEFAULT
447#include <netinet/in.h>])
448
449# enable -Werror when we check for certain characteristics:
450
451old_CFLAGS="${CFLAGS}"
452CFLAGS="${CFLAGS} $gcc_werror"
453AC_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.
459if 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
470fi
471
472CFLAGS="${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.
477AC_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])])])
490AC_DEFINE_UNQUOTED([gcrypt_hash_handle],[$rjk_cv_gcrypt_hash_handle],
491 [libgcrypt hash handle type])
492
493AC_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])])
501if 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])
503fi
504
505# Checks for functions
506if 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
527fi
5b708e0c 528AC_CHECK_FUNCS([ioctl nl_langinfo strsignal setenv unsetenv],[:],[
460b9539 529 missing_functions="$missing_functions $ac_func"
530])
531# fsync will do if fdatasync not available
532AC_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"])])
536if test ! -z "$missing_functions"; then
537 AC_MSG_ERROR([missing functions:$missing_functions])
538fi
7c8c2fc9
RK
539
540# Functions we can take or leave
541AC_CHECK_FUNCS([fls])
542
460b9539 543if 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
f4687532 554 #if DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR <= 2
460b9539 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
564fi
565
e63c38e8 566AM_CONDITIONAL([SERVER], [test x$want_server = xyes])
588b2763
RK
567if test $want_gtk = yes; then
568 AC_DEFINE([WITH_GTK], [1], [define if using GTK+])
569fi
e63c38e8 570
460b9539 571if test "x$GCC" = xyes; then
e84ca290
RK
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
f368d6c7
RK
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
460b9539 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
f368d6c7
RK
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"
588b2763
RK
631 AC_TRY_COMPILE([#if WITH_GTK
632 #include <gtk/gtk.h>
633#endif
634
635struct s { int a, b; };
636const struct s sv = { .a = 1 };],
f368d6c7
RK
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
460b9539 645 fi
646 CC="${CC} $gcc_werror"
647
648 # for older GCCs that don't know %ju (etc)
9a5f7aba 649 AC_CACHE_CHECK([whether -Wno-format is required],
460b9539 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
9a5f7aba 661 AC_CACHE_CHECK([whether -Wshadow is OK],
460b9539 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
460b9539 676fi
677
1a00f590
RK
678RJK_GCOV
679
460b9539 680AH_BOTTOM([#ifdef __GNUC__
681# define attribute(x) __attribute__(x)
682#else
683# define attribute(x)
684#endif])
685
686AC_CONFIG_FILES([Makefile
460b9539 687 images/Makefile
688 scripts/Makefile
689 lib/Makefile
690 server/Makefile
05b75f8d 691 cgi/Makefile
460b9539 692 clients/Makefile
693 disobedience/Makefile
694 doc/Makefile
3e1616b6 695 templates/Makefile
460b9539 696 plugins/Makefile
697 driver/Makefile
698 debian/Makefile
699 sounds/Makefile
700 python/Makefile
c5dbcd79 701 examples/Makefile
7affb407 702 libtests/Makefile
c5dbcd79 703 tests/Makefile])
460b9539 704AC_OUTPUT
f368d6c7
RK
705
706if test $GCC = yes && test "$gcc_werror" = ''; then
707 AC_MSG_WARN([building without -Werror])
708fi
56fac00d
RK
709if test $want_python = no; then
710 AC_MSG_WARN([cannot run the test suit without Python])
711fi
4cbafe13
RK
712
713# Local Variables:
714# indent-tabs-mode:nil
715# End: