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