1 # Process this file with autoconf to produce a configure script.
3 # This file is part of DisOrder.
4 # Copyright (C) 2004, 2005, 2006, 2007 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], [2.0+], [richard+disorder@sfere.greenend.org.uk])
24 AC_CONFIG_AUX_DIR([config.aux])
25 AM_INIT_AUTOMAKE(disorder, [2.0+])
26 AC_CONFIG_SRCDIR([server/disorderd.c])
27 AM_CONFIG_HEADER([config.h])
32 # What we want to build
41 # Checks for programs.
44 if test "x$GCC" = xyes; then
51 [AS_HELP_STRING([--without-alsa],
52 [do not build with ALSA support])],
55 [AS_HELP_STRING([--without-oss],
56 [do not build with OSS support])],
58 AC_ARG_WITH([coreaudio],
59 [AS_HELP_STRING([--without-coreaudio],
60 [do not build with Core Audio support])],
61 [want_coreaudio=$withval])
63 AC_MSG_CHECKING([for a known target platform])
66 AC_MSG_RESULT([empeg car stereo])
67 AC_DEFINE([EMPEG_HOST],[1],[define if host is an empeg car stereo])
68 # work around broken toolchain
69 AC_CHECK_LIB([gpg-error], [gpg_strerror])
70 AC_CHECK_LIB([pthread], [pthread_create])
74 AC_MSG_RESULT([Linux])
78 AC_MSG_RESULT([Mac OS X])
80 if test $want_coreaudio = yes; then
81 COREAUDIO="-framework CoreAudio"
86 AC_MSG_RESULT([FreeBSD])
88 # Ports install to /usr/local but the compiler stupidly doesn't look
90 LDFLAGS="${LDFLAGS} -L/usr/local/lib"
91 CPPFLAGS="${CPPFLAGS} -I/usr/local/include"
92 # libdb installs elsewhere again
93 LDFLAGS="${LDFLAGS} -L/usr/local/lib/db44"
94 CPPFLAGS="${CPPFLAGS} -I/usr/local/include/db44"
97 AC_MSG_RESULT([unknown, winging it])
101 AC_SUBST([COREAUDIO])
103 AC_ARG_WITH([browser],
104 [AS_HELP_STRING([--with-browser=BROWSER],
105 [use BROWSER to display HTML])],
108 AC_CACHE_CHECK([default HTML viewer],[rjk_cv_browser],[
109 rjk_cv_browser=UNKNOWN
110 for candidate in x-www-browser firefox mozilla konqueror netscape; do
111 if type $candidate >/dev/null 2>&1; then
112 rjk_cv_browser="$candidate"
117 if test -z "$browser"; then
118 browser="$rjk_cv_browser"
120 AC_DEFINE_UNQUOTED([BROWSER],["$browser"],[HTML viewer])
122 AC_ARG_WITH([server],
123 [AS_HELP_STRING([--without-server],
124 [do not build server])],
125 [want_server=$withval])
127 [AS_HELP_STRING([--without-gtk],
128 [do not build GTK+ client])],
130 AC_ARG_WITH([python],
131 [AS_HELP_STRING([--without-python],
132 [do not build Python support])],
133 [want_python=$withval])
135 subdirs="scripts lib clients doc examples debian"
137 if test $want_server = yes; then
138 subdirs="${subdirs} server plugins driver templates sounds images"
140 if test $want_gtk = yes; then
141 subdirs="${subdirs} disobedience"
142 if test $want_server = no; then
143 subdirs="${subdirs} images"
146 if test $want_python = yes; then
147 AM_PATH_PYTHON([2.4])
148 subdirs="${subdirs} python tests"
158 AC_CACHE_CHECK([for GNU sed],[rjk_cv_gnused],[
159 rjk_cv_gnused="not found"
160 for candidate in sed gsed; do
161 if $candidate --version >/dev/null 2>&1; then
162 rjk_cv_gnused=$candidate
166 GNUSED="${GNUSED:-$rjk_cv_gnused}"
167 if test "$GNUSED" = "not found"; then
168 AC_MSG_ERROR([GNU sed is required to build this program])
176 AC_DEFINE(_GNU_SOURCE, 1, [required for e.g. strsignal])
178 # Macs might have libraries under fink's root
179 AC_PATH_PROG([FINK],[fink],[none],[$PATH:/sw/bin])
180 if test "x$FINK" != xnone; then
181 AC_CACHE_CHECK([fink install directory],[rjk_cv_finkprefix],[
182 rjk_cv_finkprefix="`echo "$FINK" | sed 's,/bin/fink$,,'`"
184 finkdir="${rjk_cv_finkprefix}"
185 finkbindir="${rjk_cv_finkprefix}/bin"
186 CPPFLAGS="${CPPFLAGS} -I${rjk_cv_finkprefix}/include/gc -I${rjk_cv_finkprefix}/include"
187 if test $want_server = yes; then
188 CPPFLAGS="${CPPFLAGS} -I${rjk_cv_finkprefix}/include/db4"
190 LDFLAGS="${LDFLAGS} -L${rjk_cv_finkprefix}/lib"
195 AC_SUBST([finkbindir])
197 # Checks for libraries.
198 # We save up a list of missing libraries that we can't do without
199 # and report them all at once.
200 AC_CHECK_LIB(gc, GC_malloc, [AC_SUBST(LIBGC,[-lgc])],
201 [missing_libraries="$missing_libraries libgc"])
202 AC_CHECK_LIB(gcrypt, gcry_md_open,
203 [AC_SUBST(LIBGCRYPT,[-lgcrypt])],
204 [missing_libraries="$missing_libraries libgcrypt"])
205 AC_CHECK_LIB(pcre, pcre_compile,
206 [AC_SUBST(LIBPCRE,[-lpcre])],
207 [missing_libraries="$missing_libraries libpcre"])
208 if test $want_alsa = yes; then
209 AC_CHECK_LIB([asound], [snd_pcm_open],
210 [AC_SUBST(LIBASOUND,[-lasound])])
212 if test $want_server = yes; then
213 RJK_CHECK_LIB(db, db_create, [#include <db.h>],
214 [AC_SUBST(LIBDB,[-ldb])],
215 [missing_libraries="$missing_libraries libdb"])
216 AC_CHECK_LIB(vorbis, vorbis_info_clear,
218 [missing_libraries="$missing_libraries libvorbis"])
219 AC_CHECK_LIB(vorbisfile, ov_open,
220 [AC_SUBST(LIBVORBISFILE,["-lvorbisfile -lvorbis"])],
221 [missing_libraries="$missing_libraries libvorbisfile"],
223 AC_CHECK_LIB(mad, mad_stream_init,
224 [AC_SUBST(LIBMAD,[-lmad])],
225 [missing_libraries="$missing_libraries libmad"])
226 AC_CHECK_LIB([ao], [ao_initialize],
227 [AC_SUBST(LIBAO,[-lao])],
228 [missing_libraries="$missing_libraries libao"])
229 AC_CHECK_LIB([FLAC], [FLAC__stream_decoder_new],
230 [AC_SUBST(LIBFLAC,[-lFLAC])],
231 [missing_libraries="$missing_libraries libFLAC"])
233 AC_CHECK_LIB([pthread], [pthread_create],
234 [AC_SUBST(LIBPTHREAD,[-lpthread])],
235 [missing_libraries="$missing_libraries libpthread"])
237 if test $want_gtk = yes; then
238 AM_PATH_GLIB_2_0([],[],[missing_libraries="$missing_libraries libglib"])
239 AM_PATH_GTK_2_0([],[],[missing_libraries="$missing_libraries libgtk"])
242 # Some platforms have iconv already
243 AC_CHECK_FUNC(iconv_open, [:],
244 [RJK_CHECK_LIB(iconv, iconv_open, [#include <iconv.h>],
245 [AC_SUBST(LIBICONV,[-liconv])],
246 [missing_functions="$missing_functions iconv_open"])])
247 AC_CHECK_FUNC([gethostbyname],[:],[
248 AC_CHECK_LIB(nsl,gethostbyname,
249 [AC_SUBST(LIBNSL,[-lnsl])],
250 [missing_functions="$missing_functions gethostbyname"])])
251 AC_CHECK_FUNC([socket],[:],[
252 AC_CHECK_LIB(socket,socket,
253 [AC_SUBST(LIBSOCKET,[-lsocket])],
254 [missing_functions="$missing_functions socket"])])
255 AC_CHECK_FUNC([dlopen],[:],[
256 AC_CHECK_LIB(dl,dlopen,
257 [AC_SUBST(LIBDL,[-ldl])],
258 [missing_functions="$missing_functions dlopen"])])
260 if test ! -z "$missing_libraries"; then
261 AC_MSG_ERROR([missing libraries:$missing_libraries])
264 # Checks for header files.
266 if test $want_oss = yes; then
267 AC_CHECK_HEADERS([sys/soundcard.h])
269 if test $want_alsa = yes; then
270 AC_CHECK_HEADERS([alsa/asoundlib.h])
272 if test $want_coreaudio = yes; then
273 AC_CHECK_HEADERS([CoreAudio/AudioHardware.h])
275 AC_CHECK_HEADERS([inttypes.h])
276 # We don't bother checking very standard stuff
277 # Compilation will fail if any of these headers are missing, so we
278 # check for them here and fail early.
279 if test $want_server = yes; then
280 AC_CHECK_HEADERS([db.h],[:],[
281 missing_headers="$missing_headers $ac_header"
283 AC_CHECK_HEADERS([FLAC/file_decoder.h])
285 AC_CHECK_HEADERS([dlfcn.h gcrypt.h \
286 getopt.h iconv.h langinfo.h \
288 syslog.h unistd.h],[:],[
289 missing_headers="$missing_headers $ac_header"
292 if test ! -z "$missing_headers"; then
293 AC_MSG_ERROR([missing headers:$missing_headers])
296 # We require that libpcre support UTF-8
297 RJK_REQUIRE_PCRE_UTF8([-lpcre])
299 # Checks for typedefs, structures, and compiler characteristics.
304 AC_CHECK_TYPES([struct sockaddr_in6],,,[AC_INCLUDES_DEFAULT
305 #include <netinet/in.h>])
307 # enable -Werror when we check for certain characteristics:
309 old_CFLAGS="${CFLAGS}"
310 CFLAGS="${CFLAGS} $gcc_werror"
311 AC_CHECK_TYPES([long long,uint32_t,uint8_t,intmax_t,uintmax_t])
313 # Some GCC invocations warn for converting function pointers to void *.
314 # This is fair enough, as it's technically forbidden, but we use dlsym()
315 # which can pretty much only exist if object and function pointers are
316 # interconvertable. So we disable -Werror if need be.
317 if test ! -z "$gcc_werror"; then
318 AC_CACHE_CHECK([whether function pointers can be converted to void * without a warning],
319 [rjk_cv_function_pointer_cast],[
320 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
321 void somefunction(void);],
322 [(void *)somefunction])],
323 [rjk_cv_function_pointer_cast=yes],
324 [rjk_cv_function_pointer_cast=no])])
325 if test $rjk_cv_function_pointer_cast = no; then
330 CFLAGS="${old_CFLAGS}"
332 # gcrypt maintainers keep changing everything. Design your interface
333 # first, then implement it once, rather than getting it wrong three or
334 # four times and shipping between each attempt.
335 AC_CACHE_CHECK([for hash handle type in <grypt.h>],
336 [rjk_cv_gcrypt_hash_handle],[
337 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
341 [rjk_cv_gcrypt_hash_handle=gcry_md_hd_t],[
342 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
346 [rjk_cv_gcrypt_hash_handle=GcryMDHd],
347 [rjk_cv_gcrypt_hash_handle=GCRY_MD_HD])])])
348 AC_DEFINE_UNQUOTED([gcrypt_hash_handle],[$rjk_cv_gcrypt_hash_handle],
349 [libgcrypt hash handle type])
351 AC_CACHE_CHECK([for gcry_error_t in <grypt.h>],
352 [rjk_cv_have_gcry_error_t],[
353 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
357 [rjk_cv_have_gcry_error_t=yes],
358 [rjk_cv_have_gcry_error_t=no])])
359 if test $rjk_cv_have_gcry_error_t = yes; then
360 AC_DEFINE([HAVE_GCRY_ERROR_T],1,[define if <gcrypt.h> defines gcry_error_t])
363 # Checks for functions
364 if test $ac_cv_type_long_long = yes; then
365 AC_CHECK_FUNCS([atoll strtoll],[:],[
366 missing_functions="$missing_functions $ac_func"
368 # Darwin sometimes fails to declare strtoll (e.g. if you ask for -std=c99)
369 AC_CACHE_CHECK([whether strtoll is declared in <stdlib.h>],
370 [rjk_cv_strtoll_declared],[
371 AC_EGREP_HEADER([strtoll], [stdlib.h],
372 [rjk_cv_strtoll_declared=yes],
373 [rjk_cv_strtoll_declared=no])])
374 if test $rjk_cv_strtoll_declared = yes; then
375 AC_DEFINE([DECLARES_STRTOLL],[1],[define if <stdlib.h> declares strtoll])
377 AC_CACHE_CHECK([whether atoll is declared in <stdlib.h>],
378 [rjk_cv_atoll_declared],[
379 AC_EGREP_HEADER([atoll], [stdlib.h],
380 [rjk_cv_atoll_declared=yes],
381 [rjk_cv_atoll_declared=no])])
382 if test $rjk_cv_atoll_declared = yes; then
383 AC_DEFINE([DECLARES_ATOLL],[1],[define if <stdlib.h> declares atoll])
386 AC_CHECK_FUNCS([ioctl nl_langinfo strsignal],[:],[
387 missing_functions="$missing_functions $ac_func"
389 # fsync will do if fdatasync not available
390 AC_CHECK_FUNCS([fdatasync],[:],[
391 AC_CHECK_FUNCS([fsync],
392 [AC_DEFINE([fdatasync],[fsync],[define fdatasync to fsync if not available])],
393 [missing_functions="$missing_functions fdatasync"])])
394 if test ! -z "$missing_functions"; then
395 AC_MSG_ERROR([missing functions:$missing_functions])
397 if test $want_server = yes; then
398 # <db.h> had better be version 3 or later
399 AC_CACHE_CHECK([db.h version],[rjk_cv_db_version],[
402 #ifndef DB_VERSION_MAJOR
403 # error cannot determine db version
405 #if DB_VERSION_MAJOR < 4
406 # error inadequate db version
408 #if DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR < 2
409 # error inadequate db version
412 [rjk_cv_db_version=ok],
413 [rjk_cv_db_version=inadequate])
415 if test $rjk_cv_db_version != ok; then
416 AC_MSG_ERROR([need db.h version at least 4.2])
420 if test "x$GCC" = xyes; then
421 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29478
422 AC_CACHE_CHECK([checking for GCC bug 29478],[rjk_cv_pr29478],[
424 if test $GCC = yes; then
425 CC="$CC -Wall -Werror"
428 static int x(char *f) {
431 int z(const char *g) {
439 if test $rjk_cv_pr29478 = yes; then
443 # a reasonable default set of warnings
444 CC="${CC} -Wall -W -Wpointer-arith -Wbad-function-cast \
445 -Wwrite-strings -Wmissing-prototypes \
446 -Wmissing-declarations -Wnested-externs"
448 # Fix up GTK+ and GLib compiler flags
449 GTK_CFLAGS="`echo \"$GTK_CFLAGS\"|sed 's/-I/-isystem /g'`"
450 GLIB_CFLAGS="`echo \"$GLIB_CFLAGS\"|sed 's/-I/-isystem /g'`"
452 if test "$gcc_werror" != ''; then
453 # GCC 2.95 doesn't know to ignore warnings from system headers
454 AC_CACHE_CHECK([whether -Werror is usable],
456 save_CFLAGS="${CFLAGS}"
457 CFLAGS="${CFLAGS} ${GTK_CFLAGS} -Werror"
458 AC_TRY_COMPILE([#include <gtk/gtk.h>],
462 CFLAGS="${save_CFLAGS}"
464 if test $rjk_cv_werror = no; then
468 CC="${CC} $gcc_werror"
470 # for older GCCs that don't know %ju (etc)
471 AC_CACHE_CHECK([whether -Wno-format is required],
473 AC_TRY_COMPILE([#include <stdio.h>
476 [printf("%ju", (uintmax_t)0);],
477 [rjk_cv_noformat=no],
478 [rjk_cv_noformat=yes]))
479 if test $rjk_cv_noformat = yes; then
480 CC="${CC} -Wno-format"
483 AC_CACHE_CHECK([whether -Wshadow is OK],
489 #include <vorbis/vorbisfile.h>
495 if test $rjk_cv_shadow = yes; then
502 AH_BOTTOM([#ifdef __GNUC__
503 # define attribute(x) __attribute__(x)
505 # define attribute(x)
508 AC_CONFIG_FILES([Makefile
515 disobedience/Makefile
526 if test $GCC = yes && test "$gcc_werror" = ''; then
527 AC_MSG_WARN([building without -Werror])
529 if test $want_python = no; then
530 AC_MSG_WARN([cannot run the test suit without Python])