2 # Process this file with autoconf to produce a configure script.
4 # This file is part of DisOrder.
5 # Copyright (C) 2004-2008 Richard Kettlewell
6 # Portions copyright (C) 2007 Ross Younger
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
24 AC_INIT([disorder], [3.0+], [richard+disorder@sfere.greenend.org.uk])
25 AC_CONFIG_AUX_DIR([config.aux])
26 AM_INIT_AUTOMAKE(disorder, [3.0+])
27 AC_CONFIG_SRCDIR([server/disorderd.c])
28 AM_CONFIG_HEADER([config.h])
33 # What we want to build
42 # Checks for programs.
45 if test "x$GCC" = xyes; then
52 [AS_HELP_STRING([--without-alsa],
53 [do not build with ALSA support])],
56 [AS_HELP_STRING([--without-oss],
57 [do not build with OSS support])],
59 AC_ARG_WITH([coreaudio],
60 [AS_HELP_STRING([--without-coreaudio],
61 [do not build with Core Audio support])],
62 [want_coreaudio=$withval])
64 AC_MSG_CHECKING([for a known target platform])
67 AC_MSG_RESULT([empeg car stereo])
68 AC_DEFINE([EMPEG_HOST],[1],[define if host is an empeg car stereo])
69 # work around broken toolchain
70 AC_CHECK_LIB([gpg-error], [gpg_strerror])
71 AC_CHECK_LIB([pthread], [pthread_create])
75 AC_MSG_RESULT([Linux])
79 AC_MSG_RESULT([Mac OS X])
81 if test $want_coreaudio = yes; then
82 COREAUDIO="-framework CoreAudio"
85 AC_MSG_CHECKING([Mac OS X target version])
86 # We honor MACOSX_DEPLOYMENT_TARGET in the environment, emulating gcc's
87 # behaviour. But we provide a command line option to override it and
88 # we default to wide support instead of supporting only the build platform.
90 # Currently if you ask for 10.5 you will get a deprecation warning
91 # when building the CoreAudio support code. For the time being the
92 # answer to this is "don't do that then". If a good reason to ask
93 # for a 10.5 deployment target emerges then this will be fixed.
94 if test -z "$MACOSX_DEPLOYMENT_TARGET"; then
95 MACOSX_DEPLOYMENT_TARGET=10.0
97 AC_ARG_WITH([deployment-target],
98 [AS_HELP_STRING([--with-deployment-target=TARGET],
99 [set target OS X version])],
100 [MACOSX_DEPLOYMENT_TARGET=$withval])
101 # Convert to desired format
102 underscored=`echo $MACOSX_DEPLOYMENT_TARGET|sed 's/\./_/'`
103 minver="MAC_OS_X_VERSION_$underscored"
104 AC_MSG_RESULT([$minver])
105 AC_DEFINE_UNQUOTED([MAC_OS_X_VERSION_MIN_REQUIRED], [$minver],
106 [define to minimum version of Mac OS X to support])
109 AC_MSG_RESULT([FreeBSD])
111 # Ports install to /usr/local but the compiler stupidly doesn't look
113 LDFLAGS="${LDFLAGS} -L/usr/local/lib"
114 CPPFLAGS="${CPPFLAGS} -isystem /usr/local/include"
115 # Look for a suitable version of libdb among the versions found in FreeBSD 7.0
116 AC_CACHE_CHECK([looking for a libdb install],[rjk_cv_libdb],[
118 for db in db43 db44 db45 db46; do
119 if test -e /usr/local/lib/$db; then
125 if test $rjk_cv_libdb != none; then
126 LDFLAGS="${LDFLAGS} -L/usr/local/lib/$rjk_cv_libdb"
127 CPPFLAGS="${CPPFLAGS} -isystem /usr/local/include/$rjk_cv_libdb"
131 AC_MSG_RESULT([unknown, winging it])
135 AC_SUBST([COREAUDIO])
137 AC_ARG_WITH([browser],
138 [AS_HELP_STRING([--with-browser=BROWSER],
139 [use BROWSER to display HTML])],
142 AC_CACHE_CHECK([default HTML viewer],[rjk_cv_browser],[
143 rjk_cv_browser=UNKNOWN
144 for candidate in x-www-browser sensible-browser firefox mozilla konqueror netscape; do
145 if type $candidate >/dev/null 2>&1; then
146 rjk_cv_browser="$candidate"
151 if test -z "$browser"; then
152 browser="$rjk_cv_browser"
154 AC_DEFINE_UNQUOTED([BROWSER],["$browser"],[HTML viewer])
156 AC_ARG_WITH([server],
157 [AS_HELP_STRING([--without-server],
158 [do not build server])],
159 [want_server=$withval])
161 [AS_HELP_STRING([--without-gtk],
162 [do not build GTK+ client])],
164 AC_ARG_WITH([python],
165 [AS_HELP_STRING([--without-python],
166 [do not build Python support])],
167 [want_python=$withval])
169 subdirs="scripts lib clients doc examples debian"
171 if test $want_server = yes; then
172 subdirs="${subdirs} server plugins driver templates sounds images"
174 if test $want_gtk = yes; then
175 subdirs="${subdirs} disobedience"
176 if test $want_server = no; then
177 subdirs="${subdirs} images"
180 if test $want_python = yes; then
181 AM_PATH_PYTHON([2.4])
182 subdirs="${subdirs} python tests"
192 AC_CACHE_CHECK([for GNU sed],[rjk_cv_gnused],[
193 rjk_cv_gnused="not found"
194 for candidate in sed gsed; do
195 if $candidate --version >/dev/null 2>&1; then
196 rjk_cv_gnused=$candidate
200 GNUSED="${GNUSED:-$rjk_cv_gnused}"
201 if test "$GNUSED" = "not found"; then
202 AC_MSG_ERROR([GNU sed is required to build this program])
210 AC_DEFINE(_GNU_SOURCE, 1, [required for e.g. strsignal])
212 # Macs might have libraries under fink's root
213 AC_PATH_PROG([FINK],[fink],[none],[$PATH:/sw/bin])
214 if test "x$FINK" != xnone; then
215 AC_CACHE_CHECK([fink install directory],[rjk_cv_finkprefix],[
216 rjk_cv_finkprefix="`echo "$FINK" | sed 's,/bin/fink$,,'`"
218 finkdir="${rjk_cv_finkprefix}"
219 finkbindir="${rjk_cv_finkprefix}/bin"
220 CPPFLAGS="${CPPFLAGS} -I${rjk_cv_finkprefix}/include/gc -I${rjk_cv_finkprefix}/include"
221 if test $want_server = yes; then
222 CPPFLAGS="${CPPFLAGS} -I${rjk_cv_finkprefix}/include/db4"
224 LDFLAGS="${LDFLAGS} -L${rjk_cv_finkprefix}/lib"
229 AC_SUBST([finkbindir])
231 # Checks for libraries.
232 # We save up a list of missing libraries that we can't do without
233 # and report them all at once.
234 AC_CHECK_LIB(gc, GC_malloc, [AC_SUBST(LIBGC,[-lgc])],
235 [missing_libraries="$missing_libraries libgc"])
236 AC_CHECK_LIB(gcrypt, gcry_md_open,
237 [AC_SUBST(LIBGCRYPT,[-lgcrypt])],
238 [missing_libraries="$missing_libraries libgcrypt"])
239 AC_CHECK_LIB(pcre, pcre_compile,
240 [AC_SUBST(LIBPCRE,[-lpcre])],
241 [missing_libraries="$missing_libraries libpcre"])
242 if test $want_alsa = yes; then
243 AC_CHECK_LIB([asound], [snd_pcm_open],
244 [AC_SUBST(LIBASOUND,[-lasound])])
246 if test $want_server = yes; then
247 RJK_CHECK_LIB(db, db_create, [#include <db.h>],
248 [AC_SUBST(LIBDB,[-ldb])],
249 [missing_libraries="$missing_libraries libdb"])
250 AC_CHECK_LIB(vorbis, vorbis_info_clear,
252 [missing_libraries="$missing_libraries libvorbis"])
253 AC_CHECK_LIB(vorbisfile, ov_open,
254 [AC_SUBST(LIBVORBISFILE,["-lvorbisfile -lvorbis"])],
255 [missing_libraries="$missing_libraries libvorbisfile"],
257 AC_CHECK_LIB(mad, mad_stream_init,
258 [AC_SUBST(LIBMAD,[-lmad])],
259 [missing_libraries="$missing_libraries libmad"])
260 AC_CHECK_LIB([ao], [ao_initialize],
261 [AC_SUBST(LIBAO,[-lao])],
262 [missing_libraries="$missing_libraries libao"])
263 AC_CHECK_LIB([FLAC], [FLAC__stream_decoder_new],
264 [AC_SUBST(LIBFLAC,[-lFLAC])],
265 [missing_libraries="$missing_libraries libFLAC"])
267 AC_CHECK_LIB([pthread], [pthread_create],
268 [AC_SUBST(LIBPTHREAD,[-lpthread])],
269 [missing_libraries="$missing_libraries libpthread"])
271 if test $want_gtk = yes; then
272 AM_PATH_GLIB_2_0([],[],[missing_libraries="$missing_libraries libglib"])
273 AM_PATH_GTK_2_0([],[],[missing_libraries="$missing_libraries libgtk"])
276 # Some platforms have iconv already
277 AC_CHECK_FUNC(iconv_open, [:],
278 [RJK_CHECK_LIB(iconv, iconv_open, [#include <iconv.h>],
279 [AC_SUBST(LIBICONV,[-liconv])],
280 [missing_functions="$missing_functions iconv_open"])])
281 AC_CHECK_FUNC([gethostbyname],[:],[
282 AC_CHECK_LIB(nsl,gethostbyname,
283 [AC_SUBST(LIBNSL,[-lnsl])],
284 [missing_functions="$missing_functions gethostbyname"])])
285 AC_CHECK_FUNC([socket],[:],[
286 AC_CHECK_LIB(socket,socket,
287 [AC_SUBST(LIBSOCKET,[-lsocket])],
288 [missing_functions="$missing_functions socket"])])
289 AC_CHECK_FUNC([dlopen],[:],[
290 AC_CHECK_LIB(dl,dlopen,
291 [AC_SUBST(LIBDL,[-ldl])],
292 [missing_functions="$missing_functions dlopen"])])
294 if test ! -z "$missing_libraries"; then
295 AC_MSG_ERROR([missing libraries:$missing_libraries])
298 # Checks for header files.
300 if test $want_oss = yes; then
301 AC_CHECK_HEADERS([sys/soundcard.h])
303 if test $want_alsa = yes; then
304 AC_CHECK_HEADERS([alsa/asoundlib.h])
306 if test $want_coreaudio = yes; then
307 AC_CHECK_HEADERS([CoreAudio/AudioHardware.h])
309 AC_CHECK_HEADERS([inttypes.h])
310 # We don't bother checking very standard stuff
311 # Compilation will fail if any of these headers are missing, so we
312 # check for them here and fail early.
313 if test $want_server = yes; then
314 AC_CHECK_HEADERS([db.h],[:],[
315 missing_headers="$missing_headers $ac_header"
317 AC_CHECK_HEADERS([FLAC/file_decoder.h])
319 AC_CHECK_HEADERS([dlfcn.h gcrypt.h \
320 getopt.h iconv.h langinfo.h \
322 syslog.h unistd.h],[:],[
323 missing_headers="$missing_headers $ac_header"
326 if test ! -z "$missing_headers"; then
327 AC_MSG_ERROR([missing headers:$missing_headers])
330 # We require that libpcre support UTF-8
331 RJK_REQUIRE_PCRE_UTF8([-lpcre])
333 # Checks for typedefs, structures, and compiler characteristics.
338 AC_CHECK_TYPES([struct sockaddr_in6],,,[AC_INCLUDES_DEFAULT
339 #include <netinet/in.h>])
341 # enable -Werror when we check for certain characteristics:
343 old_CFLAGS="${CFLAGS}"
344 CFLAGS="${CFLAGS} $gcc_werror"
345 AC_CHECK_TYPES([long long,uint32_t,uint8_t,intmax_t,uintmax_t])
347 # Some GCC invocations warn for converting function pointers to void *.
348 # This is fair enough, as it's technically forbidden, but we use dlsym()
349 # which can pretty much only exist if object and function pointers are
350 # interconvertable. So we disable -Werror if need be.
351 if test ! -z "$gcc_werror"; then
352 AC_CACHE_CHECK([whether function pointers can be converted to void * without a warning],
353 [rjk_cv_function_pointer_cast],[
354 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
355 void somefunction(void);],
356 [(void *)somefunction])],
357 [rjk_cv_function_pointer_cast=yes],
358 [rjk_cv_function_pointer_cast=no])])
359 if test $rjk_cv_function_pointer_cast = no; then
364 CFLAGS="${old_CFLAGS}"
366 # gcrypt maintainers keep changing everything. Design your interface
367 # first, then implement it once, rather than getting it wrong three or
368 # four times and shipping between each attempt.
369 AC_CACHE_CHECK([for hash handle type in <grypt.h>],
370 [rjk_cv_gcrypt_hash_handle],[
371 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
375 [rjk_cv_gcrypt_hash_handle=gcry_md_hd_t],[
376 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
380 [rjk_cv_gcrypt_hash_handle=GcryMDHd],
381 [rjk_cv_gcrypt_hash_handle=GCRY_MD_HD])])])
382 AC_DEFINE_UNQUOTED([gcrypt_hash_handle],[$rjk_cv_gcrypt_hash_handle],
383 [libgcrypt hash handle type])
385 AC_CACHE_CHECK([for gcry_error_t in <grypt.h>],
386 [rjk_cv_have_gcry_error_t],[
387 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
391 [rjk_cv_have_gcry_error_t=yes],
392 [rjk_cv_have_gcry_error_t=no])])
393 if test $rjk_cv_have_gcry_error_t = yes; then
394 AC_DEFINE([HAVE_GCRY_ERROR_T],1,[define if <gcrypt.h> defines gcry_error_t])
397 # Checks for functions
398 if test $ac_cv_type_long_long = yes; then
399 AC_CHECK_FUNCS([atoll strtoll],[:],[
400 missing_functions="$missing_functions $ac_func"
402 # Darwin sometimes fails to declare strtoll (e.g. if you ask for -std=c99)
403 AC_CACHE_CHECK([whether strtoll is declared in <stdlib.h>],
404 [rjk_cv_strtoll_declared],[
405 AC_EGREP_HEADER([strtoll], [stdlib.h],
406 [rjk_cv_strtoll_declared=yes],
407 [rjk_cv_strtoll_declared=no])])
408 if test $rjk_cv_strtoll_declared = yes; then
409 AC_DEFINE([DECLARES_STRTOLL],[1],[define if <stdlib.h> declares strtoll])
411 AC_CACHE_CHECK([whether atoll is declared in <stdlib.h>],
412 [rjk_cv_atoll_declared],[
413 AC_EGREP_HEADER([atoll], [stdlib.h],
414 [rjk_cv_atoll_declared=yes],
415 [rjk_cv_atoll_declared=no])])
416 if test $rjk_cv_atoll_declared = yes; then
417 AC_DEFINE([DECLARES_ATOLL],[1],[define if <stdlib.h> declares atoll])
420 AC_CHECK_FUNCS([ioctl nl_langinfo strsignal],[:],[
421 missing_functions="$missing_functions $ac_func"
423 # fsync will do if fdatasync not available
424 AC_CHECK_FUNCS([fdatasync],[:],[
425 AC_CHECK_FUNCS([fsync],
426 [AC_DEFINE([fdatasync],[fsync],[define fdatasync to fsync if not available])],
427 [missing_functions="$missing_functions fdatasync"])])
428 if test ! -z "$missing_functions"; then
429 AC_MSG_ERROR([missing functions:$missing_functions])
432 # Functions we can take or leave
433 AC_CHECK_FUNCS([fls])
435 if test $want_server = yes; then
436 # <db.h> had better be version 3 or later
437 AC_CACHE_CHECK([db.h version],[rjk_cv_db_version],[
440 #ifndef DB_VERSION_MAJOR
441 # error cannot determine db version
443 #if DB_VERSION_MAJOR < 4
444 # error inadequate db version
446 #if DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR <= 2
447 # error inadequate db version
450 [rjk_cv_db_version=ok],
451 [rjk_cv_db_version=inadequate])
453 if test $rjk_cv_db_version != ok; then
454 AC_MSG_ERROR([need db.h version at least 4.2])
458 AM_CONDITIONAL([SERVER], [test x$want_server = xyes])
460 if test "x$GCC" = xyes; then
461 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29478
462 AC_CACHE_CHECK([checking for GCC bug 29478],[rjk_cv_pr29478],[
464 if test $GCC = yes; then
465 CC="$CC -Wall -Werror"
468 static int x(char *f) {
471 int z(const char *g) {
479 if test $rjk_cv_pr29478 = yes; then
483 # a reasonable default set of warnings
484 CC="${CC} -Wall -W -Wpointer-arith -Wbad-function-cast \
485 -Wwrite-strings -Wmissing-prototypes \
486 -Wmissing-declarations -Wnested-externs"
488 # Fix up GTK+ and GLib compiler flags
489 GTK_CFLAGS="`echo \"$GTK_CFLAGS\"|sed 's/-I/-isystem /g'`"
490 GLIB_CFLAGS="`echo \"$GLIB_CFLAGS\"|sed 's/-I/-isystem /g'`"
492 if test "$gcc_werror" != ''; then
493 # GCC 2.95 doesn't know to ignore warnings from system headers
494 AC_CACHE_CHECK([whether -Werror is usable],
496 save_CFLAGS="${CFLAGS}"
497 CFLAGS="${CFLAGS} ${GTK_CFLAGS} -Werror"
498 AC_TRY_COMPILE([#include <gtk/gtk.h>],
502 CFLAGS="${save_CFLAGS}"
504 if test $rjk_cv_werror = no; then
508 CC="${CC} $gcc_werror"
510 # for older GCCs that don't know %ju (etc)
511 AC_CACHE_CHECK([whether -Wno-format is required],
513 AC_TRY_COMPILE([#include <stdio.h>
516 [printf("%ju", (uintmax_t)0);],
517 [rjk_cv_noformat=no],
518 [rjk_cv_noformat=yes]))
519 if test $rjk_cv_noformat = yes; then
520 CC="${CC} -Wno-format"
523 AC_CACHE_CHECK([whether -Wshadow is OK],
529 #include <vorbis/vorbisfile.h>
535 if test $rjk_cv_shadow = yes; then
542 AH_BOTTOM([#ifdef __GNUC__
543 # define attribute(x) __attribute__(x)
545 # define attribute(x)
548 AC_CONFIG_FILES([Makefile
555 disobedience/Makefile
566 if test $GCC = yes && test "$gcc_werror" = ''; then
567 AC_MSG_WARN([building without -Werror])
569 if test $want_python = no; then
570 AC_MSG_WARN([cannot run the test suit without Python])