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
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22 AC_INIT([disorder], [1.5.99+], [richard+disorder@sfere.greenend.org.uk])
23 AC_CONFIG_AUX_DIR([config.aux])
24 AM_INIT_AUTOMAKE(disorder, [1.5.99+])
25 AC_CONFIG_SRCDIR([server/disorderd.c])
26 AM_CONFIG_HEADER([config.h])
31 # What we want to build
40 # Checks for programs.
43 if test "x$GCC" = xyes; then
50 [AS_HELP_STRING([--without-alsa],
51 [do not build with ALSA support])],
54 [AS_HELP_STRING([--without-oss],
55 [do not build with OSS support])],
57 AC_ARG_WITH([coreaudio],
58 [AS_HELP_STRING([--without-coreaudio],
59 [do not build with Core Audio support])],
60 [want_coreaudio=$withval])
62 AC_MSG_CHECKING([for a known target platform])
65 AC_MSG_RESULT([empeg car stereo])
66 AC_DEFINE([EMPEG_HOST],[1],[define if host is an empeg car stereo])
67 # work around broken toolchain
68 AC_CHECK_LIB([gpg-error], [gpg_strerror])
69 AC_CHECK_LIB([pthread], [pthread_create])
73 AC_MSG_RESULT([Linux])
77 AC_MSG_RESULT([Mac OS X])
79 if test $want_coreaudio = yes; then
80 COREAUDIO="-framework CoreAudio"
85 AC_MSG_RESULT([unknown, winging it])
91 AC_ARG_WITH([browser],
92 [AS_HELP_STRING([--with-browser=BROWSER],
93 [use BROWSER to display HTML])],
96 AC_CACHE_CHECK([default HTML viewer],[rjk_cv_browser],[
97 rjk_cv_browser=UNKNOWN
98 for candidate in x-www-browser firefox mozilla konqueror netscape; do
99 if type $candidate >/dev/null 2>&1; then
100 rjk_cv_browser="$candidate"
105 if test -z "$browser"; then
106 browser="$rjk_cv_browser"
108 AC_DEFINE_UNQUOTED([BROWSER],["$browser"],[HTML viewer])
110 AC_ARG_WITH([server],
111 [AS_HELP_STRING([--without-server],
112 [do not build server])],
113 [want_server=$withval])
115 [AS_HELP_STRING([--without-gtk],
116 [do not build GTK+ client])],
118 AC_ARG_WITH([python],
119 [AS_HELP_STRING([--without-python],
120 [do not build Python support])],
121 [want_python=$withval])
123 subdirs="scripts lib clients doc examples debian"
125 if test $want_server = yes; then
126 subdirs="${subdirs} server plugins driver templates sounds images"
128 if test $want_python = yes; then
130 subdirs="${subdirs} python"
132 if test $want_gtk = yes; then
133 subdirs="${subdirs} disobedience"
134 if test $want_server = no; then
135 subdirs="${subdirs} images"
138 subdirs="${subdirs} tests"
151 AC_DEFINE(_GNU_SOURCE, 1, [required for e.g. strsignal])
153 # Macs might have libraries under fink's root
154 AC_PATH_PROG([FINK],[fink],[none],[$PATH:/sw/bin])
155 if test "x$FINK" != xnone; then
156 AC_CACHE_CHECK([fink install directory],[rjk_cv_finkprefix],[
157 rjk_cv_finkprefix="`echo "$FINK" | sed 's,/bin/fink$,,'`"
159 finkdir="${rjk_cv_finkprefix}"
160 finkbindir="${rjk_cv_finkprefix}/bin"
161 CPPFLAGS="${CPPFLAGS} -I${rjk_cv_finkprefix}/include/gc -I${rjk_cv_finkprefix}/include"
162 if test $want_server = yes; then
163 CPPFLAGS="${CPPFLAGS} -I${rjk_cv_finkprefix}/include/db4"
165 LDFLAGS="${LDFLAGS} -L${rjk_cv_finkprefix}/lib"
170 AC_SUBST([finkbindir])
172 # Checks for libraries.
173 # We save up a list of missing libraries that we can't do without
174 # and report them all at once.
175 AC_CHECK_LIB(gc, GC_malloc, [AC_SUBST(LIBGC,[-lgc])],
176 [missing_libraries="$missing_libraries libgc"])
177 AC_CHECK_LIB(gcrypt, gcry_md_open,
178 [AC_SUBST(LIBGCRYPT,[-lgcrypt])],
179 [missing_libraries="$missing_libraries libgcrypt"])
180 AC_CHECK_LIB(pcre, pcre_compile,
181 [AC_SUBST(LIBPCRE,[-lpcre])],
182 [missing_libraries="$missing_libraries libpcre"])
183 if test $want_alsa = yes; then
184 AC_CHECK_LIB([asound], [snd_pcm_open],
185 [AC_SUBST(LIBASOUND,[-lasound])])
187 if test $want_server = yes; then
188 RJK_CHECK_LIB(db, db_create, [#include <db.h>],
189 [AC_SUBST(LIBDB,[-ldb])],
190 [missing_libraries="$missing_libraries libdb"])
191 AC_CHECK_LIB(vorbis, vorbis_info_clear,
193 [missing_libraries="$missing_libraries libvorbis"])
194 AC_CHECK_LIB(vorbisfile, ov_open,
195 [AC_SUBST(LIBVORBISFILE,["-lvorbisfile -lvorbis"])],
196 [missing_libraries="$missing_libraries libvorbisfile"],
198 AC_CHECK_LIB(mad, mad_stream_init,
199 [AC_SUBST(LIBMAD,[-lmad])],
200 [missing_libraries="$missing_libraries libmad"])
201 AC_CHECK_LIB([ao], [ao_initialize],
202 [AC_SUBST(LIBAO,[-lao])],
203 [missing_libraries="$missing_libraries libao"])
204 AC_CHECK_LIB([FLAC], [FLAC__stream_decoder_new],
205 [AC_SUBST(LIBFLAC,[-lFLAC])],
206 [missing_libraries="$missing_libraries libFLAC"])
209 if test $want_gtk = yes; then
210 AM_PATH_GLIB_2_0([],[],[missing_libraries="$missing_libraries libglib"])
211 AM_PATH_GTK_2_0([],[],[missing_libraries="$missing_libraries libgtk"])
214 # Some platforms have iconv already
215 AC_CHECK_FUNC(iconv_open, [:],
216 [RJK_CHECK_LIB(iconv, iconv_open, [#include <iconv.h>],
217 [AC_SUBST(LIBICONV,[-liconv])],
218 [missing_functions="$missing_functions iconv_open"])])
219 AC_CHECK_FUNC([gethostbyname],[:],[
220 AC_CHECK_LIB(nsl,gethostbyname,
221 [AC_SUBST(LIBNSL,[-lnsl])],
222 [missing_functions="$missing_functions gethostbyname"])])
223 AC_CHECK_FUNC([socket],[:],[
224 AC_CHECK_LIB(socket,socket,
225 [AC_SUBST(LIBSOCKET,[-lsocket])],
226 [missing_functions="$missing_functions socket"])])
227 AC_CHECK_FUNC([dlopen],[:],[
228 AC_CHECK_LIB(dl,dlopen,
229 [AC_SUBST(LIBDL,[-ldl])],
230 [missing_functions="$missing_functions dlopen"])])
232 if test ! -z "$missing_libraries"; then
233 AC_MSG_ERROR([missing libraries:$missing_libraries])
236 # We require that libpcre support UTF-8
237 RJK_REQUIRE_PCRE_UTF8([-lpcre])
239 # Checks for header files.
241 if test $want_oss = yes; then
242 AC_CHECK_HEADERS([sys/soundcard.h])
244 if test $want_alsa = yes; then
245 AC_CHECK_HEADERS([alsa/asoundlib.h])
247 if test $want_coreaudio = yes; then
248 AC_CHECK_HEADERS([CoreAudio/AudioHardware.h])
250 AC_CHECK_HEADERS([inttypes.h])
251 # We don't bother checking very standard stuff
252 # Compilation will fail if any of these headers are missing, so we
253 # check for them here and fail early.
254 if test $want_server = yes; then
255 AC_CHECK_HEADERS([db.h],[:],[
256 missing_headers="$missing_headers $ac_header"
259 AC_CHECK_HEADERS([dlfcn.h gcrypt.h \
260 getopt.h iconv.h langinfo.h \
262 syslog.h unistd.h],[:],[
263 missing_headers="$missing_headers $ac_header"
266 if test ! -z "$missing_headers"; then
267 AC_MSG_ERROR([missing headers:$missing_headers])
270 # Checks for typedefs, structures, and compiler characteristics.
275 AC_CHECK_TYPES([struct sockaddr_in6],,,[AC_INCLUDES_DEFAULT
276 #include <netinet/in.h>])
278 # enable -Werror when we check for certain characteristics:
280 old_CFLAGS="${CFLAGS}"
281 CFLAGS="${CFLAGS} $gcc_werror"
282 AC_CHECK_TYPES([long long,uint32_t,uint8_t,intmax_t,uintmax_t])
284 # Some GCC invocations warn for converting function pointers to void *.
285 # This is fair enough, as it's technically forbidden, but we use dlsym()
286 # which can pretty much only exist if object and function pointers are
287 # interconvertable. So we disable -Werror if need be.
288 if test ! -z "$gcc_werror"; then
289 AC_CACHE_CHECK([whether function pointers can be converted to void * without a warning],
290 [rjk_cv_function_pointer_cast],[
291 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
292 void somefunction(void);],
293 [(void *)somefunction])],
294 [rjk_cv_function_pointer_cast=yes],
295 [rjk_cv_function_pointer_cast=no])])
296 if test $rjk_cv_function_pointer_cast = no; then
301 CFLAGS="${old_CFLAGS}"
303 # gcrypt maintainers keep changing everything. Design your interface
304 # first, then implement it once, rather than getting it wrong three or
305 # four times and shipping between each attempt.
306 AC_CACHE_CHECK([for hash handle type in <grypt.h>],
307 [rjk_cv_gcrypt_hash_handle],[
308 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
312 [rjk_cv_gcrypt_hash_handle=gcry_md_hd_t],[
313 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
317 [rjk_cv_gcrypt_hash_handle=GcryMDHd],
318 [rjk_cv_gcrypt_hash_handle=GCRY_MD_HD])])])
319 AC_DEFINE_UNQUOTED([gcrypt_hash_handle],[$rjk_cv_gcrypt_hash_handle],
320 [libgcrypt hash handle type])
322 AC_CACHE_CHECK([for gcry_error_t in <grypt.h>],
323 [rjk_cv_have_gcry_error_t],[
324 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
328 [rjk_cv_have_gcry_error_t=yes],
329 [rjk_cv_have_gcry_error_t=no])])
330 if test $rjk_cv_have_gcry_error_t = yes; then
331 AC_DEFINE([HAVE_GCRY_ERROR_T],1,[define if <gcrypt.h> defines gcry_error_t])
334 # Checks for functions
335 if test $ac_cv_type_long_long = yes; then
336 AC_CHECK_FUNCS([atoll strtoll],[:],[
337 missing_functions="$missing_functions $ac_func"
339 # Darwin sometimes fails to declare strtoll (e.g. if you ask for -std=c99)
340 AC_CACHE_CHECK([whether strtoll is declared in <stdlib.h>],
341 [rjk_cv_strtoll_declared],[
342 AC_EGREP_HEADER([strtoll], [stdlib.h],
343 [rjk_cv_strtoll_declared=yes],
344 [rjk_cv_strtoll_declared=no])])
345 if test $rjk_cv_strtoll_declared = yes; then
346 AC_DEFINE([DECLARES_STRTOLL],[1],[define if <stdlib.h> declares strtoll])
348 AC_CACHE_CHECK([whether atoll is declared in <stdlib.h>],
349 [rjk_cv_atoll_declared],[
350 AC_EGREP_HEADER([atoll], [stdlib.h],
351 [rjk_cv_atoll_declared=yes],
352 [rjk_cv_atoll_declared=no])])
353 if test $rjk_cv_atoll_declared = yes; then
354 AC_DEFINE([DECLARES_ATOLL],[1],[define if <stdlib.h> declares atoll])
357 AC_CHECK_FUNCS([ioctl nl_langinfo strsignal],[:],[
358 missing_functions="$missing_functions $ac_func"
360 # fsync will do if fdatasync not available
361 AC_CHECK_FUNCS([fdatasync],[:],[
362 AC_CHECK_FUNCS([fsync],
363 [AC_DEFINE([fdatasync],[fsync],[define fdatasync to fsync if not available])],
364 [missing_functions="$missing_functions fdatasync"])])
365 if test ! -z "$missing_functions"; then
366 AC_MSG_ERROR([missing functions:$missing_functions])
368 if test $want_server = yes; then
369 # <db.h> had better be version 3 or later
370 AC_CACHE_CHECK([db.h version],[rjk_cv_db_version],[
373 #ifndef DB_VERSION_MAJOR
374 # error cannot determine db version
376 #if DB_VERSION_MAJOR < 4
377 # error inadequate db version
379 #if DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR < 2
380 # error inadequate db version
383 [rjk_cv_db_version=ok],
384 [rjk_cv_db_version=inadequate])
386 if test $rjk_cv_db_version != ok; then
387 AC_MSG_ERROR([need db.h version at least 4.2])
391 if test "x$GCC" = xyes; then
392 # a reasonable default set of warnings
393 CC="${CC} -Wall -W -Wpointer-arith -Wbad-function-cast \
394 -Wwrite-strings -Wmissing-prototypes \
395 -Wmissing-declarations -Wnested-externs"
397 # Fix up GTK+ and GLib compiler flags
398 GTK_CFLAGS="`echo \"$GTK_CFLAGS\"|sed 's/-I/-isystem /g'`"
399 GLIB_CFLAGS="`echo \"$GLIB_CFLAGS\"|sed 's/-I/-isystem /g'`"
401 # GCC 2.95 doesn't know to ignore warnings from system headers
402 AC_CACHE_CHECK([whether -Werror is usable],
404 save_CFLAGS="${CFLAGS}"
405 CFLAGS="${CFLAGS} ${GTK_CFLAGS} -Werror"
406 AC_TRY_COMPILE([#include <gtk/gtk.h>],
410 CFLAGS="${save_CFLAGS}"
412 if test $rjk_cv_werror = no; then
415 CC="${CC} $gcc_werror"
417 # for older GCCs that don't know %ju (etc)
418 AC_CACHE_CHECK([whether -Wno-format is required],
420 AC_TRY_COMPILE([#include <stdio.h>
423 [printf("%ju", (uintmax_t)0);],
424 [rjk_cv_noformat=no],
425 [rjk_cv_noformat=yes]))
426 if test $rjk_cv_noformat = yes; then
427 CC="${CC} -Wno-format"
430 AC_CACHE_CHECK([whether -Wshadow is OK],
436 #include <vorbis/vorbisfile.h>
442 if test $rjk_cv_shadow = yes; then
449 AH_BOTTOM([#ifdef __GNUC__
450 # define attribute(x) __attribute__(x)
452 # define attribute(x)
455 AC_CONFIG_FILES([Makefile
462 disobedience/Makefile