chiark / gitweb /
speaker beforepoll() now gets to modify the timeout. This allows
[disorder] / configure.ac
CommitLineData
460b9539 1# Process this file with autoconf to produce a configure script.
2#
3# This file is part of DisOrder.
dea8f8aa 4# Copyright (C) 2004, 2005, 2006, 2007 Richard Kettlewell
460b9539 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
187f23fb 22AC_INIT(disorder, 1.5.99+, richard+disorder@sfere.greenend.org.uk)
460b9539 23AC_CONFIG_AUX_DIR([config.aux])
187f23fb 24AM_INIT_AUTOMAKE(disorder, 1.5.99+)
460b9539 25AC_CONFIG_SRCDIR([server/disorderd.c])
26AM_CONFIG_HEADER([config.h])
27
dea8f8aa
RK
28# Find host type
29AC_CANONICAL_HOST
30
460b9539 31# What we want to build
460b9539 32want_gtk=yes
33want_python=yes
34
a9f0ad12
RK
35# Checks for programs.
36AC_PROG_CC
37AC_SET_MAKE
38if test "x$GCC" = xyes; then
39 gcc_werror=-Werror
40else
41 gcc_werror=""
42fi
43
44AC_MSG_CHECKING([for a known target platform])
dea8f8aa 45case "$host" in
a9f0ad12 46*empeg* )
e3426f7b 47 AC_MSG_RESULT([empeg car stereo])
a9f0ad12
RK
48 AC_DEFINE([EMPEG_HOST],[1],[define if host is an empeg car stereo])
49 # work around broken toolchain
50 AC_CHECK_LIB([gpg-error], [gpg_strerror])
e3426f7b 51 AC_CHECK_LIB([pthread], [pthread_create])
2d2effe2
RK
52 # lib/queue.c really wants to be split into server and non-server bits
53 AC_CHECK_LIB([dl], [dlopen])
a9f0ad12 54 want_server=no
a9f0ad12 55 ;;
dea8f8aa 56*linux* | *Linux* )
a9f0ad12 57 AC_MSG_RESULT([Linux])
e3426f7b 58 want_server=yes
dea8f8aa 59 ;;
9086a105 60*-apple-darwin* )
e3426f7b 61 AC_MSG_RESULT([Mac OS X])
68122e5f 62 want_server=no
9086a105
RK
63 COREAUDIO="-framework CoreAudio"
64 ;;
dea8f8aa 65* )
a9f0ad12 66 AC_MSG_RESULT([unknown, winging it])
e3426f7b 67 want_server=no
dea8f8aa
RK
68 ;;
69esac
9086a105 70AC_SUBST([COREAUDIO])
dea8f8aa 71
460b9539 72AC_ARG_WITH([server],
73 [AS_HELP_STRING([--without-server],
74 [do not build server])],
75 [want_server=$withval])
76AC_ARG_WITH([gtk],
77 [AS_HELP_STRING([--without-gtk],
78 [do not build GTK+ client])],
79 [want_gtk=$withval])
80AC_ARG_WITH([python],
81 [AS_HELP_STRING([--without-python],
82 [do not build Python support])],
83 [want_python=$withval])
84
1798e51d 85subdirs="scripts lib clients doc examples debian"
460b9539 86
87if test $want_server = yes; then
88 subdirs="${subdirs} server plugins driver templates sounds images"
89fi
90if test $want_python = yes; then
91 AM_PATH_PYTHON
92 subdirs="${subdirs} python"
93fi
94if test $want_gtk = yes; then
95 subdirs="${subdirs} disobedience"
96 if test $want_server = no; then
97 subdirs="${subdirs} images"
98 fi
99fi
1798e51d 100subdirs="${subdirs} tests"
460b9539 101AC_SUBST([subdirs])
102
103# libtool config
104AC_LIBTOOL_DLOPEN
105AC_DISABLE_STATIC
106
107AC_PROG_LIBTOOL
108
109missing_libraries=""
110missing_headers=""
111missing_functions=""
112
113AC_DEFINE(_GNU_SOURCE, 1, [required for e.g. strsignal])
114
115# Macs might have libraries under fink's root
116AC_PATH_PROG([FINK],[fink],[none],[$PATH:/sw/bin])
117if test "x$FINK" != xnone; then
118 AC_CACHE_CHECK([fink install directory],[rjk_cv_finkprefix],[
119 rjk_cv_finkprefix="`echo "$FINK" | sed 's,/bin/fink$,,'`"
120 ])
e83d0967 121 finkbindir="${rjk_cv_finkprefix}/bin"
762f2539 122 CPPFLAGS="${CPPFLAGS} -I${rjk_cv_finkprefix}/include/gc -I${rjk_cv_finkprefix}/include"
460b9539 123 if test $want_server = yes; then
124 CPPFLAGS="${CPPFLAGS} -I${rjk_cv_finkprefix}/include/db4"
125 fi
126 LDFLAGS="${LDFLAGS} -L${rjk_cv_finkprefix}/lib"
e83d0967
RK
127else
128 finkbindir=""
460b9539 129fi
e83d0967 130AC_SUBST([finkbindir])
460b9539 131
132# Checks for libraries.
133# We save up a list of missing libraries that we can't do without
134# and report them all at once.
135AC_CHECK_LIB(gc, GC_malloc, [AC_SUBST(LIBGC,[-lgc])],
136 [missing_libraries="$missing_libraries libgc"])
137AC_CHECK_LIB(gcrypt, gcry_md_open,
138 [AC_SUBST(LIBGCRYPT,[-lgcrypt])],
139 [missing_libraries="$missing_libraries libgcrypt"])
140AC_CHECK_LIB(pcre, pcre_compile,
141 [AC_SUBST(LIBPCRE,[-lpcre])],
142 [missing_libraries="$missing_libraries libpcre"])
146e86fb 143AC_CHECK_LIB([asound], [snd_pcm_open],
144 [AC_SUBST(LIBASOUND,[-lasound])])
460b9539 145if test $want_server = yes; then
146 RJK_CHECK_LIB(db, db_create, [#include <db.h>],
147 [AC_SUBST(LIBDB,[-ldb])],
148 [missing_libraries="$missing_libraries libdb"])
149 AC_CHECK_LIB(vorbis, vorbis_info_clear,
150 [:],
151 [missing_libraries="$missing_libraries libvorbis"])
152 AC_CHECK_LIB(vorbisfile, ov_open,
153 [AC_SUBST(LIBVORBISFILE,["-lvorbisfile -lvorbis"])],
154 [missing_libraries="$missing_libraries libvorbisfile"],
155 [-lvorbis])
156 AC_CHECK_LIB(mad, mad_stream_init,
157 [AC_SUBST(LIBMAD,[-lmad])],
158 [missing_libraries="$missing_libraries libmad"])
159 AC_CHECK_LIB([ao], [ao_initialize],
160 [AC_SUBST(LIBAO,[-lao])],
161 [missing_libraries="$missing_libraries libao"])
c57f1201 162 AC_CHECK_LIB([FLAC], [FLAC__stream_decoder_new],
163 [AC_SUBST(LIBFLAC,[-lFLAC])],
164 [missing_libraries="$missing_libraries libFLAC"])
d19ccd72 165fi
460b9539 166
167if test $want_gtk = yes; then
168 AM_PATH_GLIB_2_0([],[],[missing_libraries="$missing_libraries libglib"])
169 AM_PATH_GTK_2_0([],[],[missing_libraries="$missing_libraries libgtk"])
170fi
171
172# Some platforms have iconv already
173AC_CHECK_FUNC(iconv_open, [:],
174 [RJK_CHECK_LIB(iconv, iconv_open, [#include <iconv.h>],
175 [AC_SUBST(LIBICONV,[-liconv])],
176 [missing_functions="$missing_functions iconv_open"])])
177AC_CHECK_FUNC([gethostbyname],[:],[
178 AC_CHECK_LIB(nsl,gethostbyname,
179 [AC_SUBST(LIBNSL,[-lnsl])],
180 [missing_functions="$missing_functions gethostbyname"])])
181AC_CHECK_FUNC([socket],[:],[
182 AC_CHECK_LIB(socket,socket,
183 [AC_SUBST(LIBSOCKET,[-lsocket])],
184 [missing_functions="$missing_functions socket"])])
185AC_CHECK_FUNC([dlopen],[:],[
186 AC_CHECK_LIB(dl,dlopen,
187 [AC_SUBST(LIBDL,[-ldl])],
188 [missing_functions="$missing_functions dlopen"])])
189
190if test ! -z "$missing_libraries"; then
191 AC_MSG_ERROR([missing libraries:$missing_libraries])
192fi
193
194# We require that libpcre support UTF-8
195RJK_REQUIRE_PCRE_UTF8([-lpcre])
196
197# Checks for header files.
198RJK_FIND_GC_H
a9f0ad12 199AC_CHECK_HEADERS([inttypes.h CoreAudio/AudioHardware.h sys/soundcard.h alsa/asoundlib.h])
146e86fb 200# We don't bother checking very standard stuff
460b9539 201# Compilation will fail if any of these headers are missing, so we
202# check for them here and fail early.
460b9539 203if test $want_server = yes; then
204 AC_CHECK_HEADERS([db.h],[:],[
205 missing_headers="$missing_headers $ac_header"
206 ])
460b9539 207fi
208AC_CHECK_HEADERS([dlfcn.h gcrypt.h \
209 getopt.h iconv.h langinfo.h \
210 pcre.h sys/ioctl.h \
211 syslog.h unistd.h],[:],[
212 missing_headers="$missing_headers $ac_header"
213])
214
215if test ! -z "$missing_headers"; then
216 AC_MSG_ERROR([missing headers:$missing_headers])
217fi
218
219# Checks for typedefs, structures, and compiler characteristics.
220AC_C_CONST
221AC_TYPE_SIZE_T
222AC_C_INLINE
5330d674 223AC_C_BIGENDIAN
460b9539 224AC_CHECK_TYPES([struct sockaddr_in6],,,[AC_INCLUDES_DEFAULT
225#include <netinet/in.h>])
226
227# enable -Werror when we check for certain characteristics:
228
229old_CFLAGS="${CFLAGS}"
230CFLAGS="${CFLAGS} $gcc_werror"
231AC_CHECK_TYPES([long long,uint32_t,uint8_t,intmax_t,uintmax_t])
232
233# Some GCC invocations warn for converting function pointers to void *.
234# This is fair enough, as it's technically forbidden, but we use dlsym()
235# which can pretty much only exist if object and function pointers are
236# interconvertable. So we disable -Werror if need be.
237if test ! -z "$gcc_werror"; then
238 AC_CACHE_CHECK([whether function pointers can be converted to void * without a warning],
239 [rjk_cv_function_pointer_cast],[
240 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
241 void somefunction(void);],
242 [(void *)somefunction])],
243 [rjk_cv_function_pointer_cast=yes],
244 [rjk_cv_function_pointer_cast=no])])
245 if test $rjk_cv_function_pointer_cast = no; then
246 gcc_werror=""
247 fi
248fi
249
250CFLAGS="${old_CFLAGS}"
251
252# gcrypt maintainers keep changing everything. Design your interface
253# first, then implement it once, rather than getting it wrong three or
254# four times and shipping between each attempt.
255AC_CACHE_CHECK([for hash handle type in <grypt.h>],
256 [rjk_cv_gcrypt_hash_handle],[
257 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
258#include <gcrypt.h>
259],
260 [gcry_md_hd_t h;])],
261 [rjk_cv_gcrypt_hash_handle=gcry_md_hd_t],[
262 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
263#include <gcrypt.h>
264],
265 [GcryMDHd h;])],
266 [rjk_cv_gcrypt_hash_handle=GcryMDHd],
267 [rjk_cv_gcrypt_hash_handle=GCRY_MD_HD])])])
268AC_DEFINE_UNQUOTED([gcrypt_hash_handle],[$rjk_cv_gcrypt_hash_handle],
269 [libgcrypt hash handle type])
270
271AC_CACHE_CHECK([for gcry_error_t in <grypt.h>],
272 [rjk_cv_have_gcry_error_t],[
273 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
274#include <gcrypt.h>
275],
276 [gcry_error_t e;])],
277 [rjk_cv_have_gcry_error_t=yes],
278 [rjk_cv_have_gcry_error_t=no])])
279if test $rjk_cv_have_gcry_error_t = yes; then
280 AC_DEFINE([HAVE_GCRY_ERROR_T],1,[define if <gcrypt.h> defines gcry_error_t])
281fi
282
283# Checks for functions
284if test $ac_cv_type_long_long = yes; then
285 AC_CHECK_FUNCS([atoll strtoll],[:],[
286 missing_functions="$missing_functions $ac_func"
287 ])
288 # Darwin sometimes fails to declare strtoll (e.g. if you ask for -std=c99)
289 AC_CACHE_CHECK([whether strtoll is declared in <stdlib.h>],
290 [rjk_cv_strtoll_declared],[
291 AC_EGREP_HEADER([strtoll], [stdlib.h],
292 [rjk_cv_strtoll_declared=yes],
293 [rjk_cv_strtoll_declared=no])])
294 if test $rjk_cv_strtoll_declared = yes; then
295 AC_DEFINE([DECLARES_STRTOLL],[1],[define if <stdlib.h> declares strtoll])
296 fi
297 AC_CACHE_CHECK([whether atoll is declared in <stdlib.h>],
298 [rjk_cv_atoll_declared],[
299 AC_EGREP_HEADER([atoll], [stdlib.h],
300 [rjk_cv_atoll_declared=yes],
301 [rjk_cv_atoll_declared=no])])
302 if test $rjk_cv_atoll_declared = yes; then
303 AC_DEFINE([DECLARES_ATOLL],[1],[define if <stdlib.h> declares atoll])
304 fi
305fi
306AC_CHECK_FUNCS([ioctl nl_langinfo strsignal],[:],[
307 missing_functions="$missing_functions $ac_func"
308])
309# fsync will do if fdatasync not available
310AC_CHECK_FUNCS([fdatasync],[:],[
311 AC_CHECK_FUNCS([fsync],
312 [AC_DEFINE([fdatasync],[fsync],[define fdatasync to fsync if not available])],
313 [missing_functions="$missing_functions fdatasync"])])
314if test ! -z "$missing_functions"; then
315 AC_MSG_ERROR([missing functions:$missing_functions])
316fi
317if test $want_server = yes; then
318 # <db.h> had better be version 3 or later
319 AC_CACHE_CHECK([db.h version],[rjk_cv_db_version],[
320 AC_PREPROC_IFELSE([
321 #include <db.h>
322 #ifndef DB_VERSION_MAJOR
323 # error cannot determine db version
324 #endif
325 #if DB_VERSION_MAJOR < 4
326 # error inadequate db version
327 #endif
328 #if DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR < 2
329 # error inadequate db version
330 #endif
331 ],
332 [rjk_cv_db_version=ok],
333 [rjk_cv_db_version=inadequate])
334 ])
335 if test $rjk_cv_db_version != ok; then
336 AC_MSG_ERROR([need db.h version at least 4.2])
337 fi
338fi
339
340if test "x$GCC" = xyes; then
341 # a reasonable default set of warnings
342 CC="${CC} -Wall -W -Wpointer-arith -Wbad-function-cast \
343 -Wwrite-strings -Wmissing-prototypes \
344 -Wmissing-declarations -Wnested-externs"
345
346 # Fix up GTK+ and GLib compiler flags
347 GTK_CFLAGS="`echo \"$GTK_CFLAGS\"|sed 's/-I/-isystem /g'`"
348 GLIB_CFLAGS="`echo \"$GLIB_CFLAGS\"|sed 's/-I/-isystem /g'`"
349
350 # GCC 2.95 doesn't know to ignore warnings from system headers
351 AC_CACHE_CHECK([whether -Werror is usable],
352 rjk_cv_werror, [
353 save_CFLAGS="${CFLAGS}"
354 CFLAGS="${CFLAGS} ${GTK_CFLAGS} -Werror"
355 AC_TRY_COMPILE([#include <gtk/gtk.h>],
356 [],
357 [rjk_cv_werror=yes],
358 [rjk_cv_werror=no])
359 CFLAGS="${save_CFLAGS}"
360 ])
361 if test $rjk_cv_werror = no; then
362 gcc_werror=''
363 fi
364 CC="${CC} $gcc_werror"
365
366 # for older GCCs that don't know %ju (etc)
9a5f7aba 367 AC_CACHE_CHECK([whether -Wno-format is required],
460b9539 368 rjk_cv_noformat,
369 AC_TRY_COMPILE([#include <stdio.h>
370#include <stdint.h>
371],
372 [printf("%ju", (uintmax_t)0);],
373 [rjk_cv_noformat=no],
374 [rjk_cv_noformat=yes]))
375 if test $rjk_cv_noformat = yes; then
376 CC="${CC} -Wno-format"
377 fi
378
9a5f7aba 379 AC_CACHE_CHECK([whether -Wshadow is OK],
460b9539 380 rjk_cv_shadow,
381 oldCC="${CC}"
382 CC="${CC} -Wshadow"
383 [AC_TRY_COMPILE([
384#include <unistd.h>
385#include <vorbis/vorbisfile.h>
386],
387 [],
388 [rjk_cv_shadow=yes],
389 [rjk_cv_shadow=no])
390 CC="${oldCC}"])
391 if test $rjk_cv_shadow = yes; then
392 CC="${CC} -Wshadow"
393 fi
394
395
396fi
397
398AH_BOTTOM([#ifdef __GNUC__
399# define attribute(x) __attribute__(x)
400#else
401# define attribute(x)
402#endif])
403
404AC_CONFIG_FILES([Makefile
405 templates/Makefile
406 images/Makefile
407 scripts/Makefile
408 lib/Makefile
409 server/Makefile
410 clients/Makefile
411 disobedience/Makefile
412 doc/Makefile
413 plugins/Makefile
414 driver/Makefile
415 debian/Makefile
416 sounds/Makefile
417 python/Makefile
c5dbcd79
RK
418 examples/Makefile
419 tests/Makefile])
460b9539 420AC_OUTPUT