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