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 LDFLAGS="${LDFLAGS} -L/usr/local/lib"
89 CPPFLAGS="${CPPFLAGS} -I/usr/local/include"
92 AC_MSG_RESULT([unknown, winging it])
98 AC_ARG_WITH([browser],
99 [AS_HELP_STRING([--with-browser=BROWSER],
100 [use BROWSER to display HTML])],
103 AC_CACHE_CHECK([default HTML viewer],[rjk_cv_browser],[
104 rjk_cv_browser=UNKNOWN
105 for candidate in x-www-browser firefox mozilla konqueror netscape; do
106 if type $candidate >/dev/null 2>&1; then
107 rjk_cv_browser="$candidate"
112 if test -z "$browser"; then
113 browser="$rjk_cv_browser"
115 AC_DEFINE_UNQUOTED([BROWSER],["$browser"],[HTML viewer])
117 AC_ARG_WITH([server],
118 [AS_HELP_STRING([--without-server],
119 [do not build server])],
120 [want_server=$withval])
122 [AS_HELP_STRING([--without-gtk],
123 [do not build GTK+ client])],
125 AC_ARG_WITH([python],
126 [AS_HELP_STRING([--without-python],
127 [do not build Python support])],
128 [want_python=$withval])
130 subdirs="scripts lib clients doc examples debian"
132 if test $want_server = yes; then
133 subdirs="${subdirs} server plugins driver templates sounds images"
135 if test $want_gtk = yes; then
136 subdirs="${subdirs} disobedience"
137 if test $want_server = no; then
138 subdirs="${subdirs} images"
141 if test $want_python = yes; then
142 AM_PATH_PYTHON([2.4])
143 subdirs="${subdirs} python tests"
157 AC_DEFINE(_GNU_SOURCE, 1, [required for e.g. strsignal])
159 # Macs might have libraries under fink's root
160 AC_PATH_PROG([FINK],[fink],[none],[$PATH:/sw/bin])
161 if test "x$FINK" != xnone; then
162 AC_CACHE_CHECK([fink install directory],[rjk_cv_finkprefix],[
163 rjk_cv_finkprefix="`echo "$FINK" | sed 's,/bin/fink$,,'`"
165 finkdir="${rjk_cv_finkprefix}"
166 finkbindir="${rjk_cv_finkprefix}/bin"
167 CPPFLAGS="${CPPFLAGS} -I${rjk_cv_finkprefix}/include/gc -I${rjk_cv_finkprefix}/include"
168 if test $want_server = yes; then
169 CPPFLAGS="${CPPFLAGS} -I${rjk_cv_finkprefix}/include/db4"
171 LDFLAGS="${LDFLAGS} -L${rjk_cv_finkprefix}/lib"
176 AC_SUBST([finkbindir])
178 # Checks for libraries.
179 # We save up a list of missing libraries that we can't do without
180 # and report them all at once.
181 AC_CHECK_LIB(gc, GC_malloc, [AC_SUBST(LIBGC,[-lgc])],
182 [missing_libraries="$missing_libraries libgc"])
183 AC_CHECK_LIB(gcrypt, gcry_md_open,
184 [AC_SUBST(LIBGCRYPT,[-lgcrypt])],
185 [missing_libraries="$missing_libraries libgcrypt"])
186 AC_CHECK_LIB(pcre, pcre_compile,
187 [AC_SUBST(LIBPCRE,[-lpcre])],
188 [missing_libraries="$missing_libraries libpcre"])
189 if test $want_alsa = yes; then
190 AC_CHECK_LIB([asound], [snd_pcm_open],
191 [AC_SUBST(LIBASOUND,[-lasound])])
193 if test $want_server = yes; then
194 RJK_CHECK_LIB(db, db_create, [#include <db.h>],
195 [AC_SUBST(LIBDB,[-ldb])],
196 [missing_libraries="$missing_libraries libdb"])
197 AC_CHECK_LIB(vorbis, vorbis_info_clear,
199 [missing_libraries="$missing_libraries libvorbis"])
200 AC_CHECK_LIB(vorbisfile, ov_open,
201 [AC_SUBST(LIBVORBISFILE,["-lvorbisfile -lvorbis"])],
202 [missing_libraries="$missing_libraries libvorbisfile"],
204 AC_CHECK_LIB(mad, mad_stream_init,
205 [AC_SUBST(LIBMAD,[-lmad])],
206 [missing_libraries="$missing_libraries libmad"])
207 AC_CHECK_LIB([ao], [ao_initialize],
208 [AC_SUBST(LIBAO,[-lao])],
209 [missing_libraries="$missing_libraries libao"])
210 AC_CHECK_LIB([FLAC], [FLAC__stream_decoder_new],
211 [AC_SUBST(LIBFLAC,[-lFLAC])],
212 [missing_libraries="$missing_libraries libFLAC"])
215 if test $want_gtk = yes; then
216 AM_PATH_GLIB_2_0([],[],[missing_libraries="$missing_libraries libglib"])
217 AM_PATH_GTK_2_0([],[],[missing_libraries="$missing_libraries libgtk"])
220 # Some platforms have iconv already
221 AC_CHECK_FUNC(iconv_open, [:],
222 [RJK_CHECK_LIB(iconv, iconv_open, [#include <iconv.h>],
223 [AC_SUBST(LIBICONV,[-liconv])],
224 [missing_functions="$missing_functions iconv_open"])])
225 AC_CHECK_FUNC([gethostbyname],[:],[
226 AC_CHECK_LIB(nsl,gethostbyname,
227 [AC_SUBST(LIBNSL,[-lnsl])],
228 [missing_functions="$missing_functions gethostbyname"])])
229 AC_CHECK_FUNC([socket],[:],[
230 AC_CHECK_LIB(socket,socket,
231 [AC_SUBST(LIBSOCKET,[-lsocket])],
232 [missing_functions="$missing_functions socket"])])
233 AC_CHECK_FUNC([dlopen],[:],[
234 AC_CHECK_LIB(dl,dlopen,
235 [AC_SUBST(LIBDL,[-ldl])],
236 [missing_functions="$missing_functions dlopen"])])
238 if test ! -z "$missing_libraries"; then
239 AC_MSG_ERROR([missing libraries:$missing_libraries])
242 # Checks for header files.
244 if test $want_oss = yes; then
245 AC_CHECK_HEADERS([sys/soundcard.h])
247 if test $want_alsa = yes; then
248 AC_CHECK_HEADERS([alsa/asoundlib.h])
250 if test $want_coreaudio = yes; then
251 AC_CHECK_HEADERS([CoreAudio/AudioHardware.h])
253 AC_CHECK_HEADERS([inttypes.h])
254 # We don't bother checking very standard stuff
255 # Compilation will fail if any of these headers are missing, so we
256 # check for them here and fail early.
257 if test $want_server = yes; then
258 AC_CHECK_HEADERS([db.h],[:],[
259 missing_headers="$missing_headers $ac_header"
261 AC_CHECK_HEADERS([FLAC/file_decoder.h])
263 AC_CHECK_HEADERS([dlfcn.h gcrypt.h \
264 getopt.h iconv.h langinfo.h \
266 syslog.h unistd.h],[:],[
267 missing_headers="$missing_headers $ac_header"
270 if test ! -z "$missing_headers"; then
271 AC_MSG_ERROR([missing headers:$missing_headers])
274 # We require that libpcre support UTF-8
275 RJK_REQUIRE_PCRE_UTF8([-lpcre])
277 # Checks for typedefs, structures, and compiler characteristics.
282 AC_CHECK_TYPES([struct sockaddr_in6],,,[AC_INCLUDES_DEFAULT
283 #include <netinet/in.h>])
285 # enable -Werror when we check for certain characteristics:
287 old_CFLAGS="${CFLAGS}"
288 CFLAGS="${CFLAGS} $gcc_werror"
289 AC_CHECK_TYPES([long long,uint32_t,uint8_t,intmax_t,uintmax_t])
291 # Some GCC invocations warn for converting function pointers to void *.
292 # This is fair enough, as it's technically forbidden, but we use dlsym()
293 # which can pretty much only exist if object and function pointers are
294 # interconvertable. So we disable -Werror if need be.
295 if test ! -z "$gcc_werror"; then
296 AC_CACHE_CHECK([whether function pointers can be converted to void * without a warning],
297 [rjk_cv_function_pointer_cast],[
298 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
299 void somefunction(void);],
300 [(void *)somefunction])],
301 [rjk_cv_function_pointer_cast=yes],
302 [rjk_cv_function_pointer_cast=no])])
303 if test $rjk_cv_function_pointer_cast = no; then
308 CFLAGS="${old_CFLAGS}"
310 # gcrypt maintainers keep changing everything. Design your interface
311 # first, then implement it once, rather than getting it wrong three or
312 # four times and shipping between each attempt.
313 AC_CACHE_CHECK([for hash handle type in <grypt.h>],
314 [rjk_cv_gcrypt_hash_handle],[
315 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
319 [rjk_cv_gcrypt_hash_handle=gcry_md_hd_t],[
320 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
324 [rjk_cv_gcrypt_hash_handle=GcryMDHd],
325 [rjk_cv_gcrypt_hash_handle=GCRY_MD_HD])])])
326 AC_DEFINE_UNQUOTED([gcrypt_hash_handle],[$rjk_cv_gcrypt_hash_handle],
327 [libgcrypt hash handle type])
329 AC_CACHE_CHECK([for gcry_error_t in <grypt.h>],
330 [rjk_cv_have_gcry_error_t],[
331 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
335 [rjk_cv_have_gcry_error_t=yes],
336 [rjk_cv_have_gcry_error_t=no])])
337 if test $rjk_cv_have_gcry_error_t = yes; then
338 AC_DEFINE([HAVE_GCRY_ERROR_T],1,[define if <gcrypt.h> defines gcry_error_t])
341 # Checks for functions
342 if test $ac_cv_type_long_long = yes; then
343 AC_CHECK_FUNCS([atoll strtoll],[:],[
344 missing_functions="$missing_functions $ac_func"
346 # Darwin sometimes fails to declare strtoll (e.g. if you ask for -std=c99)
347 AC_CACHE_CHECK([whether strtoll is declared in <stdlib.h>],
348 [rjk_cv_strtoll_declared],[
349 AC_EGREP_HEADER([strtoll], [stdlib.h],
350 [rjk_cv_strtoll_declared=yes],
351 [rjk_cv_strtoll_declared=no])])
352 if test $rjk_cv_strtoll_declared = yes; then
353 AC_DEFINE([DECLARES_STRTOLL],[1],[define if <stdlib.h> declares strtoll])
355 AC_CACHE_CHECK([whether atoll is declared in <stdlib.h>],
356 [rjk_cv_atoll_declared],[
357 AC_EGREP_HEADER([atoll], [stdlib.h],
358 [rjk_cv_atoll_declared=yes],
359 [rjk_cv_atoll_declared=no])])
360 if test $rjk_cv_atoll_declared = yes; then
361 AC_DEFINE([DECLARES_ATOLL],[1],[define if <stdlib.h> declares atoll])
364 AC_CHECK_FUNCS([ioctl nl_langinfo strsignal],[:],[
365 missing_functions="$missing_functions $ac_func"
367 # fsync will do if fdatasync not available
368 AC_CHECK_FUNCS([fdatasync],[:],[
369 AC_CHECK_FUNCS([fsync],
370 [AC_DEFINE([fdatasync],[fsync],[define fdatasync to fsync if not available])],
371 [missing_functions="$missing_functions fdatasync"])])
372 if test ! -z "$missing_functions"; then
373 AC_MSG_ERROR([missing functions:$missing_functions])
375 if test $want_server = yes; then
376 # <db.h> had better be version 3 or later
377 AC_CACHE_CHECK([db.h version],[rjk_cv_db_version],[
380 #ifndef DB_VERSION_MAJOR
381 # error cannot determine db version
383 #if DB_VERSION_MAJOR < 4
384 # error inadequate db version
386 #if DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR < 2
387 # error inadequate db version
390 [rjk_cv_db_version=ok],
391 [rjk_cv_db_version=inadequate])
393 if test $rjk_cv_db_version != ok; then
394 AC_MSG_ERROR([need db.h version at least 4.2])
398 if test "x$GCC" = xyes; then
399 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29478
400 AC_CACHE_CHECK([checking for GCC bug 29478],[rjk_cv_pr29478],[
402 if test $GCC = yes; then
403 CC="$CC -Wall -Werror"
406 static int x(char *f) {
409 int z(const char *g) {
417 if test $rjk_cv_pr29478 = yes; then
421 # a reasonable default set of warnings
422 CC="${CC} -Wall -W -Wpointer-arith -Wbad-function-cast \
423 -Wwrite-strings -Wmissing-prototypes \
424 -Wmissing-declarations -Wnested-externs"
426 # Fix up GTK+ and GLib compiler flags
427 GTK_CFLAGS="`echo \"$GTK_CFLAGS\"|sed 's/-I/-isystem /g'`"
428 GLIB_CFLAGS="`echo \"$GLIB_CFLAGS\"|sed 's/-I/-isystem /g'`"
430 if test "$gcc_werror" != ''; then
431 # GCC 2.95 doesn't know to ignore warnings from system headers
432 AC_CACHE_CHECK([whether -Werror is usable],
434 save_CFLAGS="${CFLAGS}"
435 CFLAGS="${CFLAGS} ${GTK_CFLAGS} -Werror"
436 AC_TRY_COMPILE([#include <gtk/gtk.h>],
440 CFLAGS="${save_CFLAGS}"
442 if test $rjk_cv_werror = no; then
446 CC="${CC} $gcc_werror"
448 # for older GCCs that don't know %ju (etc)
449 AC_CACHE_CHECK([whether -Wno-format is required],
451 AC_TRY_COMPILE([#include <stdio.h>
454 [printf("%ju", (uintmax_t)0);],
455 [rjk_cv_noformat=no],
456 [rjk_cv_noformat=yes]))
457 if test $rjk_cv_noformat = yes; then
458 CC="${CC} -Wno-format"
461 AC_CACHE_CHECK([whether -Wshadow is OK],
467 #include <vorbis/vorbisfile.h>
473 if test $rjk_cv_shadow = yes; then
480 AH_BOTTOM([#ifdef __GNUC__
481 # define attribute(x) __attribute__(x)
483 # define attribute(x)
486 AC_CONFIG_FILES([Makefile
493 disobedience/Makefile
504 if test $GCC = yes && test "$gcc_werror" = ''; then
505 AC_MSG_WARN([building without -Werror])
507 if test $want_python = no; then
508 AC_MSG_WARN([cannot run the test suit without Python])