chiark / gitweb /
more thorough kvp.c testing
[disorder] / configure.ac
... / ...
CommitLineData
1# Process this file with autoconf to produce a configure script.
2#
3# This file is part of DisOrder.
4# Copyright (C) 2004, 2005, 2006, 2007 Richard Kettlewell
5#
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.
10#
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.
15#
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
19# USA
20#
21
22AC_INIT([disorder], [1.5.99+], [richard+disorder@sfere.greenend.org.uk])
23AC_CONFIG_AUX_DIR([config.aux])
24AM_INIT_AUTOMAKE(disorder, [1.5.99+])
25AC_CONFIG_SRCDIR([server/disorderd.c])
26AM_CONFIG_HEADER([config.h])
27
28# Find host type
29AC_CANONICAL_HOST
30
31# What we want to build
32want_gtk=yes
33want_python=yes
34
35# APIs we want
36want_alsa=yes
37want_oss=yes
38want_coreaudio=yes
39
40# Checks for programs.
41AC_PROG_CC
42AC_SET_MAKE
43if test "x$GCC" = xyes; then
44 gcc_werror=-Werror
45else
46 gcc_werror=""
47fi
48
49AC_ARG_WITH([alsa],
50 [AS_HELP_STRING([--without-alsa],
51 [do not build with ALSA support])],
52 [want_alsa=$withval])
53AC_ARG_WITH([oss],
54 [AS_HELP_STRING([--without-oss],
55 [do not build with OSS support])],
56 [want_oss=$withval])
57AC_ARG_WITH([coreaudio],
58 [AS_HELP_STRING([--without-coreaudio],
59 [do not build with Core Audio support])],
60 [want_coreaudio=$withval])
61
62AC_MSG_CHECKING([for a known target platform])
63case "$host" in
64*empeg* )
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])
70 want_server=no
71 ;;
72*linux* | *Linux* )
73 AC_MSG_RESULT([Linux])
74 want_server=yes
75 ;;
76*-apple-darwin* )
77 AC_MSG_RESULT([Mac OS X])
78 want_server=yes
79 if test $want_coreaudio = yes; then
80 COREAUDIO="-framework CoreAudio"
81 fi
82 browser=open
83 ;;
84* )
85 AC_MSG_RESULT([unknown, winging it])
86 want_server=no
87 ;;
88esac
89AC_SUBST([COREAUDIO])
90
91AC_ARG_WITH([browser],
92 [AS_HELP_STRING([--with-browser=BROWSER],
93 [use BROWSER to display HTML])],
94 [browser=$withval])
95
96AC_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"
101 break
102 fi
103 done
104])
105if test -z "$browser"; then
106 browser="$rjk_cv_browser"
107fi
108AC_DEFINE_UNQUOTED([BROWSER],["$browser"],[HTML viewer])
109
110AC_ARG_WITH([server],
111 [AS_HELP_STRING([--without-server],
112 [do not build server])],
113 [want_server=$withval])
114AC_ARG_WITH([gtk],
115 [AS_HELP_STRING([--without-gtk],
116 [do not build GTK+ client])],
117 [want_gtk=$withval])
118AC_ARG_WITH([python],
119 [AS_HELP_STRING([--without-python],
120 [do not build Python support])],
121 [want_python=$withval])
122
123subdirs="scripts lib clients doc examples debian"
124
125if test $want_server = yes; then
126 subdirs="${subdirs} server plugins driver templates sounds images"
127fi
128if test $want_gtk = yes; then
129 subdirs="${subdirs} disobedience"
130 if test $want_server = no; then
131 subdirs="${subdirs} images"
132 fi
133fi
134if test $want_python = yes; then
135 AM_PATH_PYTHON([2.4])
136 subdirs="${subdirs} python tests"
137fi
138AC_SUBST([subdirs])
139
140# libtool config
141AC_LIBTOOL_DLOPEN
142AC_DISABLE_STATIC
143
144AC_PROG_LIBTOOL
145
146missing_libraries=""
147missing_headers=""
148missing_functions=""
149
150AC_DEFINE(_GNU_SOURCE, 1, [required for e.g. strsignal])
151
152# Macs might have libraries under fink's root
153AC_PATH_PROG([FINK],[fink],[none],[$PATH:/sw/bin])
154if test "x$FINK" != xnone; then
155 AC_CACHE_CHECK([fink install directory],[rjk_cv_finkprefix],[
156 rjk_cv_finkprefix="`echo "$FINK" | sed 's,/bin/fink$,,'`"
157 ])
158 finkdir="${rjk_cv_finkprefix}"
159 finkbindir="${rjk_cv_finkprefix}/bin"
160 CPPFLAGS="${CPPFLAGS} -I${rjk_cv_finkprefix}/include/gc -I${rjk_cv_finkprefix}/include"
161 if test $want_server = yes; then
162 CPPFLAGS="${CPPFLAGS} -I${rjk_cv_finkprefix}/include/db4"
163 fi
164 LDFLAGS="${LDFLAGS} -L${rjk_cv_finkprefix}/lib"
165else
166 finkbindir=""
167fi
168AC_SUBST([finkdir])
169AC_SUBST([finkbindir])
170
171# Checks for libraries.
172# We save up a list of missing libraries that we can't do without
173# and report them all at once.
174AC_CHECK_LIB(gc, GC_malloc, [AC_SUBST(LIBGC,[-lgc])],
175 [missing_libraries="$missing_libraries libgc"])
176AC_CHECK_LIB(gcrypt, gcry_md_open,
177 [AC_SUBST(LIBGCRYPT,[-lgcrypt])],
178 [missing_libraries="$missing_libraries libgcrypt"])
179AC_CHECK_LIB(pcre, pcre_compile,
180 [AC_SUBST(LIBPCRE,[-lpcre])],
181 [missing_libraries="$missing_libraries libpcre"])
182if test $want_alsa = yes; then
183 AC_CHECK_LIB([asound], [snd_pcm_open],
184 [AC_SUBST(LIBASOUND,[-lasound])])
185fi
186if test $want_server = yes; then
187 RJK_CHECK_LIB(db, db_create, [#include <db.h>],
188 [AC_SUBST(LIBDB,[-ldb])],
189 [missing_libraries="$missing_libraries libdb"])
190 AC_CHECK_LIB(vorbis, vorbis_info_clear,
191 [:],
192 [missing_libraries="$missing_libraries libvorbis"])
193 AC_CHECK_LIB(vorbisfile, ov_open,
194 [AC_SUBST(LIBVORBISFILE,["-lvorbisfile -lvorbis"])],
195 [missing_libraries="$missing_libraries libvorbisfile"],
196 [-lvorbis])
197 AC_CHECK_LIB(mad, mad_stream_init,
198 [AC_SUBST(LIBMAD,[-lmad])],
199 [missing_libraries="$missing_libraries libmad"])
200 AC_CHECK_LIB([ao], [ao_initialize],
201 [AC_SUBST(LIBAO,[-lao])],
202 [missing_libraries="$missing_libraries libao"])
203 AC_CHECK_LIB([FLAC], [FLAC__stream_decoder_new],
204 [AC_SUBST(LIBFLAC,[-lFLAC])],
205 [missing_libraries="$missing_libraries libFLAC"])
206fi
207
208if test $want_gtk = yes; then
209 AM_PATH_GLIB_2_0([],[],[missing_libraries="$missing_libraries libglib"])
210 AM_PATH_GTK_2_0([],[],[missing_libraries="$missing_libraries libgtk"])
211fi
212
213# Some platforms have iconv already
214AC_CHECK_FUNC(iconv_open, [:],
215 [RJK_CHECK_LIB(iconv, iconv_open, [#include <iconv.h>],
216 [AC_SUBST(LIBICONV,[-liconv])],
217 [missing_functions="$missing_functions iconv_open"])])
218AC_CHECK_FUNC([gethostbyname],[:],[
219 AC_CHECK_LIB(nsl,gethostbyname,
220 [AC_SUBST(LIBNSL,[-lnsl])],
221 [missing_functions="$missing_functions gethostbyname"])])
222AC_CHECK_FUNC([socket],[:],[
223 AC_CHECK_LIB(socket,socket,
224 [AC_SUBST(LIBSOCKET,[-lsocket])],
225 [missing_functions="$missing_functions socket"])])
226AC_CHECK_FUNC([dlopen],[:],[
227 AC_CHECK_LIB(dl,dlopen,
228 [AC_SUBST(LIBDL,[-ldl])],
229 [missing_functions="$missing_functions dlopen"])])
230
231if test ! -z "$missing_libraries"; then
232 AC_MSG_ERROR([missing libraries:$missing_libraries])
233fi
234
235# We require that libpcre support UTF-8
236RJK_REQUIRE_PCRE_UTF8([-lpcre])
237
238# Checks for header files.
239RJK_FIND_GC_H
240if test $want_oss = yes; then
241 AC_CHECK_HEADERS([sys/soundcard.h])
242fi
243if test $want_alsa = yes; then
244 AC_CHECK_HEADERS([alsa/asoundlib.h])
245fi
246if test $want_coreaudio = yes; then
247 AC_CHECK_HEADERS([CoreAudio/AudioHardware.h])
248fi
249AC_CHECK_HEADERS([inttypes.h])
250# We don't bother checking very standard stuff
251# Compilation will fail if any of these headers are missing, so we
252# check for them here and fail early.
253if test $want_server = yes; then
254 AC_CHECK_HEADERS([db.h],[:],[
255 missing_headers="$missing_headers $ac_header"
256 ])
257 AC_CHECK_HEADERS([FLAC/file_decoder.h])
258fi
259AC_CHECK_HEADERS([dlfcn.h gcrypt.h \
260 getopt.h iconv.h langinfo.h \
261 pcre.h sys/ioctl.h \
262 syslog.h unistd.h],[:],[
263 missing_headers="$missing_headers $ac_header"
264])
265
266if test ! -z "$missing_headers"; then
267 AC_MSG_ERROR([missing headers:$missing_headers])
268fi
269
270# Checks for typedefs, structures, and compiler characteristics.
271AC_C_CONST
272AC_TYPE_SIZE_T
273AC_C_INLINE
274AC_C_BIGENDIAN
275AC_CHECK_TYPES([struct sockaddr_in6],,,[AC_INCLUDES_DEFAULT
276#include <netinet/in.h>])
277
278# enable -Werror when we check for certain characteristics:
279
280old_CFLAGS="${CFLAGS}"
281CFLAGS="${CFLAGS} $gcc_werror"
282AC_CHECK_TYPES([long long,uint32_t,uint8_t,intmax_t,uintmax_t])
283
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.
288if 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
297 gcc_werror=""
298 fi
299fi
300
301CFLAGS="${old_CFLAGS}"
302
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.
306AC_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
309#include <gcrypt.h>
310],
311 [gcry_md_hd_t h;])],
312 [rjk_cv_gcrypt_hash_handle=gcry_md_hd_t],[
313 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
314#include <gcrypt.h>
315],
316 [GcryMDHd h;])],
317 [rjk_cv_gcrypt_hash_handle=GcryMDHd],
318 [rjk_cv_gcrypt_hash_handle=GCRY_MD_HD])])])
319AC_DEFINE_UNQUOTED([gcrypt_hash_handle],[$rjk_cv_gcrypt_hash_handle],
320 [libgcrypt hash handle type])
321
322AC_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
325#include <gcrypt.h>
326],
327 [gcry_error_t e;])],
328 [rjk_cv_have_gcry_error_t=yes],
329 [rjk_cv_have_gcry_error_t=no])])
330if 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])
332fi
333
334# Checks for functions
335if test $ac_cv_type_long_long = yes; then
336 AC_CHECK_FUNCS([atoll strtoll],[:],[
337 missing_functions="$missing_functions $ac_func"
338 ])
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])
347 fi
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])
355 fi
356fi
357AC_CHECK_FUNCS([ioctl nl_langinfo strsignal],[:],[
358 missing_functions="$missing_functions $ac_func"
359])
360# fsync will do if fdatasync not available
361AC_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"])])
365if test ! -z "$missing_functions"; then
366 AC_MSG_ERROR([missing functions:$missing_functions])
367fi
368if 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],[
371 AC_PREPROC_IFELSE([
372 #include <db.h>
373 #ifndef DB_VERSION_MAJOR
374 # error cannot determine db version
375 #endif
376 #if DB_VERSION_MAJOR < 4
377 # error inadequate db version
378 #endif
379 #if DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR < 2
380 # error inadequate db version
381 #endif
382 ],
383 [rjk_cv_db_version=ok],
384 [rjk_cv_db_version=inadequate])
385 ])
386 if test $rjk_cv_db_version != ok; then
387 AC_MSG_ERROR([need db.h version at least 4.2])
388 fi
389fi
390
391if test "x$GCC" = xyes; then
392 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29478
393 AC_CACHE_CHECK([checking for GCC bug 29478],[rjk_cv_pr29478],[
394 old_CC="$CC"
395 if test $GCC = yes; then
396 CC="$CC -Wall -Werror"
397 fi
398 AC_COMPILE_IFELSE([
399 static int x(char *f) {
400 return *f;
401 }
402 int z(const char *g) {
403 return x((char *)g);
404 }],
405 [rjk_cv_pr29478=no],
406 [rjk_cv_pr29478=yes]
407 )
408 CC="$old_CC"
409 ])
410 if test $rjk_cv_pr29478 = yes; then
411 gcc_werror=''
412 fi
413
414 # a reasonable default set of warnings
415 CC="${CC} -Wall -W -Wpointer-arith -Wbad-function-cast \
416 -Wwrite-strings -Wmissing-prototypes \
417 -Wmissing-declarations -Wnested-externs"
418
419 # Fix up GTK+ and GLib compiler flags
420 GTK_CFLAGS="`echo \"$GTK_CFLAGS\"|sed 's/-I/-isystem /g'`"
421 GLIB_CFLAGS="`echo \"$GLIB_CFLAGS\"|sed 's/-I/-isystem /g'`"
422
423 if test "$gcc_werror" != ''; then
424 # GCC 2.95 doesn't know to ignore warnings from system headers
425 AC_CACHE_CHECK([whether -Werror is usable],
426 rjk_cv_werror, [
427 save_CFLAGS="${CFLAGS}"
428 CFLAGS="${CFLAGS} ${GTK_CFLAGS} -Werror"
429 AC_TRY_COMPILE([#include <gtk/gtk.h>],
430 [],
431 [rjk_cv_werror=yes],
432 [rjk_cv_werror=no])
433 CFLAGS="${save_CFLAGS}"
434 ])
435 if test $rjk_cv_werror = no; then
436 gcc_werror=''
437 fi
438 fi
439 CC="${CC} $gcc_werror"
440
441 # for older GCCs that don't know %ju (etc)
442 AC_CACHE_CHECK([whether -Wno-format is required],
443 rjk_cv_noformat,
444 AC_TRY_COMPILE([#include <stdio.h>
445#include <stdint.h>
446],
447 [printf("%ju", (uintmax_t)0);],
448 [rjk_cv_noformat=no],
449 [rjk_cv_noformat=yes]))
450 if test $rjk_cv_noformat = yes; then
451 CC="${CC} -Wno-format"
452 fi
453
454 AC_CACHE_CHECK([whether -Wshadow is OK],
455 rjk_cv_shadow,
456 oldCC="${CC}"
457 CC="${CC} -Wshadow"
458 [AC_TRY_COMPILE([
459#include <unistd.h>
460#include <vorbis/vorbisfile.h>
461],
462 [],
463 [rjk_cv_shadow=yes],
464 [rjk_cv_shadow=no])
465 CC="${oldCC}"])
466 if test $rjk_cv_shadow = yes; then
467 CC="${CC} -Wshadow"
468 fi
469fi
470
471RJK_GCOV
472
473AH_BOTTOM([#ifdef __GNUC__
474# define attribute(x) __attribute__(x)
475#else
476# define attribute(x)
477#endif])
478
479AC_CONFIG_FILES([Makefile
480 templates/Makefile
481 images/Makefile
482 scripts/Makefile
483 lib/Makefile
484 server/Makefile
485 clients/Makefile
486 disobedience/Makefile
487 doc/Makefile
488 plugins/Makefile
489 driver/Makefile
490 debian/Makefile
491 sounds/Makefile
492 python/Makefile
493 examples/Makefile
494 tests/Makefile])
495AC_OUTPUT
496
497if test $GCC = yes && test "$gcc_werror" = ''; then
498 AC_MSG_WARN([building without -Werror])
499fi
500if test $want_python = no; then
501 AC_MSG_WARN([cannot run the test suit without Python])
502fi