chiark / gitweb /
speaker-network.c network_play() no longer assumes
[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# Portions copyright (C) 2007 Ross Younger
6#
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.
11#
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.
16#
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
20# USA
21#
22
23AC_INIT([disorder], [2.0+], [richard+disorder@sfere.greenend.org.uk])
24AC_CONFIG_AUX_DIR([config.aux])
25AM_INIT_AUTOMAKE(disorder, [2.0+])
26AC_CONFIG_SRCDIR([server/disorderd.c])
27AM_CONFIG_HEADER([config.h])
28
29# Find host type
30AC_CANONICAL_HOST
31
32# What we want to build
33want_gtk=yes
34want_python=yes
35
36# APIs we want
37want_alsa=yes
38want_oss=yes
39want_coreaudio=yes
40
41# Checks for programs.
42AC_PROG_CC
43AC_SET_MAKE
44if test "x$GCC" = xyes; then
45 gcc_werror=-Werror
46else
47 gcc_werror=""
48fi
49
50AC_ARG_WITH([alsa],
51 [AS_HELP_STRING([--without-alsa],
52 [do not build with ALSA support])],
53 [want_alsa=$withval])
54AC_ARG_WITH([oss],
55 [AS_HELP_STRING([--without-oss],
56 [do not build with OSS support])],
57 [want_oss=$withval])
58AC_ARG_WITH([coreaudio],
59 [AS_HELP_STRING([--without-coreaudio],
60 [do not build with Core Audio support])],
61 [want_coreaudio=$withval])
62
63AC_MSG_CHECKING([for a known target platform])
64case "$host" in
65*empeg* )
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])
71 want_server=no
72 ;;
73*linux* | *Linux* )
74 AC_MSG_RESULT([Linux])
75 want_server=yes
76 ;;
77*-apple-darwin* )
78 AC_MSG_RESULT([Mac OS X])
79 want_server=yes
80 if test $want_coreaudio = yes; then
81 COREAUDIO="-framework CoreAudio"
82 fi
83 browser=open
84 AC_MSG_CHECKING([Mac OS X target version])
85 # We honor MACOSX_DEPLOYMENT_TARGET in the environment, emulating gcc's
86 # behaviour. But we provide a command line option to override it and
87 # we default to wide support instead of supporting only the build platform.
88 #
89 # Currently if you ask for 10.5 you will get a deprecation warning
90 # when building the CoreAudio support code. For the time being the
91 # answer to this is "don't do that then". If a good reason to ask
92 # for a 10.5 deployment target emerges then this will be fixed.
93 if test -z "$MACOSX_DEPLOYMENT_TARGET"; then
94 MACOSX_DEPLOYMENT_TARGET=10.0
95 fi
96 AC_ARG_WITH([deployment-target],
97 [AS_HELP_STRING([--with-deployment-target=TARGET],
98 [set target OS X version])],
99 [MACOSX_DEPLOYMENT_TARGET=$withval])
100 # Convert to desired format
101 underscored=`echo $MACOSX_DEPLOYMENT_TARGET|sed 's/\./_/'`
102 minver="MAC_OS_X_VERSION_$underscored"
103 AC_MSG_RESULT([$minver])
104 AC_DEFINE_UNQUOTED([MAC_OS_X_VERSION_MIN_REQUIRED], [$minver],
105 [define to minimum version of Mac OS X to support])
106 ;;
107*-freebsd* )
108 AC_MSG_RESULT([FreeBSD])
109 want_server=yes
110 # Ports install to /usr/local but the compiler stupidly doesn't look
111 # there by default
112 LDFLAGS="${LDFLAGS} -L/usr/local/lib"
113 CPPFLAGS="${CPPFLAGS} -isystem /usr/local/include"
114 # libdb installs elsewhere again
115 LDFLAGS="${LDFLAGS} -L/usr/local/lib/db44"
116 CPPFLAGS="${CPPFLAGS} -isystem /usr/local/include/db44"
117 ;;
118* )
119 AC_MSG_RESULT([unknown, winging it])
120 want_server=no
121 ;;
122esac
123AC_SUBST([COREAUDIO])
124
125AC_ARG_WITH([browser],
126 [AS_HELP_STRING([--with-browser=BROWSER],
127 [use BROWSER to display HTML])],
128 [browser=$withval])
129
130AC_CACHE_CHECK([default HTML viewer],[rjk_cv_browser],[
131 rjk_cv_browser=UNKNOWN
132 for candidate in x-www-browser firefox mozilla konqueror netscape; do
133 if type $candidate >/dev/null 2>&1; then
134 rjk_cv_browser="$candidate"
135 break
136 fi
137 done
138])
139if test -z "$browser"; then
140 browser="$rjk_cv_browser"
141fi
142AC_DEFINE_UNQUOTED([BROWSER],["$browser"],[HTML viewer])
143
144AC_ARG_WITH([server],
145 [AS_HELP_STRING([--without-server],
146 [do not build server])],
147 [want_server=$withval])
148AC_ARG_WITH([gtk],
149 [AS_HELP_STRING([--without-gtk],
150 [do not build GTK+ client])],
151 [want_gtk=$withval])
152AC_ARG_WITH([python],
153 [AS_HELP_STRING([--without-python],
154 [do not build Python support])],
155 [want_python=$withval])
156
157subdirs="scripts lib clients doc examples debian"
158
159if test $want_server = yes; then
160 subdirs="${subdirs} server plugins driver templates sounds images"
161fi
162if test $want_gtk = yes; then
163 subdirs="${subdirs} disobedience"
164 if test $want_server = no; then
165 subdirs="${subdirs} images"
166 fi
167fi
168if test $want_python = yes; then
169 AM_PATH_PYTHON([2.4])
170 subdirs="${subdirs} python tests"
171fi
172AC_SUBST([subdirs])
173
174# libtool config
175AC_LIBTOOL_DLOPEN
176AC_DISABLE_STATIC
177
178AC_PROG_LIBTOOL
179
180AC_CACHE_CHECK([for GNU sed],[rjk_cv_gnused],[
181 rjk_cv_gnused="not found"
182 for candidate in sed gsed; do
183 if $candidate --version >/dev/null 2>&1; then
184 rjk_cv_gnused=$candidate
185 fi
186 done
187])
188GNUSED="${GNUSED:-$rjk_cv_gnused}"
189if test "$GNUSED" = "not found"; then
190 AC_MSG_ERROR([GNU sed is required to build this program])
191fi
192AC_SUBST([GNUSED])
193
194missing_libraries=""
195missing_headers=""
196missing_functions=""
197
198AC_DEFINE(_GNU_SOURCE, 1, [required for e.g. strsignal])
199
200# Macs might have libraries under fink's root
201AC_PATH_PROG([FINK],[fink],[none],[$PATH:/sw/bin])
202if test "x$FINK" != xnone; then
203 AC_CACHE_CHECK([fink install directory],[rjk_cv_finkprefix],[
204 rjk_cv_finkprefix="`echo "$FINK" | sed 's,/bin/fink$,,'`"
205 ])
206 finkdir="${rjk_cv_finkprefix}"
207 finkbindir="${rjk_cv_finkprefix}/bin"
208 CPPFLAGS="${CPPFLAGS} -I${rjk_cv_finkprefix}/include/gc -I${rjk_cv_finkprefix}/include"
209 if test $want_server = yes; then
210 CPPFLAGS="${CPPFLAGS} -I${rjk_cv_finkprefix}/include/db4"
211 fi
212 LDFLAGS="${LDFLAGS} -L${rjk_cv_finkprefix}/lib"
213else
214 finkbindir=""
215fi
216AC_SUBST([finkdir])
217AC_SUBST([finkbindir])
218
219# Checks for libraries.
220# We save up a list of missing libraries that we can't do without
221# and report them all at once.
222AC_CHECK_LIB(gc, GC_malloc, [AC_SUBST(LIBGC,[-lgc])],
223 [missing_libraries="$missing_libraries libgc"])
224AC_CHECK_LIB(gcrypt, gcry_md_open,
225 [AC_SUBST(LIBGCRYPT,[-lgcrypt])],
226 [missing_libraries="$missing_libraries libgcrypt"])
227AC_CHECK_LIB(pcre, pcre_compile,
228 [AC_SUBST(LIBPCRE,[-lpcre])],
229 [missing_libraries="$missing_libraries libpcre"])
230if test $want_alsa = yes; then
231 AC_CHECK_LIB([asound], [snd_pcm_open],
232 [AC_SUBST(LIBASOUND,[-lasound])])
233fi
234if test $want_server = yes; then
235 RJK_CHECK_LIB(db, db_create, [#include <db.h>],
236 [AC_SUBST(LIBDB,[-ldb])],
237 [missing_libraries="$missing_libraries libdb"])
238 AC_CHECK_LIB(vorbis, vorbis_info_clear,
239 [:],
240 [missing_libraries="$missing_libraries libvorbis"])
241 AC_CHECK_LIB(vorbisfile, ov_open,
242 [AC_SUBST(LIBVORBISFILE,["-lvorbisfile -lvorbis"])],
243 [missing_libraries="$missing_libraries libvorbisfile"],
244 [-lvorbis])
245 AC_CHECK_LIB(mad, mad_stream_init,
246 [AC_SUBST(LIBMAD,[-lmad])],
247 [missing_libraries="$missing_libraries libmad"])
248 AC_CHECK_LIB([ao], [ao_initialize],
249 [AC_SUBST(LIBAO,[-lao])],
250 [missing_libraries="$missing_libraries libao"])
251 AC_CHECK_LIB([FLAC], [FLAC__stream_decoder_new],
252 [AC_SUBST(LIBFLAC,[-lFLAC])],
253 [missing_libraries="$missing_libraries libFLAC"])
254fi
255AC_CHECK_LIB([pthread], [pthread_create],
256 [AC_SUBST(LIBPTHREAD,[-lpthread])],
257 [missing_libraries="$missing_libraries libpthread"])
258
259if test $want_gtk = yes; then
260 AM_PATH_GLIB_2_0([],[],[missing_libraries="$missing_libraries libglib"])
261 AM_PATH_GTK_2_0([],[],[missing_libraries="$missing_libraries libgtk"])
262fi
263
264# Some platforms have iconv already
265AC_CHECK_FUNC(iconv_open, [:],
266 [RJK_CHECK_LIB(iconv, iconv_open, [#include <iconv.h>],
267 [AC_SUBST(LIBICONV,[-liconv])],
268 [missing_functions="$missing_functions iconv_open"])])
269AC_CHECK_FUNC([gethostbyname],[:],[
270 AC_CHECK_LIB(nsl,gethostbyname,
271 [AC_SUBST(LIBNSL,[-lnsl])],
272 [missing_functions="$missing_functions gethostbyname"])])
273AC_CHECK_FUNC([socket],[:],[
274 AC_CHECK_LIB(socket,socket,
275 [AC_SUBST(LIBSOCKET,[-lsocket])],
276 [missing_functions="$missing_functions socket"])])
277AC_CHECK_FUNC([dlopen],[:],[
278 AC_CHECK_LIB(dl,dlopen,
279 [AC_SUBST(LIBDL,[-ldl])],
280 [missing_functions="$missing_functions dlopen"])])
281
282if test ! -z "$missing_libraries"; then
283 AC_MSG_ERROR([missing libraries:$missing_libraries])
284fi
285
286# Checks for header files.
287RJK_FIND_GC_H
288if test $want_oss = yes; then
289 AC_CHECK_HEADERS([sys/soundcard.h])
290fi
291if test $want_alsa = yes; then
292 AC_CHECK_HEADERS([alsa/asoundlib.h])
293fi
294if test $want_coreaudio = yes; then
295 AC_CHECK_HEADERS([CoreAudio/AudioHardware.h])
296fi
297AC_CHECK_HEADERS([inttypes.h])
298# We don't bother checking very standard stuff
299# Compilation will fail if any of these headers are missing, so we
300# check for them here and fail early.
301if test $want_server = yes; then
302 AC_CHECK_HEADERS([db.h],[:],[
303 missing_headers="$missing_headers $ac_header"
304 ])
305 AC_CHECK_HEADERS([FLAC/file_decoder.h])
306fi
307AC_CHECK_HEADERS([dlfcn.h gcrypt.h \
308 getopt.h iconv.h langinfo.h \
309 pcre.h sys/ioctl.h \
310 syslog.h unistd.h],[:],[
311 missing_headers="$missing_headers $ac_header"
312])
313
314if test ! -z "$missing_headers"; then
315 AC_MSG_ERROR([missing headers:$missing_headers])
316fi
317
318# We require that libpcre support UTF-8
319RJK_REQUIRE_PCRE_UTF8([-lpcre])
320
321# Checks for typedefs, structures, and compiler characteristics.
322AC_C_CONST
323AC_TYPE_SIZE_T
324AC_C_INLINE
325AC_C_BIGENDIAN
326AC_CHECK_TYPES([struct sockaddr_in6],,,[AC_INCLUDES_DEFAULT
327#include <netinet/in.h>])
328
329# enable -Werror when we check for certain characteristics:
330
331old_CFLAGS="${CFLAGS}"
332CFLAGS="${CFLAGS} $gcc_werror"
333AC_CHECK_TYPES([long long,uint32_t,uint8_t,intmax_t,uintmax_t])
334
335# Some GCC invocations warn for converting function pointers to void *.
336# This is fair enough, as it's technically forbidden, but we use dlsym()
337# which can pretty much only exist if object and function pointers are
338# interconvertable. So we disable -Werror if need be.
339if test ! -z "$gcc_werror"; then
340 AC_CACHE_CHECK([whether function pointers can be converted to void * without a warning],
341 [rjk_cv_function_pointer_cast],[
342 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
343 void somefunction(void);],
344 [(void *)somefunction])],
345 [rjk_cv_function_pointer_cast=yes],
346 [rjk_cv_function_pointer_cast=no])])
347 if test $rjk_cv_function_pointer_cast = no; then
348 gcc_werror=""
349 fi
350fi
351
352CFLAGS="${old_CFLAGS}"
353
354# gcrypt maintainers keep changing everything. Design your interface
355# first, then implement it once, rather than getting it wrong three or
356# four times and shipping between each attempt.
357AC_CACHE_CHECK([for hash handle type in <grypt.h>],
358 [rjk_cv_gcrypt_hash_handle],[
359 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
360#include <gcrypt.h>
361],
362 [gcry_md_hd_t h;])],
363 [rjk_cv_gcrypt_hash_handle=gcry_md_hd_t],[
364 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
365#include <gcrypt.h>
366],
367 [GcryMDHd h;])],
368 [rjk_cv_gcrypt_hash_handle=GcryMDHd],
369 [rjk_cv_gcrypt_hash_handle=GCRY_MD_HD])])])
370AC_DEFINE_UNQUOTED([gcrypt_hash_handle],[$rjk_cv_gcrypt_hash_handle],
371 [libgcrypt hash handle type])
372
373AC_CACHE_CHECK([for gcry_error_t in <grypt.h>],
374 [rjk_cv_have_gcry_error_t],[
375 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
376#include <gcrypt.h>
377],
378 [gcry_error_t e;])],
379 [rjk_cv_have_gcry_error_t=yes],
380 [rjk_cv_have_gcry_error_t=no])])
381if test $rjk_cv_have_gcry_error_t = yes; then
382 AC_DEFINE([HAVE_GCRY_ERROR_T],1,[define if <gcrypt.h> defines gcry_error_t])
383fi
384
385# Checks for functions
386if test $ac_cv_type_long_long = yes; then
387 AC_CHECK_FUNCS([atoll strtoll],[:],[
388 missing_functions="$missing_functions $ac_func"
389 ])
390 # Darwin sometimes fails to declare strtoll (e.g. if you ask for -std=c99)
391 AC_CACHE_CHECK([whether strtoll is declared in <stdlib.h>],
392 [rjk_cv_strtoll_declared],[
393 AC_EGREP_HEADER([strtoll], [stdlib.h],
394 [rjk_cv_strtoll_declared=yes],
395 [rjk_cv_strtoll_declared=no])])
396 if test $rjk_cv_strtoll_declared = yes; then
397 AC_DEFINE([DECLARES_STRTOLL],[1],[define if <stdlib.h> declares strtoll])
398 fi
399 AC_CACHE_CHECK([whether atoll is declared in <stdlib.h>],
400 [rjk_cv_atoll_declared],[
401 AC_EGREP_HEADER([atoll], [stdlib.h],
402 [rjk_cv_atoll_declared=yes],
403 [rjk_cv_atoll_declared=no])])
404 if test $rjk_cv_atoll_declared = yes; then
405 AC_DEFINE([DECLARES_ATOLL],[1],[define if <stdlib.h> declares atoll])
406 fi
407fi
408AC_CHECK_FUNCS([ioctl nl_langinfo strsignal],[:],[
409 missing_functions="$missing_functions $ac_func"
410])
411# fsync will do if fdatasync not available
412AC_CHECK_FUNCS([fdatasync],[:],[
413 AC_CHECK_FUNCS([fsync],
414 [AC_DEFINE([fdatasync],[fsync],[define fdatasync to fsync if not available])],
415 [missing_functions="$missing_functions fdatasync"])])
416if test ! -z "$missing_functions"; then
417 AC_MSG_ERROR([missing functions:$missing_functions])
418fi
419if test $want_server = yes; then
420 # <db.h> had better be version 3 or later
421 AC_CACHE_CHECK([db.h version],[rjk_cv_db_version],[
422 AC_PREPROC_IFELSE([
423 #include <db.h>
424 #ifndef DB_VERSION_MAJOR
425 # error cannot determine db version
426 #endif
427 #if DB_VERSION_MAJOR < 4
428 # error inadequate db version
429 #endif
430 #if DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR <= 2
431 # error inadequate db version
432 #endif
433 ],
434 [rjk_cv_db_version=ok],
435 [rjk_cv_db_version=inadequate])
436 ])
437 if test $rjk_cv_db_version != ok; then
438 AC_MSG_ERROR([need db.h version at least 4.2])
439 fi
440fi
441
442if test "x$GCC" = xyes; then
443 # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29478
444 AC_CACHE_CHECK([checking for GCC bug 29478],[rjk_cv_pr29478],[
445 old_CC="$CC"
446 if test $GCC = yes; then
447 CC="$CC -Wall -Werror"
448 fi
449 AC_COMPILE_IFELSE([
450 static int x(char *f) {
451 return *f;
452 }
453 int z(const char *g) {
454 return x((char *)g);
455 }],
456 [rjk_cv_pr29478=no],
457 [rjk_cv_pr29478=yes]
458 )
459 CC="$old_CC"
460 ])
461 if test $rjk_cv_pr29478 = yes; then
462 gcc_werror=''
463 fi
464
465 # a reasonable default set of warnings
466 CC="${CC} -Wall -W -Wpointer-arith -Wbad-function-cast \
467 -Wwrite-strings -Wmissing-prototypes \
468 -Wmissing-declarations -Wnested-externs"
469
470 # Fix up GTK+ and GLib compiler flags
471 GTK_CFLAGS="`echo \"$GTK_CFLAGS\"|sed 's/-I/-isystem /g'`"
472 GLIB_CFLAGS="`echo \"$GLIB_CFLAGS\"|sed 's/-I/-isystem /g'`"
473
474 if test "$gcc_werror" != ''; then
475 # GCC 2.95 doesn't know to ignore warnings from system headers
476 AC_CACHE_CHECK([whether -Werror is usable],
477 rjk_cv_werror, [
478 save_CFLAGS="${CFLAGS}"
479 CFLAGS="${CFLAGS} ${GTK_CFLAGS} -Werror"
480 AC_TRY_COMPILE([#include <gtk/gtk.h>],
481 [],
482 [rjk_cv_werror=yes],
483 [rjk_cv_werror=no])
484 CFLAGS="${save_CFLAGS}"
485 ])
486 if test $rjk_cv_werror = no; then
487 gcc_werror=''
488 fi
489 fi
490 CC="${CC} $gcc_werror"
491
492 # for older GCCs that don't know %ju (etc)
493 AC_CACHE_CHECK([whether -Wno-format is required],
494 rjk_cv_noformat,
495 AC_TRY_COMPILE([#include <stdio.h>
496#include <stdint.h>
497],
498 [printf("%ju", (uintmax_t)0);],
499 [rjk_cv_noformat=no],
500 [rjk_cv_noformat=yes]))
501 if test $rjk_cv_noformat = yes; then
502 CC="${CC} -Wno-format"
503 fi
504
505 AC_CACHE_CHECK([whether -Wshadow is OK],
506 rjk_cv_shadow,
507 oldCC="${CC}"
508 CC="${CC} -Wshadow"
509 [AC_TRY_COMPILE([
510#include <unistd.h>
511#include <vorbis/vorbisfile.h>
512],
513 [],
514 [rjk_cv_shadow=yes],
515 [rjk_cv_shadow=no])
516 CC="${oldCC}"])
517 if test $rjk_cv_shadow = yes; then
518 CC="${CC} -Wshadow"
519 fi
520fi
521
522RJK_GCOV
523
524AH_BOTTOM([#ifdef __GNUC__
525# define attribute(x) __attribute__(x)
526#else
527# define attribute(x)
528#endif])
529
530AC_CONFIG_FILES([Makefile
531 templates/Makefile
532 images/Makefile
533 scripts/Makefile
534 lib/Makefile
535 server/Makefile
536 clients/Makefile
537 disobedience/Makefile
538 doc/Makefile
539 plugins/Makefile
540 driver/Makefile
541 debian/Makefile
542 sounds/Makefile
543 python/Makefile
544 examples/Makefile
545 tests/Makefile])
546AC_OUTPUT
547
548if test $GCC = yes && test "$gcc_werror" = ''; then
549 AC_MSG_WARN([building without -Werror])
550fi
551if test $want_python = no; then
552 AC_MSG_WARN([cannot run the test suit without Python])
553fi