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