1 # Process this file with autoconf to produce a configure script.
3 # This file is part of DisOrder.
4 # Copyright (C) 2004-2008 Richard Kettlewell
5 # Portions copyright (C) 2007 Ross Younger
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.
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.
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
23 AC_INIT([disorder], [3.0+], [richard+disorder@sfere.greenend.org.uk])
24 AC_CONFIG_AUX_DIR([config.aux])
25 AM_INIT_AUTOMAKE(disorder, [3.0+])
26 AC_CONFIG_SRCDIR([server/disorderd.c])
27 AM_CONFIG_HEADER([config.h])
32 # What we want to build
42 # Checks for programs.
45 if test "x$GCC" = xyes; then
48 AC_MSG_ERROR([GNU C is required to build this program])
53 [AS_HELP_STRING([--without-alsa],
54 [do not build with ALSA support])],
57 [AS_HELP_STRING([--without-oss],
58 [do not build with OSS support])],
60 AC_ARG_WITH([coreaudio],
61 [AS_HELP_STRING([--without-coreaudio],
62 [do not build with Core Audio support])],
63 [want_coreaudio=$withval])
65 [AS_HELP_STRING([--without-tests],
66 [do not build test suit])],
67 [want_tests=$withval])
69 AC_MSG_CHECKING([for a known target platform])
72 AC_MSG_RESULT([empeg car stereo])
73 AC_DEFINE([EMPEG_HOST],[1],[define if host is an empeg car stereo])
74 # work around broken toolchain
75 AC_CHECK_LIB([gpg-error], [gpg_strerror])
76 AC_CHECK_LIB([pthread], [pthread_create])
80 AC_MSG_RESULT([Linux])
84 AC_MSG_RESULT([Mac OS X])
86 if test $want_coreaudio = yes; then
87 COREAUDIO="-framework CoreAudio"
90 AC_MSG_CHECKING([Mac OS X target version])
91 # We honor MACOSX_DEPLOYMENT_TARGET in the environment, emulating gcc's
92 # behaviour. But we provide a command line option to override it and
93 # we default to wide support instead of supporting only the build platform.
95 # Currently if you ask for 10.5 you will get a deprecation warning
96 # when building the CoreAudio support code. For the time being the
97 # answer to this is "don't do that then". If a good reason to ask
98 # for a 10.5 deployment target emerges then this will be fixed.
99 if test -z "$MACOSX_DEPLOYMENT_TARGET"; then
100 MACOSX_DEPLOYMENT_TARGET=10.0
102 AC_ARG_WITH([deployment-target],
103 [AS_HELP_STRING([--with-deployment-target=TARGET],
104 [set target OS X version])],
105 [MACOSX_DEPLOYMENT_TARGET=$withval])
106 # Convert to desired format
107 underscored=`echo $MACOSX_DEPLOYMENT_TARGET|sed 's/\./_/'`
108 minver="MAC_OS_X_VERSION_$underscored"
109 AC_MSG_RESULT([$minver])
110 AC_DEFINE_UNQUOTED([MAC_OS_X_VERSION_MIN_REQUIRED], [$minver],
111 [define to minimum version of Mac OS X to support])
114 AC_MSG_RESULT([FreeBSD])
116 # Ports install to /usr/local but the compiler stupidly doesn't look
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],[
123 for db in db43 db44 db45 db46; do
124 if test -e /usr/local/lib/$db; then
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"
136 AC_MSG_RESULT([unknown, winging it])
140 AC_SUBST([COREAUDIO])
142 AC_ARG_WITH([browser],
143 [AS_HELP_STRING([--with-browser=BROWSER],
144 [use BROWSER to display HTML])],
147 AC_CACHE_CHECK([default HTML viewer],[rjk_cv_browser],[
148 rjk_cv_browser=UNKNOWN
149 for candidate in x-www-browser sensible-browser firefox mozilla konqueror netscape; do
150 if type $candidate >/dev/null 2>&1; then
151 rjk_cv_browser="$candidate"
156 if test -z "$browser"; then
157 browser="$rjk_cv_browser"
159 AC_DEFINE_UNQUOTED([BROWSER],["$browser"],[HTML viewer])
161 AC_ARG_WITH([server],
162 [AS_HELP_STRING([--without-server],
163 [do not build server])],
164 [want_server=$withval])
166 [AS_HELP_STRING([--without-gtk],
167 [do not build GTK+ client])],
169 AC_ARG_WITH([python],
170 [AS_HELP_STRING([--without-python],
171 [do not build Python support])],
172 [want_python=$withval])
174 subdirs="scripts lib"
175 if test $want_tests = yes; then
176 subdirs="${subdirs} libtests"
178 subdirs="${subdirs} clients doc examples debian"
180 if test $want_server = yes; then
181 subdirs="${subdirs} server cgi plugins driver templates sounds images"
183 if test $want_gtk = yes; then
184 subdirs="${subdirs} disobedience"
185 if test $want_server = no; then
186 subdirs="${subdirs} images"
189 if test $want_tests = yes && test $want_python = yes; then
190 AM_PATH_PYTHON([2.4])
191 subdirs="${subdirs} python tests"
201 AC_CACHE_CHECK([for GNU sed],[rjk_cv_gnused],[
202 rjk_cv_gnused="not found"
203 for candidate in sed gsed; do
204 if $candidate --version >/dev/null 2>&1; then
205 rjk_cv_gnused=$candidate
209 GNUSED="${GNUSED:-$rjk_cv_gnused}"
210 if test "$GNUSED" = "not found"; then
211 AC_MSG_ERROR([GNU sed is required to build this program])
215 AC_CHECK_PROGS([GROG],[grog])
216 AM_CONDITIONAL([GROG],[test "x$GROG" != xnone])
222 AC_DEFINE(_GNU_SOURCE, 1, [required for e.g. strsignal])
224 # Macs might have libraries under fink's root
225 AC_PATH_PROG([FINK],[fink],[none],[$PATH:/sw/bin])
226 if test "x$FINK" != xnone; then
227 AC_CACHE_CHECK([fink install directory],[rjk_cv_finkprefix],[
228 rjk_cv_finkprefix="`echo "$FINK" | sed 's,/bin/fink$,,'`"
230 finkdir="${rjk_cv_finkprefix}"
231 finkbindir="${rjk_cv_finkprefix}/bin"
232 CPPFLAGS="${CPPFLAGS} -I${rjk_cv_finkprefix}/include/gc -I${rjk_cv_finkprefix}/include"
233 if test $want_server = yes; then
234 CPPFLAGS="${CPPFLAGS} -I${rjk_cv_finkprefix}/include/db4"
236 LDFLAGS="${LDFLAGS} -L${rjk_cv_finkprefix}/lib"
241 AC_SUBST([finkbindir])
243 # Checks for libraries.
244 # We save up a list of missing libraries that we can't do without
245 # and report them all at once.
246 AC_CHECK_LIB(gc, GC_malloc, [AC_SUBST(LIBGC,[-lgc])],
247 [missing_libraries="$missing_libraries libgc"])
248 AC_CHECK_LIB(gcrypt, gcry_md_open,
249 [AC_SUBST(LIBGCRYPT,[-lgcrypt])],
250 [missing_libraries="$missing_libraries libgcrypt"])
251 AC_CHECK_LIB(pcre, pcre_compile,
252 [AC_SUBST(LIBPCRE,[-lpcre])],
253 [missing_libraries="$missing_libraries libpcre"])
254 if test $want_alsa = yes; then
255 AC_CHECK_LIB([asound], [snd_pcm_open],
256 [AC_SUBST(LIBASOUND,[-lasound])])
258 if test $want_server = yes; then
259 RJK_CHECK_LIB(db, db_create, [#include <db.h>],
260 [AC_SUBST(LIBDB,[-ldb])],
261 [missing_libraries="$missing_libraries libdb"])
262 AC_CHECK_LIB(vorbis, vorbis_info_clear,
264 [missing_libraries="$missing_libraries libvorbis"])
265 AC_CHECK_LIB(vorbisfile, ov_open,
266 [AC_SUBST(LIBVORBISFILE,["-lvorbisfile -lvorbis"])],
267 [missing_libraries="$missing_libraries libvorbisfile"],
269 AC_CHECK_LIB(mad, mad_stream_init,
270 [AC_SUBST(LIBMAD,[-lmad])],
271 [missing_libraries="$missing_libraries libmad"])
272 AC_CHECK_LIB([ao], [ao_initialize],
273 [AC_SUBST(LIBAO,[-lao])],
274 [missing_libraries="$missing_libraries libao"])
275 AC_CHECK_LIB([FLAC], [FLAC__stream_decoder_new],
276 [AC_SUBST(LIBFLAC,[-lFLAC])],
277 [missing_libraries="$missing_libraries libFLAC"])
279 AC_CHECK_LIB([pthread], [pthread_create],
280 [AC_SUBST(LIBPTHREAD,[-lpthread])],
281 [missing_libraries="$missing_libraries libpthread"])
283 if test $want_gtk = yes; then
284 AM_PATH_GLIB_2_0([],[],[missing_libraries="$missing_libraries libglib"])
285 AM_PATH_GTK_2_0([],[],[missing_libraries="$missing_libraries libgtk"])
288 # Some platforms have iconv already
289 AC_CHECK_FUNC(iconv_open, [:],
290 [RJK_CHECK_LIB(iconv, iconv_open, [#include <iconv.h>],
291 [AC_SUBST(LIBICONV,[-liconv])],
292 [missing_functions="$missing_functions iconv_open"])])
293 AC_CHECK_FUNC([gethostbyname],[:],[
294 AC_CHECK_LIB(nsl,gethostbyname,
295 [AC_SUBST(LIBNSL,[-lnsl])],
296 [missing_functions="$missing_functions gethostbyname"])])
297 AC_CHECK_FUNC([socket],[:],[
298 AC_CHECK_LIB(socket,socket,
299 [AC_SUBST(LIBSOCKET,[-lsocket])],
300 [missing_functions="$missing_functions socket"])])
301 AC_CHECK_FUNC([dlopen],[:],[
302 AC_CHECK_LIB(dl,dlopen,
303 [AC_SUBST(LIBDL,[-ldl])],
304 [missing_functions="$missing_functions dlopen"])])
306 if test ! -z "$missing_libraries"; then
307 AC_MSG_ERROR([missing libraries:$missing_libraries])
310 # Checks for header files.
312 if test $want_oss = yes; then
313 AC_CHECK_HEADERS([sys/soundcard.h])
315 if test $want_alsa = yes; then
316 AC_CHECK_HEADERS([alsa/asoundlib.h])
318 if test $want_coreaudio = yes; then
319 AC_CHECK_HEADERS([CoreAudio/AudioHardware.h])
321 AC_CHECK_HEADERS([inttypes.h])
322 # We don't bother checking very standard stuff
323 # Compilation will fail if any of these headers are missing, so we
324 # check for them here and fail early.
325 if test $want_server = yes; then
326 AC_CHECK_HEADERS([db.h],[:],[
327 missing_headers="$missing_headers $ac_header"
329 AC_CHECK_HEADERS([FLAC/file_decoder.h])
331 AC_CHECK_HEADERS([dlfcn.h gcrypt.h \
332 getopt.h iconv.h langinfo.h \
334 syslog.h unistd.h],[:],[
335 missing_headers="$missing_headers $ac_header"
338 if test ! -z "$missing_headers"; then
339 AC_MSG_ERROR([missing headers:$missing_headers])
342 # We require that libpcre support UTF-8
343 RJK_REQUIRE_PCRE_UTF8([-lpcre])
345 # Checks for typedefs, structures, and compiler characteristics.
350 AC_CHECK_TYPES([struct sockaddr_in6],,,[AC_INCLUDES_DEFAULT
351 #include <netinet/in.h>])
353 # enable -Werror when we check for certain characteristics:
355 old_CFLAGS="${CFLAGS}"
356 CFLAGS="${CFLAGS} $gcc_werror"
357 AC_CHECK_TYPES([long long,uint32_t,uint8_t,intmax_t,uintmax_t])
359 # Some GCC invocations warn for converting function pointers to void *.
360 # This is fair enough, as it's technically forbidden, but we use dlsym()
361 # which can pretty much only exist if object and function pointers are
362 # interconvertable. So we disable -Werror if need be.
363 if test ! -z "$gcc_werror"; then
364 AC_CACHE_CHECK([whether function pointers can be converted to void * without a warning],
365 [rjk_cv_function_pointer_cast],[
366 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
367 void somefunction(void);],
368 [(void *)somefunction])],
369 [rjk_cv_function_pointer_cast=yes],
370 [rjk_cv_function_pointer_cast=no])])
371 if test $rjk_cv_function_pointer_cast = no; then
376 CFLAGS="${old_CFLAGS}"
378 # gcrypt maintainers keep changing everything. Design your interface
379 # first, then implement it once, rather than getting it wrong three or
380 # four times and shipping between each attempt.
381 AC_CACHE_CHECK([for hash handle type in <grypt.h>],
382 [rjk_cv_gcrypt_hash_handle],[
383 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
387 [rjk_cv_gcrypt_hash_handle=gcry_md_hd_t],[
388 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
392 [rjk_cv_gcrypt_hash_handle=GcryMDHd],
393 [rjk_cv_gcrypt_hash_handle=GCRY_MD_HD])])])
394 AC_DEFINE_UNQUOTED([gcrypt_hash_handle],[$rjk_cv_gcrypt_hash_handle],
395 [libgcrypt hash handle type])
397 AC_CACHE_CHECK([for gcry_error_t in <grypt.h>],
398 [rjk_cv_have_gcry_error_t],[
399 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
403 [rjk_cv_have_gcry_error_t=yes],
404 [rjk_cv_have_gcry_error_t=no])])
405 if test $rjk_cv_have_gcry_error_t = yes; then
406 AC_DEFINE([HAVE_GCRY_ERROR_T],1,[define if <gcrypt.h> defines gcry_error_t])
409 # Checks for functions
410 if test $ac_cv_type_long_long = yes; then
411 AC_CHECK_FUNCS([atoll strtoll],[:],[
412 missing_functions="$missing_functions $ac_func"
414 # Darwin sometimes fails to declare strtoll (e.g. if you ask for -std=c99)
415 AC_CACHE_CHECK([whether strtoll is declared in <stdlib.h>],
416 [rjk_cv_strtoll_declared],[
417 AC_EGREP_HEADER([strtoll], [stdlib.h],
418 [rjk_cv_strtoll_declared=yes],
419 [rjk_cv_strtoll_declared=no])])
420 if test $rjk_cv_strtoll_declared = yes; then
421 AC_DEFINE([DECLARES_STRTOLL],[1],[define if <stdlib.h> declares strtoll])
423 AC_CACHE_CHECK([whether atoll is declared in <stdlib.h>],
424 [rjk_cv_atoll_declared],[
425 AC_EGREP_HEADER([atoll], [stdlib.h],
426 [rjk_cv_atoll_declared=yes],
427 [rjk_cv_atoll_declared=no])])
428 if test $rjk_cv_atoll_declared = yes; then
429 AC_DEFINE([DECLARES_ATOLL],[1],[define if <stdlib.h> declares atoll])
432 AC_CHECK_FUNCS([ioctl nl_langinfo strsignal setenv unsetenv],[:],[
433 missing_functions="$missing_functions $ac_func"
435 # fsync will do if fdatasync not available
436 AC_CHECK_FUNCS([fdatasync],[:],[
437 AC_CHECK_FUNCS([fsync],
438 [AC_DEFINE([fdatasync],[fsync],[define fdatasync to fsync if not available])],
439 [missing_functions="$missing_functions fdatasync"])])
440 if test ! -z "$missing_functions"; then
441 AC_MSG_ERROR([missing functions:$missing_functions])
444 # Functions we can take or leave
445 AC_CHECK_FUNCS([fls])
447 if test $want_server = yes; then
448 # <db.h> had better be version 3 or later
449 AC_CACHE_CHECK([db.h version],[rjk_cv_db_version],[
452 #ifndef DB_VERSION_MAJOR
453 # error cannot determine db version
455 #if DB_VERSION_MAJOR < 4
456 # error inadequate db version
458 #if DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR <= 2
459 # error inadequate db version
462 [rjk_cv_db_version=ok],
463 [rjk_cv_db_version=inadequate])
465 if test $rjk_cv_db_version != ok; then
466 AC_MSG_ERROR([need db.h version at least 4.2])
470 AM_CONDITIONAL([SERVER], [test x$want_server = xyes])
471 if test $want_gtk = yes; then
472 AC_DEFINE([WITH_GTK], [1], [define if using GTK+])
475 if test "x$GCC" = xyes; then
476 # We need LLONG_MAX and annoyingly GCC doesn't always give it to us
478 AC_CACHE_CHECK([what C version to ask for],[rjk_cv_cstd],[
479 AC_TRY_COMPILE([#include <limits.h>],[
480 long long n = LLONG_MAX;
481 ],[rjk_cv_cstd=default],[
483 CC="${CC} -std=gnu99"
484 AC_TRY_COMPILE([#include <limits.h>],[
485 long long n = LLONG_MAX;
486 ],[rjk_cv_cstd=gnu99],[rjk_cv_cstd=unknown])
494 CC="${CC} -std=${rjk_cv_cstd}"
498 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29478
499 AC_CACHE_CHECK([checking for GCC bug 29478],[rjk_cv_pr29478],[
501 if test $GCC = yes; then
502 CC="$CC -Wall -Werror"
505 static int x(char *f) {
508 int z(const char *g) {
516 if test $rjk_cv_pr29478 = yes; then
520 # a reasonable default set of warnings
521 CC="${CC} -Wall -W -Wpointer-arith -Wbad-function-cast \
522 -Wwrite-strings -Wmissing-prototypes \
523 -Wmissing-declarations -Wnested-externs"
525 # Fix up GTK+ and GLib compiler flags
526 GTK_CFLAGS="`echo \"$GTK_CFLAGS\"|sed 's/-I/-isystem /g'`"
527 GLIB_CFLAGS="`echo \"$GLIB_CFLAGS\"|sed 's/-I/-isystem /g'`"
529 if test "$gcc_werror" != ''; then
530 # GCC 2.95 doesn't know to ignore warnings from system headers
531 AC_CACHE_CHECK([whether -Werror is usable],
533 save_CFLAGS="${CFLAGS}"
534 CFLAGS="${CFLAGS} ${GTK_CFLAGS} -Werror"
535 AC_TRY_COMPILE([#if WITH_GTK
539 struct s { int a, b; };
540 const struct s sv = { .a = 1 };],
544 CFLAGS="${save_CFLAGS}"
546 if test $rjk_cv_werror = no; then
550 CC="${CC} $gcc_werror"
552 # for older GCCs that don't know %ju (etc)
553 AC_CACHE_CHECK([whether -Wno-format is required],
555 AC_TRY_COMPILE([#include <stdio.h>
558 [printf("%ju", (uintmax_t)0);],
559 [rjk_cv_noformat=no],
560 [rjk_cv_noformat=yes]))
561 if test $rjk_cv_noformat = yes; then
562 CC="${CC} -Wno-format"
565 AC_CACHE_CHECK([whether -Wshadow is OK],
571 #include <vorbis/vorbisfile.h>
577 if test $rjk_cv_shadow = yes; then
584 AH_BOTTOM([#ifdef __GNUC__
585 # define attribute(x) __attribute__(x)
587 # define attribute(x)
590 AC_CONFIG_FILES([Makefile
597 disobedience/Makefile
610 if test $GCC = yes && test "$gcc_werror" = ''; then
611 AC_MSG_WARN([building without -Werror])
613 if test $want_python = no; then
614 AC_MSG_WARN([cannot run the test suit without Python])